2
$\begingroup$

Problem Description:

Today,I am countered with a integral problem that I need visualize a 2D graph of the equation $|x|+|x+y|=1$

I plots it step-by-step by hand:

  • When $x \geq 0, x+|x+y|=1$ $$\begin{cases} 2x+y=1 & y\geq -x \\ y=-1 & y<-x \end{cases} $$
  • When $x<0, -x+|x+y|=1$

$$\begin{cases} y=1 & y \geq -x \\ 2x+y=-1 & y<-x \end{cases} $$

So I ploted this graph by four lines.

the 2-D graph of Abs[x]+Abs[x+y]==1?

However,now I want to use Mathematica to solve it.

Have a try:

Plot[y /. {Solve[Abs@x + Abs@(x + y) == 1, y]}, {x, -1, 1}, 
AspectRatio -> Automatic]

but the Mathematica give the following warning information:

“Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. >>”

So I think my solution has flaws.My question is how to revise it or give another method to solve it?

$\endgroup$

2 Answers 2

4
$\begingroup$

No warning information:

With[{sol = y /. Solve[Abs@x + Abs@(x + y) == 1, y, Reals]},
 Plot[sol, {x, -2, 2}, PlotRange -> 2, AspectRatio -> Automatic]
 ]

Plot[y /. Solve[Abs@x + Abs@(x + y) == 1, y, Reals] //  Evaluate,
 {x, -2, 2}, PlotRange -> 2, AspectRatio -> Automatic, PlotStyle -> Blue]
$\endgroup$
13
$\begingroup$
ContourPlot[Abs[x] + Abs[x + y] == 1, {x, -2, 2}, {y, -2, 2}]

enter image description here

$\endgroup$

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.