# How to solve an ODE with an absolute value?

I am a bit confused about how to solve an ODE of this type

$$y'= \mid x \mid - \mid y \mid$$ , $$y(0)=0$$

Do I need to divide the ODE into four phases :

1. $$x>0$$ & $$y>0$$

2. $$x>0$$ & $$y<0$$

3. $$x<0$$ & $$y>0$$

4. $$x<0$$ & $$y<0$$

or is there another approach?

• Note that the solution of this problem is unique, since the right hand side is Lipschitz continuous. So if you can somehow guess a solution and verify it, you are done. Why don't you try that ? :) – Hans Engler May 4 at 13:54
• CAS says:$y(x)=\begin{cases} x-e^x+1 & x\leq 0 \\ x+e^{-x}-1 & x>0 \end{cases}$ – Mariusz Iwaniuk May 4 at 14:09
• But those two equations (above) only answer the situation of (y>0). isn't that right? – baraah baryhe May 4 at 16:52