# Differential Equations

I have solve this differential equation :

\left\{\begin{aligned}\frac{dy}{dx} + y &= f(x) \\ y (0)&=0. \end{aligned}\right. where $f (x) = \begin{cases}2 & \text{if } 0 \leq x < 1 \\ 0 &\text{if }x \geq 1.\end{cases}$
Please explain how to solve as it involves discontinuous function $f$.

-
This is not an exact differential equation. You'd need to multiply it by an integrating factor to get an exact differential equation. – Robert Israel Sep 13 '11 at 20:07
The integrating factor does not involve the function on the right. It would be the same integrating factor if the equation was $\frac{dy}{dx} + y = 0$. – Robert Israel Sep 13 '11 at 20:15
@ Robert Israel: Thanks, I got the I.F as e ^x. – rupa Sep 13 '11 at 20:18
@Robert Israel : Please suggest how to proceed beyond this. – rupa Sep 13 '11 at 20:24

Multiply by the integrating factor $e^x$ and then you can factor the LHS: $$(e^xy)'=e^xf(x).$$ Now integrate from $0$ to $x$ to get $$e^xy(x)-e^0y(0)=\int_0^xe^uf(u)du$$ but remember $y(0)=0$. Now divide by the integrating factor and you have $y(x)=e^{-x}\int_0^xe^uf(u)du$. We can evaluate this by (a) looking at $x\in[0,1)$ and then (b) looking at $x\ge1$ for a piecewised defined solution $y$ (note: in the latter case you will have to split $\int_0^x$ into $\int_0^1+\int_1^x$ to substitute for $f$).