# Andrew Ngs Class - Why Did He Change up the Cost Function?

I am taking Andrew Ng's Machine Learning Intro class. Looks like he changed the cost function without any explanation in the second week. Specifically:

• He no longer squares each deviation between the estimated and the actual value
• He no longer divides the sum of deviations by 2 (I guess because he doesn't square it, but that leaves the question of why for both
• He multiplies the whole thing by the first number in the sample for which he is finding the delta between estimated and actual. Why?

This image might explain it better for those familiar with the class:

Also, which of the two is "correct"? Or if there is no "correct" answer, what is the use case for each?

When the derivative of a function raised to a power, the exponent becomes a constant. In this case, the derivative of the squared loss function becomes a constant 2, and the 2 in the numerator then cancels with the 2 in the denominator. The result is just dividing by $$m$$.