Method of Undetermined Coefficients
The general solution to the linear differential equation $$${L}{\left({y}\right)}=\phi{\left({x}\right)}$$$ is given as $$${y}={y}_{{h}}+{y}_{{p}}$$$, where $$${y}_{{p}}$$$ denotes one solution to the differential equation and $$${y}_{{h}}$$$ is the general solution to the associated homogeneous equation $$${L}{\left({y}\right)}={0}$$$. For the method to obtain $$${y}_{{h}}$$$ when the differential equation has constant coefficients, see the method of solutions note.
Here, one method will be given for obtaining the particular solution $$${y}_{{p}}$$$ once $$${y}_{{h}}$$$ is known.
The method of undetermined coefficients is applicable only if $$$\phi{\left({x}\right)}$$$ and all of its derivatives can be written in terms of the same finite set of linearly independent functions, which we denote by {$$${y}_{{1}}{\left({x}\right)},\ {y}_{{2}}{\left({x}\right)},\ \ldots,\ {y}_{{n}}{\left({x}\right)}$$$}.
The method is initiated by assuming a particular solution of the form $$${y}_{{p}}={A}_{{1}}{y}_{{1}}{\left({x}\right)}+{A}_{{2}}{y}_{{2}}{\left({x}\right)}+\ldots+{A}_{{n}}{y}_{{n}}{\left({x}\right)}$$$, where $$${A}_{{1}},\ {A}_{{2}},\ldots,{A}_{{n}}$$$ denote arbitrary multiplicative constants. These arbitrary constants are then evaluated by substituting the proposed solution into the given differential equation and equating the coefficients of the like terms.
Case 1. $$$\phi{\left({x}\right)}={p}_{{n}}{\left({x}\right)}$$$, a polynomial of n-th degree. Assume the solution of the form $$${y}_{{p}}={A}_{{n}}{{x}}^{{n}}+{A}_{{{n}-{1}}}{{x}}^{{{n}-{1}}}+\ldots+{A}{x}+{A}_{{0}}$$$, where $$${A}_{{j}}, j=0,{1},\ldots,n$$$ are the constants to be determined.
Example 1. Find the particular solution of $$${y}''+{3}{y}'+{2}{y}={{x}}^{{2}}+{2}$$$.
Assume that the particular solution is of the form $$${y}_{{p}}={A}{{x}}^{{2}}+{B}{x}+{C}$$$.
Then, $$${y}_{{p}}'={2}{A}{x}+{B}$$$, and $$${y}_{{p}}''={2}{A}$$$.
Now, plug these values into the differential equation:
$$${\left({2}{A}\right)}+{3}{\left({2}{A}{x}+{B}\right)}+{2}{\left({A}{{x}}^{{2}}+{B}{x}+{C}\right)}={2}{A}{{x}}^{{2}}+{\left({6}{A}+{2}{B}\right)}{x}+{\left({2}{A}+{3}{B}+{C}\right)}$$$.
Equating the like terms with $$${{x}}^{{2}}+{2}$$$ gives:
$$${\left\{\begin{array}{c}{2}{A}={1}\\{6}{A}+{2}{B}={0}\\{2}{A}+{3}{B}+{C}={2}\\ \end{array}\right.}$$$,
Which has the solution $$${A}=\frac{{1}}{{2}},{B}=-\frac{{3}}{{2}},{C}=\frac{{11}}{{4}}$$$.
So, the particular solution is $$${y}_{{p}}=\frac{{1}}{{2}}{{x}}^{{2}}-\frac{{3}}{{2}}{x}+\frac{{11}}{{4}}$$$.
Case 2. $$$\phi{\left({x}\right)}={k}{{e}}^{{\alpha{x}}}$$$. Assume the solution of the form $$${y}_{{p}}={A}{{e}}^{{\alpha{x}}}$$$, where $$${A}$$$ is the constant to be determined.
Example 2. Find the particular solution of $$${y}'''-{4}{y}'+{2}{y}={3}{{e}}^{{{7}{x}}}$$$.
Assume that the particular solution is of the form $$${y}_{{p}}={A}{{e}}^{{{7}{x}}}$$$.
Then, $$${y}_{{p}}'={7}{A}{{e}}^{{{7}{x}}}$$$, $$${y}_{{p}}''={49}{A}{{e}}^{{{7}{x}}}$$$, and $$${y}_{{p}}'''={343}{A}{{e}}^{{{7}{x}}}$$$.
Plugging these values into the equation gives $$${343}{A}{{e}}^{{{7}{x}}}-{4}\cdot{7}{A}{{e}}^{{{7}{x}}}+{2}{A}{{e}}^{{{7}{x}}}={317}{A}{{e}}^{{{7}{x}}}$$$.
Equating the coefficients with $$${3}{{e}}^{{{7}{x}}}$$$ gives $$${317}{A}={3}$$$, or $$${A}=\frac{{3}}{{317}}$$$.
So, the particular solution is $$${y}_{{p}}=\frac{{3}}{{317}}{{e}}^{{{7}{x}}}$$$.
Case 3. $$$\phi{\left({x}\right)}={k}_{{1}}{\cos{{\left(\beta{x}\right)}}}+{k}_{{2}}{\sin{{\left(\beta{x}\right)}}}$$$. Assume the solution in the form of $$${y}_{{p}}={A}{\cos{{\left(\beta{x}\right)}}}+{B}{\cos{{\left(\beta{x}\right)}}}$$$ (even when either $$${k}_{{1}}$$$ or $$${k}_{{2}}$$$ equals zero).
Example 3. Solve $$${y}''+{y}={\cos{{\left({2}{x}\right)}}}$$$.
We are asked to solve the equation, so we should first detemine the solution of the homogeneous equation $$${y}''+{y}={0}$$$.
The characteristic equation is $$${{r}}^{{2}}+{1}={0}$$$ that has the roots $$${r}_{{1}}={i},\ {r}_{{2}}=-{i}$$$; so, the solution of the homogeneous equation (see how to solve a homogeneous equation) is $$${y}_{{h}}={c}_{{1}}{\cos{{\left({x}\right)}}}+{c}_{{2}}{\sin{{\left({x}\right)}}}$$$.
Now, assume that the particular solution is of the form $$${y}_{{p}}={A}{\cos{{\left({2}{x}\right)}}}+{B}{\sin{{\left({2}{x}\right)}}}$$$; then, $$${y}_{{p}}'=-{2}{A}{\sin{{\left({2}{x}\right)}}}+{2}{B}{\cos{{\left({2}{x}\right)}}}$$$, and $$${y}_{{p}}''=-{4}{A}{\cos{{\left({2}{x}\right)}}}-{4}{B}{\sin{{\left({2}{x}\right)}}}$$$.
Plugging these values into the equation gives: $$$-{4}{A}{\cos{{\left({2}{x}\right)}}}-{4}{B}{\sin{{\left({2}{x}\right)}}}+{A}{\cos{{\left({2}{x}\right)}}}+{B}{\sin{{\left({2}{x}\right)}}}=-{3}{A}{\cos{{\left({2}{x}\right)}}}-{3}{B}{\sin{{\left({2}{x}\right)}}}$$$.
Equating the like terms with $$${\cos{{\left({2}{x}\right)}}}$$$, we obtain that
$$${\left\{\begin{array}{c}-{3}{A}={1}\\-{3}{B}={0}\\ \end{array}\right.}$$$
So, $$${A}=-\frac{{1}}{{3}},{B}={0}$$$.
Thus, the particular solution is $$${y}_{{p}}=-\frac{{1}}{{3}}{\cos{{\left({2}{x}\right)}}}$$$.
Finally, the general solution is $$${y}={y}_{{h}}+{y}_{{p}}={c}_{{1}}{\cos{{\left({x}\right)}}}+{c}_{{2}}{\sin{{\left({2}{x}\right)}}}-\frac{{1}}{{3}}{\cos{{\left({2}{x}\right)}}}$$$.
Generalizations. If $$$\phi{\left({x}\right)}$$$ is the product of functions from the above cases, assume the particular solution to be the product of the assumed solutions of the corresponding cases. For example, if $$$\phi{\left({x}\right)}={{e}}^{{\alpha{x}}}{p}_{{n}}{\left({x}\right)}{\sin{{\left(\beta{x}\right)}}}$$$ or $$$\phi{\left({x}\right)}={{e}}^{{\alpha{x}}}{p}_{{n}}{\left({x}\right)}{\cos{{\left(\beta{x}\right)}}}$$$, assume the particular solution in the form
$$${y}_{{p}}={{e}}^{{\alpha{x}}}{\left({A}_{{n}}{{x}}^{{n}}+{A}_{{{n}-{1}}}{{x}}^{{{n}-{1}}}+\ldots+{A}_{{1}}{x}+{A}_{{0}}\right)}{\cos{{\left(\beta{x}\right)}}}+$$$
$$$+{{e}}^{{\alpha{x}}}{\left({B}_{{n}}{{x}}^{{n}}+{B}_{{{n}-{1}}}{{x}}^{{{n}-{1}}}+\ldots+{B}_{{1}}{x}+{B}_{{0}}\right)}{\cos{{\left(\beta{x}\right)}}}$$$, where $$${A}_{{j}}$$$ and $$${B}_{{j}},j=0,1,\ldots,n$$$ are constants that still need to be determined.
If $$$\phi{\left({x}\right)}$$$ is the sum (or difference) of the terms already considered, then we take $$${y}_{{p}}$$$ to be the sum (or difference) of the corresponding assumed solutions and algebraically combine the arbitrary constants where possible.
Example 4. Find the particular solution of $$${y}''+{y}={{e}}^{{-{x}}}{\cos{{\left({2}{x}\right)}}}+{{x}}^{{2}}$$$.
Here, $$$\phi{\left({x}\right)}$$$ is the sum of two manageable functions: $$$\phi{\left({x}\right)}={\left({{e}}^{{-{x}}}{\cos{{\left({2}{x}\right)}}}\right)}+{\left({{x}}^{{2}}\right)}$$$.
So, assume the particular solution in the form of $$${y}_{{p}}={\left({{e}}^{{-{x}}}{\left({A}{\cos{{\left({2}{x}\right)}}}+{B}{\sin{{\left({2}{x}\right)}}}\right)}\right)}+{\left({C}{{x}}^{{2}}+{D}{x}+{E}\right)}$$$.
Then, $$${y}_{{p}}'=-{A}{{e}}^{{-{x}}}{\cos{{\left({2}{x}\right)}}}-{2}{A}{{e}}^{{-{x}}}{\sin{{\left({2}{x}\right)}}}-{B}{{e}}^{{-{x}}}{\sin{{\left({2}{x}\right)}}}+{2}{B}{{e}}^{{-{x}}}{\cos{{\left({2}{x}\right)}}}+{2}{C}{x}+{D}$$$, and
$$${y}_{{p}}''={A}{{e}}^{{-{x}}}{\cos{{\left({2}{x}\right)}}}+{2}{A}{{e}}^{{-{x}}}{\sin{{\left({2}{x}\right)}}}+{2}{A}{{e}}^{{-{x}}}{\sin{{\left({2}{x}\right)}}}-{4}{A}{{e}}^{{-{x}}}{\cos{{\left({2}{x}\right)}}}+{B}{{e}}^{{-{x}}}{\sin{{\left({2}{x}\right)}}}-{2}{B}{{e}}^{{-{x}}}{\cos{{\left({2}{x}\right)}}}-{2}{B}{{e}}^{{-{x}}}{\cos{{\left({2}{x}\right)}}}-{4}{B}{{e}}^{{-{x}}}{\sin{{\left({2}{x}\right)}}}+{2}{C}$$$.
Plugging these values into the equation gives:
$$${A}{{e}}^{{-{x}}}{\cos{{\left({2}{x}\right)}}}+{2}{A}{{e}}^{{-{x}}}{\sin{{\left({2}{x}\right)}}}+{2}{A}{{e}}^{{-{x}}}{\sin{{\left({2}{x}\right)}}}-{4}{A}{{e}}^{{-{x}}}{\cos{{\left({2}{x}\right)}}}+{B}{{e}}^{{-{x}}}{\sin{{\left({2}{x}\right)}}}-{2}{B}{{e}}^{{-{x}}}{\cos{{\left({2}{x}\right)}}}-{2}{B}{{e}}^{{-{x}}}{\cos{{\left({2}{x}\right)}}}-{4}{B}{{e}}^{{-{x}}}{\sin{{\left({2}{x}\right)}}}+{2}{C}+{{e}}^{{-{x}}}{\left({A}{\cos{{\left({2}{x}\right)}}}+{B}{\sin{{\left({2}{x}\right)}}}\right)}+{C}{{x}}^{{2}}+{D}{x}+{E}={\left({A}-{4}{A}-{2}{B}-{2}{B}+{A}\right)}{{e}}^{{-{x}}}{\cos{{\left({2}{x}\right)}}}+{\left({2}{A}+{2}{A}+{B}-{4}{B}+{B}\right)}{{e}}^{{-{x}}}{\sin{{\left({2}{x}\right)}}}+{C}{{x}}^{{2}}+{D}{x}+{\left({2}{C}+{E}\right)}={\left(-{2}{A}-{4}{B}\right)}{{e}}^{{-{x}}}{\cos{{\left({2}{x}\right)}}}+{\left({4}{A}-{2}{B}\right)}{{e}}^{{-{x}}}{\sin{{\left({2}{x}\right)}}}+{C}{{x}}^{{2}}+{D}{x}+{\left({2}{C}+{E}\right)}$$$
Equating the like terms with $$${{e}}^{{-{x}}}{\cos{{\left({2}{x}\right)}}}+{{x}}^{{2}}$$$, we obtain that
$$${\left\{\begin{array}{c}-{2}{A}-{4}{B}={1}\\{4}{A}-{2}{B}={0}\\{C}={1}\\{D}={0}\\{2}{C}+{E}={0}\\ \end{array}\right.}$$$
This system has the following solution: $$${A}=-\frac{{1}}{{10}},{B}=-\frac{{1}}{{5}},{C}={1},{D}={0},{E}=-{2}$$$; so, the particular solution is
$$${y}_{{p}}=-\frac{{1}}{{10}}{{e}}^{{-{x}}}{\cos{{\left({2}{x}\right)}}}-\frac{{1}}{{5}}{{e}}^{{-{x}}}{\sin{{\left({2}{x}\right)}}}+{{x}}^{{2}}-{2}$$$.
If any term of the assumed solution, disregarding the multiplicative constants, is also a term of $$${y}_{{h}}$$$ (the homogeneous solution), the assumed solution has to be modified by multiplying it by $$${{x}}^{{m}}$$$, where $$${m}$$$ is the smallest positive integer such that the product of $$${x}_{{m}}$$$ with the assumed solution has no terms in common with $$${y}_{{h}}$$$.
Example 5. Find the particular solution of $$${y}''+{y}={\cos{{\left({x}\right)}}}$$$.
As already known from example 3, the homogeneous solution is $$${y}_{{h}}={c}_{{1}}{\cos{{\left({x}\right)}}}+{c}_{{2}}{\sin{{\left({x}\right)}}}$$$.
We can't take the particular solution to be $$${A}{\cos{{\left({x}\right)}}}+{B}{\sin{{\left({x}\right)}}}$$$ because its terms are parts of the homogeneous solution; so, let
$$${y}_{{p}}={A}{x}{\cos{{\left({x}\right)}}}+{B}{x}{\sin{{\left({x}\right)}}}$$$.
Then, $$${y}_{{p}}'={A}{\cos{{\left({x}\right)}}}-{A}{x}{\sin{{\left({x}\right)}}}+{B}{\sin{{\left({x}\right)}}}+{B}{x}{\cos{{\left({x}\right)}}}$$$, and $$${y}_{{p}}''=-{A}{\sin{{\left({x}\right)}}}-{A}{\sin{{\left({x}\right)}}}-{A}{x}{\cos{{\left({x}\right)}}}+{B}{\cos{{\left({x}\right)}}}+{B}{\cos{{\left({x}\right)}}}-{B}{x}{\sin{{\left({x}\right)}}}$$$.
Plugging these values into the equation gives:
$$$-{A}{\sin{{\left({x}\right)}}}-{A}{\sin{{\left({x}\right)}}}-{A}{x}{\cos{{\left({x}\right)}}}+{B}{\cos{{\left({x}\right)}}}+{B}{\cos{{\left({x}\right)}}}-{B}{x}{\sin{{\left({x}\right)}}}+{A}{x}{\cos{{\left({x}\right)}}}+{B}{x}{\sin{{\left({x}\right)}}}=-{2}{A}{\sin{{\left({x}\right)}}}+{2}{B}{\cos{{\left({x}\right)}}}$$$.
Equating the like terms with $$${\cos{{\left({x}\right)}}}$$$, we obtain that
$$${\left\{\begin{array}{c}-{2}{A}={0}\\{2}{B}={1}\\ \end{array}\right.}$$$
The solution is $$${A}={0},{B}=\frac{{1}}{{2}}$$$.
So, the particular solution is $$${y}_{{p}}=\frac{{1}}{{2}}{x}{\sin{{\left({x}\right)}}}$$$.
Now, let's take a look at another example.
Example 6. Solve $$${y}''-{2}{y}'+{y}={{e}}^{{{x}}}$$$.
First, find the solution of the corresponding homogeneous equation $$${y}''-{2}{y}'+{y}={0}$$$.
The characteristic equation is $$${{r}}^{{2}}-{2}{r}+{1}={0}$$$ or $$${{\left({r}-{1}\right)}}^{{2}}={0}$$$ that has the roots $$${r}_{{1}}={1},{r}_{{2}}={1}$$$.
There is one root of the multiplicity 2; so, the solution is $$${y}_{{h}}={c}_{{1}}{{e}}^{{x}}+{c}_{{2}}{x}{{e}}^{{x}}$$$.
Now, what will be the particular solution? It isn't $$${{e}}^{{x}}$$$ because $$${{e}}^{{x}}$$$ is already in the solution, it is not $$${x}{{e}}^{{x}}$$$ either. The lowest number $$${m}$$$ for which $$${{x}}^{{m}}{{e}}^{{x}}$$$ is not in the solution is $$${m}={2}$$$: $$${{x}}^{{2}}{{e}}^{{x}}$$$.
So, let $$${y}_{{p}}={A}{{x}}^{{2}}{{e}}^{{x}}$$$.
Then, $$${y}_{{p}}'={2}{A}{x}{{e}}^{{x}}+{A}{{x}}^{{2}}{{e}}^{{x}}={A}{{e}}^{{x}}{\left({{x}}^{{2}}+{2}{x}\right)}$$$, and $$${y}_{{p}}''={2}{A}{{e}}^{{x}}+{2}{A}{x}{{e}}^{{x}}+{2}{A}{x}{{e}}^{{x}}+{A}{{x}}^{{2}}{{e}}^{{x}}={A}{{e}}^{{x}}{\left({{x}}^{{2}}+{4}{x}+{2}\right)}$$$.
Plugging the obtained values into equation, we have
$$${A}{{e}}^{{x}}{\left({{x}}^{{2}}+{4}{x}+{2}\right)}-{2}{A}{{e}}^{{x}}{\left({{x}}^{{2}}+{2}{x}\right)}+{A}{{x}}^{{2}}{{e}}^{{x}}={{e}}^{{x}}$$$
$$${2}{A}{{e}}^{{x}}={{e}}^{{x}}$$$
Equating the like terms with $$${{e}}^{{x}}$$$ gives $$${2}{A}={1}$$$, or $$${A}=\frac{{1}}{{2}}$$$.
So, the particular soltuion is $$${y}_{{p}}=\frac{{1}}{{2}}{{x}}^{{2}}{{e}}^{{x}}$$$.
Finally, the general solution is $$${y}={y}_{{h}}+{y}_{{p}}={c}_{{1}}{{e}}^{{x}}+{c}_{{2}}{x}{{e}}^{{x}}+\frac{{1}}{{2}}{{x}}^{{2}}{{e}}^{{x}}$$$.
As can be seen, the method of undetermined coefficients requires many calculations and solving a system of linear equations. So, it is time-consuming.
In general, if $$$\phi{\left({x}\right)}$$$ is not one of the types of functions considered above or if the differential equation does not have constant coefficients, the method of undetermined coefficients is unapplicable. For example, the particular solution to the equation $$${y}''+{y}=\frac{{{\cos{{\left({x}\right)}}}}}{{\sin{{\left({x}\right)}}}}$$$ cannot be found with the method of undetermined coefficients.