How can I find ranges of inequalities using solve in live script

10 views (last 30 days)
When using solve in mupad to find the range of function ouputs for a given input inequality, the answers do not (1) match those obtained using mupad nor do they make sense. Does anyone know the cause of this inconsistency. I'm new to solvers in matlab and on the basis of Mathwork's suggestion to use live scripts rather than mupad, I'm assuming that most functions should perform similarly?
In brief, I have one equation for which I would like to find the zero roots and also the > 0 and < 0 ranges for this equation.
In mupad the code is as follows:
solve(x^4 +7*x -3*x^3 -6 = 0, x,Real,IgnoreAnalyticConstraints)
with = replaced by either < or >, respectively. The answers in mupad are as expected from graphing the function.
In live script the solver does not give me a solution for the < 0 condition, and gives me two values for the > 0 condition (rather the the union of intervals as expected), which I struggle to understand.
The live script code is as follows:
syms x
S = solve(x^4 +7*x -3*x^3 -6 == 0, x,'IgnoreAnalyticConstraints', true, 'MaxDegree', 4, 'Real', true)
vpa(S)
Again == is replaced by either > or <. In this case, only the equality gives expected values. As a simple test I changed the < and > to <= and >0, here the one of ranges (or interval) should start at the root values. This is not the case. rather the the union of intervals (as expected).
Could anyone explain this to me. Any help is much appreciated.
Johan

Accepted Answer

Karan Gill
Karan Gill on 10 Mar 2017
Edited: Karan Gill on 10 Mar 2017
Try the 'ReturnConditions' option:
syms x
ineq = x^4 +7*x -3*x^3 -6 > 0;
S = solve(x^4 +7*x -3*x^3 -6 > 0, x,'IgnoreAnalyticConstraints', true, 'MaxDegree', 4, 'Real', true, 'ReturnConditions', true)
S =
struct with fields:
x: [2×1 sym]
parameters: [1×1 sym]
conditions: [2×1 sym]
Check the conditions on "x".
S.conditions
ans =
x < 1/3 - (61/54 - 29^(1/2)/6)^(1/3) - 7/(9*(61/54 - 29^(1/2)/6)^(1/3))
2 < x
Under these two conditions, the inequality is always satisfied. I think this is the union of two conditions you're looking for? For more info, see the documentation on 'ReturnConditions'.
Without 'ReturnConditions', I think "solve" is simply returning valid values of "x". But I'm not sure right now.
  3 Comments
Karan Gill
Karan Gill on 12 Mar 2017
Yes, the "solve" command is a bit complex. I show the "ReturnConditions" option in the first example itself, but maybe the use was not clear? Any feedback on the doc would be welcome.
Karan (Symbolic doc)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!