# Math Help - Differential with sin

1. ## Differential with sin

Hello.

When you have the problem y' + y = sin x then how do you go about solving it? I was going to use partial integration, but I end up in one big loop where sins and cos' are being constantly created and canceled out. Is there a special rule for such a situation

edit: Said double substitution, but meant partial integration. (hope that is the English phrase at least. uv- integral u'v dx)

2. ## Re: Differential with sin

This is a first order linear ODE, so is solved using the integrating factor method.

The integrating factor is \displaystyle \begin{align*} e^{\int{1\,dx}} = e^x \end{align*}, so multiplying both sides of the DE by the integrating factor gives

\displaystyle \begin{align*} \frac{dy}{dx} + y &= \sin{(x)} \\ e^x\,\frac{dy}{dx} + e^x\,y &= e^x\sin{(x)} \\ \frac{d}{dx} \left( e^x\,y \right) &= e^x\sin{(x)} \\ e^x\,y &= \int{e^x\sin{(x)}\,dx} \end{align*}

Now to evaluate the integral we need to use Integration by Parts.

\displaystyle \begin{align*} I &= \int{e^x\sin{(x)}\,dx} \\ I &= e^x\sin{(x)} - \int{ e^x\cos{(x)}\,dx} \\ I &= e^x\sin{(x)} - \left[ e^x\cos{(x)} - \int{ -e^x\sin{(x)}\,dx } \right] \\ I &= e^x\sin{(x)} - e^x\cos{(x)} - \int{e^x\sin{(x)}\,dx} \\ I &= e^x\sin{(x)} - e^x\cos{(x)} - I \\ 2I &= e^x\sin{(x)} - e^x\cos{(x)} \\ I &= \frac{1}{2}e^x\sin{(x)} - \frac{1}{2}e^x\cos{(x)} \end{align*}

So now going back to the DE

\displaystyle \begin{align*} e^x\,y &= \frac{1}{2}e^x\sin{(x)} - \frac{1}{2}e^x\cos{(x)} + C \\ y &= \frac{1}{2}\sin{(x)} - \frac{1}{2}\cos{(x)} + C\,e^{-x} \end{align*}

3. ## Re: Differential with sin

Ah! Now I see it. Instead of looping through integration by parts, you turn that integration back into I, and put it over on the other side. Clever. Thank you very much!