Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two lists liste = {x, -y, y, -z} and listv = {1, -2, 3, -4}, which represent the inequities obtained evaluating liste - listv <= 0. How do I reassemble or join those two separate lists into a more readable one having the form {x <= 1, 2 <= y <= 3, z >= 4}?

I further require that, when an expression comes with both a lower bound and a upper bound like the y above, it should not be written in two separate equalities y >= 2 and y <= 3, but in the more compact form 2 <= y <= 3.

share|improve this question
Thread[liste - listv <= 0] // Reduce
2 <= y <= 3 && z >= 4 && x <= 1
List @@ %
{2 <= y <= 3, z >= 4, x <= 1}
share|improve this answer
4  
Can be written directly as List @@ Reduce @ Thread[liste - listv <= 0] – m_goldberg 4 hours ago
1  
Great answer. If the three variable names I used change to liste={z, -x1, x1, -x2}, the answer generated would be {x2 >= 4, z <= 1, 2 <= x1 <= 3}. How do I reorder the inequities in an "alphabetic + numeric" order, such as {2 <= x1 <= 3, x2 >= 4, z <= 1}? – nanjun 4 hours ago

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.