Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to derive the equations in 3:19-3:30 provide in a MIT opencourse ware lecture about the least square method?


Thanks in advance!

share|cite|improve this question
up vote 3 down vote accepted

Suppose that you have a collection of data points $(x_i,y_i)$ and you are trying to optimize the parameters of a line $y=ax+b$ to get the best fit, where we're defining best fit to mean least squares. Then we want to minimize

$$\sum_i (ax_i+b-y_i)^2 $$

This will happen when the partial derivatives with respect to both $a$ and $b$ are zero. If we take the partial derivative with respect to $a$, we obtain

$$2\sum_i (ax_i+b-y_i)x_i=0$$

and if we take the partial with respect to $b$ we obtain

$$2\sum_i (ax_i+b-y_i)=0$$.

The equations on the board are just these rewritten.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.