Nonhomogeneous Linear Equations

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)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)(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) 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.

try it

Given that yp(x)=2 is a particular solution to 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), 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.

In Example “Undetermined Coefficients When 𝑟(𝑥) 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 yy2y=2e3x.

try it

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

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=3e2x. Based on the form of r(x), we guess a particular solution of the form yp(x)=Ae2x. 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)=2Ae2x

and

yp=4Ae2x,

so we want

y+5y+6y=3e2x4Ae2x+(2Ae2x)+6Ae2x=3e2x4Ae2x10Ae2x+6Ae2x=3e2x0=3e2x,

which is not possible.

Looking closely, we see that, in this case, the general solution to the complementary equation is c1e2x+c2e2x. 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)=Ae2x, we have

yp(x)=A(e2x2xe2x)

and

yp(x)=4Ae2x+4Axe2x.

Substitution gives

y+5y+6y=3e2x(4Ae2x+4Axe2x)+5(Ae2x2Axe2x)+6Axe2x=3e2x4Ae2x+4Axe2x10Axe2x+6Axe2x=3e2xAe2x=3e2x,

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

y(x)=c1e2x+c2e2x+3xe2x.

Note that if xe2x were also a solution to the complementary equation, we would have to multiply by x again, and we would try yp(x)=Ax2e2x.

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), make an initial guess for yp(x).
  3. 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.
  4. Substitute yp(x) into the differential equation and equate like terms to find values for the unknown coefficients in 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: solving nonhomogeneous equations

Find the general solutions to the following differential equations.

  1. y9y=6cos3x
  2. x+2x+x=4et
  3. y2y+5y=1023x3
  4. y3y=12t

try it

Find the general solution to the following differential equations.

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

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+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).

Note that y1 and y2 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).

If we simplify this equation by imposing the additional condition uy1+vy2=0, the first two terms are zero, and this reduces to 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).

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=0z13x2z2=2x.

try it

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

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

problem-solving strategy: method of variation of parameters

  1. Solve the complementary equation and write down the general solution

    c1y1(x)+c2y2(x).

  2. Use Cramer’s rule or another suitable technique to find functions u(x) and v(x) satisfying

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

  3. 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.
  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: using the method of variation of parameters

Find the general solution to the following differential equations.

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

try it

Find the general solution to the following differential equations.

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

Watch the following videos to see the worked solution to the above Try It