I want to solve a linear system in 3 variables Ax=b
where A
is a 4×3 matrix and b
is a vector.
A
is the matrix A=[1 1 1 ; 1 2 1 ; 1 2 3 ; 1 4 1]
while b=[1 1 1 2]
The complete 4×4 matrix A|b
has rank 4:
> rank([A b'])
ans = 4
so the system has no solution.
I used linsolve
:
> linsolve(A,b')
ans =
0.6071
0.3571
-0.1071
which is nonsense from a mathematical point of view, given that Ax=b
has no solutions!
The only thing I can imagine, is that the software is providing a least-square solution for the system, that is a solution of A'Ax=A'b
; in fact you get
> linsolve(A'*A,A'*b')
ans =
0.6071
0.3571
-0.1071
yet it doesn’t warn me about this: it provides the solution linsolve(A,b')
as if it were an actual solution, which it isn’t!
Am I doing something wrong or missing something?