Problem Solving Symbolic Inequalities

28 次查看(过去 30 天)
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.

采纳的回答

Stefan Wehmeier
Stefan Wehmeier 2012-3-19
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 个评论
Alexander
Alexander 2012-3-19
|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
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)

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2012-3-14
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.

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by