49 views (last 30 days)

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?

David Goodmanson
on 9 Jan 2021

Edited: David Goodmanson
on 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..

David Goodmanson
on 10 Jan 2021

Hi Paul,

I have no idea why solve would impose x~=0 in one case but not the other. And certainly the solver is very useful, but in an edge-of-the-solution case like this one, there is a very real sense in which I don't care what the solver does. In your original question the two cases are basically the same, and the decision is the same. Are you going to allow (x1+x2+x3) to go to zero in the limit, or not? Are you going to invoke continuity and/or L'Hopital's rule, or not? I would myself, but your judgment here is a lot more valuable than what some solver has to say.

Had the original equations been set as

X1 = a*(X1 + X2 + X3)

X2 = b*(X1 + X2 + X3)

X3 = c*(X1 + X2 + X3)

then there is nothing to solve unless one of a,b,c is nonzero. Let's say c. Then tossing the third equation because it is linearly dependent on the other two, you can solve the first two to obtain

X1 = a/c X3

X2 = b/c X3

as expected. Then there are no issues because X3 can be any value you wish, including 0.

David Goodmanson
on 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.

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

Start Hunting!
## 0 Comments

Sign in to comment.