# Thread: Lines of best fit

1. ## Lines of best fit

The question

Find the best fit to the set of points {(0, 1) (1, 1) (2, 2) (4, 3)} in $\displaystyle R^2$ within the curve $\displaystyle y = ax^2 + bx + c$

My attempt
I used the formula $\displaystyle A^TAx = A^Ty$, and got the following equation:

$\displaystyle \begin{pmatrix}273 & 73 & 21\\73 & 21 & 7\\21 & 7 & 4\end{pmatrix}\begin{pmatrix}a\\b\\c\end{pmatrix} = \begin{pmatrix}57\\17\\7\end{pmatrix}$

I tried to use Gaussian elimination, and made a massive mess of the matrix. I was far off a correct solution. Is there a trick to getting an answer without grinding through row operations (or, at least, minimising the work)?

Cheers.

2. ## Re: Lines of best fit

You might find it simpler to reverse $\displaystyle ax^2+ bx+ c$ to $\displaystyle c+ bx+ ax^2$ so that your vector is $\displaystyle \begin{pmatrix}c \\ b\\ a\end{pmatrix}$ and reverse the order of the points. that will make $\displaystyle A^TA$ equal to
$\displaystyle \begin{pmatrix}3 & 7 & 21 \\ 7 & 21 & 73 \\ 21 & 73 & 273\end{pmatrix}$ which, at least, lets you start with smaller numbers. (Note the "3" in the upper left. Recheck the calculation that gave you that "4".)