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 Comments
Sign in to comment.