#### 2.3   ODE No. 3

$a y(x)-b \sin (c x)+y'(x)=0$ Mathematica : cpu = 0.0547595 (sec), leaf count = 40

$\left \{\left \{y(x)\to \frac {b (a \sin (c x)-c \cos (c x))}{a^2+c^2}+c_1 e^{-a x}\right \}\right \}$ Maple : cpu = 0.026 (sec), leaf count = 37

$\left \{ y \left ( x \right ) ={{\rm e}^{-ax}}{\it \_C1}+{\frac {b \left ( \sin \left ( cx \right ) a-c\cos \left ( cx \right ) \right ) }{{a}^{2}+{c}^{2}}} \right \}$

Hand solution

\begin {equation} \frac {dy}{dx}+ay\left ( x\right ) =b\sin \left ( cx\right ) \tag {1} \end {equation}

Integrating factor $$\mu =e^{\int adx}=e^{ax}$$. Hence (1) becomes

\begin {align*} \frac {d}{dx}\left ( \mu y\left ( x\right ) \right ) & =\mu b\sin \left ( cx\right ) \\ \mu y\left ( x\right ) & =b\int \mu \sin \left ( cx\right ) dx+C \end {align*}

Replacing $$\mu$$ by $$e^{ax}$$

\begin {equation} y\left ( x\right ) =be^{-ax}\int e^{ax}\sin \left ( cx\right ) dx+Ce^{-ax}\tag {2} \end {equation}

Using $$\sin \left ( cx\right ) =\frac {e^{icx}-e^{-icx}}{2i}$$ then \begin {align*} \int e^{ax}\sin \left ( cx\right ) dx & =\int \frac {e^{\left ( ic+a\right ) x}-e^{\left ( -ic+a\right ) x}}{2i}dx\\ & =\frac {1}{2i}\left ( \frac {e^{\left ( ic+a\right ) x}}{ic+a}-\frac {e^{\left ( -ic+a\right ) x}}{-ic+a}\right ) \\ & =\frac {1}{2i}e^{ax}\left ( \frac {e^{icx}}{ic+a}-\frac {e^{-icx}}{-ic+a}\right ) \\ & =\frac {1}{2i}e^{ax}\left ( \frac {e^{icx}\left ( -ic+a\right ) -e^{-icx}\left ( ic+a\right ) }{\left ( ic+a\right ) \left ( -ic+a\right ) }\right ) \\ & =\frac {1}{2i}e^{ax}\left ( \frac {-ice^{icx}+ae^{icx}-ice^{-icx}-ae^{-icx}}{\left ( c^{2}+a^{2}\right ) }\right ) \\ & =\frac {1}{2i}e^{ax}\left ( \frac {-ic\left ( e^{icx}+e^{-icx}\right ) +a\left ( e^{icx}-e^{-icx}\right ) }{\left ( c^{2}+a^{2}\right ) }\right ) \\ & =\frac {e^{ax}}{\left ( c^{2}+a^{2}\right ) }\left ( \frac {-ic\left ( e^{icx}+e^{-icx}\right ) }{2i}+\frac {a\left ( e^{icx}-e^{-icx}\right ) }{2i}\right ) \\ & =\frac {e^{ax}}{\left ( c^{2}+a^{2}\right ) }\left ( -c\cos cx+a\sin cx\right ) \end {align*}

Therefore (2) becomes

\begin {align*} y\left ( x\right ) & =be^{-ax}\left [ \frac {e^{ax}}{\left ( c^{2}+a^{2}\right ) }\left ( -c\cos cx+a\sin cx\right ) \right ] +Ce^{-ax}\\ & =\frac {b}{\left ( c^{2}+a^{2}\right ) }\left ( -c\cos cx+a\sin cx\right ) +Ce^{-ax} \end {align*}