# how to solve this linear differential equation

the differential equation is :

$$\frac{dy}{dx}+y=f(x),~~~~~~~~ y(0)=0$$

where,

$$f(x)=\cases{2,& if 0\le x\lt1\\0,& if x\ge 1}.$$

So what i did was....

since it is a linear differential equation, i calculated its I.F(integrating factor)= $e^x$

and used..

$$y(I.F)=\int (e^x f(x)+c\tag{1})\,dx.$$

Now, how should i use the splitting of $f(x)$ to solve for $y$ in $(1)$

• Another approach is Laplace transforms. – Amzoti Jan 17 '15 at 15:17
• @Amzoti i have no idea of that, i'll look into it for sure. – Shobhit Jan 17 '15 at 15:21
• write up two solution in the different range and match them at the boundary by requiring $y$ to be continuous. the derivative will certainly have a jump. – abel Jan 20 '15 at 16:29

solving for $y$ in the interval $[0,1],$ you find $y = 2 -2 e^{-x}$ and $y(1) = 2 - 2/e.$ use this as the initial value and solve $\dfrac{dy}{dx} + y = 0$ to get $y = 2(e-1)e^{-x}$ for $x \ge 1$.

• oh yeah, got it. thnks – Shobhit Jan 22 '15 at 15:10