MuPAD Fails to Solve a Simple Inequality

1 visualizzazione (ultimi 30 giorni)
Bruno
Bruno il 27 Giu 2016
Risposto: Karan Gill il 7 Lug 2016
I have a simple inequality and MuPAD is doing something very strange.
Here are the variables:
>> syms X ndot4B xiA ndot4B ndot4A xiB
I'm trying to solve the following inequality (please do it yourself "on paper"!):
>> solve(X*ndot4B*xiA - ndot4B*xiA + X*ndot4A*xiB > 0, xiA)
The answer is:
ans =
(X*ndot4A*xiB - 1)/(ndot4B - X*ndot4B)
But this is not correct! If instead I solve it as an equality:
>> solve(X*ndot4B*xiA - ndot4B*xiA + X*ndot4A*xiB, xiA)
The result is:
ans =
(X*ndot4A*xiB)/(ndot4B - X*ndot4B)
The above is correct (i.e., xiA has to be greater than the solution above). The difference is in the numerator. Maple gets it right (as it should). Any ideas of what may be going on? It's hard to believe that MuPAD would screw up on such simple calculation.

Risposte (1)

Karan Gill
Karan Gill il 7 Lug 2016
solve's answer is correct. You can verify it as:
syms X ndot4B xiA ndot4A xiB
eqn = X*ndot4B*xiA - ndot4B*xiA + X*ndot4A*xiB > 0;
trySol = (X*ndot4A*xiB)/(ndot4B - X*ndot4B); % let's try the proposed answer
tryCondition = subs(eqn,xiA,trySol); % substitute the answer to get the condition
isAlways(tryCondition) % check if the condition holds?
ans =
logical
0
The condition doesn't hold. Now try solve's answer with the same steps:
trySol = (X*ndot4A*xiB - 1)/(ndot4B - X*ndot4B);
tryCondition = subs(eqn,xiA,trySol);
isAlways(tryCondition)
ans =
logical
1
This answer is correct. You can check on paper yourself by substituting these two values for "xiA". You just need some positive value in the numerator to satisfy the ">" inequality. For example, even using eps instead of "-1" will work:
trySol = (X*ndot4A*xiB - eps)/(ndot4B - X*ndot4B);
isAlways(subs(eqn,xiA,trySol))
ans =
logical
1
As shown on the StackOverflow thread, if you make change the ">" to "==", then you don't need the positive value. I'll mirror my answer over there. Hope this helps.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by