Skip to ContentGo to accessibility pageKeyboard shortcuts menu
OpenStax Logo
Calculus Volume 3

7.2 Nonhomogeneous Linear Equations

Calculus Volume 37.2 Nonhomogeneous Linear Equations

Learning Objectives

  • 7.2.1 Write the general solution to a nonhomogeneous differential equation.
  • 7.2.2 Solve a nonhomogeneous differential equation by the method of undetermined coefficients.
  • 7.2.3 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).a2(x)y+a1(x)y+a0(x)y=r(x).

The associated homogeneous equation

a2(x)y+a1(x)y+a0(x)y=0a2(x)y+a1(x)y+a0(x)y=0
(7.3)

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)yp(x) of a differential equation that contains no arbitrary constants is called a particular solution to the equation.

Theorem 7.4

General Solution to a Nonhomogeneous Equation

Let yp(x)yp(x) be any particular solution to the nonhomogeneous linear differential equation

a2(x)y+a1(x)y+a0(x)y=r(x).a2(x)y+a1(x)y+a0(x)y=r(x).

Also, let c1y1(x)+c2y2(x)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).y(x)=c1y1(x)+c2y2(x)+yp(x).
(7.4)

Proof

To prove y(x)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)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).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)y(x) is a solution.

Now, let z(x)z(x) be any solution to a2(x)y+a1(x)y+a0(x)y=r(x).a2(x)y+a1(x)y+a0(x)y=r(x). Then

a2(x)(zyp)+a1(x)(zyp)+a0(x)(zyp)=(a2(x)z+a1(x)z+a0(x)z)(a2(x)yp+a1(x)yp+a0(x)yp)=r(x)r(x)=0,a2(x)(zyp)+a1(x)(zyp)+a0(x)(zyp)=(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)z(x)yp(x) is a solution to the complementary equation. But, c1y1(x)+c2y2(x)c1y1(x)+c2y2(x) is the general solution to the complementary equation, so there are constants c1c1 and c2c2 such that

z(x)yp(x)=c1y1(x)+c2y2(x).z(x)yp(x)=c1y1(x)+c2y2(x).

Hence, we see that z(x)=c1y1(x)+c2y2(x)+yp(x).z(x)=c1y1(x)+c2y2(x)+yp(x).

Example 7.11

Verifying the General Solution

Given that yp(x)=xyp(x)=x is a particular solution to the differential equation y+y=x,y+y=x, write the general solution and check by verifying that the solution satisfies the equation.

Checkpoint 7.10

Given that yp(x)=−2yp(x)=−2 is a particular solution to y3y4y=8,y3y4y=8, write the general solution and verify that the general solution satisfies the equation.

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),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).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)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 7.12

Undetermined Coefficients When r(x)r(x) Is a Polynomial

Find the general solution to y+4y+3y=3x.y+4y+3y=3x.

In Example 7.12, notice that even though r(x)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=Axyp=Ax (with no constant term), we would not have been able to find a solution. (Verify this!) If the function r(x)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).r(x).

Example 7.13

Undetermined Coefficients When r(x)r(x) Is an Exponential

Find the general solution to yy2y=2e3x.yy2y=2e3x.

Checkpoint 7.11

Find the general solution to y4y+4y=7sintcost.y4y+4y=7sintcost.

In the previous checkpoint, r(x)r(x) included both sine and cosine terms. However, even if r(x)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)r(x) and the associated guesses for yp(x)yp(x) are summarized in Table 7.2.

r(x)r(x) Initial guess for yp(x)yp(x)
kk (a constant) AA (a constant)
ax+bax+b Ax+BAx+B (Note: The guess must include both terms even if b=0.b=0.)
ax2+bx+cax2+bx+c Ax2+Bx+CAx2+Bx+C (Note: The guess must include all three terms even if bb or cc are zero.)
Higher-order polynomials Polynomial of the same order as r(x)r(x)
aeλxaeλx AeλxAeλx
acosβx+bsinβxacosβx+bsinβx Acosβx+BsinβxAcosβx+Bsinβx (Note: The guess must include both terms even if either a=0a=0 or b=0.b=0.)
aeαxcosβx+beαxsinβxaeαxcosβx+beαxsinβx Aeαxcosβx+BeαxsinβxAeαxcosβx+Beαxsinβx
(ax2+bx+c)eλx(ax2+bx+c)eλ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)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 (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.y+5y+6y=3e−2x. Based on the form of r(x),r(x), we guess a particular solution of the form yp(x)=Ae−2x.yp(x)=Ae−2x. But when we substitute this expression into the differential equation to find a value for A,A, we run into a problem. We have

yp(x)=−2Ae−2xyp(x)=−2Ae−2x

and

yp=4Ae−2x,yp=4Ae−2x,

so we want

y+5y+6y=3e−2x4Ae−2x+5(−2Ae−2x)+6Ae−2x=3e−2x4Ae−2x10Ae−2x+6Ae−2x=3e−2x0=3e−2x,y+5y+6y=3e−2x4Ae−2x+5(−2Ae−2x)+6Ae−2x=3e−2x4Ae−2x10Ae−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.c1e−2x+c2e−3x. The exponential function in r(x)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 byx.x. Using the new guess, yp(x)=Axe−2x,yp(x)=Axe−2x, we have

yp(x)=A(e−2x2xe−2x)yp(x)=A(e−2x2xe−2x)

and

yp(x)=−4Ae−2x+4Axe−2x.yp(x)=−4Ae−2x+4Axe−2x.

Substitution gives

y+5y+6y=3e−2x(−4Ae−2x+4Axe−2x)+5(Ae−2x2Axe−2x)+6Axe−2x=3e−2x−4Ae−2x+4Axe−2x+5Ae−2x10Axe−2x+6Axe−2x=3e−2xAe−2x=3e−2x.y+5y+6y=3e−2x(−4Ae−2x+4Axe−2x)+5(Ae−2x2Axe−2x)+6Axe−2x=3e−2x−4Ae−2x+4Axe−2x+5Ae−2x10Axe−2x+6Axe−2x=3e−2xAe−2x=3e−2x.

So, A=3A=3 and yp(x)=3xe−2x.yp(x)=3xe−2x. This gives us the following general solution

y(x)=c1e−2x+c2e−3x+3xe−2x.y(x)=c1e−2x+c2e−3x+3xe−2x.

Note that if xe−2xxe−2x were also a solution to the complementary equation, we would have to multiply by xx again, and we would try yp(x)=Ax2e−2x.yp(x)=Ax2e−2x.

Problem-Solving Strategy

Problem-Solving Strategy: Method of Undetermined Coefficients

  1. Solve the complementary equation and write down the general solution.
  2. Based on the form of r(x),r(x), make an initial guess for yp(x).yp(x).
  3. Check whether any term in the guess for yp(x)yp(x) is a solution to the complementary equation. If so, multiply the guess byx.x. Repeat this step until there are no terms in yp(x)yp(x) that solve the complementary equation.
  4. Substitute yp(x)yp(x) into the differential equation and equate like terms to find values for the unknown coefficients in yp(x).yp(x).
  5. 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 7.14

Solving Nonhomogeneous Equations

Find the general solutions to the following differential equations.

  1. y9y=−6cos3xy9y=−6cos3x
  2. x+2x+x=4etx+2x+x=4et
  3. y2y+5y=10x23x3y2y+5y=10x23x3
  4. y3y=−12ty3y=−12t

Checkpoint 7.12

Find the general solution to the following differential equations.

  1. y5y+4y=3exy5y+4y=3ex
  2. y+y6y=52cos2ty+y6y=52cos2t

Variation of Parameters

Sometimes, r(x)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,a, so we have a leading coefficient of 1. Then the differential equation has the form

y+py+qy=r(x),y+py+qy=r(x),

where pp and qq are constants.

If the general solution to the complementary equation is given by c1y1(x)+c2y2(x),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).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)u(x) and v(x)v(x) such that yp(x)yp(x) satisfies the differential equation. We have

yp=uy1+vy2yp=uy1+uy1+vy2+vy2yp=(uy1+vy2)+uy1+uy1+vy2+vy2.yp=uy1+vy2yp=uy1+uy1+vy2+vy2yp=(uy1+vy2)+uy1+uy1+vy2+vy2.

Substituting into the differential equation, we obtain

yp+pyp+qyp=[(uy1+vy2)+uy1+uy1+vy2+vy2]+p[uy1+uy1+vy2+vy2]+q[uy1+vy2]=u[y1+py1+qy1]+v[y2+py2+qy2]+(uy1+vy2)+p(uy1+vy2)+(uy1+vy2).yp+pyp+qyp=[(uy1+vy2)+uy1+uy1+vy2+vy2]+p[uy1+uy1+vy2+vy2]+q[uy1+vy2]=u[y1+py1+qy1]+v[y2+py2+qy2]+(uy1+vy2)+p(uy1+vy2)+(uy1+vy2).

Note that y1y1 and y2y2 are solutions to the complementary equation, so the first two terms are zero. Thus, we have

(uy1+vy2)+p(uy1+vy2)+(uy1+vy2)=r(x).(uy1+vy2)+p(uy1+vy2)+(uy1+vy2)=r(x).

If we simplify this equation by imposing the additional condition uy1+vy2=0,uy1+vy2=0, the first two terms are zero, and this reduces to uy1+vy2=r(x).uy1+vy2=r(x). So, with this additional condition, we have a system of two equations in two unknowns:

uy1+vy2=0uy1+vy2=r(x).uy1+vy2=0uy1+vy2=r(x).

Solving this system gives us uu and v,v, which we can integrate to find u and v.

Then, yp(x)=u(x)y1(x)+v(x)y2(x)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=r2a1z1+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|andz2=|a1r1a2r2||a1b1a2b2|.z1=|r1b1r2b2||a1b1a2b2|andz2=|a1r1a2r2||a1b1a2b2|.

Example 7.15

Using Cramer’s Rule

Use Cramer’s rule to solve the following system of equations.

x2z1+2xz2=0z13x2z2=2xx2z1+2xz2=0z13x2z2=2x

Checkpoint 7.13

Use Cramer’s rule to solve the following system of equations.

2xz13z2=0x2z1+4xz2=x+12xz13z2=0x2z1+4xz2=x+1

Problem-Solving Strategy

Problem-Solving Strategy: Method of Variation of Parameters

  1. Solve the complementary equation and write down the general solution
    c1y1(x)+c2y2(x).c1y1(x)+c2y2(x).
  2. Use Cramer’s rule or another suitable technique to find functions u(x)u(x) and v(x)v(x) satisfying
    uy1+vy2=0uy1+vy2=r(x).uy1+vy2=0uy1+vy2=r(x).
  3. Integrate uu and vv to find u(x)u(x) and v(x).v(x). Then, yp(x)=u(x)y1(x)+v(x)y2(x)yp(x)=u(x)y1(x)+v(x)y2(x) is a particular solution to the equation.
  4. 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 7.16

Using the Method of Variation of Parameters

Find the general solution to the following differential equations.

  1. y2y+y=ett2y2y+y=ett2
  2. y+y=3sin2xy+y=3sin2x

Checkpoint 7.14

Find the general solution to the following differential equations.

  1. y+y=secxy+y=secx
  2. x2x+x=ettx2x+x=ett

Section 7.2 Exercises

Solve the following equations using the method of undetermined coefficients.

54.

2 y 5 y 12 y = 6 2 y 5 y 12 y = 6

55.

3 y + y 4 y = 8 3 y + y 4 y = 8

56.

y 6 y + 5 y = e x y 6 y + 5 y = e x

57.

y + 16 y = e −2 x y + 16 y = e −2 x

58.

y 4 y = x 2 + 1 y 4 y = x 2 + 1

59.

y 4 y + 4 y = 8 x 2 + 4 x y 4 y + 4 y = 8 x 2 + 4 x

60.

y 2 y 3 y = sin 2 x y 2 y 3 y = sin 2 x

61.

y + 2 y + y = sin x + cos x y + 2 y + y = sin x + cos x

62.

y + 9 y = e x cos x y + 9 y = e x cos x

63.

y + y = 3 sin 2 x + x cos 2 x y + y = 3 sin 2 x + x cos 2 x

64.

y + 3 y 28 y = 10 e 4 x y + 3 y 28 y = 10 e 4 x

65.

y + 10 y + 25 y = x e −5 x + 4 y + 10 y + 25 y = x e −5 x + 4

In each of the following problems,

  1. Write the form for the particular solution yp(x)yp(x) for the method of undetermined coefficients.
  2. [T] Use a computer algebra system to find a particular solution to the given equation.
66.

y y y = x + e x y y y = x + e x

67.

y 3 y = x 2 4 x + 11 y 3 y = x 2 4 x + 11

68.

y y 4 y = e x cos 3 x y y 4 y = e x cos 3 x

69.

2 y y + y = ( x 2 5 x ) e x 2 y y + y = ( x 2 5 x ) e x

70.

4 y + 5 y 2 y = e 2 x + x sin x 4 y + 5 y 2 y = e 2 x + x sin x

71.

y y 2 y = x 2 e x sin x y y 2 y = x 2 e x sin x

Solve the differential equation using either the method of undetermined coefficients or the variation of parameters.

72.

y + 3 y 4 y = 2 e x y + 3 y 4 y = 2 e x

73.

y + 2 y = e 3 x y + 2 y = e 3 x

74.

y + 6 y + 9 y = e x y + 6 y + 9 y = e x

75.

y + 2 y 8 y = 6 e 2 x y + 2 y 8 y = 6 e 2 x

Solve the differential equation using the method of variation of parameters.

76.

4 y + y = 2 sin x 4 y + y = 2 sin x

77.

y 9 y = 8 x y 9 y = 8 x

78.

y + y = sec x , 0 < x < π / 2 y + y = sec x , 0 < x < π / 2

79.

y + 4 y = 3 csc 2 x , 0 < x < π / 2 y + 4 y = 3 csc 2 x , 0 < x < π / 2

Find the unique solution satisfying the differential equation and the initial conditions given, where yp(x)yp(x) is the particular solution.

80.

y2y+y=12ex,y2y+y=12ex, yp(x)=6x2ex,yp(x)=6x2ex, y(0)=6,y(0)=0y(0)=6,y(0)=0

81.

y7y=4xe7x,y7y=4xe7x, yp(x)=27x2e7x449xe7x,yp(x)=27x2e7x449xe7x, y(0)=−1,y(0)=0y(0)=−1,y(0)=0

82.

y+y=cosx4sinx,y+y=cosx4sinx, yp(x)=2xcosx+12xsinx,yp(x)=2xcosx+12xsinx, y(0)=8,y(0)=−4y(0)=8,y(0)=−4

83.

y5y=e5x+8e−5x,y5y=e5x+8e−5x, yp(x)=15xe5x+425e−5x,yp(x)=15xe5x+425e−5x, y(0)=−2,y(0)=0y(0)=−2,y(0)=0

In each of the following problems, two linearly independent solutions—y1y1 and y2y2—are given that satisfy the corresponding homogeneous equation. Use the method of variation of parameters to find a particular solution to the given nonhomogeneous equation. Assume x > 0 in each exercise.

84.

x2y+2xy2y=3x,x2y+2xy2y=3x, y1(x)=x,y2(x)=x−2y1(x)=x,y2(x)=x−2

85.

x2y2y=10x21,x2y2y=10x21, y1(x)=x2,y2(x)=x−1y1(x)=x2,y2(x)=x−1

Order a print copy

As an Amazon Associate we earn from qualifying purchases.

Citation/Attribution

This book may not be used in the training of large language models or otherwise be ingested into large language models or generative AI offerings without OpenStax's permission.

Want to cite, share, or modify this book? This book uses the Creative Commons Attribution-NonCommercial-ShareAlike License and you must attribute OpenStax.

Attribution information
  • If you are redistributing all or part of this book in a print format, then you must include on every physical page the following attribution:
    Access for free at https://openstax.org/books/calculus-volume-3/pages/1-introduction
  • If you are redistributing all or part of this book in a digital format, then you must include on every digital page view the following attribution:
    Access for free at https://openstax.org/books/calculus-volume-3/pages/1-introduction
Citation information

© Feb 5, 2024 OpenStax. Textbook content produced by OpenStax is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike License . The OpenStax name, OpenStax logo, OpenStax book covers, OpenStax CNX name, and OpenStax CNX logo are not subject to the Creative Commons license and may not be reproduced without the prior and express written consent of Rice University.