How do you get a general solution of and underdetermined system?
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Thomas van de Wiel
el 29 de Dic. de 2015
Comentada: John D'Errico
el 31 de Dic. de 2015
How can you obtain the general solution of an underdetermined system? What I have now is:
A=[1 2 3;-2 -1 0;0 2 4];
b=[5;-1;6];
x=A\b
but this gives me the answer x =
NaN
NaN
NaN
hope someone can help me
0 comentarios
Respuesta aceptada
Star Strider
el 29 de Dic. de 2015
I would use the pseudo-inverse pinv function:
x = pinv(A)*b
x =
166.6667e-003
666.6667e-003
1.1667e+000
There may be other options, such as the sparse matrix lsqr funciton, which gives the same result:
x = lsqr(A,b)
2 comentarios
John D'Errico
el 31 de Dic. de 2015
What Star has NOT explained is that this is NOT in fact the general solution!
When you have a singular problem, there will be issues. First of all, there may be no exact solution at all. If we change b slightly, than that would happen.
A=[1 2 3;-2 -1 0;0 2 4];
b=[5;-1;6];
x = pinv(A)*b
x =
0.16667
0.66667
1.1667
A*x
ans =
5
-1
6
bhat = b;
bhat(3) = 5
bhat =
5
-1
5
xhat = pinv(A)*bhat
xhat =
0.28161
0.64368
1.0057
Is the solution now exact? No.
A*xhat
ans =
4.5862
-1.2069
5.3103
In fact, NO exact solution exists to the modified problem, where b was perturbed slightly.
A*xhat = bhat
As we saw in the first case, the solution for b was exact. But is it the unique solution? When A is a singular matrix, the solution will not be unique. Lets see what the true solution is. There will be an undetermined coefficient, that we can vary arbitrarily. I'll call it k here. The general solution for the case of A is given by what I call xtrue, since A is a 3x3 matrix that is of rank 2.
syms k
xtrue = pinv(A)*b + k*null(A)
xtrue =
(6^(1/2)*k)/6 + 1/6
2/3 - (2^(1/2)*3^(1/2)*k)/3
(6^(½)*k)/6 + 7/6
Yes, I know this looks a bit messy, but we can pick a specific, arbitrary value of k, and get this:
vpa(subs(xtrue,k,3))
ans =
1.3914115380582557157653087040196
-1.7828230761165114315306174080392
2.3914115380582557157653087040196
A*ans
ans =
5.0
-1.0
6.0
In fact, we can always pick ANY value for k, and get a different solution, which is equally valid.
simplify(A*xtrue)
ans =
5
-1
6
So when you asked for the general solution, Star misled you, telling you it was obtainable from pinv. In fact, that was NOT the general solution.
Más respuestas (0)
Ver también
Categorías
Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!