First-order linear ordinary differential equation with piecewise constant source term Find a continuous solution satisfying the DE: $\frac{dy}{dx} + 2y = f(x)$
$$\begin{align}
f(x) &= \begin{cases}
1, &  0 \leq x \leq 3 \\
0, &  x>3\text{.}\end{cases}\\
y(0)&=0\end{align}
$$
I don't get this problem at all. Can anyone explain what the above means for starters?
 A: solve the equation in two pieces and then match it at the boundary $x = 1.$ the two problems ares $$y' + 2y = 1,  y(0) = 0 $$ has the solution 
$$y = \frac 12(1-e^{-2x}), \, x \le  3.\tag 1 $$  now solve $$y' + 2y = 0, y(3) = \frac12(1 - e^{-6}). $$  the solution is $$y = \frac 12(1-1/e^6)e^{6-2x} , \quad 3 \le x < \infty. \tag 2$$
therefore $(1)$ and $2$ give the solution on the entire line.
A: This ODE is first order linear. You've probably seen it as follows: Consider
$$ \left \{ \begin{array}{cc} y'(x) + p(x) y(x) = g(x) \\y(0) =0 \end{array} \right.$$
The solution is found using an integrating factor
$$ \mu (x) = \exp \left [ \int_{0}^x p(s) ds  \right ]$$
and "factoring" the ODE to obtain
$$ y(x) = \frac{1}{\mu(x)} \int_{0}^x \mu(s) g(s) ds  $$
Thus in our case we have
$$ \mu(x) = \exp \left [ \int_0^x 2ds \right ] = \exp (2x) $$
so
$$y(x) = e^{-2x} \int_0^x 1_{[0,3]}(s)e^{2s} ds =  \left \{ \begin{array}{cc} \frac{1}{2}(e^{-2x}-1) & x <3 \\ \frac{1}{2}(e^{-2x}-e^{6-2x}) & x\geq 3 \end{array} \right . $$
Notice that the limit from both side of $y$ to $x=3$ approach the same limit. Thus $y$ is continuous.
