**17.2** Nonhomogeneous Linear

### Equations

### Nonhomogeneous Linear Equations

In this section we learn how to solve second-order

nonhomogeneous linear differential equations with constant coefficients, that is, equations of the form

*ay″ + by′ + cy = G(x)*

*where a, b, and c are constants and G is a continuous *
function. The related homogeneous equation

*ay″ + by′ + cy = 0*

**is called the complementary equation and plays an **
important role in the solution of the original

nonhomogeneous equation (1).

### Nonhomogeneous Linear Equations

There are two methods for finding a particular solution:

The method of undetermined coefficients is straightforward
*but works only for a restricted class of functions G.*

The method of variation of parameters works for every
*function G but is usually more difficult to apply in practice.*

### The Method of Undetermined

### Coefficients

### The Method of Undetermined Coefficients

We first illustrate the method of undetermined coefficients for the equation

*ay″ + by′ + cy = G(x)*
*where G(x) is a polynomial.*

It is reasonable to guess that there is a particular solution
*y*_{p }*that is a polynomial of the same degree as G because if *
*y is a polynomial, then ay″ + by′ + cy is also a polynomial. *

*We therefore substitute y*_{p}*(x) = a polynomial (of the same *
*degree as G) into the differential equation and determine *
the coefficients.

### Example 1

*Solve the equation y″ + y′ – 2y = x*^{2}.
Solution:

*The auxiliary equation of y″ + y′ – 2y = 0 is*
*r*^{2} *+ r – 2 = (r – 1)(r + 2) = 0*
*with roots r = 1, –2.*

So the solution of the complementary equation is
*y*_{c}*= c*_{1}*e*^{x}*+ c*_{2}*e *^{–2x}

*Example 1 – Solution*

*Since G(x) = x*^{2 }is a polynomial of degree 2, we seek a
particular solution of the form

*y*_{p}*(x) = Ax*^{2} *+ Bx + C*

Then *= 2Ax + B and* *= 2A so, substituting into the *
given differential equation, we have

*(2A) + (2Ax + B) – 2(Ax*^{2} *+ Bx + C) = x*^{2}
or

*–2Ax*^{2} *+ (2A – 2B)x + (2A + B – 2C) = x*^{2}

Polynomials are equal when their coefficients are equal.

cont’d

*Example 1 – Solution*

Thus

*–2A = 1* *2A – 2B = 0* *2A + B – 2C = 0*

The solution of this system of equations is

*A = * *B = * *C =*

A particular solution is therefore
*y*_{p}*(x) =*

and, by Theorem 3, the general solution is
*y = y*_{c}*+ y** _{p}* =

cont’d

### Example 3

*Solve y″ + y′ – 2y = sin x.*

Solution:

We try a particular solution

*y*_{p}*(x) = A cos x + B sin x*
Then

*= –A sin x + B cos x*

*= –A cos x – B sin x*

*Example 3 – Solution*

So substitution in the differential equation gives

or

This is true if

*–3A + B = 0 and –A – 3B = 1 *
The solution of this system is

*A = * *B =*

cont’d

*Example 3 – Solution*

So a particular solution is
*y*_{p}*(x) =*

In Example 1 we determined that the solution of the complementary equation is

*y*_{c}*= c*_{1}*e*^{x}*+ c*_{2}*e*^{–2x}*.*

Thus the general solution of the given equation is

*y(x) = c*_{1}*e*^{x}*+ c*_{2}*e ** ^{–2x}* –

*(cos x + 3 sin x)*

cont’d

### The Method of Undetermined Coefficients

*If G(x) is a product of functions of the preceding types, then *
we take the trial solution to be a product of functions of the
same type.

For instance, in solving the differential equation
*y″ + 2y′ + 4y = x cos 3x*

we would try

*y*_{p}*(x) = (Ax + B) cos 3x + (Cx + D) sin 3x*

### The Method of Undetermined Coefficients

*If G(x) is a sum of functions of these types, we use the *
*easily verified principle of superposition, which says that if*

and are solutions of

*ay″ + by′ + cy = G*_{1}*(x)*
*ay″ + by′ + cy = G*_{2}*(x)*

respectively, then is a solution of
*ay″ + by′ + cy = G*_{1}*(x) + G*_{2}*(x)*

### The Method of Undetermined Coefficients

### Example 6

Determine the form of the trial solution for the differential equation

*y″ – 4y + 13y = e*^{2x}*cos 3x.*

Solution:

*Here G(x) has the form of part 2 of the summary, where*
*k = 2, m = 3, and P(x) = 1.*

So, at first glance, the form of the trial solution would be
*y*_{p}*(x) = e*^{2x}*(A cos 3x + B sin 3x)*

*Example 6 – Solution*

*But the auxiliary equation is r*^{2} *– 4r + 13 = 0, with roots *

*r = 2 ± 3i, so the solution of the complementary equation is*

*y*_{c}*(x) = e*^{2x}*(c*_{1}*cos 3x + c*_{2}*sin 3x)*

This means that we have to multiply the suggested trial
*solution by x.*

So, instead, we use

*y*_{p}*(x) = xe*^{2x}*(A cos 3x + B sin 3x)*

cont’d

### The Method of Variation

### of Parameters

### The Method of Variation of Parameters

Suppose we have already solved the homogeneous
*equation ay″ + by′ + cy = 0 and written the solution as*

*y(x) = c*_{1}*y*_{1}*(x) + c*_{2}*y*_{2}*(x)*

*where y*_{1} *and y*_{2} are linearly independent solutions.

*Let’s replace the constants (or parameters) c*_{1} *and c*_{2} in
*Equation 4 by arbitrary functions and u*_{1}*(x) and u*_{2}*(x).*

### The Method of Variation of Parameters

We look for a particular solution of the nonhomogeneous
*equation ay″ + by′ + cy = G(x) of the form*

*y*_{p}*(x) = u*_{1}*(x) y*_{1}*(x) + u*_{2}*(x) y*_{2}*(x) *

**(This method is called variation of parameters because **
*we have varied the parameters c*_{1 }*and c*_{2} to make them
functions.)

### The Method of Variation of Parameters

Differentiating Equation 5, we get

*Since u*_{1} *and u*_{2 }are arbitrary functions, we can impose two
conditions on them.

*One condition is that y** _{p}* is a solution of the differential
equation; we can choose the other condition so as to
simplify our calculations.

### The Method of Variation of Parameters

In view of the expression in Equation 6, let’s impose the condition that

Then

Substituting in the differential equation, we get

or

### The Method of Variation of Parameters

*But y*_{1 }*and y*_{2 }are solutions of the complementary equation,
so

and and Equation 8 simplifies to

Equations 7 and 9 form a system of two equations in the unknown functions and .

After solving this system we may be able to integrate to find
*u*_{1 }*and u*_{2} then the particular solution is given by Equation 5.

### Example 7

Solve the equation

*y″ + y = tan x, 0 < x <* π/2.

Solution:

*The auxiliary equation is r*^{2} + 1 = 0 with roots ±i, so the
*solution of y″ + y = 0 is y(x) = c*_{1 }*sin x + c*_{2} *cos x.*

Using variation of parameters, we seek a solution of the form

*y*_{p}*(x) = u*_{1}*(x) sin x + u*_{2}*(x) cos x*
Then

*Example 7 – Solution*

Set

Then

*For y** _{p}* to be a solution we must have

Solving Equations 10 and 11, we get

(sin^{2}*x + cos*^{2}*x) = cos x tan x*

cont’d

*Example 7 – Solution*

*= sinx u*_{1}*(x) = –cos x*

(We seek a particular solution, so we don’t need a constant of integration here.)

Then, from Equation 10, we obtain

cont’d

*Example 7 – Solution*

*= cos x – sec x*
So

*u*_{2}*(x) = sin x – ln(sec x + tan x)*

*(Note that sec x + tan x > 0 for 0 < x <* π/2.)
Therefore

*y*_{p}*(x) = –cos x sin x + [sin x – ln(sec x + tan x)] cos x *

*= –cos x ln(sec x + tan x)*
and the general solution is

*y(x) = c*_{1}*sin x + c*_{2}*cos x – cos x ln(sec x + tan x)*

cont’d