# Ordinary Differential Equations/Nonhomogeneous second order equations:Method of undetermined coefficients

Consider a differencial equation of the form

${\displaystyle y''+p(t)y'+q(t)y=g(t)}$

Clerarly, this is not homogeneous, as ${\displaystyle g(t)\neq 0}$.

So, to solve this, we first proceeed as normal, but assume that the equation is homogeneous; set ${\displaystyle g(t)=0}$for now. Then the first part of the solution pans like

${\displaystyle y(t)=c_{1}e^{r_{1}t}+c_{2}e^{r_{2}t}.}$
.

Now we need to find the particular integral. To do this, make an appropriate substitution that relates to what ${\displaystyle g(t)}$ is. For instance, if ${\displaystyle g(t)=e^{2x}}$, then take substitution ${\displaystyle Ae^{2x}}$. As ${\displaystyle y''}$ and ${\displaystyle y'}$ are multiples of ${\displaystyle y}$ in this case, you'll simply get a linear equation in ${\displaystyle A}$. Then just plug the value of ${\displaystyle A}$ in the equation.

Hence the solution is

y = general solution + particular integral.

There is one important caveat which you should be aware though. In the previous example for instance, if the general solution already had ${\displaystyle e^{2x}}$, the substitution cannot be ${\displaystyle Ae^{2x}}$, as the particular integral cannot be equal to the general solution. In such cases, you need to take the substitution as ${\displaystyle Axe^{2x}}$.

## Example

Solve the differential equation

${\displaystyle {\frac {d^{2}y}{dx^{2}}}+{\frac {2dy}{dx}}+2y=4+e^{-2x}}$

Given that
${\displaystyle y(0)=4,y'(0)=-1}$

### Solution

Take ${\displaystyle y=e^{mx}}$ . Then

${\displaystyle (d^{2}y)/(dx^{2})+2dy/dx+2y\rightarrow (m+1)^{2}+1=0\rightarrow m+1=\pm i\rightarrow m=-1\pm i}$

Hence the general form of the equation becomes

${\displaystyle y=e^{-x}\left(P\cos {x}+Q\sin {x}\right)}$

Now, the particular integral has to be found. To do so, we consider RHS: ${\displaystyle 4+{2e}^{-2x}}$ . The substation then becomes ${\displaystyle A+Be^{-2x}}$ . Then ${\displaystyle y^{\prime }=-2Be^{-2x}}$  and ${\displaystyle y^{\prime \prime }=4Be^{-2x}}$ . Then the equation reduces to ${\displaystyle 4B-4B+2\left(A+Be^{-2x}\right)=4+2e^{-2x}\rightarrow 2A+2Be^{-2x}=4+2e^{-2x}}$ . Hence ${\displaystyle A=2,B=1}$ . The equation is now

${\displaystyle y=e^{-x}\left(P\cos {x}+Q\sin {x}\right)+2+e^{-2x}}$

${\displaystyle y\left(0\right)=4.}$  Then ${\displaystyle 4=P+2+1\rightarrow P=1.}$
${\displaystyle y^{\prime }\left(0\right)=-1}$ . Then

${\displaystyle -e^{-x}\left(P\cos {x}+Q\sin {x}\right)+e^{-x}\left(Q\cos {x}-P\sin {x}\right)-2e^{-2x}=-1=>\ Q-P-2=-1\rightarrow Q-P=1\rightarrow Q=2.}$

Hence the final equation is

${\displaystyle y=e^{-x}\left(\cos {x}+2\sin {x}\right)+2+e^{-2x}}$