\(\dfrac{dy}{dx} + 2y = \sin x\)
Show solutionHide solution
\(\dfrac{dy}{dx}+2y=\sin x\).
The coefficient of \(y\) is \(2\), so an integrating factor is \[\mu(x)=e^{\int 2\,dx}=e^{2x}.\] Multiplying both sides by \(e^{2x}\), \[e^{2x}\dfrac{dy}{dx}+2e^{2x}y=e^{2x}\sin x,\] so \[\dfrac{d}{dx}\left(e^{2x}y\right)=e^{2x}\sin x.\] Integrating, \[e^{2x}y=\int e^{2x}\sin x\,dx.\] Using \[\int e^{ax}\sin(bx)\,dx=\dfrac{e^{ax}}{a^2+b^2}\bigl(a\sin(bx)-b\cos(bx)\bigr)+C,\] with \(a=2\) and \(b=1\), we get \[\int e^{2x}\sin x\,dx=\dfrac{e^{2x}}{5}(2\sin x-\cos x)+C.\] Therefore \[e^{2x}y=\dfrac{e^{2x}}{5}(2\sin x-\cos x)+C,\] and hence \[y=\dfrac{2\sin x-\cos x}{5}+Ce^{-2x},\] where \(C\) is an arbitrary real constant. The solution is valid for all real \(x\).
A quick check: \[y'=\dfrac{2\cos x+\sin x}{5}-2Ce^{-2x},\] so \[y'+2y=\dfrac{2\cos x+\sin x}{5}-2Ce^{-2x}+2\left(\dfrac{2\sin x-\cos x}{5}+Ce^{-2x}\right)=\sin x,\] as required.