Learning Objectives
- Write the general solution to a nonhomogeneous differential equation.
- Solve a nonhomogeneous differential equation by the method of undetermined coefficients.
- Solve a nonhomogeneous differential equation by the method of variation of parameters.
General Solution to a Nonhomogeneous Linear Equation
Consider the nonhomogeneous linear differential equation
a2(x)y′′+a1(x)y′+a0(x)y=r(x).
The associated homogeneous equation
a2(x)y′′+a1(x)y′+a0(x)y=0
is called the complementary equation. We will see that solving the complementary equation is an important step in solving a nonhomogeneous differential equation.
definition
A solution yp(x) of a differential equation that contains no arbitrary constants is called a particular solution to the equation.
Theorem: general solution to a nonhomogeneous equation
Let yp(x) be any particular solution to the nonhomogeneous linear differential equation
a2(x)y′′+a1(x)y′+a0(x)y=r(x).
Also, let c1y1(x)+c2y2(x) denote the general solution to the complementary equation. Then, the general solution to the nonhomogeneous equation is given by
y(x)=c1y1(x)+c2y2(x)+yp(x).
Proof
To prove y(x) is the general solution, we must first show that it solves the differential equation and, second, that any solution to the differential equation can be written in that form. Substituting y(x) into the differential equation, we have
a2(x)y′′+a1(x)y′+a0(x)y=a2(x)(c1y1+c2y2+yp)′′+a1(x)(c1y1+c2y2+yp)′+a0(x)(c1y1+c2y2+yp)=[a2(x)(c1y1+c2y2)′′+a1(x)(c1y1+c2y2)′+a0(x)(c1y1+c2y2)]+a2(x)y′′p+a1(x)y′p+a0(x)yp=0+r(x)=r(x).
So y(x) is a solution.
Now, let z(x) be any solution to a2(x)y′′+a1(x)y′+a0(x)y=r(x). Then
a2(x)(z−yp)′′+a1(x)(z−yp)′+a0(x)(z−yp)=(a2(x)z′′+a1(x)z′+a0(x)z)−(a2(x)y′′p+a1(x)y′p+a0(x)yp)=r(x)−r(x)=0,
so z(x)=yp(x) is a solution to the complementary equation. But, c1y1(x)+c2y2(x) is the general solution to the complementary equation, so there are constants c1 and c2 such that
z(x)=yp(x)=c1y1(x)+c2y2(x).
Hence, we see that z(x)=c1y1(x)+c2y2(x)yp(x).
■
Example: verifying the general solution
Given that yp(x)=x is a particular solution to the differential equation y′′+y=x, write the general solution and check by verifying that the solution satisfies the equation.
Show Solution
The complementary equation is y′′+y=0, which has the general solution c1cosx+c2sinx. So, the general solution to the nonhomogeneous equation is
y(x)=c1cosx+c2sinx+x.
To verify that this is a solution, substitute it into the differential equation. We have
y′(x)=−c1sinx+c2cosx+1 and y′′=−c1cosx−c2sinx.
Then
y′′(x)+y(x)=−c1cosx−c2sinx+c1cosx+c2sinx+x.
So, y(x) is a solution to y′′+y=x.
try it
Given that yp(x)=−2 is a particular solution to y′′−3y′−4y=8, write the general solution and verify that the general solution satisfies the equation.
Show Solution
y(x)=c1e−x+c2e4x−2
In the preceding section, we learned how to solve homogeneous equations with constant coefficients. Therefore, for nonhomogeneous equations of the form ay′′+by′+cy=r(x), we already know how to solve the complementary equation, and the problem boils down to finding a particular solution for the nonhomogeneous equation. We now examine two techniques for this: the method of undetermined coefficients and the method of variation of parameters.
Undetermined Coefficients
The method of undetermined coefficients involves making educated guesses about the form of the particular solution based on the form of r(x). When we take derivatives of polynomials, exponential functions, sines, and cosines, we get polynomials, exponential functions, sines, and cosines. So when r(x) has one of these forms, it is possible that the solution to the nonhomogeneous differential equation might take that same form. Let’s look at some examples to see how this works.
Example: undetermined coefficients when r(x) is a polynomial
Find the general solution to y′′+4y′+3y=3x.
Show Solution
The complementary equation is y′′+4y′+3y=0, with general solution c1e−x+c2e−3x. Since r(x)=3x, the particular solution might have the form yp(x)=Ax+B. If this is the case, then we have y′p(x)=A and ypy′′(x)=0. For yp to be a solution to the differential equation, we must find values for A and B such that
y′′+4′+3y=3x0+4(A)+3(Ax+B)=3x3Ax+(4A+3B)=3x.
Setting coefficients of like terms equal, we have
3A=34A+3b=0.
Then, A=1 and B=−43, so yp(x)=x−43 and the general solution is
y(x)=c1e−x+c2e−3x+x−43.
In Example “Undetermined Coefficients When r(x) Is a Polynomial”, notice that even though r(x) did not include a constant term, it was necessary for us to include the constant term in our guess. If we had assumed a solution of the form yp=Ax (with no constant term), we would not have been able to find a solution. (Verify this!) If the function r(x) is a polynomial, our guess for the particular solution should be a polynomial of the same degree, and it must include all lower-order terms, regardless of whether they are present in r(x).
Example: undetermined coefficients when r(x) is an exponential
Find the general solution to y′′−y′−2y=2e3x.
Show Solution
The complementary equation is y′′−y′−2y=0, with the general solution c1e−x+c2e2x. Since r(x)=2e3x, the particular solution might have the form yp=Ae3x. Then, we have y′p(x)=3Ae3x and y′′=9Ae3x. For yp to be a solution to the differential equation, we must find a value for A such that
y′′−y′−2y=2e3x9Ae3x−3Ae3x−2Ae3x=2Ae3x4Ae3x=2Ae3x.
So, 4A=2 and A=12. Then, yp(x)=(12)e3x, and the general solution is
y(x)=c1e−x+c2e2x+12e3x.
try it
Find the general solution to y′′−4y′+4y=7sint−cost.
Show Solution
y(t)=c1e2t+c2te2t+sint+cost
Watch the following video to see the worked solution to the above Try It
In the previous checkpoint, r(x) included both sine and cosine terms. However, even if r(x) included a sine term only or a cosine term only, both terms must be present in the guess. The method of undetermined coefficients also works with products of polynomials, exponentials, sines, and cosines. Some of the key forms of r(x) and the associated guesses for yp(x) are summarized in Table 7.2 Key Forms for the Method of Undetermined Coefficients below.
r(x) |
Initial guess for yp(x) |
k (a constant) |
A (a constant) |
ax+b |
Ax+B (Note: The guess must include both terms even if b=0.) |
ax2+bx+c |
Ax2+Bx+C (Note: The guess must include all three terms even if b or c are zero.) |
Higher-order polynomials |
Polynomial of the same order as r(x) |
aeλx |
Aeλx |
acosβx+bsinβx |
Acosβx+Bsinβx (Note: The guess must include both terms even if either a=0 or b=0.) |
aeαxcosβx+beαxsinβx |
Aeαxcosβx+Beαxsinβx |
(ax2+bx+c)eλx |
(Ax2+Bx+C)eλx |
(a2x2+a1x+a0)cosβx+(b2x2+b1x+b0)sinβx |
(A2x2+A1x+A0)cosβx+(B2x2+B1x+B0)sinβx |
(a2x2+a1x+a0)eαxcosβx+(b2x2+b1x+b0)eαxsinβx |
(A2x2+A1x+A0)eαxcosβx+(B2x2+B1x+B0)eαxsinβx |
Table 7.2 Key Forms for the Method of Undetermined Coefficients
Keep in mind that there is a key pitfall to this method. Consider the differential equation y′′+5y′+6y=3e−2x. Based on the form of r(x), we guess a particular solution of the form yp(x)=Ae−2x. But when we substitute this expression into the differential equation to find a value for A, we run into a problem. We have
y′p(x)=−2Ae−2x
and
y′′p=4Ae−2x,
so we want
y′′+5y′+6y=3e−2x4Ae−2x+(−2Ae−2x)+6Ae−2x=3e−2x4Ae−2x−10Ae−2x+6Ae−2x=3e−2x0=3e−2x,
which is not possible.
Looking closely, we see that, in this case, the general solution to the complementary equation is c1e−2x+c2e−2x. The exponential function in r(x) is actually a solution to the complementary equation, so, as we just saw, all the terms on the left side of the equation cancel out. We can still use the method of undetermined coefficients in this case, but we have to alter our guess by multiplying it by x. Using the new guess, yp(x)=Ae−2x, we have
y′p(x)=A(e−2x−2xe−2x)
and
y′′p(x)=−4Ae−2x+4Axe−2x.
Substitution gives
y′′+5y′+6y=3e−2x(−4Ae−2x+4Axe−2x)+5(Ae−2x−2Axe−2x)+6Axe−2x=3e−2x−4Ae−2x+4Axe−2x−10Axe−2x+6Axe−2x=3e−2xAe−2x=3e−2x,
So, A=3 and yp(x)=3xe−2x. This gives us the following general solution
y(x)=c1e−2x+c2e−2x+3xe−2x.
Note that if xe−2x were also a solution to the complementary equation, we would have to multiply by x again, and we would try yp(x)=Ax2e−2x.
problem-solving strategy: method of undetermined coefficients
- Solve the complementary equation and write down the general solution.
- Based on the form of r(x), make an initial guess for yp(x).
- Check whether any term in the guess for yp(x) is a solution to the complementary equation. If so, multiply the guess by x. Repeat this step until there are no terms in yp(x) that solve the complementary equation.
- Substitute yp(x) into the differential equation and equate like terms to find values for the unknown coefficients in yp(x)
- Add the general solution to the complementary equation and the particular solution you just found to obtain the general solution to the nonhomogeneous equation.
example: solving nonhomogeneous equations
Find the general solutions to the following differential equations.
- y′′−9y=−6cos3x
- x′′+2x′+x=4e−t
- y′′−2y′+5y=102−3x−3
- y′′−3y′=−12t
Show Solution
-
- The complementary equation is y′′−9y=0, which has the general solution c1e3x+c2e−3x (step 1). Based on the form of r(x)=−6cos3x, our initial guess for the particular solution is yp(x)=Acos3x+Bsin3x (step 2). None of the terms in yp(x) solve the complementary equation, so this is a valid guess (step 3).
Now we want to find values for A and B, so substitute yp into the differential equation. We have
y′p(x)=−3Asin3x+3Bcos3x and y′′p(x)=−9Acos3x−9Bsin3x,
so we want to find values of A and B such that
y′′−9y=−6cos3x−9Acos3x−9Bsin3x−9(Acos3x+Bsin3x)=−6cos3x−18Acos3x−18Bsin3x=−6cos3x
Therefore,
−18A=−6−18B=0.
This gives A=13 and B=0, so yp(x)=(13)cos3x (step 4).
Putting everything together, we have the general solution
y(x)=c1e3x+c2e−3x+13cos3x.
- The complementary equation is x′′+2x′+x=0, which has the general solution c1e−t+c2te−t (step 1). Based on the form r(t)=4e−t, our initial guess for the particular solution is xp(t)=Ae−t (step 2). However, we see that this guess solves the complementary equation, so we must multiply by t, which gives a new guess: xp(t)=Ate−t (step 3). Checking this new guess, we see that it, too, solves the complementary equation, so we must multiply by t again, which gives xp(t)=At2e−t (step 3 again). Now, checking this guess, we see that xp(t) does not solve the complementary equation, so this is a valid guess (step 3 yet again).
We now want to find a value for A, so we substitute xp into the differential equation. We have
xp(t)=At2e−tx′p(t)=2Ate−t−At2e−t
and x′′p=2Ae−t−2Ate−t−(2Ate−t−At2e−t)=2Ae−t−4Ate−t+At2e−t.
Substituting into the differential equation, we want to find a value of A so that
x′′+2x′+x=4e−t2Ae−t−4Ate−t+At2e−t+2(2Ate−t−At2e−t)+At2e−t=4e−t2Ae−t=4e−t.
This gives A=2, so xp(t)=2t2e−t (step 4). Putting everything together, we have the general solution
x(t)=c1e−t+c2te−t+2t2e−t.
- The complementary equation is y′′−2y′+5y=0, which has the general solution c1excos2x+c2exsin2x (step 1). Based on the form r(x)=10x2−3x−3, our initial guess for the particular solution is yp(x)=Ax2+Bx+C (step 2). None of the terms in yp(x) solve the complementary equation, so this is a valid guess (step 3). We now want to find values for A, B, and C, so we substitute yp into the differential equation. We have y′p(x)=2Ax+B and y′′p(x)=2A, so we want to find values of A, B, and C such that
y′′−2y′+5y=10x2−3x−32A−2(2Ax+b)+5(Ax2+Bx+C)=10x2−3x−35Ax2+(5B−4A)x+(5C−2B+2A)=10x2−3x−3.
Therefore,
5A=105B−4A=−35C−2B+2A=−3.
This gives A=2, B=1, and C=−1, so yp(x)=2x2+x−1 (step 4). Putting everything together, we have the general solution
y(x)=c1excos2x+c2exsin2x+2x2+x−1.
- The complementary equation is y′′−3y′=0, which has the general solution c1e3t+c2 (step 1). Based on the form r(t)=−12t, our initial guess for the particular solution is yp(t)=At+B (step 2). However, we see that the constant term in this guess solves the complementary equation, so we must multiply by t, which gives a new guess: yP(t)=At2+Bt (step 3). Checking this new guess, we see that none of the terms in yp(t) solve the complementary equation, so this is a valid guess (step 3 again). We now want to find values for A and B, so we substitute yp into the differential equation. We have y′p(t)=2At+B and y′′p(t)=2A, so we want to find values of A and B such that
y′′−3y′=−12t2A−3(2At+B)=−12t−6At+(2A−3B)=−12t.
Therefore,
−6A=−122A−3B=0.
This gives A=2 and b=4/3, so yp(t)=2t2+(4/3)t (step 4). Putting everything together, we have the general solution
y(t)=c1e3t+c2+2t2+43t.
try it
Find the general solution to the following differential equations.
- y′′−5y′+4y=3ex
- y′′+y′−6y=52cos2t
Show Solution
a. y(x)=c1e4x+c2ex−xex
b. y(t)=c1et+c2tet+tetln|t|
Variation of Parameters
Sometimes, r(x) is not a combination of polynomials, exponentials, or sines and cosines. When this is the case, the method of undetermined coefficients does not work, and we have to use another approach to find a particular solution to the differential equation. We use an approach called the method of variation of parameters.
To simplify our calculations a little, we are going to divide the differential equation through by a, so we have a leading coefficient of 1. Then the differential equation has the form
y′′+py′+qy=r(x),
where p and q are constants.
If the general solution to the complementary equation is given by c1y1(x)+c2y2(x), we are going to look for a particular solution of the form yp(x)=u(x)y1(x)+v(x)y2(x). In this case, we use the two linearly independent solutions to the complementary equation to form our particular solution. However, we are assuming the coefficients are functions of x, rather than constants. We want to find functions u(x) and v(x) such that yp(x) satisfies the differential equation. We have
yp=uy1+vy2y′p=u′+uy′1+v′y2+vy′2y′′p=(u′y1+v′y2)′+u′y′1+uy′′1+v′y′2+vy′′2.
Substituting into the differential equation, we obtain
y′′p+py′p+qyp=[(u′y1+v′y2)+u′y′1+uy′′1+v′y′2+vy′′2]+p[u′y1+uy′1+v′y2+vy′2]+q[uy1+vy2]=u[y′′1+py′1+qy1]+v[y′′2+py′2+qy2]+(u′y1+v′y2)′+p(u′y1+v′y2)+(u′y′1+v′y′2).
Note that y1 and y2 are solutions to the complementary equation, so the first two terms are zero. Thus, we have
(u′y1+v′y2)′+p(u′y1+v′y2)+(u′y′1+v′y′2)=r(x).
If we simplify this equation by imposing the additional condition u′y1+v′y2=0, the first two terms are zero, and this reduces to u′y′1+v′y2=r(x). So, with this additional condition, we have a system of two equations in two unknowns:
u′y1+v′y2=0u′y′1+v′y′2=r(x).
Solving this system gives us u′ and v′, which we can integrate to find u and v.
Then, yp(x)=u(x)y1(x)+v(x)y2(x) is a particular solution to the differential equation. Solving this system of equations is sometimes challenging, so let’s take this opportunity to review Cramer’s rule, which allows us to solve the system of equations using determinants.
rule: cramer’s rule
The system of equations
a1z1+b1z2=r1a2z1+b2z2=r2
has a unique solution if and only if the determinant of the coefficients is not zero. In this case, the solution is given by
z1=∣∣∣r1b1r2b2∣∣∣∣∣∣a1b1a2b2∣∣∣ and z2=∣∣∣a1r1a2r2∣∣∣∣∣∣a1b1a2b2∣∣∣.
Example: using cramer’s rule
Use Cramer’s rule to solve the following system of equations.
x2z1+2xz2=0z1−3x2z2=2x.
Show Solution
We have
a1(x)=x2a2(x)=1b1(x)=2xb2(x)=−3x2r1(x)=0r2(x)=2x.
Then,
∣∣∣a1b1a2b2∣∣∣=∣∣∣x22x1−3x2∣∣∣=−3x4−2x
and
∣∣∣r1b1r2b2∣∣∣=∣∣∣02x2x−3x2∣∣∣=0−4x2=−4x2.
Thus,
z1=∣∣∣r1b1r2b2∣∣∣∣∣∣a1b1a2b2∣∣∣=−4x2−3x4−2x=4x3x3+2.
In addition,
∣∣∣a1r1a2r2∣∣∣=∣∣∣x2012x∣∣∣=2x3−0=2x3.
Thus,
z2=∣∣∣a1r1a2r2∣∣∣∣∣∣a1b1a2b2∣∣∣=2x3−3x4−2x=−2x23x3+2.
try it
Use Cramer’s rule to solve the following system of equations.
2xz1−3z2=0x2z1+4xz2=x+1.
Show Solution
z1=3x+311x2, z22x+211x
problem-solving strategy: method of variation of parameters
- Solve the complementary equation and write down the general solution
c1y1(x)+c2y2(x).
- Use Cramer’s rule or another suitable technique to find functions u′(x) and v′(x) satisfying
u′y1+v′y2=0u′y′1+v′y′2=r(x)
- Integrate u′ and v′ to find u(x) and v(x). Then, yp(x)=u(x)y1(x)+v(x)y2(x) is a particular solution to the equation.
- Add the general solution to the complementary equation and the particular solution found in step 3 to obtain the general solution to the nonhomogeneous equation.
example: using the method of variation of parameters
Find the general solution to the following differential equations.
- y′′−2y′+y=ett2
- y′′+y=3sin2x
Show Solution
- The complementary equation is y′′−2y′+y=0 with associated general solution c1et+c2tet. Therefore, y1(t)=et and y2(t)=tet. Calculating the derivatives, we get y′1(t)=et and y′2(t)=et+tet (step 1). Then, we want to find functions u′(t) and v′(t) so that
u′et+v′tet=0u′et+v′(et+tet)=ett2
Applying Cramer’s rule, we have
u′=∣∣
∣∣0tetett2et+tet∣∣
∣∣∣∣∣ettetetet+tet∣∣∣=0−tet(ett2)et(et+tet)−ettet=−e2tte2t=−1t
and
v′=∣∣
∣∣et0etett2∣∣
∣∣∣∣∣ettetetet+tet∣∣∣=et(ett2)e2t=1t2 (step 2).
Integrating, we get
u=−∫1t dt=−ln|t|v=∫1t2dt=−1t(step 3).
Then we have
yp=−etln|t|−1ttet=−etln|t|−et(step 4).
The et term is a solution to the complementary equation, so we don’t need to carry that term into our general solution explicitly. The general solution is
y(t)=c1et+c2tet−etln|t| (step 5).
- The complementary equation is y′′+y+0 with associated general solution c1cosx+c2sinx. So, y1(x)=cosx and y2(x)=sinx (step 1). Then, we want to find functions u′(x) and v′(x) such that
[latex]\begin{aligned}
u^\prime\cos x+v^\prime\sin x&=0 \\ -y^\prime\sin x+v^\prime\cos x&=3\sin^2x \end{aligned}[/latex].
Applying Cramer’s rule, we have
u′=∣∣∣0sinx3sin2xcosx∣∣∣∣∣∣cosxsinx−sinxcosx∣∣∣=0−3sin3xcos2x+sin2x=−3sin3x
and
v′=∣∣∣cosx0−sinx3sin2x∣∣∣∣∣∣cosxsinx−sinxcosx∣∣∣=3sin2xcosx1=3sin2xcosx (step 2).
Integrating first to find u, we get
u=∫−3sin3xdx=−3[−13sin2xcosx+23∫sinxdx]=sin2xcosx+2cosx (step 3).
Now, we integrate to find v. Using substitution (with w=sinx), we get
v=∫3sin2xcosxdx=∫3w2dw=w3=sin3x.
Then,
yp=(sin2xcosx+2cosx)cosx+(sin3x)sinx=sin2xcos2x+2cos2x+sin4x=2cos2x+sin2x(cos2x+sin2x) (step4).=2cos2x+sin2=cos2x+1
The general solution is
y(x)=c1cosx+c2sinx+1+cos2x (step 5).
try it
Find the general solution to the following differential equations.
- y′′+y=secx
- x′′−2x′+x=ett
Show Solution
a. y(x)=c1cosx+c2sinx+cosxln|cosx|+xsinx
b. x(t)=c1et+c2tet+tetln|t|
Watch the following videos to see the worked solution to the above Try It
Candela Citations
CC licensed content, Original
CC licensed content, Shared previously