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

)

11.6. APPROXIMATIONS 203Thus, after computing A7A,A’yhixy vie xi m\_ Lie Miive xi n b veiSolving this system of equations for m and b,(Lai) (Ly yi) + (Ly xii) n( iI x?) n—(YEy xi)and 5— = (yi) Peat (Ly i) VEG= 5 .(Leia?) a— (Lexi)One could clearly do a least squares fit for curves of the form y = ax? + bx+c in thesame way. In this case you want to solve as well as possible for a,b, and c the system2xy xy 1 a YI. b =2Xx Xn 1 c Ynand 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 equations134mb565Of course there is no solution so you look for a least squares solution. You have A’ A equals58 1818 78528RW WN NN CO1111111and A’ b is