Effacer les filtres
Effacer les filtres

Problem Solving Symbolic Inequalities

28 vues (au cours des 30 derniers jours)
Ben
Ben le 14 Mar 2012
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.

Réponse acceptée

Stefan Wehmeier
Stefan Wehmeier le 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 commentaires
Alexander
Alexander le 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 le 14 Juil 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)

Connectez-vous pour commenter.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 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.

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by