Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Suppose we want to solve the inequality $ax^2+bx+c<0$. For simplicity, presume that $a>0$ and $b^2-4ac>0$. In this form, this is almost a trivial problem. Despite that, if we want to solve it with Mathematica (Reduce), version 8, the

Assuming[a > 0 && b^2 - 4*a*c > 0, Reduce[a*x^2 + b*x + c < 0, x, Reals]]

command generates dozens of lines (instead of simply being -(b/(2 a)) - 1/2 Sqrt[(b^2 - 4 a c)/a^2] < x < -(b/(2 a)) + 1/2 Sqrt[(b^2 - 4 a c)/a^2], in which this solution is present somewhere deeply, but it is full of

  • unnecessary case separations (as if it couldn't interpret the $b^2-4ac<0$ condition, and although it was given as assumption, it repeats this in the solution in equivalent forms),
  • impossible conditions (such as $a\leq 0$ which should have been ruled out by the assumptions),
  • branches with clearly contradictory conditions (such as x < -(b/(2 a)) - 1/2 Sqrt[(b^2 - 4 a c)/a^2] || x > -(b/(2 a)) - 1/2 Sqrt[(b^2 - 4 a c)/a^2] at the very beginning).

The usage of

Reduce[{a > 0, b^2 - 4*a*c > 0, a*x^2 + b*x + c < 0}, x, Reals]

and especially

FullSimplify[Reduce[{a > 0, b^2 - 4*a*c > 0, a*x^2 + b*x + c < 0}, x, Reals]]

alleviates the issue a bit (which is itself surprising given of what Assuming should do... or at least what I thought it should do...), but it is still far from what I've expected as a result. (Especially because this last command, although it produces the shortest output, it doesn't even give an explicit solution for $x$.)

Thank you in advance!

share|improve this question
    
Clearly, what Mathematica finds almost trivial and what you find almost trivial are two entirely different things. Solving inequalities algorithmically is not an easy problem. Did you make sure that $b$ and $c$ are treated as real numbers as well? –  Greg Graviton Nov 21 '11 at 9:29
1  
How about FullSimplify[Reduce[{a x^2 + b x + c < 0, b^2 > 4 a c, a > 0}, x, Reals, Backsubstitution -> True], b^2 > 4 a c && a > 0]? The problem with using FullSimplify on its own is that it assumes nothing; you have to either give assumptions as its second argument, or wrap it in Assume[]. –  J. M. Nov 21 '11 at 9:29
1  
@Greg, the third domain argument for Reduce[] ensures that every variable is treated as a member of the domain. On the other hand, since everything in the first argument is an inequality, using Reals is in fact not needed... –  J. M. Nov 21 '11 at 9:31

1 Answer 1

up vote 4 down vote accepted

As far as I know, Reduce doesn't use the assumptions system, only Refine, Simplify, FullSimplify and FunctionExpand do.

So you could manually put the assumptions into Reduce, then remove them from the result using the simplify mechanism:

$Assumptions = a > 0 && b^2 - 4*a*c > 0;
Reduce[a*x^2 + b*x + c < 0 && $Assumptions, x] // FullSimplify

which yields

output

If you include $b\neq0$ in your assumptions, then you get the simple result that you're looking for:

$Assumptions = a > 0 && b^2 - 4*a*c > 0 && b != 0;
Reduce[a*x^2 + b*x + c < 0 && $Assumptions, x] // FullSimplify

(* Returns:
(-b - Sqrt[b^2 - 4 a c])/(2 a) < x < (-b + Sqrt[b^2 - 4 a c])/(2 a)
*)
share|improve this answer
    
I just noticed that this is basically what J.M. did in the comments above (although the Backsubstitution -> True was not necessary). –  Simon Nov 21 '11 at 11:04
    
Ah, it works without that option. Great! :) Of course, the only trouble with mucking with $Assumptions is that you might forget that you assigned values to it, especially with long sessions. If you can't trust your memory, it is best to use Assume[] instead. –  J. M. Nov 21 '11 at 11:45
    
@J.M.: Sure, for one off assumptions, the explicit argument or Assumptions option or Assuming[] is best. Assuming basically just Blocks $Assumptions anyway. –  Simon Nov 21 '11 at 12:41
    
@ J. M.: Actually, by including b!=0 it works perfectly! (As well - obviously these are equivalent approaches.) Thank you! –  Tamas Ferenci Nov 21 '11 at 13:45
1  
@Tamas: The $b\neq0$ assumption is not included in the $b^2>4ac$ assumption, since $c$ can be less than zero. This is (almost) clear from the image posted in my answer. PS If you're happy with the answer, press the tick button to accept it! –  Simon Nov 22 '11 at 5:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.