linsolve consistency problem in system equation
3 views (last 30 days)
Show older comments
Hi
When I run this code I obtain a simple solution.
x=rand(1,3);
swc(1,1:3)=x+1;
syms x1 x2 x3;
eqn11=swc(1,1)==x1+1;
eqn12=swc(1,2)==x2+1;
eqn13=swc(1,3)==x3+1;
[A,B] = equationsToMatrix([eqn11,eqn12,eqn13], [x1,x2,x3]);
X = linsolve(A,B)
X =
1069854916266911/1125899906842624
77565677658637/2251799813685248
987964467329731/2251799813685248
x-X'
ans =
[ 0, 0, 0]
but when I run this I obtain an error :
x=rand(1,3);
swc(1,1:3)=x+1;
swc(2,1:3)=x+2;
swc(3,1:3)=x+3;
syms x1 x2 x3;
eqn11=swc(1,1)==x1+1;
eqn12=swc(1,2)==x2+1;
eqn13=swc(1,3)==x3+1;
eqn21=swc(2,1)==x1+2;
eqn22=swc(2,2)==x2+2;
eqn23=swc(2,3)==x3+2;
eqn31=swc(3,1)==x1+3;
eqn32=swc(3,2)==x2+3;
eqn33=swc(3,3)==x3+3;
[A,B] = equationsToMatrix([eqn11,eqn21,eqn31,eqn12,eqn22,eqn32,eqn13,eqn23,eqn33], [x1,x2,x3]);
X = linsolve(A,B)
Warning: solution does not exist because the system is inconsistent.
> In symengine
In sym/privBinaryOp (line 1034)
In sym/linsolve (line 63)
X =
Inf
Inf
Inf
The problem is that in this deliberately trivial example the lines are parallel 3 by 3 and therefore return the exact same value of x , so we should find ourselves in the case of a system of dependent but consistent equations. (following the link https://ionamaths.weebly.com/uploads/1/4/2/0/14204419/consistencyanddependency.pdf )
Why don't I obtain simply x as in the the previous example ???
Thanks!
0 Comments
Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!