# Differential equations/Linear inhomogeneous differential equations

## Method of Undetermined Coefficients

### Definition

A non-homogeneous second order equation is an equation where the right hand side is equal to some constant or function of the independent variable. This technique is best when the right hand side of the equation has a fairly simple derivative.

### Solution

The solution is divided into two parts and then added together by superposition. The first part is obtained by solving the complimentary (homogeneous) equation. The second part is obtained from a set of equations. To illustrate the solution, we will take the equation $y''+2y'+y=x^{2}$ as an example.

1. Solve the homogeneous equation ($y''+2y'+y=0$ ) and get the roots of the characteristic equation ($(m+1)^{2}=0,m=-1$ ) .
2. Plug the roots into the general solution ($y_{c}=c_{1}\sin(x)+c_{2}\cos(x)$ ) to obtain the complementary (homogeneous) solution.
3. To get the typical (specific) solution to the differential equation, we need to choose a "solution" from a table.
1. $1$ (any constant): $A$ 2. $5x+7$ : $Ax+B$ 3. $3x^{2}-2$ : $Ax^{2}+Bx+C$ 4. $x^{3}-x+1$ : $Ax^{3}+Bx^{2}+Cx+D$ 5. $\sin(4x)$ : $A\cos(4x)+B\sin(4x)$ 6. $\cos(4x)$ : $A\cos(4x)+B\sin(4x)$ 7. $e^{5x}$ : $Ae^{5x}$ 8. $(9x-2)e^{5x}$ : $(Ax+B)e^{5x}$ 9. $x^{2}e^{5x}$ : $(Ax^{2}+Bx+C)e^{5x}$ 10. $e^{3x}\sin(4x)$ : $Ae^{3x}\cos(4x)+Be^{3x}\sin(4x)$ 11. $5x^{2}\sin(4x)$ : $(Ax^{2}+Bx+C)\cos(4x)+(Ex^{2}+Fx+G)\sin(4x)$ 12. $xe^{3x}\cos(4x)$ : $(Ax+B)e^{3x}\cos(4x)+(Cx+E)e^{3x}\sin(4x)$ 4. Choose the "solution" that best fits the right hand side of the equation. (the solution of $\textstyle x^{2}$ must take the form $\textstyle y_{p}=Ax^{2}+Bx+C$ ).
5. Differentiate the "solution" to get the derivatives of the solution ($y_{p}^{'}=2Ax+B,y_{p}^{''}=2A$ ).
6. Substitute those solutions into the left hand side of the original differential equation ($(2A)+2(2Ax+B)+(Ax^{2}+Bx+C)=x^{2}$ ).
7. Collect and compare like terms to solve for the coefficients ($A=1,B=-4,C=6$ ).
8. Substitute the coefficients back into typical "solution" ($y_{p}=x^{2}-4x+6$ ).
9. Add the typical and the complementary solutions to get the complete solution
$y=y_{c}+y_{p}=c_{1}\cos(x)+c_{2}\sin(x)+x^{2}-4x+6$ ## Variation of Parameters

### Definition

A non-homogeneous second order equation is an equation where the right hand side is equal to some constant or function of the independent variable. This technique is best when the right hand side of the equation has a fairly complicated derivative.

### Solution

This technique involves solving the complementary equation and using both solutions ($y_{1}$ and $y_{2}$ ) as a basis to solve for two more particular solutions that combine to form the typical solution $y_{p}=u_{1}(x)+u_{2}(x)$ . To illustrate, let's solve the differential equation $y''-2y'-1=2xe^{3x}$ .

1. Solve for the complementary solution ($(m-1)^{2}=0,m=\pm 1,y_{c}=e^{x}+xe^{x}$ ).
2. Take each term in the complementary solution and make them separate functions ($y_{1}=e^{x},y_{2}=xe^{x}$ ).
3. Set up the following three Wronksian matrices and take the determinants of them:
1. $W={\begin{vmatrix}y_{1}(x)&y_{2}(x)\\y_{1}^{'}(x)&y_{2}^{'}(x)\end{vmatrix}}={\begin{vmatrix}e^{x}&xe^{x}\\e^{x}&e^{x}(1+x)\end{vmatrix}}=e^{2x}$ 2. $W_{1}={\begin{vmatrix}0&y_{2}(x)\\f(x)&y_{2}^{'}(x)\end{vmatrix}}={\begin{vmatrix}0&xe^{x}\\2xe^{3x}&e^{x}(1+x)\end{vmatrix}}=-2x^{2}e^{4x}$ 3. $W_{2}={\begin{vmatrix}y_{1}(x)&0\\y_{1}^{'}(x)&f(x)\end{vmatrix}}={\begin{vmatrix}e^{x}&0\\e^{x}&2xe^{3x}\end{vmatrix}}=2xe^{4x}$ 4. Solve for the terms $u_{1}^{'}={\frac {W_{1}}{W}}={\frac {-2x^{2}e^{4x}}{e^{2x}}}=-2x^{2}e^{2x}$ and $u_{2}^{'}={\frac {W_{2}}{W}}={\frac {2xe^{4x}}{e^{2x}}}=2xe^{2x}$ .
5. Integrate them to get the terms $u_{1}={\frac {-(2x^{2}-2x+1)e^{2x}}{2}}$ and $u_{2}={\frac {(2x-1)e^{2x}}{2}}$ .
6. Combine them with the complementary solution to get the complete solution ($y=y_{c}+y_{p}=c_{1}e^{x}+c_{2}xe^{x}-{\frac {(2x^{2}-2x+1)e^{2x}}{2}}+{\frac {(2x-1)e^{2x}}{2}}$ ) .