The least squares solution vector is a 2x1 vector. We can quickly find it using the normal equations.
To find from here we can either invert the matrix on the left hand side, or use gaussian elimination. We choose the latter.
Hence
Finally, how does this translate to the linear function whose graph best fits the four given points? In other words, find m and t such that
best fits the four given points (x1,y1), (x2,y2), (x3,y3), (x4,y4). To answer this we need to understand how the matrix A and the vector b were chosen. We notice that b holds the y values. Further, the x values of the points, are in the second column of A. The first column of A is ones and this is because the same constant t appears for each (x,y) pair. In matrix notation
Reading line by line reveals
for j = 1,2,3,4. Comparing to y = mx + t we obtain
The graph below is just for illustration purposes. It is not necessary to include a graph in your answer.
Therefore, the linear function is given by