# Least square method solution for constant

I would like to ask, why method of least square approximation (A*x=b) gives us solution, that is equal 1/n, where n is number of unknown elements.

example: Let A = $\begin{bmatrix} 7 & 7 & 7\\ 7 & 7 & 7 \\ 7 & 7 & 7\\ 7 & 7 & 7\end{bmatrix}$ and b=$\begin{pmatrix} 7\\7 \\7\\7\end{pmatrix}$ Why are then components of vector x equal to 0.33 (1/3). I understand that this would be minimal squared distances between points and new function, but I don't know how to give proof for it (that components of vector x are equal and they are x equal to 1/(number of components)

• # rows of A should be equal to length of b? – gimusi Mar 12 '18 at 21:39
• of course. I'm sorry for a mistake. – Mirjan Pecenko Mar 12 '18 at 21:41
• How have you calculated x? – gimusi Mar 12 '18 at 21:48

In this case $b\in col(A)$ thus the solution is trivial and all the solution $x=(a,b,c)$ with $a+b+c=1$ are valid.

• but why is then a=b=c? Every time I input some constant matrix and same constant output. (xi=yi=k) it gives 1/n components to solution – Mirjan Pecenko Mar 12 '18 at 21:44
• @MirjanPecenko Least square makes sense when $b\not \in col(A)$, in this case we are solving a system with infinitely many solutions and x=$(1/3,1/3,1/3)$ is one of them. – gimusi Mar 12 '18 at 21:46

The method of ordinary least squares will not yield the solution $x=(\frac13, \frac13, \frac13)$ as the system is under-determinate.

This solution will be obtained from the pseudo-inverse of the matrix, a more powerful tool. It selects the minimum norm solution among all those possible.

• gyazo.com/f42c9419f6d25a27ed16e68fb4b8b7da . So this is not true? Because I don't understand how is it possible to get step 6 (final equation) – Mirjan Pecenko Mar 12 '18 at 22:05
• @MirjanPecenko: what is the exact dimension of your system ? You are giving incoherent information. – Yves Daoust Mar 12 '18 at 22:26
• dimensions are : A = m x n. (m=rows, n=columns). x = m x 1 and b = m x 1. Are elements in A and b are equal (some constant) – Mirjan Pecenko Mar 12 '18 at 22:42
• @MirjanPecenko: your system is 1 x n, not m x n. – Yves Daoust Mar 13 '18 at 7:20