# Initial values problem with absolute value

I've some doubts about initial values problems involving differential equation with absolute values.

For example if I have a differential equation like $y'=|x+1|$ with initial condition $y(3)=-2$, since $3>-1$ I can trascurate the absolute value and solve $y'=x+1$, is it correct?

But if the condition is for instance $y(-1)=2$ then I must consider the two different cases? That is, $y'=x+1$ if $x>-1$ and $y'=-x-1$ if $x<-1$

Is this the right way to solve this kind of problems?

You have two ODEs: $$y_1' = x + 1\tag{1}$$ which holds for $x \ge -1$, and $$y_2' = -x-1\tag{2}$$ which holds for $x \le -1$. The solutions combine to give the solution $y$ to $y' = |x + 1|$: $$y(x) = \begin{cases} y_1(x) & x \ge -1\\y_2(x) & x \le -1\end{cases}$$ Since $y$ is continuous, it is required that $y_1(-1) = y_2(-1)$.

In your first example, ODE (1) has initial value $y_1(3) = -2$, which uniquely defines $y_1(x)$ for $x \in [-1, \infty)$. ODE (2) is then uniquely defined by the continuity condition $y_2(-1) = y_1(-1)$.

In your second example, both (1) and (2) have initial value $y_1(-1) = y_2(-1) = 2$, which automatically meets the continuity condition.

In either case, in order to get the full solution, you have to examine both sides of $x = -1$.

The equation $y'(x)=|x+1|$ does not require ODE theory since it does not involve $y$. It is just an equation that can be integrated. Integrating both sides over $x \in [t_0, t]$ gives:

$$y(t) - y(t_0) = \int_{t_0}^t |x+1|dx$$

You likely intended to consider equations like $y'+y=|x+1|$ or $y'=|y+1|$.

The equation $y'=|y+1|$ is more interesting: If $y(0)=-1$ then $y(t)=-1$ for all $t \geq 0$. If $y(0)>-1$ then $y(t)>-1$ for all $t \geq 0$ (since solutions with different initial conditions cannot cross). So you can use $y'=y+1$ for that case. The case $y(0)<-1$ is similar.