Using variation of parameters with a system of equations to find the particular solution

 
 
Variation of parameters, system of equations blog post.jpeg
 
 
 

Method of variation of parameters, systems of equations, and Cramer’s rule

Like the method of undetermined coefficients, variation of parameters is a method you can use to find the general solution to a second-order (or higher-order) nonhomogeneous differential equation.

Remember that homogenous differential equations have a 00 on the right side, where nonhomogeneous differential equations have a non-zero function on the right side.

Krista King Math.jpg

Hi! I'm krista.

I create online courses to help you rock your math class. Read more.

 
 
homogeneous vs nonhomogeneous differential equations
 

The general solution Y(x)Y(x) to a nonhomogeneous differential equation will always be the sum of the complementary solution yc(x)y_c(x) and the particular solution yp(x)y_p(x).

Y(x)=yc(x)+yp(x)Y(x)=y_c(x)+y_p(x)

We’ll start by finding the complementary solution by pretending that the nonhomogeneous equation is actually a homogenous equation. In other words, we just replace g(x)g(x) with 00 and then solve for the values of xx that are solutions to the homogenous equation.

Depending on the values of xx that we find, we’ll generate the complementary solution to the differential equation.

 
complementary solution based on the roots of the homogeneous equation
 

From the complementary solution, we’ll pick out the fundamental set of solutions {y1,y2}\{y_1,y_2\}. The set of solutions will be everything but the coefficients c1c_1 and c2c_2. In other words,

 
fundamental set of solutions for each type of complementary solution
 

Which means we could rewrite the complementary solutions as

 
complementary solutions in terms of the fundamental set of solutions
 

Once we have the fundamental set of solutions, we’ll plug it into the simple system of linear equations

u1y1+u2y2=0u_1'y_1+u_2'y_2=0

u1y1+u2y2=g(x)u_1'y_1'+u_2'y_2'=g(x)

and then solve the system for u1u_1' and u2u_2'. The reason we want to solve for u1u_1' and u2u_2' is so that we can integrate both of them in order to find u1u_1 and u2u_2.

If we can find u1u_1 and u2u_2, then we can say that the particular solution is

yp(x)=u1y1+u2y2y_p(x)=u_1y_1+u_2y_2

Since the general solution is the sum of the complementary and particular solutions,

Y(x)=yc(x)+yp(x)Y(x)=y_c(x)+y_p(x)

we just add the particular solution to the complementary solution we found earlier in order to get the general solution. Since the complementary solution can always be written as yc(x)=c1y1+c2y2y_c(x)=c_1y_1+c_2y_2, the general solution will always be

Y(x)=c1y1+c2y2+u1y1+u2y2Y(x)=c_1y_1+c_2y_2+u_1y_1+u_2y_2

With this method, it’s important to note that you’ll want the coefficient on yy'' (or y(n)y^{(n)} for higher-degree differential equations) to be 11. If it isn’t already 11, just divide it out to make it 11.

 
 

Using the method of variation of parameters and a system of equations to find the particular solution for a differential equation


 
Krista King Math Signup.png
 
Differential Equations course.png

Take the course

Want to learn more about Differential Equations? I have a step-by-step course for that. :)

 
 

 
 

How to use variation of parameters, and Cramer’s rule for larger solution sets

Example

Use variation of parameters to find the general solution to the differential equation.

y+4y+4y=e2xx3y''+4y'+4y=\frac{e^{-2x}}{x^3}


First, we’ll make the differential equation homogeneous and solve for its roots.

y+4y+4y=0y''+4y'+4y=0

r2+4r+4=0r^2+4r+4=0

(r+2)(r+2)=0(r+2)(r+2)=0

r=2r=-2

Since we found equal real roots, we’ll use yc(x)=c1er1x+c2xer1xy_c(x)=c_1e^{r_1x}+c_2xe^{r_1x} for the complementary solution, and we get

yc(x)=c1e2x+c2xe2xy_c(x)=c_1e^{-2x}+c_2xe^{-2x}

The fundamental set of solutions is therefore

{e2x,xe2x}\left\{e^{-2x},xe^{-2x}\right\}

Now we need to generate our system of linear equations, so

u1y1+u2y2=0u_1'y_1+u_2'y_2=0

u1y1+u2y2=g(x)u_1'y_1'+u_2'y_2'=g(x)

becomes

u1e2x+u2xe2x=0u_1'e^{-2x}+u_2'xe^{-2x}=0

u1(2e2x)+u2(e2x2xe2x)=e2xx3u_1'\left(-2e^{-2x}\right)+u_2'\left(e^{-2x}-2xe^{-2x}\right)=\frac{e^{-2x}}{x^3}

If we simplify the second equation, the system becomes

u1e2x+u2xe2x=0u_1'e^{-2x}+u_2'xe^{-2x}=0

2u1e2x+u2e2x2u2xe2x=e2xx3-2u_1'e^{-2x}+u_2'e^{-2x}-2u_2'xe^{-2x}=\frac{e^{-2x}}{x^3}

To eliminate u1u_1', we’ll multiply the first equation by 22.

2u1e2x+2u2xe2x=02u_1'e^{-2x}+2u_2'xe^{-2x}=0

2u1e2x+u2e2x2u2xe2x=e2xx3-2u_1'e^{-2x}+u_2'e^{-2x}-2u_2'xe^{-2x}=\frac{e^{-2x}}{x^3}

Then adding the equations together will eliminate u1u_1'.

(2u1e2x2u1e2x)+(2u2xe2x2u2xe2x)+u2e2x=0+e2xx3\left(2u_1'e^{-2x}-2u_1'e^{-2x}\right)+\left(2u_2'xe^{-2x}-2u_2'xe^{-2x}\right)+u_2'e^{-2x}=0+\frac{e^{-2x}}{x^3}

u2e2x=e2xx3u_2'e^{-2x}=\frac{e^{-2x}}{x^3}

u2=e2xx3e2xu_2'=\frac{e^{-2x}}{x^3e^{-2x}}

u2=1x3u_2'=\frac{1}{x^3}

Plugging the value we found for u2u_2' back into 2u1e2x+2u2xe2x=02u_1'e^{-2x}+2u_2'xe^{-2x}=0 to find u1u_1', we get

2u1e2x+2(1x3)xe2x=02u_1'e^{-2x}+2\left(\frac{1}{x^3}\right)xe^{-2x}=0

2u1e2x+2e2xx2=02u_1'e^{-2x}+\frac{2e^{-2x}}{x^2}=0

2u1e2x=2e2xx22u_1'e^{-2x}=-\frac{2e^{-2x}}{x^2}

u1=2e2x2x2e2xu_1'=-\frac{2e^{-2x}}{2x^2e^{-2x}}

u1=1x2u_1'=-\frac{1}{x^2}

Now we’ll integrate u1u_1' and u2u_2' in order to find u1u_1 and u2u_2.

u1=u1=1x2 dxu_1=\int u_1'=\int-\frac{1}{x^2}\ dx

u1=x2 dxu_1=\int-x^{-2}\ dx

u1=11x1u_1=-\frac{1}{-1}x^{-1}

u1=x1u_1=x^{-1}

u1=1xu_1=\frac{1}{x}

and

u2=u2=1x3 dxu_2=\int u_2'=\int\frac{1}{x^3}\ dx

u2=x3 dxu_2=\int x^{-3}\ dx

u2=12x2u_2=\frac{1}{-2}x^{-2}

u2=12x2u_2=-\frac{1}{2}x^{-2}

u2=12x2u_2=-\frac{1}{2x^2}

Now the particular solution is given by

yp(x)=u1y1+u2y2y_p(x)=u_1y_1+u_2y_2

yp(x)=1xy112x2y2y_p(x)=\frac{1}{x}y_1-\frac{1}{2x^2}y_2

yp(x)=1xe2x12x2xe2xy_p(x)=\frac{1}{x}e^{-2x}-\frac{1}{2x^2}xe^{-2x}

yp(x)=e2xxe2x2xy_p(x)=\frac{e^{-2x}}{x}-\frac{e^{-2x}}{2x}

yp(x)=2e2x2xe2x2xy_p(x)=\frac{2e^{-2x}}{2x}-\frac{e^{-2x}}{2x}

yp(x)=2e2xe2x2xy_p(x)=\frac{2e^{-2x}-e^{-2x}}{2x}

yp(x)=e2x2xy_p(x)=\frac{e^{-2x}}{2x}

Adding this particular solution to the complementary solution gives us the general solution Y(x)Y(x).

Y(x)=c1e2x+c2xe2x+e2x2xY(x)=c_1e^{-2x}+c_2xe^{-2x}+\frac{e^{-2x}}{2x}



Larger solution sets

It’s easy to solve the system of linear equations

u1y1+u2y2=0u_1'y_1+u_2'y_2=0

u1y1+u2y2=g(x)u_1'y_1'+u_2'y_2'=g(x)

because there were only two solutions in the solution set {y1,y2}\{y_1,y_2\}, and so there were only two unknowns, u1u_1' and u2u_2'. But sometimes the solution set will be larger, for example {y1,y2,y3,y4,...,yn}\{y_1,y_2,y_3,y_4,...,y_n\}. If there were four solutions in the solution set, for example, we’d have to solve this system:

u1y1+u2y2=0u_1'y_1+u_2'y_2=0

u1y1+u2y2=0u_1'y_1'+u_2'y_2'=0

u1y1+u2y2=0u_1'y_1''+u_2'y_2''=0

u1y1+u2y2=g(x)u_1'y_1'''+u_2'y_2'''=g(x)

because you need the same number of equations in the system as you have solutions in the solution set. g(x)g(x) is always the right side of the last equation in the system; each of the other equations has 00 as its right side.

If the size of the solution set, and therefore the size of the system of linear equations becomes unmanageable, it’ll be more convenient to use Cramer’s rule to find the particular solution.

We’ll still start by changing the nonhomogeneous equation to a homogeneous equation so that we can find the complementary solution and pull out the fundamental set of solutions.

To find each unknown, u1u_1', u2u_2', u3u_3', etc., instead of solving the the system of linear equations, we’ll use a set of matrices. Let’s assume there are four solutions in our fundamental set. Then we’ll need to find the determinants of these matrices:

matrix determinants

Then, in this example,

u prime values

Therefore,

integrated u values

Which means that the particular solution is

yp(x)=u1y1+u2y2+u3y3+u4y4y_p(x)=u_1y_1+u_2y_2+u_3y_3+u_4y_4

which is really the same as

yp(x)=y1g(x)W1W+y2g(x)W2W+y3g(x)W3W+y4g(x)W4Wy_p(x)=y_1\int\frac{g(x)W_1}{W}+y_2\int\frac{g(x)W_2}{W}+y_3\int\frac{g(x)W_3}{W}+y_4\int\frac{g(x)W_4}{W}

Remember that you can modify the system of linear equations and these formulas for the complementary and particular solutions depending on how many solutions you have in the fundamental set of solutions.

Let’s try an example where we use Cramer’s rule instead of solving the system of linear equations. You usually use Cramer’s rule with higher-order differential equations, because they often turn out to have more than two solutions in the fundamental set. In this example, we’ll only get two solutions in the fundamental set, but for the sake of example we’ll start use Cramer’s rule instead of the system of linear equations.

Variation of parameters systems of equations for Differential Equations.jpg

If the size of the solution set, and therefore the size of the system of linear equations becomes unmanageable, it’ll be more convenient to use Cramer’s rule to find the particular solution.

Example

Use variation of parameters to find the general solution to the differential equation.

yy=xex+2x+1+3sinxy'''-y''=xe^x+2x+1+3\sin{x}


First, we’ll turn the nonhomogeneous equation into a homogeneous equation, so that we can find the roots of the homogeneous equation.

yy=0y'''-y''=0

r3r2=0r^3-r^2=0

r2(r1)=0r^2(r-1)=0

r=0, 1r=0,\ 1

Since these are distinct real roots, we’ll use yc(x)=c1er1x+c2er2xy_c(x)=c_1e^{r_1x}+c_2e^{r_2x} to model the complementary solution.

yc(x)=c1er1x+c2er2xy_c(x)=c_1e^{r_1x}+c_2e^{r_2x}

yc(x)=c1e0x+c2e1xy_c(x)=c_1e^{0x}+c_2e^{1x}

yc(x)=c1(1)+c2exy_c(x)=c_1(1)+c_2e^x

yc(x)=c1+c2exy_c(x)=c_1+c_2e^x

From the complementary solution, we can say that the fundamental set of solutions is

{1,ex}\left\{1,e^x\right\}

Instead of solving the system of linear equations, we’ll use Cramer’s rule and find the determinants of WW, W1W_1 and W2W_2.

Screen Shot 2020-12-28 at 6.27.46 PM.png

Now we’ll use these values, and g(x)g(x) from the right side of the nonhomogeneous equation to find u1u_1' and u2u_2'.

u1=g(x)W1Wu_1'=\frac{g(x)W_1}{W}

u1=(xex+2x+1+3sinx)(ex)exu_1'=\frac{\left(xe^x+2x+1+3\sin{x}\right)\left(-e^x\right)}{e^x}

u1=(xex+2x+1+3sinx)u_1'=-\left(xe^x+2x+1+3\sin{x}\right)

and

u2=g(x)W2Wu_2'=\frac{g(x)W_2}{W}

u2=(xex+2x+1+3sinx)(1)exu_2'=\frac{\left(xe^x+2x+1+3\sin{x}\right)(1)}{e^x}

u2=xex+2x+1+3sinxexu_2'=\frac{xe^x+2x+1+3\sin{x}}{e^x}

Integrate u1u_1' to find u1u_1.

u1=(xex+2x+1+3sinx) dxu_1=\int-\left(xe^x+2x+1+3\sin{x}\right)\ dx

u1=xex2x13sinx dxu_1=\int-xe^x-2x-1-3\sin{x}\ dx

u1=3cosxx2xxex dxu_1=3\cos{x}-x^2-x-\int xe^x\ dx

Use integration by parts with u=xu=x, v=exv=e^x, du=dxdu=dx, and dv=ex dxdv=e^x\ dx.

u1=3cosxx2x[xexex dx]u_1=3\cos{x}-x^2-x-\left[xe^x-\int e^x\ dx\right]

u1=3cosxx2xxex+ex dxu_1=3\cos{x}-x^2-x-xe^x+\int e^x\ dx

u1=3cosxx2xxex+exu_1=3\cos{x}-x^2-x-xe^x+e^x

Integrate u2u_2' to find u2u_2.

u2=xex+2x+1+3sinxex dxu_2=\int \frac{xe^x+2x+1+3\sin{x}}{e^x}\ dx

u2=xexex+2xex+1ex+3sinxex dxu_2=\int\frac{xe^x}{e^x}+\frac{2x}{e^x}+\frac{1}{e^x}+\frac{3\sin{x}}{e^x}\ dx

u2=x+2xex+ex+3exsinx dxu_2=\int x+2xe^{-x}+e^{-x}+3e^{-x}\sin{x}\ dx

u2=12x2ex+2xex dx+3exsinx dxu_2=\frac12 x^2-e^{-x}+\int2xe^{-x}\ dx+\int3e^{-x}\sin{x}\ dx

Use integration by parts with u=2xu=2x, v=exv=-e^{-x}, du=2 dxdu=2\ dx, and dv=ex dxdv=e^{-x}\ dx, in order to integrate 2xex2xe^{-x}.

u2=12x2ex+[2xex2ex dx]+3exsinx dxu_2=\frac12 x^2-e^{-x}+\left[-2xe^{-x}-\int -2e^{-x}\ dx\right]+\int3e^{-x}\sin{x}\ dx

u2=12x2ex2xex+2ex dx+3exsinx dxu_2=\frac12 x^2-e^{-x}-2xe^{-x}+\int 2e^{-x}\ dx+\int3e^{-x}\sin{x}\ dx

u2=12x2ex2xex2ex+3exsinx dxu_2=\frac12 x^2-e^{-x}-2xe^{-x}-2e^{-x}+\int3e^{-x}\sin{x}\ dx

u2=12x23ex2xex+3exsinx dxu_2=\frac12 x^2-3e^{-x}-2xe^{-x}+\int3e^{-x}\sin{x}\ dx

For now, we’ll set aside the first few terms of u2u_2 and focus just on the remaining integral. In order to integrate 3exsinx3e^{-x}\sin{x}, use integration by parts with u=3exu=3e^{-x}, v=cosxv=-\cos{x}, du=3ex dxdu=-3e^{-x}\ dx, and dv=sinx dxdv=\sin{x}\ dx.

3exsinx dx=3excosx3excosx dx\int3e^{-x}\sin{x}\ dx=-3e^{-x}\cos{x}-\int 3e^{-x}\cos{x}\ dx

Use integration by parts again with u=3exu=3e^{-x}, v=sinxv=\sin{x}, du=3ex dxdu=-3e^{-x}\ dx, and dv=cosx dxdv=\cos{x}\ dx, in order to integrate 3excosx3e^{-x}\cos{x}.

3exsinx dx=3excosx[3exsinx3exsinx dx]\int3e^{-x}\sin{x}\ dx=-3e^{-x}\cos{x}-\left[3e^{-x}\sin{x}-\int -3e^{-x}\sin{x}\ dx\right]

3exsinx dx=3excosx[3exsinx+3exsinx dx]\int3e^{-x}\sin{x}\ dx=-3e^{-x}\cos{x}-\left[3e^{-x}\sin{x}+\int 3e^{-x}\sin{x}\ dx\right]

3exsinx dx=3excosx3exsinx3exsinx dx\int3e^{-x}\sin{x}\ dx=-3e^{-x}\cos{x}-3e^{-x}\sin{x}-\int 3e^{-x}\sin{x}\ dx

The integrals on either side of the equation are like-terms, so we can combine them and then solve for the integral we’re interested in.

23exsinx dx=3excosx3exsinx2\int3e^{-x}\sin{x}\ dx=-3e^{-x}\cos{x}-3e^{-x}\sin{x}

3exsinx dx=32excosx32exsinx\int3e^{-x}\sin{x}\ dx=-\frac32 e^{-x}\cos{x}-\frac32 e^{-x}\sin{x}

Plugging this value for the integral back into the equation for u2u_2,

u2=12x23ex2xex+3exsinx dxu_2=\frac12 x^2-3e^{-x}-2xe^{-x}+\int3e^{-x}\sin{x}\ dx

we get

u2=12x23ex2xex32excosx32exsinxu_2=\frac12 x^2-3e^{-x}-2xe^{-x}-\frac32 e^{-x}\cos{x}-\frac32 e^{-x}\sin{x}

u2=x223ex2xex3cosx2ex3sinx2exu_2=\frac{x^2}{2}-\frac{3}{e^x}-\frac{2x}{e^x}-\frac{3\cos{x}}{2e^x}-\frac{3\sin{x}}{2e^x}

u2=x223+2xex3cosx+3sinx2exu_2=\frac{x^2}{2}-\frac{3+2x}{e^x}-\frac{3\cos{x}+3\sin{x}}{2e^x}

u2=x2ex2ex6+4x2ex3cosx+3sinx2exu_2=\frac{x^2e^x}{2e^x}-\frac{6+4x}{2e^x}-\frac{3\cos{x}+3\sin{x}}{2e^x}

u2=x2ex64x3cosx3sinx2exu_2=\frac{x^2e^x-6-4x-3\cos{x}-3\sin{x}}{2e^x}

u2=x2ex4x3cosx3sinx62exu_2=\frac{x^2e^x-4x-3\cos{x}-3\sin{x}-6}{2e^x}

With u1u_1 and u2u_2, we can say that the particular solution is

yp(x)=u1y1+u2y2y_p(x)=u_1y_1+u_2y_2

yp(x)=(3cosxx2xxex+ex)y1+x2ex4x3cosx3sinx62exy2y_p(x)=\left(3\cos{x}-x^2-x-xe^x+e^x\right)y_1+\frac{x^2e^x-4x-3\cos{x}-3\sin{x}-6}{2e^x}y_2

yp(x)=(3cosxx2xxex+ex)(1)+x2ex4x3cosx3sinx62ex(ex)y_p(x)=\left(3\cos{x}-x^2-x-xe^x+e^x\right)(1)+\frac{x^2e^x-4x-3\cos{x}-3\sin{x}-6}{2e^x}\left(e^x\right)

yp(x)=3cosxx2xxex+ex+x2ex4x3cosx3sinx62y_p(x)=3\cos{x}-x^2-x-xe^x+e^x+\frac{x^2e^x-4x-3\cos{x}-3\sin{x}-6}{2}

yp(x)=6cosx2x22x2xex+2ex2+x2ex4x3cosx3sinx62y_p(x)=\frac{6\cos{x}-2x^2-2x-2xe^x+2e^x}{2}+\frac{x^2e^x-4x-3\cos{x}-3\sin{x}-6}{2}

yp(x)=6cosx2x22x2xex+2ex+x2ex4x3cosx3sinx62y_p(x)=\frac{6\cos{x}-2x^2-2x-2xe^x+2e^x+x^2e^x-4x-3\cos{x}-3\sin{x}-6}{2}

yp(x)=x2ex2x22xex6x+2ex+3cosx3sinx62y_p(x)=\frac{x^2e^x-2x^2-2xe^x-6x+2e^x+3\cos{x}-3\sin{x}-6}{2}

yp(x)=12x2exx2xex3x+ex+32cosx32sinx3y_p(x)=\frac12x^2e^x-x^2-xe^x-3x+e^x+\frac32\cos{x}-\frac32\sin{x}-3

Adding this particular solution to the complementary solution gives us the general solution Y(x)Y(x).

Y(x)=c1+c2ex+12x2exx2xex3x+ex+32cosx32sinx3Y(x)=c_1+c_2e^x+\frac12x^2e^x-x^2-xe^x-3x+e^x+\frac32\cos{x}-\frac32\sin{x}-3

 
Krista King.png
 

Get access to the complete Differential Equations course