Find a continuous solution satisfying: $$ \frac{dy}{dx} +y= f(x) $$ Where $$ f(x) = \begin{cases} 1 &\text{ for } 0 < x < 1, \\ 0 & \text{ for } x > 1 \end{cases} $$ with the initial condition $y(0)=0$.
I'm not sure what the best way to approach this question is. I thought I could solve it using Fourier series which gave me the particular solution of:
$$f(x) = -\frac12 + \sum_{n=1}^{\infty}\left[-\frac{1}{n\pi} + \frac{1}{n\pi} (-1)^n \right] \sin (n\pi x) $$
Then I found the complementary function $y = e^{-x}$
Is this correct? If so, I'm not sure what the full general solution would be, or if this is even a 'continuous solution'.
The function $f$ is not periodic, thus the Fourier series will not help. Perhaps you know the Laplace transform?
The easiest path is to take the homogeneous solution and apply the integrating factor resp. the variation of constants approach. Then $$ (e^xy(x))'=e^xf(x) $$ which now can be easily integrated over $(0,1)$ and $(1,\infty)$ with adaptation of the integrating factor to get the pieces together to a continuous function $y$.
$$ y(x)=\begin{cases} 1-e^{-x}&0<x<1,\\ 1-e^{-1}&x=1,\\ (e-1)e^{-x}&x>1. \end{cases} $$