Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want

Abs[x] + Abs[y] <= 1

to be convert to

x + y <= 1 && x + y >= -1 && x - y <= 1 && x - y >= -1  

How could I get it with Mathematica?

share|improve this question
3  
Reduce[Abs[x] + Abs[y] <= 1, {x, y}, Reals] already does a pretty good job--and incidentally shows that all solutions lie in the interval $[-1,1]$. –  whuber Jan 30 '13 at 19:22
add comment

3 Answers

up vote 5 down vote accepted
expandAbs[eq_] := And @@ Flatten@Module[{case},
eq //. 
 x_?((case = Cases[#, Abs[_], Infinity, 1]) =!= {} &) :> (case = 
    First[case]; {x /. case -> First[case], 
    x /. case -> -First[case]})]
expandAbs[Abs[x] + Abs[y] <= 1]
share|improve this answer
    
This isn't always algebraically correct, but this is: expandAbs[eq_] := Module[{case}, eq //. x_?((case = Cases[#, Abs[_], Infinity, 1]) =!= {} &) :> (case = First[case]; Or[(x /. case -> First[case]) && First@case >= 0, (x /. case -> -First[case]) && First@case < 0])] –  VF1 Aug 30 '13 at 5:06
add comment

In case you want to visualize the answer:

RegionPlot[Evaluate@Reduce[Abs[x] + Abs[y] <= 1, {x, y}, Reals], {x,-2,2}, {y,-2,2}]

enter image description here

share|improve this answer
add comment
Abs[x] + Abs[y] //. (k_: 1) Abs[x_] + y_ :> {k x + y, -k x + y} /.
 t_ :> And @@ Thread[Flatten[t] <= 1]

x + y <= 1 && x - y <= 1 && -x + y <= 1 && -x - y <= 1

Abs[x] + 2 Abs[y] + 3 Abs[z] //. (k_: 1) Abs[x_] + y_ :> {k x + y, -k x + y} /.
 t_ :> And @@ Thread[Flatten[t] <= 1]

x + 2 y + 3 z <= 1 && x + 2 y - 3 z <= 1 && x - 2 y + 3 z <= 1 && x - 2 y - 3 z <= 1 && -x + 2 y + 3 z <= 1 && -x + 2 y - 3 z <= 1 && -x - 2 y + 3 z <= 1 && -x - 2 y - 3 z <= 1

share|improve this answer
add comment

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.