Undetermined Coefficients

In the previous post, we learned how to solve differential equations of the form

$\begin{align*} a_ny^{(n)} + \cdots + a_2 y'' + a_1 y' + a_0 y = 0. \end{align*}$


Now, we consider differential equations of the form

$\begin{align*} a_ny^{(n)} + \cdots + a_2 y'' + a_1 y' + a_0 y = f(x) \end{align*}$


where the right hand side is no longer strictly $0$, but rather some function $f(x)$. The solution to such a differential equation is given by

$\begin{align*} y(x) = y_0(x) + y_f(x) \end{align*}$


where $y_0$ is the general solution to the “homogeneous” equation

$\begin{align*} a_ny^{(n)} + \cdots + a_2 y'' + a_1 y' + a_0 y = 0 \end{align*}$


and $y_f$ is a particular solution which satisfies the “inhomogeneous” equation

$\begin{align*} a_ny^{(n)} + \cdots + a_2 y'' + a_1 y' + a_0 y = f(x). \end{align*}$


We already know how to use the characteristic polynomial to find $y_0$, and now we will learn how to use the method of undetermined coefficients to find $y_f$.

The method of undetermined coefficients involves guessing a solution $y_f(x)$ having the same form as $f(x)$, except possibly multiplied by some other coefficients. We then substitute this guess into the differential equation, and solve for the value of the coefficient that will make the guess correct.

For example, to find a particular solution to the differential equation $y’^\prime+2y’+y=1-2e^{3x}$, we can guess that $y_f(x)=A+Be^{3x}$ for some values of $A$ and $B$. Substituting our guess into the equation, we can solve for the correct values of $A$ and $B$.

$\begin{align*} y''+2y'+y &= 1−2e^{3x} \\ \left( A+Be^{3x} \right)'' + 2 \left( A+Be^{3x} \right)' + A+Be^{3x} &= 1−2e^{3x} \\ 9Be^{3x} + 6Be^{3x} + A+Be^{3x} &= 1−2e^{3x} \\ 16Be^{3x} + A &= 1−2e^{3x} \\ A = 1, & \hspace{.25cm} B = −\frac{1}{8} \end{align*}$


Our particular solution is then given by $y_f(x)=1-\frac{1}{8}e^{3x}$. Then, using the characteristic polynomial method, we solve $y’^\prime+2y’+y=0$ to find $y_0(x)=(C_1+C_2)e^{-x}$. The full solution to the differential equation $y’^\prime+2y’+y=1-2e^{3x}$ is then given by

$\begin{align*} y(x) &= y_0(x) + y_f(x) \\ &= (C_1+C_2x)e^{−x} + 1 − \frac{1}{8}e^{3x}. \end{align*}$


In cases where $f(x)$ contains $\sin \theta$ or $\cos \theta$, we include both $\sin \theta$ and $\cos \theta$ in our guess for $y_0$. For example, to find a particular solution to the differential equation $y’’^\prime-3y’^\prime+2y’=-3\cos 2x$, we need to construct a guess that contains both $\sin 2x$ and $\cos 2x$. Our guess, then, is

$\begin{align*} y_f(x) = A \sin 2x + B \cos 2x. \end{align*}$


We substitute this guess into the differential equation and simplify.

$\begin{align*} \begin{matrix} \left( A \sin 2x + B \cos 2x \right)''' − 3\left( A \sin 2x + B \cos 2x \right)'' \\ + 2\left( A \sin 2x + B \cos 2x \right)' \end{matrix} &= −3\cos 2x \\ \begin{matrix} \text{ } \\ \left( −8A \cos 2x + 8B \sin 2x \right) − 3\left( −4A \sin 2x −4B \cos 2x \right) \\ + 2\left( 2A \cos 2x − 2B \sin 2x \right) \\ \text{ } \end{matrix} &= −3\cos 2x \\ (12A+4B) \sin 2x + (−4A+12B) \cos 2x &= −3\cos 2x \end{align*}$


Equating coefficients on the left and right sides of the equation yields a system of equations for $A$ and $B$.

$\begin{align*} \begin{cases} 12A+4B &= 0 \\ −4A+12B &= −3 \end{cases} \end{align*}$


Solving this system, we find $A=\frac{3}{40}$ and $B=-\frac{9}{40}$. The particular solution is then $y_f(x) = \frac{3}{40} \sin 2x − \frac{9}{40} \cos 2x$. Using the characteristic polynomial to solve $y’’^\prime-3y’^\prime+2y’=0$ yields $y_0(x)=C_1+C_2 e^x + C_3 e^{2x}$, and the full solution of the differential equation $y’’^\prime-3y’^\prime+2y’=-3\cos 2x$ is then given by

$\begin{align*} y(x) &= y_0(x) + y_f(x) \\ &= C_1 + C_2 e^x + C_3 e^{2x} + \frac{3}{40} \sin 2x − \frac{9}{40} \cos 2x. \end{align*}$


When we have multiple values of $\theta$, we end up with even more unknown coefficients in our guess. For example, to find a particular solution to the differential equation $y’^\prime-2y=4\sin 3x - \cos 5x$, we need to construct a guess that contains both $\sin \theta$ and $\cos \theta$, for both $\theta = 3x$ and $\theta = 5x$. Our guess, then, is

$\begin{align*} y_f(x) = A\sin 3x + B\cos 3x + C \sin 5x + D \cos 5x. \end{align*}$


We substitute this guess into the differential equation and simplify.

$\begin{align*} \begin{matrix} \left( A\sin 3x + B\cos 3x + C \sin 5x + D \cos 5x \right)'' \\ − 2\left( A\sin 3x + B\cos 3x + C \sin 5x + D \cos 5x \right) \end{matrix} &= 4\sin 3x − \cos 5x \\ \begin{matrix} \text{ } \\ \left( −9A\sin 3x −9 B \cos 3x − 25C \sin 5x − 25D \cos 5x \right) \\ − 2\left( A\sin 3x + B\cos 3x + C \sin 5x + D \cos 5x \right) \\ \text{ } \end{matrix} &= 4\sin 3x − \cos 5x \\ −11A \sin 3x − 11B \cos 3x − 27C \sin 5x − 27D \cos 5x &= 4\sin 3x − \cos 5x \end{align*}$


Equating coefficients on the left and right sides of the equation yields $A=-\frac{4}{11}$, $B=0$, $C=0$, and $D=\frac{1}{27}$. The particular solution is then $y_f(x) = −\frac{4}{11} \sin 3x + \frac{1}{27} \cos 5x$. Using the characteristic polynomial to solve $y’^\prime-2y=0$ yields $y_0(x) = C_1e^{\sqrt{2} x} + C_2e^{−\sqrt{2} x}$, and the full solution of the differential equation $y’^\prime−2y=4\sin 3x −\cos 5x$ is then given by

$\begin{align*} y(x) &= y_0(x) + y_f(x) \\ &= C_1e^{\sqrt{2} x} + C_2e^{−\sqrt{2} x} −\frac{4}{11} \sin 3x + \frac{1}{27} \cos 5x . \end{align*}$


Lastly, the differential equation $y’^\prime+y’=x^3-2x+e^{2x}$ has a polynomial and an exponential term, so our guess for the particular solution needs to contain a polynomial and an exponential term. The polynomial in the differential equation is of degree $3$, and the differential equation itself is of degree $2$, so our guess needs to contain a polynomial of degree $3+2=5$.

$\begin{align*} y_f(x) = Ax^5 + Bx^4 + Cx^3 + Dx^2 + Ex + F + Ge^{2x} \end{align*}$


We substitute this guess into the differential equation and simplify.

$\begin{align*} \begin{matrix} \left( Ax^5 + Bx^4 + Cx^3 + Dx^2 + Ex + F + Ge^{2x} \right)'' \\ + \left( Ax^5 + Bx^4 + Cx^3 + Dx^2 + Ex + F + Ge^{2x} \right)' \end{matrix} &= x^3−2x+e^{2x} \\ \begin{matrix} \text{ } \\ \left( 20Ax^3 + 12Bx^2 + 6Cx + 2D + 4Ge^{2x} \right) \\ + \left( 5Ax^4 + 4Bx^3 + 3Cx^2 + 2Dx + E + 2Ge^{2x} \right) \\ \text{ } \end{matrix} &= x^3−2x+e^{2x} \\ \begin{matrix} 5Ax^4+(20A+4B)x^3+(12B+3C)x^2 \\ + (6C+2D)x+2D+E + 6Ge^{2x} \end{matrix} &= x^3−2x+e^{2x} \end{align*}$


Equating coefficients on the left and right sides of the equation yields $A=0$, $B=\frac{1}{4}$, $C=-1$, $D=2$, $E=-4$, and $G=\frac{1}{6}$. The coefficient $F$ can still be any number, so we leave it as-is. The particular solution is then

$\begin{align*} y_f(x) = \frac{1}{4}x^4 −x^3 +2x^2 −4x + F +\frac{1}{6} e^{2x} . \end{align*}$


Using the characteristic polynomial to solve $y’^\prime+y’=0$ yields $y_0(x) = C_1 + C_2 e^has {-x}$, and the full solution of the differential equation $y’^\prime+y’=x^3-2x+e^{2x}$ is then given by

$\begin{align*} y(x) &= y_0(x) + y_f(x) \\ &= C_1 + C_2e^{−x} +\frac{1}{4}x^4 −x^3 +2x^2 −4x + F +\frac{1}{6} e^{2x}. \end{align*}$


To eliminate redundancy, we can lump the $F$ constant into the $C_1$ constant, since $C_1+F$ is itself just another constant.

$\begin{align*} y(x) = C_1 + C_2e^{−x} +\frac{1}{4}x^4 −x^3 +2x^2 −4x +\frac{1}{6} e^{2x} \end{align*}$



Practice Problems


Use the method of undetermined coefficients to solve the following differential equations. (You can view the solution by clicking on the problem.)

$\begin{align*} 1) \hspace{.5cm} y''+y=4e^{5x} \end{align*}$
Solution:
$\begin{align*} y=C_1 \cos x + C_2 \sin x + \frac{2}{13}e^{5x} \end{align*}$

$\begin{align*} 2) \hspace{.5cm} y'+3y=\sin(2x) \end{align*}$
Solution:
$\begin{align*} y=C_1e^{−3x}+\frac{3\sin 2x − 2\cos 2x}{13} \end{align*}$

$\begin{align*} 3) \hspace{.5cm} y''-y'=\cos(\pi x) \end{align*}$
Solution:
$\begin{align*} y=C_1e^x + C_2 − \frac{\sin (\pi x)+ \pi \cos (\pi x)}{\pi + \pi^3} \end{align*}$

$\begin{align*} 4) \hspace{.5cm} y'''-2y'=x^2+1 \end{align*}$
Solution:
$\begin{align*} y=C_1e^{\sqrt{2}x} + C_2e^{−\sqrt{2}x} + C_3 − \frac{1}{6}x^3−x \end{align*}$

$\begin{align*} 5) \hspace{.5cm} 2y'-y=\sin(x)-\cos(2x) \end{align*}$
Solution:
$\begin{align*} y=C_1 e^{\frac{1}{2}x}−\frac{\sin x + 2 \cos x}{5} + \frac{\cos(2x)−4\sin(2x)}{17} \end{align*}$

$\begin{align*} 6) \hspace{.5cm} 2y'+y=e^x+3\sin(x) \end{align*}$
Solution:
$\begin{align*} y=C_1e^{−\frac{1}{2}x} + \frac{1}{3}e^{x} + \frac{3\sin x− 6\cos x}{5} \end{align*}$

$\begin{align*} 7) \hspace{.5cm} 4y''-9y=2x^4-3x^2+\cos(x+1) \end{align*}$
Solution:
$\begin{align*} y=C_1e^{\frac{3}{2}x} + C_2e^{−\frac{3}{2}x} − \frac{2}{9}x^4−\frac{23}{27}x^2−\frac{1}{13}\cos(x+1)−\frac{184}{243} \end{align*}$

$\begin{align*} 8) \hspace{.5cm} y'+y=\sin(2x+1)+\cos(5x)+1 \end{align*}$
Solution:
$\begin{align*} y=C_1e^{−x} + \frac{5\sin(5x)+\cos(5x)}{26} + \frac{\sin(2x+1)−2\cos(2x+1)}{5}+1 \end{align*}$

Leave a Comment