You are on page 1of 7

First order, nonhomogeneous, linear differential equations

Problem: Solve the following initial value problem

y 0 + 3y = sin(2x)
(1)
y(π) = 0.

You may try to guess the solution and you may even find out that the function
3 2
y(x) = sin(2x) − cos(2x)
13 13
is a solution of the differential equation (1). But does it satisfy the initial condition of (1)?
3 2 2
y(π) = sin(2π) − cos(2π) = − 6= 0,
13 13 13
so the answer is no. How can we find the solution which satisfies the initial condition at the same
time? How can we do it without guessing?
We know how to solve the homogeneous part of the equation

y 0 + 3y = 0. (2)

First we rearrange to
y 0 = −3y,
then the general solution of the homogeneous differential equation (2) is

yh (x) = Ae−3x , (3)

where A is a constant.
3 2
You may notice, that not only our initial guess y(x) = 13 sin(2x) − 13 cos(2x) is a solution of
−3x 3 2
d.e.(1) but y(x) = Ae + 13 sin(2x) − 13 cos(2x) is also a solution with any constant A. (Check
this by substituting y(x) back to d.e.(1).) This is the general solution of (1).
Now, we can use the initial condition y(π) = 0 to get the solution of the initial value problem.
3 2
0 = Ae−3π + sin(2π) − cos(2π)
13 13
2
0 = Ae−3π −
13
2
= Ae−3π
13
2
A = e3π .
13
So the solution of the initial value problem (1) is
2 3π −3x 3 2
y(x) = e e + sin(2x) − cos(2x).
13 13 13
3 2
But how can we guess a solution like y(x) = 13 sin(2x) − 13 cos(2x)? We will use the method
of undetermined coefficients. The function on the right of equation (1), which makes the d.e.
nonhomogeneous, is f (x) = sin(2x). So we try to find the solution in the form of

y(x) = B sin(2x) + C cos(2x).

1
What should B and C be equal to? The function we are looking for is a solution of the nonhomo-
geneous differential equation (1), so if we plug this “guess” back to (1) we have to get equality as
functions (i.e. for all values of x).

y 0 + 3y = sin(2x)
¡ ¢0 ¡ ¢
B sin(2x) + C cos(2x) + 3 B sin(2x) + C cos(2x) = sin(2x)
2B cos(2x) − 2C sin(2x) + 3B sin(2x) + 3C cos(2x) = sin(2x).

This latter equation is true for all x if and only if the coefficients of cos(2x) and sin(2x) respectively
are the same on both sides of the equation. So compare the coefficients.
The coefficients of cos(2x):
2B + 3C = 0.
The coefficients of sin(2x):
−2C + 3B = 1.
3 2
Solving these two equations, we get B = 13 and C = − 13 and the function

3 2
y(x) = B sin(2x) + C cos(2x) = sin(2x) − cos(2x)
13 13
is a solution of (1). We will call this the particular solution of (1) and denote it by yp (x). Then the
general solution of the nonhomogeneous equation (1) is the sum of the solution of the homogeneous
part and the particular solution:
3 2
y(x) = yh + yp = Ae−3x + sin(2x) − cos(2x).
13 13

Solving first-order nonhomogeneous differential equations


We consider a first-order nonhomogeneous linear differential equation with constant coefficients

y 0 + ay = f (x). (4)

Here f (x) is a continuous function of the variable x; a is a constant. Such equations are called
nonhomogeneous because of the term f (x) which prevents the equation from being strictly linear.

Step1 First, we will look for the solution of the homogeneous part of the equation

y 0 + ay = 0.

By rearranging this equation we get


y 0 = −ay;
we showed earlier that the general solution of such a homogeneous differential equation is

yh (x) = Ae−ax

where A is constant. (Note: look for the variable of equation (4). Is it x, t or else?)

Step2 Second, we will use the method of undetermined coefficients to find a particular solution
of the originally given nonhomogeneous differential equation (4). Here is some help.

2
If f (x) is then try y(x) in the form of
polynomial polynomial of same degree
an xn + an−1 xn−1 + · · · + a0 An xn + An−1 xn−1 + · · · + A0
bekx Bekx
b sin(ax) or b cos(ax) B sin(ax) + C cos(ax)
For combinations of the above functions:
If f (x) is then try y(x) in the form of
kx n
be (an x + · · · + a0 ) e (An¡xn + An−1 xn−1 + · · · +¢A0 )
kx
kx
be sin(ax) ekx ¡B sin(ax) + C cos(ax)¢
bekx cos(ax) ¡ ekx B sin(ax)
¢ + C cos(ax)
b sin(ax)(an x + · · · + a0 ) ¡B sin(ax) + C cos(ax)¢(xn + An−1 xn−1 + · · · + A0 )
n

b cos(ax)(an xn + · · · + a0 ) B sin(ax) + C cos(ax) (xn + An−1 xn−1 + · · · + A0 )


sum of above functions sum of the corresponding functions
bekx + an xn Bekx + An xn + An−1 xn−1 + · · · + A0

This function must be a solutions of the nonhomogeneous differential equation (4), so if you
substitute your trial function y(x) back into (4), the equation has to hold for all values of x. By
comparing the coefficients of xn , xn−1 , . . ., x, sin(ax), cos(ax) and the constant terms you will
be able to find the constants in the trial formula of y(x).
We will call this solution the particular solution of the d.e. (4) and denote by yp .

Step3 Every solution of a nonhomogeneous differential equation y 0 + ay = f (x) has the form
yh (x) + yp (x) where yh (x) is the general solution of the homogeneous equation y 0 + ay = 0, and
yp (x) is a particular solution of y 0 + ay = f (x). Conversely, the sum yh (x) + yp (x) is a solution
of y 0 + ay = f (x). Therefore, the general solution of y 0 + ay = f (x) is yh (x) + yp (x).

Step4 If an initial condition is also given to accompany the differential equation, use that to find
the unique solution of the initial value problem.

Step5 Finally, don’t forget to write down the solution to the problem and answer all the questions.

Example 1
Find the solution of the initial value problem

y 0 + 2y = 3e−5x cos(x)
2 (5)
y(0) = − .
5

Step1 Solve the homogeneous part of the differential equation.

y 0 + 2y = 0
y 0 = −2y
yh (x) = Ae−2x .

3
Step2 Find a particular solution of the nonhomogeneous differential equation (5). Since the
right side of¡ equation (5) is f¢(x) = 3e−5x cos x, we look for the particular solution in the form
y(x) = e−5x B sin x + C cos x . Substitute this into the differential equation:

y 0 + 2y = 3e−5x cos x
³ ¡ ¢´0 ¡ ¢
e−5x B sin x + C cos x + 2e−5x B sin x + C cos x = 3e−5x cos x
¡ ¢ ¡ ¢ ¡ ¢
−5e−5x B sin x + C cos x + e−5x B cos x − C sin x + 2e−5x B sin x + C cos x =
= 3e−5x cos x
−5B sin x − 5C cos x + B cos x − C sin x + 2B sin x + 2C cos x = 3 cos x

Compare the coefficients. The coefficients of sin x:

−5B − C + 2B = 0.

The coefficients of cos x:


−5C + B + 2C = 3.
3 9
Solving these two equations for B and C we get B = 10 and C = − 10 . So
³3 9 ´
yp (x) = e−5x sin x − cos x .
10 10

Step3 The general solution of the nonhomogeneous differential equation (5) is:
³3 9 ´
y(x) = yh (x) + yp (x) = Ae−2x + e−5x sin x − cos x .
10 10

Step4 Use the initial value y(0) = − 25 to find the unique solution of the initial value problem, i.e.
determine the constant A.
2 ³3 9 ´
− = Ae0 + e0 sin(0) − cos(0)
5 10 10
2 9
− =A−
5 10
1
A= .
2
¡ ¢
Step5 The solution of the initial value problem (5) is y(x) = 21 e−2x + e−5x 3
10 sin x − 9
10 cos x .

Example 2
Solve the initial value problem
y − 2y 0 − 6t2 + 5 = 0
(6)
y(1) = 100.
Note: First, rewrite this differential equation in the usual form y 0 + ay = f (t):
1 5
y 0 − y = −3t2 + .
2 2
Also notice that the variable is t, so now y is a function of t.

4
Step1 Solve the homogeneous part of the differential equation.
1
y0 − y = 0
2
1
y0 = y
2
1
yh (t) = Ae 2 t .

Step2 Find a particular solution of (6). The nonhomogeneous part of the equation is f (t) =
−3t2 + 25 , a quadratic polynomial, so we look for a particular solution in the form of a quadratic
polynomial y(t) = Bt2 + Ct + D. Substituting this to the differential equation,
1 5
y 0 − y = −3t2 +
2 2
2 0 1 2 2 5
(Bt + Ct + D) − (Bt + Ct + D) = −3t +
2 2
1 2 1 1 5
2Bt + C − Bt − Ct − D = −3t2 + .
2 2 2 2
Compare the coefficients. The coefficients of t2 :
1
− B = −3.
2
The coefficients of t:
1
2B − C = 0.
2
The constant terms are:
1 5
C− D= .
2 2
So B = 6, C = 24, D = 43 and the particular solution is yp (t) = 6t2 + 24t + 43.

Step3 The general solution of the nonhomogeneous equation y − 2y 0 − 6t2 + 5 = 0 is


1
y(t) = yh + yp (t) = Ae 2 t + 6t2 + 24t + 43.

Step4 Use the initial condition y(1) = 100 to determine the value of A and so the solution of the
initial value problem.
1
100 = Ae 2 + 6 + 24 + 43
1
Ae 2 = 27
1 27
A = 27e− 2 = √ .
e

Step5 The solution of the initial value problem is


27 1
y(t) = √ e 2 t + 6t2 + 24t + 43.
e

5
Example 3
Let a and b be positive constants with a 6= 9. Find the solution of the following initial value problem
√ 0 p a 3x
ay − b e
y=
a (7)
− 12
y(0) = b .
First, we rearrange the d.e. into normal form:
√ 1
y0 − ay = √ e3x .
b

Step1 Solve the homogeneous part:



y0 − ay = 0

y 0 = ay

ax
yh (x) = Ae .

Step2 Since the nonhomogeneous term of equation (7) is f (x) = √1b e3x , we look for a particular
solution of (7) in the form of y(x) = Be3x . Substituting this to (7)
√ 1
(Be3x )0 −a(Be3x ) = √ e3x
b
√ 1
3Be3x − aBe3x = √ e3x
b
√ 1
3B − aB = √
b
1
B=√ √ .
b(3 − a)
1
The particular solution is yp (x) = √ √ e3x .
b(3− a)

Step3 The general solution of (7) is


√ 1
ax 3x
y(x) = yh + yp = Ae +√ √ e .
b(3 − a)
1
Step4 Use the initial condition y(0) = b− 2 to determine the value of A.
1 √ 1
b− 2 = Ae +√ a0
√ e
0
b(3 − a)
1 1
A = b− 2 − √ √
b(3 − a)

2− a
A= √ √ .
b(3 − a)

Step5 The solution of the initial value problem is


√ √
2− a ax 1 3x
y(x) = √ √ e +√ √ e .
b(3 − a) b(3 − a)

6
Supplementary material — Example 4
The method of undetermined coefficients that we use to solve nonhomogeneous differential equations
has limitations. There are linear nonhomogeneous differential equations with constant coefficients
2
which cannot be solved using this method. For example if f (x) = sin(2x + 3) or f (x) = e−3x or
−2
f (x) = ln x or f (x) = 1+x we cannot find a particular solution.
We can also encounter another difficulty which is demonstrated in the following problem.
Example 4: Find the general solution of the following equation

y 0 + 5y = 10e−5t . (8)

Just as we did before, first we solve the homogeneous part:

y 0 + 5y = 0
y 0 = −5y
yh (t) = Ae−5t .

Then we try to find a particular solution. Since f (t) = 10e−5t we look for a particular solution in
the form of y(t) = Be−5t . Substitute this into equation (8).

(Be−5t )0 + 5Be−5t = 10e−5t


−5Be−5t + 5Be−5t = 10e−5t
0 = 10e−5t ,

which is impossible. What happened? Notice that our guess for a particular solution, y(t) = Be−5t ,
is a solution of the homogeneous equation y 0 + 5y = 0. In this case we have to modify our trial
function to y(t) = Bte−5t . Substituting this back to the differential equation we get that
¡ ¢0 ¡ ¢
Bte−5t + 5 Bte−5t = 10e−5t
Be−5t − 5Bte−5t + 5Bte−5t = 10e−5t
B − 5Bt + 5Bt = 10
B = 10.

So the function y(t) = 10te−5t is a particular solution; and the general solution of (8) is

y(t) = yh + yp = Ae−5t + 10te−5t .

How to modify our trial functions? How to find a particular solution for other functions f ? You
will find the answers to these questions later in MA2132.
Questions: Why did we have the assumption in Example 3 that a 6= 9? Can you find the
solution if a = 9 by modifying the trial function just as we did here in Example 4?

You might also like