To solve $ y'+y=|x|$ What is the solution to the IVP $$y'+y=|x|, \ x \in \mathbb{R}, \ y(-1)=0$$


The general solution of the above problem is $y_{g}(x)=ce^{-x}$.

How to find the particular solution? As $|x|$ is not differentiable at origin. Is there any alternate way to get the solution?
Hint: using the integrating factor the equation can be rewritten as
$$
(e^{x}y(x))'=e^{x}|x|.
$$
Thus, you are left with writing down the solution to $w'(x)=f(x)$, $w(x_0)=0$ ($f$ continuous).


   $$w(x)=\int_{x_0}^x f(t)\,dt.$$
$$y'+y=|x|$$
Solving without condition :

Case $x&gt;0 \quad:\quad y'+y=x \qquad y=c_1e^{-x}+x-1$

Case $x&lt;0 \quad:\quad y'+y=-x \qquad y=c_2e^{-x}-x+1$
$$y=ce^{-x}+(x-1)\text{ sgn}(x)$$
sgn$(x)$ is the function sign of $x$

The function is discontinuous at $x=0$.



The discontinuous curve represented is only an example for a particular value of $c_1=c_2=c$. Of course they are an infinity of solutions. Don't confuse this general equation with the solution below which is strictly the answer corresponding to the condition $y(-1)=0$.

With condition $\quad y(-1)=0$ :

$y(-1)=0=c_2e^{-(-1)}+((-1)-1)(-1)=c_2e+2\quad;\quad c_2=-\frac{2}{e}$ 
$$y=-2e^{-x-1}-x+1 \quad \text{in } x\leq 0. \tag 1$$

In $x&gt;0$ :

Condition $y(0)=1-2e^{-1}$

$y(0)=1-2e^{-1}=c_1e^{-0}+0-1=c_1-1\quad;\quad c_1=2-2e^{-1}$
$$y=2(1-e^{-1})e^{-x}+x-1 \quad \text{in } x\geq 0. \tag 2$$



Note after the comments :

The above solution Eqs.$(1)$ and $(2)$ is the same as the LutzL's solution written on a different form :
$$y=ce^{-x}+sign(e^{-x}-1+x)$$
with $c=1+2e^{-1}$.