Peculiar Result with Solve (Symbolic Math Toolbox) with Three Equations and Three Unknowns. Can Anyone Explain?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Suppose I have three equations and three unknowns as so:
>> syms X1 X2 X3 real
>> e1 = X1/(X1 + X2 + X3) == 0.1;
>> e2 = X2/(X1 + X2 + X3) == 0.4;
>> e3 = X3/(X1 + X2 + X3) == 0.5;
Now solve the equations and note the condition on the parameter of the solution x ~= 0.
>> sol=solve([e1,e2,e3],[X1,X2,X3],'ReturnConditions',true);
>> [sol.X1 sol.X2 sol.X3]
ans =
[ x/5, (4*x)/5, x]
>> sol.conditions
ans =
in(x, 'real') & x ~= 0
This solution makes perfect sense. Now don't specify ReturnConditions
>> sol=solve([e1,e2,e3],[X1,X2,X3],'ReturnConditions',false);
>> [sol.X1 sol.X2 sol.X3]
ans =
[ 1/5, 4/5, 1]
sol returns one possible solution. So far so good. But now change the RHS of the equations:
>> e1 = X1/(X1 + X2 + X3) == 0;
>> e2 = X2/(X1 + X2 + X3) == 0;
>> e3 = X3/(X1 + X2 + X3) == 1;
>> sol=solve([e1,e2,e3],[X1,X2,X3],'ReturnConditions',true);
>> [sol.X1 sol.X2 sol.X3]
ans =
[ 0, 0, x]
>> sol.conditions
ans =
in(x, 'real')
The solution would make sense, except that the condtions on the parameter do not include x ~= 0. But that's an important condition. Because if x = 0, then sol.X1 = sol.X2 = sol.X3 = 0, which doesn't make sense as an allowable solution. Now don't speciify ReturnConditions
>> sol=solve([e1,e2,e3],[X1,X2,X3],'ReturnConditions',false);
>> [sol.X1 sol.X2 sol.X3]
ans =
[ 0, 0, 0]
Whoa. That result can't be correct, can it?
0 Kommentare
Antworten (1)
David Goodmanson
am 9 Jan. 2021
Bearbeitet: David Goodmanson
am 9 Jan. 2021
Hi Paul,
certainly in the first case,
[eps/5, 4eps/5,eps]
is a solution for any nonzero eps, and if you let eps--> 0 and invoke continuity, then [0 0 0] can be seen as a solution. Similarly, you can take a look at
[eps/5, 4eps/5,eps] /2eps =? [.1 .4 .5]
which is of the form 0/0 as eps ---> 0. Then L'Hopital's rule says that the equality is correct.
In the second case, consider solutions to
X1/(X1 + X2 + X3) = a
X2/(X1 + X2 + X3) = b
X3/(X1 + X2 + X3) = c
where a,b,c are assumed all nonnegative, a+b+c = 1 (required) and c~=0.
Then for X3~= 0 the solution is
[X1 X2 X3] = [a/c b/c 1] X3
because in that case the equations become
(X3/X3) (a/c)/(a/c+b/c+1) = a
(X3/X3) (b/c)/(a/c+b/c+1) = b
(X3/X3) 1/(a/c+b/c+1) = c
Now for X3 --> 0 (and any c~=0) the continuity / L'Hopital argument can be used on (X3/X3). In particular this covers the case [a b c] = [0 0 1], which produces [X1 X2 X3] = [0 0 0]. It's also good for the first case [a b c] = [.1 .4 .5] and every other case with c~=0..
6 Kommentare
David Goodmanson
am 11 Jan. 2021
Paul.
Any a,b,c such that a+b+c=1 will have a nonempty null space, so both (0,0,1) and your original example (0.1 0.4 0.5) work. (I keep trying to advance the idea that your two examples are more alike than they are different).
In line with this result, note that
det(M(a,b,c)) = a+b+c-1
so again a+b+c=1 --> det(M) = 0 --> nonempty null space.
For M*X=0, all that is required to force X = [0 0 0] to be the only solution is to have a nonzero determinant, a+b+c~=1 and I believe the other two requirements set by the solver, a+b~=1 & a~=1 are not required. It appears that wrangling solve into 100% conistency could be difficult.
Siehe auch
Kategorien
Mehr zu Assumptions finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!