# Find a and b so that f(x)=ax+b has a minimum sum of squared errors for the points (1,2),(3,4),(4,5)sum of squares of errors,s = [a(1)+b-2]^2  +[a(3)+b-4]^2  +[a(4)+b-5]^2 =(a+b-2)^2  +(3a+b-4)^2  +(4a+b-5)^2Differentiating with respect to ads/da =2(a+b-2)(1)+2(3a+b-4)(3)+2(4a+b-5)(4)=2a+2b-4+18a+6b-24+32a+8b-40=52a + 16b - 68 => 52a + 16b = 68Differentiating with respect to bds/db =2(a+b-2)+2(3a+b-4)+2(4a+b-5)=2a+2b-4+6a+2b-8+8a+2b-10=16a + 6b - 22  => 16a + 6b = 22We have simultaneous equations52a + 16b = 6816a + 6b = 22gives a = 1, b = 1f(x)=1x+1

We have a linear model `f(x) = ax+b`

and want to minimise the sum of squares of the errors `(y - (ax+b))^2` given data

`(x,y) =` (1,2),(3,4),(4,5)

Rewrite the model as

`f(x) = a(x-bar(x)) + b_1`   where `b_1 = b + abar(x)`

Then the least-squares estimate of `b_1` is `bar(y)`

So  `hat(b_1) = (2+4+5)/3 = 11/3`

The least-square estimate of `a` is given by

`hat(a) = (Sigma_1^n(x_i-bar(x))(y_i-bar(y)))/(Sigma_1^n((x_i-barx)^2)) = ((1-8/3)(2-11/3)+(3-8/3)(4-11/3)+(4-8/3)(5-11/3))/((1-8/3)^2+(3-8/3)^2+(4-8/3)^2) `

`= (14/3)"/"(14/3) = 1`

Therefore the least-square estimate of `b` is given by

`hat(b_1) -hat(a)bar(x) = 11/3-(1)8/3 = 3/3 = 1`

least squares estimates are a=1, b=1