Skip to ContentGo to accessibility page
Calculus Volume 3

7.2Nonhomogeneous 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)(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,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)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 $y″−3y′−4y=8,y″−3y′−4y=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 $y″−y′−2y=2e3x.y″−y′−2y=2e3x.$

Checkpoint 7.11

Find the general solution to $y″−4y′+4y=7sint−cost.y″−4y′+4y=7sint−cost.$

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−2x−10Ae−2x+6Ae−2x=3e−2x0=3e−2x,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.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 by$x.x.$ Using the new guess, $yp(x)=Axe−2x,yp(x)=Axe−2x,$ we have

$yp′(x)=A(e−2x−2xe−2x)yp′(x)=A(e−2x−2xe−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−2x−2Axe−2x)+6Axe−2x=3e−2x−4Ae−2x+4Axe−2x+5Ae−2x−10Axe−2x+6Axe−2x=3e−2xAe−2x=3e−2x.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=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 by$x.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. $y″−9y=−6cos3xy″−9y=−6cos3x$
2. $x″+2x′+x=4e−tx″+2x′+x=4e−t$
3. $y″−2y′+5y=10x2−3x−3y″−2y′+5y=10x2−3x−3$
4. $y″−3y′=−12ty″−3y′=−12t$
Checkpoint 7.12

Find the general solution to the following differential equations.

1. $y″−5y′+4y=3exy″−5y′+4y=3ex$
2. $y″+y′−6y=52cos2ty″+y′−6y=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′=u′y1+uy1′+v′y2+vy2′yp″=(u′y1+v′y2)′+u′y1′+uy1″+v′y2′+vy2″.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′).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 $y1y1$ and $y2y2$ 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).(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,u′y1+v′y2=0,$ the first two terms are zero, and this reduces to $u′y1′+v′y2′=r(x).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).u′y1+v′y2=0u′y1′+v′y2′=r(x).$

Solving this system gives us $u′u′$ 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=0z1−3x2z2=2xx2z1+2xz2=0z1−3x2z2=2x$
Checkpoint 7.13

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

$2xz1−3z2=0x2z1+4xz2=x+12xz1−3z2=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
$u′y1+v′y2=0u′y1′+v′y2′=r(x).u′y1+v′y2=0u′y1′+v′y2′=r(x).$
3. Integrate $u′u′$ and $v′v′$ 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. $y″−2y′+y=ett2y″−2y′+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. $x″−2x′+x=ettx″−2x′+x=ett$

Section 7.2 Exercises

Solve the following equations using the method of undetermined coefficients.

54.

$2y″−5y′−12y=62y″−5y′−12y=6$

55.

$3y″+y′−4y=83y″+y′−4y=8$

56.

$y″−6y′+5y=e−xy″−6y′+5y=e−x$

57.

$y″+16y=e−2xy″+16y=e−2x$

58.

$y″−4y=x2+1y″−4y=x2+1$

59.

$y″−4y′+4y=8x2+4xy″−4y′+4y=8x2+4x$

60.

$y″−2y′−3y=sin2xy″−2y′−3y=sin2x$

61.

$y″+2y′+y=sinx+cosxy″+2y′+y=sinx+cosx$

62.

$y″+9y=excosxy″+9y=excosx$

63.

$y″+y=3sin2x+xcos2xy″+y=3sin2x+xcos2x$

64.

$y″+3y′−28y=10e4xy″+3y′−28y=10e4x$

65.

$y″+10y′+25y=xe−5x+4y″+10y′+25y=xe−5x+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−xy″−y′−y=x+e−x$

67.

$y″−3y=x2−4x+11y″−3y=x2−4x+11$

68.

$y″−y′−4y=excos3xy″−y′−4y=excos3x$

69.

$2y″−y′+y=(x2−5x)e−x2y″−y′+y=(x2−5x)e−x$

70.

$4y″+5y′−2y=e2x+xsinx4y″+5y′−2y=e2x+xsinx$

71.

$y″−y′−2y=x2exsinxy″−y′−2y=x2exsinx$

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

72.

$y″+3y′−4y=2exy″+3y′−4y=2ex$

73.

$y″+2y′=e3xy″+2y′=e3x$

74.

$y″+6y′+9y=e−xy″+6y′+9y=e−x$

75.

$y″+2y′−8y=6e2xy″+2y′−8y=6e2x$

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

76.

$4y″+y=2sinx4y″+y=2sinx$

77.

$y″−9y=8xy″−9y=8x$

78.

$y″+y=secx,0

79.

$y″+4y=3csc2x,0

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

80.

$y″−2y′+y=12ex,y″−2y′+y=12ex,$ $yp(x)=6x2ex,yp(x)=6x2ex,$ $y(0)=6,y′(0)=0y(0)=6,y′(0)=0$

81.

$y″−7y′=4xe7x,y″−7y′=4xe7x,$ $yp(x)=27x2e7x−449xe7x,yp(x)=27x2e7x−449xe7x,$ $y(0)=−1,y′(0)=0y(0)=−1,y′(0)=0$

82.

$y″+y=cosx−4sinx,y″+y=cosx−4sinx,$ $yp(x)=2xcosx+12xsinx,yp(x)=2xcosx+12xsinx,$ $y(0)=8,y′(0)=−4y(0)=8,y′(0)=−4$

83.

$y″−5y′=e5x+8e−5x,y″−5y′=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″+2xy′−2y=3x,x2y″+2xy′−2y=3x,$ $y1(x)=x,y2(x)=x−2y1(x)=x,y2(x)=x−2$

85.

$x2y″−2y=10x2−1,x2y″−2y=10x2−1,$ $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

Want to cite, share, or modify this book? This book is Creative Commons Attribution-NonCommercial-ShareAlike License 4.0 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

© Dec 21, 2020 OpenStax. Textbook content produced by OpenStax is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike License 4.0 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.