17.2: Nonhomogeneous Linear Equations
( \newcommand{\kernel}{\mathrm{null}\,}\)
- 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.
In this section, we examine how to solve nonhomogeneous differential equations. The terminology and methods are different from those we used for homogeneous equations, so let’s start by defining some new terms.
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.
A solution yp(x) of a differential equation that contains no arbitrary constants is called a particular solution to the 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).
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)yp″+a1(x)yp′+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)yp″+a1(x)yp′+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).
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.
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″(x)=−c1cosx−c2sinx.
Then
y″(x)+y(x)=−c1cosx−c2sinx+c1cosx+c2sinx+x=x.
So, y(x) is a solution to y″+y=x.
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.
- Hint
-
Find the general solution to the complementary equation.
- Answer
-
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.
Find the general solution to y″+4y′+3y=3x.
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 yp′(x)=A and yp″(x)=0. For yp to be a solution to the differential equation, we must find values for A and B such that
y″+4y′+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 17.2.2, 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).
Find the general solution to y″−y′−2y=2e3x.
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(x)=Ae3x. Then, we have yp′(x)=3Ae3x and yp″(x)=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=2e3x4Ae3x=2e3x.
So, 4A=2 and A=1/2. Then, yp(x)=(12)e3x, and the general solution is
y(x)=c1e−x+c2e2x+12e3x.
Find the general solution to y″−4y′+4y=7sint−cost.
- Hint
-
Use yp(t)=Asint+Bcost as a guess for the particular solution.
- Answer
-
y(t)=c1e2t+c2te2t+sint+cost
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 17.2.1.
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 |
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
yp′(x)=−2Ae−2x
and
y″p=4Ae−2x,
so we want
y″+5y′+6y=3e−2x4Ae−2x+5(−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−3x. 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)=Axe−2x, we have
yp′(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+5Ae−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−3x+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.
- 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 foryp(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.
Find the general solutions to the following differential equations.
- y″−9y=−6cos3x
- x″+2x′+x=4e−t
- y″−2y′+5y=10x2−3x−3
- y″−3y′=−12t
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 haveyp′(x)=−3Asin3x+3Bcos3x and yp″(x)=−9Acos3x−9Bsin3x,
so we want to find values of A and B such thaty″−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 solutiony(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 havexp(t)=At2e−t, soxp′(t)=2Ate−t−At2e−t
and xp″(t)=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 thatx″+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 solutionx(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 yp′(x)=2Ax+B and yp″(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 solutiony(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,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 yp′(t)=2At+B and yp″(t)=2A, so we want to find values of AA and BB 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 solutiony(t)=c1e3t+c2+2t2+43t.
Find the general solution to the following differential equations.
- y″−5y′+4y=3ex
- y″+y′−6y=52cos2t
- Hint
-
Use the problem-solving strategy.
- Answer a
-
y(x)=c1e4x+c2ex−xex
- Answer b
-
y(t)=c1e−3t+c2e2t−5cos2t+sin2t
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+vy2yp′=u′y1+uy1′+v′y2+vy2′yp″=(u′y1+v′y2)′+u′y1′+uy1″+v′y2′+vy2″.
Substituting into the differential equation, we obtain
yp″+pyp′+qyp=[(u′y1+v′y2)′+u′y1′+uy1″+v′y2′+vy2″]+p[u′y1+uy1′+v′y2+vy2′]+q[uy1+vy2]=u[y1″+py1′+qy1]+v[y2″+py2′+qy2]+(u′y1+v′y2)′+p(u′y1+v′y2)+(u′y1′+v′y2′).
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′y1′+v′y2′)=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′y1′+v′y2′=r(x). So, with this additional condition, we have a system of two equations in two unknowns:
u′y1+v′y2=0u′y1′+v′y2′=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.
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=r1b1r2b2a1b1a2b2andz2=a1r1a2r2a1b1a2b2.
Use Cramer’s rule to solve the following system of equations.
x2z1+2xz2=0z1−3x2z2=2x
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=r1b1r2b2a1b1a2b2=−4x2−3x4−2x=4x3x3+2.
In addition,
a1r1a2r2=x2012x=2x3−0=2x3.
Thus,
z2=a1r1a2r2a1b1a2b2=2x3−3x4−2x=−2x23x3+2.
Use Cramer’s rule to solve the following system of equations.
2xz1−3z2=0x2z1+4xz2=x+1
- Hint
-
Use the process from the previous example.
- Answer
-
z1=3x+311x2,z2=2x+211x
- 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′y1′+v′y2′=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.
Find the general solution to the following differential equations.
- y″−2y′+y=ett2
- y″+y=3sin2x
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 y1′(t)=et and y2′(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 (Equation ???), we have
u′=0tetett2et+tetettetetet+tet=0−tet(ett2)et(et+tet)−ettet=−e2tte2t=−1t
and
v′= \dfrac{\begin{array}{|ll|}e^t 0 \\ e^t \frac{e^t}{t^2} \end{array} }{\begin{array}{|lc|}e^t te^t \\ e^t e^t+te^t \end{array} } =\dfrac{e^t(\frac{e^t}{t^2})}{e^{2t}}=\dfrac{1}{t^2}\quad(\text{step 2}). \nonumber
Integrating, we get
\begin{align*} u &=−\int \dfrac{1}{t}dt=− \ln|t| \\[4pt] v &=\int \dfrac{1}{t^2}dt=−\dfrac{1}{t} \tag{step 3} \end{align*}
Then we have
\begin{align*}y_p &=−e^t \ln|t|−\frac{1}{t}te^t \\[4pt] &=−e^t \ln |t|−e^t \tag{step 4}.\end{align*}
The e^t 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)=c_1e^t+c_2te^t−e^t \ln |t| \tag{step 5}
- The complementary equation is y″+y=0 with associated general solution c_1 \cos x+c_2 \sin x. So, y_1(x)= \cos x and y_2(x)= \sin x (step 1). Then, we want to find functions u′(x) and v′(x) such that
\begin{align*} u′ \cos x+v′ \sin x &=0 \\[4pt] −u′ \sin x+v′ \cos x &=3 \sin _2 x \end{align*}. \nonumber
Applying Cramer’s rule, we have
u′= \dfrac{\begin{array}{|cc|}0 \sin x \\ 3 \sin ^2 x \cos x \end{array}}{ \begin{array}{|cc|} \cos x \sin x \\ − \sin x \cos x \end{array}}=\dfrac{0−3 \sin^3 x}{ \cos ^2 x+ \sin ^2 x}=−3 \sin^3 x \nonumber
and
v′=\dfrac{\begin{array}{|cc|} \cos x 0 \\ - \sin x 3 \sin^2 x \end{array}}{ \begin{array}{|cc|} \cos x \sin x \\ − \sin x \cos x \end{array}}=\dfrac{ 3 \sin^2x \cos x}{ 1}=3 \sin^2 x \cos x( \text{step 2}). \nonumber
Integrating first to find u, we get
u=\int −3 \sin^3 x dx=−3 \bigg[ −\dfrac{1}{3} \sin ^2 x \cos x+\dfrac{2}{3} \int \sin x dx \bigg]= \sin^2 x \cos x+2 \cos x. \nonumber
Now, we integrate to find v. Using substitution (with w= \sin x), we get
v= \int 3 \sin ^2 x \cos x dx=\int 3w^2dw=w^3=sin^3x.\nonumber
Then,
\begin{align*}y_p &=(\sin^2 x \cos x+2 \cos x) \cos x+(\sin^3 x)\sin x \\[4pt] &=\sin_2 x \cos _2 x+2 \cos _2 x+ \sin _4x \\[4pt] &=2 \cos_2 x+ \sin_2 x(\cos^2 x+\sin ^2 x) & & (\text{step 4}). \\[4pt] &=2 \cos _2 x+\sin_2x \\[4pt] &= \cos _2 x+1 \end{align*}
The general solution is
y(x)=c_1 \cos x+c_2 \sin x+1+ \cos^2 x(\text{step 5}).\nonumber
Find the general solution to the following differential equations.
- y″+y= \sec x
- x″−2x′+x=\dfrac{e^t}{t}
- Hint
-
Follow the problem-solving strategy.
- Answer a
-
y(x)=c_1 \cos x+c_2 \sin x+ \cos x \ln| \cos x|+x \sin x
- Answer b
-
x(t)=c_1e^t+c_2te^t+te^t \ln|t|
Key Concepts
- To solve a nonhomogeneous linear second-order differential equation, first find the general solution to the complementary equation, then find a particular solution to the nonhomogeneous equation.
- Let y_p(x) be any particular solution to the nonhomogeneous linear differential equation a_2(x)y''+a_1(x)y′+a_0(x)y=r(x), \nonumber and let c_1y_1(x)+c_2y_2(x) denote the general solution to the complementary equation. Then, the general solution to the nonhomogeneous equation is given by y(x)=c_1y_1(x)+c_2y_2(x)+y_p(x). \nonumber
- When r(x) is a combination of polynomials, exponential functions, sines, and cosines, use the method of undetermined coefficients to find the particular solution. To use this method, assume a solution in the same form as r(x), multiplying by x as necessary until the assumed solution is linearly independent of the general solution to the complementary equation. Then, substitute the assumed solution into the differential equation to find values for the coefficients.
- When r(x) is not a combination of polynomials, exponential functions, or sines and cosines, use the method of variation of parameters to find the particular solution. This method involves using Cramer’s rule or another suitable technique to find functions and v′(x) satisfying \begin{align*}u′y_1+v′y_2 &=0 \\[4pt] u′y_1′+v′y_2′ &=r(x). \end{align*} Then, y_p(x)=u(x)y_1(x)+v(x)y_2(x) is a particular solution to the differential equation.
Key Equations
- Complementary equation
a_2(x)y″+a_1(x)y′+a_0(x)y=0 - General solution to a nonhomogeneous linear differential equation
y(x)=c_1y_1(x)+c_2y_2(x)+y_p(x)
Glossary
- complementary equation
- for the nonhomogeneous linear differential equation a+2(x)y″+a_1(x)y′+a_0(x)y=r(x), the associated homogeneous equation, called the complementary equation, is a_2(x)y''+a_1(x)y′+a_0(x)y=0
- method of undetermined coefficients
- a method that involves making a guess about the form of the particular solution, then solving for the coefficients in the guess
- method of variation of parameters
- a method that involves looking for particular solutions in the form y_p(x)=u(x)y_1(x)+v(x)y_2(x), where y_1 and y_2 are linearly independent solutions to the complementary equations, and then solving a system of equations to find u(x) and v(x)
- particular solution
- a solution y_p(x) of a differential equation that contains no arbitrary constants