[Math] Minimizing a summation

multivariable-calculusoptimizationregression

I have absolutely no idea how to approach this problem. I've been looking through notes, and I think I missed this when my professor discussed this in class.

$$
\text{Consider the data}\\
i\: x_i\: y_i\\
1\:2\:1\\
2\:3\:2\\
3\:3\:3\\
4\:4\:6\\
5\:5\:5\\
\text{As discussed in class, compute the line } y=p(x)mx+b \text{ that minimizes}\\
F(m,b) = \sum_{i=0}^{5}(y_i-(mx_i+b))^2 \\
\text{You find that}\\
m=\text{____}\\
b=\text{____}\\
F(m,b)=\text{____}
$$

We've been working on maximizing and minimizing functions by both partial derivatives testing for critical points and using lagrange multipliers to find max and min values, but I have no idea what to do with this to get my initial equations to work with. Can someone give me some kind of hint or instructions on what to do?

Best Answer

I found where it was in my notes. We went over it very briefly, so it was a small section. Here's what you need to do.

$$ \frac{\partial{f}}{\partial{m}} = \sum_{i=1}^{5}2(y_i-mx_i-b)*(-x_i)\\ = -2(\sum x_iy_i-m\sum x_i^2-b \sum 1) = 0\\ \frac{\partial{f}}{\partial{b}} = -2(\sum y_i -mx_i-b)\\ -2(\sum y_i -m\sum x_i-b\sum i) = 0\\ \text{now we do some algebraic manipulations}\\ m\sum x_i^2 + b\sum x_i = \sum x_iy_i\\ m\sum x_i+b\sum1=\sum y_i\\ \text{and now we can solve for parts of these equations}\\ \sum_{i = 1}^{5} 1=5\\ \sum x_i = 17\\ \sum x_i^2 = 63\\ \sum y_i = 17 \\ \sum x_iy_i = 66\\ \text{We now get two equations with two variables we can solve for}\\ Eqn 1: 63m + 17b = 66\\ Eqn 2: 17m + 5b = 17\\ \text{Solve for b in Eqn 2 yields}\\ b = \frac{17}{5}(1-m)\\ \text{Plug into Eqn 1 and solve for m}\\ m = \frac{41}{26} \\ \text{Which makes b}\\ b = \frac{17}{5}-\frac{17*41}{5*26} $$

For the final portion, $F(m,b)$ you just need to plug in all the values and do the addition.