Problem Solving Symbolic Inequalities

30 views (last 30 days)
I'm trying to use Matlab to solve inequalities like the example below, but only have partial sucess, with other times getting the result shown below.
EDU>> solution=solve('((k1^2 + 1080.0*k1 - 2948400.0)/(k1 - 4660.0))>0')
solution = matrix([[solve([0.0 < (k1^2 + 1080.0*k1 - 2948400.0)/(k1 - 4660.0)], [k1])]])
I know that the solutions for this example are -2340<k1<1260 & k1>4660, is there something that I can do differently to make this work in Matlab? Thanks.

Accepted Answer

Stefan Wehmeier
Stefan Wehmeier on 19 Mar 2012
Note that by default solve is in complex mode, i.e., you are looking for all solutions within the complex numbers. Try
solution=feval(symengine, 'solve', '((k1^2 + 1080.0*k1 - 2948400.0)/(k1 - 4660.0))>0', 'k1', 'Real')
  2 Comments
Alexander
Alexander on 19 Mar 2012
|solve| also supports the option |real|, so you don't need |feval|:
solution = solve('((k1^2 + 1080.0*k1 - 2948400.0)/(k1 - 4660.0))>0', 'Real', true)
filston Rukerandanga
filston Rukerandanga on 14 Jul 2020
Confirmed, the option 'real', solved my problem. Before it was giving me a warning like :
Warning: Unable to find explicit solution. For options, see help.
> In solve (line 317)
% So here is my working code
syms n
eq1 = -10*log10(abs(1/(1 + (.25)^(2*n))))<=0.05;
eq2 = -10*log10(abs(1/(1 + (2)^(2*n))))>10;
eq1 = rewrite( -10*log10(abs(1/(1 + (.25)^(2*n))))<=0.05,'log');
eq2 = rewrite(-10*log10(abs(1/(1 + (2)^(2*n))))>10, 'log');
soln = solve(eq1,eq2, n, 'IgnoreAnalyticConstraints',1,'real',1);
n = vpa(soln)

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 14 Mar 2012
Symbolic solvers are notoriously poor at inequalities. All except the long-gone Axiom: it was supposedly good.
In the particular case above, Maple 15 gives the solution as
RealRange(Open(-2340), Open(1260))
RealRange(Open(4660), infinity)
In general, though, what I usually end up doing is transforming the inequality in to an equality by introducing a variable that I add constraints on to:
syms k1
syms c positive
solve( ((k1^2 + 1080.0*k1 - 2948400.0)/(k1 - 4660.0)) - c, k1)
Since the assumed-positive value c needs to be subtracted for the expression to equal 0, then that is equivalent to saying that the result of the expression (without the "- c") must be positive.
There have been a fair number of expressions in Maple that I could not get anywhere on until I substituted a particular number (symbolic) as the difference and made the expressions in to equalities.

Community Treasure Hunt

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

Start Hunting!