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$
  • 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 May 25 '18 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$ – leastaction May 26 '18 at 7:03
6
$\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$
  • $\begingroup$ Your code does not work on MMA Version 8,0. What should @*List be? $\endgroup$ – Akku14 May 25 '18 at 5:09
  • 1
    $\begingroup$ @Akku14 See Composition $\endgroup$ – Michael E2 May 26 '18 at 12:04
  • $\begingroup$ Thank you @chuy for the response. This is very nice. $\endgroup$ – leastaction May 26 '18 at 14:36
  • $\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 May 30 '18 at 19:32

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.