# The Method of Undetermined Coefficients

The general solution to the linear differential equation `L(y)=phi(x)` 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(y) = 0. For method for obtaining `y_h` when the differential equation has constant coefficients see method of solutions note.

Here one method will be given for obtaining a particular solution `y_p` once `y_h` is known.

The method of undetermined coefficients is applicable onh if `phi(x)` 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(x),\ y_2(x),\ ...,\ y_n(x)`}.

The method is initiated by assuming a particular solution of the form `y_p=A_1 y_1(x)+A_2 y_2(x)+...+A_n y_n(x)` where `A_1,\ A_2, ...,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 like terms.

**Case 1**. `phi(x)=p_n(x)` , polynomial of n-th degree. Assume solution of the form `y_p=A_n x^n+A_(n-1) x^(n-1)+...+Ax+A_0` where `A_j` (j=0, 1, ..., n) are constants to be determined.

Example 1. Find particular solution of `y''+3y'+2y=x^2+2` .

Assume that particular solution is of the form `y_p=Ax^2+Bx+C` .

Then `y_p'=2Ax+B` and `y_p''=2A` .

Now plug these values into differential equation:

`(2A)+3(2Ax+B)+2(Ax^2+Bx+C)=2Ax^2+(6A+2B)x+(2A+3B+C)` .

Equating like terms with `x^2+2` gives:

`{(2A=1),(6A+2B=0),(2A+3B+C=2):}`

Which has solution `A=1/2,B=-3/2,C=11/4` .

So, particular solution is `y_p=1/2 x^2-3/2 x+11/4` .

**Case 2**. `phi(x)=ke^(alpha x)` . Assume solution of the form `y_p=Ae^(alpha x)` where A is a constant to be determined.

Example 2. Find particular solution of `y'''-4y'+2y=3e^(7x)` .

Assume that particular solution is of the form `y_p=Ae^(7x)` .

Then `y_p'=7Ae^(7x)` , `y_p''=49Ae^(7x)` and `y_p'''=343Ae^(7x)` .

Plugging this values into equation gives `343Ae^(7x)-4*7Ae^(7x)+2Ae^(7x)=317Ae^(7x)` .

Equating coefficients with `3e^(7x)` gives `317A=3` or `A=3/317` .

So, particular solution is `y_p=3/317 e^(7x)` .

**Case 3**. `phi(x)=k_1cos(beta x)+k_2 sin(beta x)` . Assume solution in the form of `y_p=Acos(beta x)+Bcos(beta x)` (even when either `k_1` or `k_2` equals zero).

Example 3. Solve `y''+y=cos(2x)` .

We are asked to solve equation, so we first detemine solution of homogeneous equation `y''+y=0` .

Characteristic equation is `r^2+1=0` that has roots `r_1=i,\ r_2=-i` so solution of homogeneous equation (see how to solve homogeneous equation) is `y_h=c_1 cos(x)+c_2 sin(x)` .

Now, assume that particular solution is of the form `y_p=Acos(2x)+Bsin(2x)` then `y_p'=-2Asin(2x)+2Bcos(2x)` and `y_p''=-4Acos(2x)-4Bsin(2x)` .

Plugging these values into equation gives: `-4Acos(2x)-4Bsin(2x)+Acos(2x)+Bsin(2x)=-3Acos(2x)-3Bsin(2x)` .

Equating like terms with `cos(2x)` we obtain that

`{(-3A=1),(-3B=0):}`

So, `A=-1/3, B=0` .

So, particular solution is `y_p=-1/3cos(2x)` .

Finally, general solution is `y=y_h+y_p=c_1 cos(x)+c_2 sin(2x)-1/3 cos(2x)` .

**Generalizations**. If `phi(x)` is the product of functions from above cases then assume particular solution to be product of assumed solutions of corresponding cases. For example, if `phi(x)=e^(alpha x)p_n(x)sin(beta x)` or `phi(x)=e^(alpha x)p_n(x)cos(beta x)` then assume particular solution in the form

`y_p=e^(alpha x)(A_n x^n+A_(n-1)x^(n-1)+...+A_1x+A_0)cos(beta x)+`

`+e^(alpha x)(B_n x^n+B_(n-1)x^(n-1)+...+B_1x+B_0)cos(beta x)` where `A_j` and `B_j` (j=0, 1, ..., n) are constants that still need to be determined.

If `phi(x)` is the sum (or difference) of terms already considered, then we take `y_p` to be the sum (or difference) of the corresponding assumed solutions and algebraically combine arbitrary constants where possible.

Example 4. Find particular solution of `y''+y=e^(-x)cos(2x)+x^2` .

Here `phi(x)` is sum of two manageable functions: `phi(x)=(e^(-x)cos(2x))+(x^2)`

So, assume particular solution in the form of `y_p=(e^(-x)(Acos(2x)+Bsin(2x)))+(Cx^2+Dx+E)` .

Then `y_p'=-Ae^(-x)cos(2x)-2Ae^(-x)sin(2x)-Be^(-x)sin(2x)+2Be^(-x)cos(2x)+2Cx+D` and

`y_p''=Ae^(-x)cos(2x)+2Ae^(-x)sin(2x)+2Ae^(-x)sin(2x)-4Ae^(-x)cos(2x)+Be^(-x)sin(2x)-2Be^(-x)cos(2x)-2Be^(-x)cos(2x)-4Be^(-x)sin(2x)+2C` .

Plugging these values into equation gives

`Ae^(-x)cos(2x)+2Ae^(-x)sin(2x)+2Ae^(-x)sin(2x)-4Ae^(-x)cos(2x)+Be^(-x)sin(2x)-2Be^(-x)cos(2x)-2Be^(-x)cos(2x)-4Be^(-x)sin(2x)+2C+e^(-x)(Acos(2x)+Bsin(2x))+Cx^2+Dx+E=(A-4A-2B-2B+A)e^(-x)cos(2x)+(2A+2A+B-4B+B)e^(-x)sin(2x)+Cx^2+Dx+(2C+E)=(-2A-4B)e^(-x)cos(2x)+(4A-2B)e^(-x)sin(2x)+Cx^2+Dx+(2C+E)`

Equating like terms with `e^(-x)cos(2x)+x^2` we obtain that

`{(-2A-4B=1),(4A-2B=0),(C=1),(D=0),(2C+E=0):}`

This system has following solution: `A=-1/10, B=-1/5, C=1, D=0,E=-2` , so particular solution is

`y_p=-1/10 e^(-x)cos(2x)-1/5 e^(-x)sin(2x)+x^2-2` .

If any term of the assumed solution, disregarding multiplicative constants, is also a term of `y_h` (the homogeneous solution), then the assumed solution must 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 yh.

Example 5. Find particular solution of `y''+y=cos(x)` .

As already known from example 3 homogeneous solution is `y_h=c_1cos(x)+c_2sin(x)` .

We can't take particular solution to be `Acos(x)+Bsin(x)` because its terms are parts of homogeneous solution so let

`y_p=Axcos(x)+Bxsin(x)` .

Then `y_p'=Acos(x)-Axsin(x)+Bsin(x)+Bxcos(x)` and `y_p''=-Asin(x)-Asin(x)-Axcos(x)+Bcos(x)+Bcos(x)-Bxsin(x)` .

Plugging these values into equation gives:

`-Asin(x)-Asin(x)-Axcos(x)+Bcos(x)+Bcos(x)-Bxsin(x)+Axcos(x)+Bxsin(x)=-2Asin(x)+2Bcos(x)` .

Equating like terms with `cos(x)` we obtain that

`{(-2A=0),(2B=1):}`

Solution is `A=0, B=1/2` .

So, particular solution is `y_p=1/2 xsin(x)` .

Example 6. Solve `y''-2y'+y=e^(x)` .

First find solution of corresponding homogeneous equation `y''-2y'+y=0` .

Characteristic equation is `r^2-2r+1=0` or `(r-1)^2=0` which has roots `r_1=1, r_2=1` .

There is one root of multiplicity 2, so solution is `y_h=c_1e^x+c_2 xe^x` .

Now, what will be the particular solution? It isn't `e^x` because `e^x` is already in solution, it is not also `xe^x` . The lowest number m for which `x^me^x` is not in solution is `m=2`: `x^2 e^x` .

So, let `y_p=Ax^2e^x`.

Then `y_p'=2Axe^x+Ax^2e^x=Ae^x (x^2+2x)` and `y_p''=2Ae^x+2Axe^x+2Axe^x+Ax^2e^x=Ae^x (x^2+4x+2)`

Plugging obtained values into equation we have

`Ae^x(x^2+4x+2)-2Ae^x(x^2+2x)+Ax^2 e^x=e^x`.

`2Ae^x=e^x`.

Equating like terms with `e^x` gives `2A=1` or `A=1/2`.

So, particular soltuion is `y_p=1/2 x^2e^x` .

Finally, general solution is `y=y_h+y_p=c_1e^x+c_2xe^x+1/2 x^2 e^x` .

As can be seen method of undetermined coefficients require many calculations and solving system of linear equations. So it is time consuming.

In general, if `phi(x)` is not one of the types of functions considered above, or if the differential equation does not have constant coefficients then method of undetermined coefficients is unapplicable. For example, particular solution to the equation `y''+y=(cos(x))/sin(x)` cannot be found with method of undetermined coefficients.