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!

  • 0
    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?2011-11-21
  • 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[]`.2011-11-21
  • 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...2011-11-21

1 Answers 1

5

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)
*)
  • 0
    I just noticed that this is basically what J.M. did in the comments above (although the `Backsubstitution -> True` was not necessary).2011-11-21
  • 0
    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.2011-11-21
  • 0
    @J.M.: Sure, for one off assumptions, the explicit argument or `Assumptions` option or `Assuming[]` is best. `Assuming` basically just `Block`s `$Assumptions` anyway.2011-11-21
  • 0
    @ J. M.: Actually, by including b!=0 it works perfectly! (As well - obviously these are equivalent approaches.) Thank you!2011-11-21
  • 0
    @Simon: Thank you very much, this is exactly what I was looking for! The only interesting thing is the necessity of the b!=0 condition. Even if b=0, the solution should be still (-b - Sqrt[b^2 - 4 a c])/(2 a) < x < (-b + Sqrt[b^2 - 4 a c])/(2 a), shouldn't it? I understand that there is no solution if b=0 and c>0 (which is implied by Mathematica's output without the b!=0 condition), but this is INCLUDED in the b^2>4ac assumption...2011-11-21
  • 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!2011-11-22
  • 0
    @Simon: Sure! :) I was just waiting for your answer on this "additional" question!2011-11-23