If $y'+y=|x|$ and $y(-1)=0$, what is $y(1)$?
I calculated the integrating factor to be $e^x$.
Then $e^x y'+ e^x y=e^x |x|$ hence $\frac {d(e^x y)}{dx}=e^x |x|$ hence $d(e^x y)=e^x|x|dx $
Integrating both sides,
$e^xy=e^x \int |x|dx- \int [(\int |x|dx)(e^x)]dx +c.$
From here how to proceed?
Can I write $\int |x|dx=-2 \int xdx, x \lt 0$? Then I will get the constant $c$ by using $y(-1)=0$. But how will it help me to calculate $y(1)$?
For $x \lt 0$, then
$$y' + y=-x$$
The general solution is
$$y(x) = C e^{-x} +1-x$$
$$y(-1) = C e + 2 = 0 \implies C = -2/e$$
and for $x \gt 0$
$$y'+y = x$$
so that $y(x)$ in this region is
$$y(x) = D e^{-x}-1+x$$
We find $D$ by requiring continuity at $x=0$:
$$1-\frac{2}{e} = D-1 \implies D = 2 -\frac{2}{e}$$
Thus,
$$y(1) = \left ( 2 -\frac{2}{e} \right ) e^{-1} = \frac{2}{e} - \frac{2}{e^2} $$