# Solve the following differential equation: {eq}y'' + 4y = 3 \:sin(x) {/eq}.

## Question:

Solve the following differential equation: {eq}y'' + 4y = 3 \:sin(x) {/eq}.

## Inhomogeneous Linear Ordinary Differential Equation:

The definition of an inhomogeneous linear ordinary differential equation with constant coefficients is an ordinary differential equation in which all terms are linear, all coefficients are constants (i.e., not functions), and also equals a non-zero function of the variable with regard to which derivatives are obtained, which encompasses the complete differential equation.

Given:

• The given function is {eq}y'' + 4y = 3\sin \,x {/eq}

{eq}4y(x) + \dfrac{{{d^2}}}{{d{x^2}}}y\left( x \right) = 3\sin (x) {/eq}

This differential equation has the form:

{eq}y'' + py' + qy = s {/eq}

Where

{eq}\begin{align} p &= 0\\ q &= 4\\ s &= - 3\sin \left( x \right) \end{align} {/eq}

It is called a linear inhomogeneous second-order differential equation with constant coefficients.

We solve the corresponding homogeneous equation

{eq}y'' + py' + qy = 0 {/eq}

To find the roots of the characteristic equation,

{eq}\begin{align} q + \left( {{k^2} + kp} \right) &= 0\\ {k^2} + 4 &= 0\\ {k_1} &= - 2i\\ {k_2} &= 2i \end{align} {/eq}

As there are 2 imaginary roots,

{eq}\begin{align} y(x) &= {C_1}\sin \left( {x\left| {{k_1}} \right|} \right) + {C_2}\cos \left( {x\left| {{k_2}} \right|} \right)\\ y(x) &= {C_1}\sin \left( {2x} \right) + {C_2}\cos \left( {2x} \right) \end{align} {/eq}

Now, to solve the inhomogeneous equation,

{eq}y'' + py' + qy = s {/eq}

The general solution is:

{eq}y(x) = {C_1}\sin \left( {2x} \right) + {C_2}\cos \left( {2x} \right) {/eq}

Hence, the solution is:

{eq}\begin{align} {y_1}\left( x \right)\dfrac{d}{{dx}}{C_1}\left( x \right) + {y_2}\left( x \right)\dfrac{d}{{dx}}{C_2}\left( x \right) &= 0\\ \dfrac{d}{{dx}}{C_1}\left( x \right)\dfrac{d}{{dx}}{y_1}\left( x \right) + \dfrac{d}{{dx}}{C_2}\left( x \right)\dfrac{d}{{dx}}{y_2}\left( x \right) &= f\left( x \right) \end{align} {/eq}

Where,

{eq}{y_1}\left( x \right),\,\,{y_2}\left( x \right) {/eq} are linearly independent of particular solutions.

{eq}\begin{align} {y_1}\left( x \right) &= \sin \left( {2x} \right)\,\left[ {{C_1} = 1,\,{C_2} = 0} \right]\\ \,{y_2}\left( x \right) &= \cos \,\left( {2x} \right)\,\left[ {{C_1} = 0,\,{C_2} = 1} \right]\\ f &= - s\\ f\left( x \right) &= 3\sin (x) \end{align} {/eq}

So the system has the form,

{eq}\begin{align} \sin (2x)\dfrac{d}{{dx}}{C_1}(x) + \cos (2x)\dfrac{d}{{dx}}{C_2}(x) &= 0\\ \dfrac{d}{{dx}}{C_1}(x)\dfrac{d}{{dx}}\sin (2x) + \dfrac{d}{{dx}}{C_2}(x)\dfrac{d}{{dx}}\cos (2x) &= 3\sin (x) \end{align} {/eq}

Solving the system,

{eq}\begin{align} \dfrac{d}{{dx}}{C_1}(x) &= \dfrac{{3\sin \,x\,\cos \,2x}}{{2{{\sin }^2}(2x) + 2{{\cos }^2}(2x)}}\\ \dfrac{d}{{dx}}{C_2}(x) &= - \dfrac{{3\sin \,x\,\cos \,2x}}{{2{{\sin }^2}(2x) + 2{{\cos }^2}(2x)}}\\ {C_1}(x) &= {C_3} + \int {\dfrac{{3\sin \,x\,\cos \,2x}}{{2{{\sin }^2}(2x) + 2{{\cos }^2}(2x)}}} \,dx\\ {C_2}(x) &= {C_4} + \int { - \dfrac{{3\sin \,x\,\cos \,2x}}{{2{{\sin }^2}(2x) + 2{{\cos }^2}(2x)}}} \,dx\\ {C_1}(x) &= {C_3} + \dfrac{{6\sin \,x\,\sin \,2x}}{{6{{\sin }^2}(2x) + 6{{\cos }^2}(2x)}} + \dfrac{{3\cos \,x\,\cos \,2x}}{{6{{\sin }^2}(2x) + 6{{\cos }^2}(2x)}}\\ {C_2}(x) &= {C_4} + \dfrac{{6\sin \,x\,\cos \,2x}}{{6{{\sin }^2}(2x) + 6{{\cos }^2}(2x)}} + \dfrac{{3\cos \,x\,\sin \,2x}}{{6{{\sin }^2}(2x) + 6{{\cos }^2}(2x)}}\\ y(x) &= {C_1}\sin 2x + {C_2}\,\cos 2x \end{align} {/eq}