Peculiar Result with Solve (Symbolic Math Toolbox) with Three Equations and Three Unknowns. Can Anyone Explain?

1 次查看(过去 30 天)
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?

回答(1 个)

David Goodmanson
David Goodmanson 2021-1-9
编辑:David Goodmanson 2021-1-9
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 个评论
Paul
Paul 2021-1-11
编辑:Paul 2021-1-11
David,
Thanks for your thoughtful response (as usual). For me, I wannt solve() to return solutions that explicitly satiisfy the equations. And I certainly want consistency.
Regarding your example, the equations can be expressed as; M*X = 0 where
M(a, b, c) =
[ a - 1, a, a]
[ b, b - 1, b]
[ c, c, c - 1]
So the only solutions are X=0 and X being in the null space of M should it have dim > 0 (depending on the values of a,b and c. Certainly a = 0, b =0, c=1 results in a null space of dim = 1 (are there any M with a non-emply null space that doesn't have two of the paramters equal zero on the other = 1?). In any case, there are clearly condtions that should result in more than one solution. But
>> clear all
>> syms X1 X2 X3 a b c real
>> e1 = X1 == a*(X1 + X2 + X3);
>> e2 = X2 == b*(X1 + X2 + X3);
>> e3 = X3 == c*(X1 + X2 + X3);
>> sol=solve([e1,e2,e3],[X1,X2,X3],'ReturnConditions',true);
>> [sol.X1 sol.X2 sol.X3]
ans =
[ 0, 0, 0]
>> sol.conditions
ans =
a + b ~= 1 & a ~= 1 & a + b + c ~= 1
solve() returns only the zero solution but then puts conditions on it, even though that zero solution should apply for any values of a,b, and c (shouldn't it?).
David Goodmanson
David Goodmanson 2021-1-11
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by