5
$\begingroup$

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!

$\endgroup$
  • $\begingroup$ 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? $\endgroup$ – Greg Graviton Nov 21 '11 at 9:29
  • 1
    $\begingroup$ 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[]. $\endgroup$ – J. M. is a poor mathematician Nov 21 '11 at 9:29
  • 1
    $\begingroup$ @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... $\endgroup$ – J. M. is a poor mathematician Nov 21 '11 at 9:31
5
$\begingroup$

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)
*)
$\endgroup$
  • $\begingroup$ I just noticed that this is basically what J.M. did in the comments above (although the Backsubstitution -> True was not necessary). $\endgroup$ – Simon Nov 21 '11 at 11:04
  • $\begingroup$ 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. $\endgroup$ – J. M. is a poor mathematician Nov 21 '11 at 11:45
  • $\begingroup$ @J.M.: Sure, for one off assumptions, the explicit argument or Assumptions option or Assuming[] is best. Assuming basically just Blocks $Assumptions anyway. $\endgroup$ – Simon Nov 21 '11 at 12:41
  • $\begingroup$ @ J. M.: Actually, by including b!=0 it works perfectly! (As well - obviously these are equivalent approaches.) Thank you! $\endgroup$ – Tamas Ferenci Nov 21 '11 at 13:45
  • 1
    $\begingroup$ @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! $\endgroup$ – Simon Nov 22 '11 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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