2
$\begingroup$

I am trying to reduce a bunch of inequalities using the Reduce command in Mathematica. But the output is very convoluted and I am wondering if there's a way to systematically organize it so that I can actually write it on a piece of paper, or at the very least, read it correctly.

For example,

Reduce[h1>=0 && h2>=0 && 2*x>=0 && -m+h1+y>=0 && m+x-y>=0 && h2-x+2y>=0, {x,y}] 

produces output that looks like this

enter image description here

which, needless to say, looks horrendous.

Is there a way to clean this up?

$\endgroup$
2
  • 1
    $\begingroup$ The output is systematically organized in a Cylindrical algebraic decomposition -- if you learn what it means you'll find it easier to use. $\endgroup$
    – Michael E2
    Commented May 25, 2018 at 0:22
  • $\begingroup$ Thanks, @MichaelE2. Knowing what it is doesn't help me read the output as cleanly as I would like, but thanks for enlightening me about CAD. $\endgroup$ Commented May 26, 2018 at 7:03

1 Answer 1

9
$\begingroup$

If you are OK with turning the Ors into Columns, you can do something like:

result = Reduce[
   h1 >= 0 && h2 >= 0 && 2*x >= 0 && -m + h1 + y >= 0 && 
    m + x - y >= 0 && h2 - x + 2 y >= 0, {x, y}];

TraditionalForm[
 result //. 
   {Or -> (Column[#, Right, Background -> {{White, LightGray}}, Frame -> All] &)@*List}]

Mathematica graphics

$\endgroup$
4
  • $\begingroup$ Your code does not work on MMA Version 8,0. What should @*List be? $\endgroup$
    – Akku14
    Commented May 25, 2018 at 5:09
  • 1
    $\begingroup$ @Akku14 See Composition $\endgroup$
    – Michael E2
    Commented May 26, 2018 at 12:04
  • $\begingroup$ Thank you @chuy for the response. This is very nice. $\endgroup$ Commented May 26, 2018 at 14:36
  • 1
    $\begingroup$ @Michael E2, thanks for the hint. This is the only code, that works in version 8.0 TraditionalForm[ result //. Or -> Composition[(Column[#, Right, Background -> {{White, LightGray}}, Frame -> All] &), List]] $\endgroup$
    – Akku14
    Commented May 30, 2018 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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