We need to find a linear function $f(x)=a_1x+a_0$ such that $\sum_{i=1}^4(f(x_i)-y_i)^2$ is minimal. $x_1=-2,x_2=-1,x_3=0,x_4=1,$ and $y_1=1,y_2=2,y_3=0,y_4=1$.

So, if I am right, I need to solve the least-squares problem for $$A=\begin{bmatrix}1 & -2\\1 & -1\\ 1&0\\1&1\end{bmatrix},b=\begin{bmatrix}1\\2\\0\\1\end{bmatrix}$$ and our "$x$"$=\begin{bmatrix}a_0\\a_1\end{bmatrix}$.

Is it correct so far?

I'm asking because the results I get on paper are questionable.

  • $\begingroup$ There is a typo in the last row and second column of $A$. It should be $1$. $\endgroup$
    – KittyL
    May 5, 2017 at 15:50
  • $\begingroup$ Thanks, I've corrected my mistakes. $\endgroup$ May 5, 2017 at 15:58
  • $\begingroup$ Then you apply the least squares formula $x=(A^TA)^{-1}A^Tb$... $\endgroup$
    – Jean Marie
    May 6, 2017 at 22:22

1 Answer 1


Yes, you are correct so far.

The title of your post suggests that you want to use a Householder transformation to solve the problem. An example of how to do that is at "Example: Solving a Least Squares Problem using Householder transformations."


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.