11.6. APPROXIMATIONS 203
Thus, after computing AT A,ATy(∑
ni=1 x2
i ∑ni=1 xi
∑ni=1 xi n
)(mb
)=
(∑
ni=1 xiyi
∑ni=1 yi
)
Solving this system of equations for m and b,
m =−(∑n
i=1 xi)(∑ni=1 yi)+(∑n
i=1 xiyi)n(∑
ni=1 x2
i
)n− (∑n
i=1 xi)2
and
b =−(∑n
i=1 xi)∑ni=1 xiyi +(∑n
i=1 yi)∑ni=1 x2
i(∑
ni=1 x2
i
)n− (∑n
i=1 xi)2 .
One could clearly do a least squares fit for curves of the form y = ax2 + bx+ c in thesame way. In this case you want to solve as well as possible for a,b, and c the system
x21 x1 1...
......
x2n xn 1
a
bc
=
y1...
yn
and one would use the same technique as above. Many other similar problems are impor-tant, including many in higher dimensions and they are all solved the same way.
Example 11.6.12 Find the least squares regression line for the data
(0,1) ,(2,3) ,(2,4) ,(3,4) ,(3,5) ,(4,6) ,(4,5)
You would ideally want to solve the following system of equations
0 12 12 13 13 14 14 1
(
mb
)=
1344565
Of course there is no solution so you look for a least squares solution. You have AT A equals(
58 1818 7
)
and ATb is (8528
)