Chapter 2 Second-Order Linear ODEs
Part 2. Non-Homogeneous DE
Wang Zhongjian
Division of Mathematical Sciences
School of Physical and Mathematical Sciences
Nanyang Technological University, Singapore
Office: SPMS-MAS-05-05
[Link]
Email: [Link]@[Link]
MH3110 – Ordinary Differential Equations, Last updated: February 3, 2026
Outline
1 Theory for Linear Nonhomogeneuous DE
2 Method of Undetermined Coefficients
3 Variation-of-Parameter Method
4 Reduction of order
2
Solution Structure: Nonhomogenous DE
Theorem
The general solution of the nonhomogeneous DE:
y ′′ + p(x)y ′ + q(x)y = f (x) (where f (x) ̸= 0) (1)
can be written in the form
y(x) = yp (x) + c1 y1 (x) + c2 y2 (x) (2)
| {z }
yc (x)
where yp (x) is a Particular Solution of (1), i.e.,
yp′′ + p(x)yp′ + q(x)yp = f (x)
and yc (x) is the GS of the associated homogeneous DE
y ′′ + p(x)y ′ + q(x)y = 0
3
Outline
1 Theory for Linear Nonhomogeneuous DE
2 Method of Undetermined Coefficients
3 Variation-of-Parameter Method
4 Reduction of order
4
Method of Undetermined Coefficients
An important step is to find a particular solution yp (x).
The method of undetermined coefficients is the simplest.
It can only be applied to find yp (x) for a linear ODE with
constant coefficients:
ay ′′ + by ′ + cy = r(x), (3)
where r(x) must be some special functions.
5
r(x) is restricted to an exponential function, a power of x, a
cosine or sine, or sums or products of such functions.
These functions have derivatives similar to r(x) itself.
We choose a form for yp similar to r(x), but with unknown
coefficients to be determined by substituting that yp and its
derivatives into the ODE.
6
Choice Rules for yp (x)
Only for linear with constant coefficients.
(a) Basic Rule. If r(x) in (3) is appears in the left column of
the table, choose yp in the same line and then determine
its undetermined coefficients by substituting yp .
(b) Sum Rule. If r(x) = r1 (x) + r2 (x), then find yp,1 for r1 and
yp,2 for r2 . By linearity, yp = yp,1 + yp,2 .
(c) Product Rule. If r(x) = Pn (x)W (x), where Pn denotes a
n-order polynomial, W (x) is one of the rest terms (except
polynomial) in the left of the table, then the trial solution
shall be in form of,
(Kn xn + · · · + K0 ) × {yp for W (x)}.
(d) Modification Rule. If a term in your choice for yp happens
to be a solution of the homogeneous ODE corresponding
to (3), multiply this usual trial yp (x) by x (or by x2 if this
solution corresponds to a double root of the CE).
7
Example
Determine the general solution to
(i) y ′′ − y = 16e3x ; (ii) y ′′ − y = 16e−x .
8
Solution of (i): y ′′ − y = 16e3x
Step 1: Find yc (x): Solve y ′′ − y = 0 with the CE
r2 − 1 = 0 ⇒ r = ±1,
so the complementary function is
yc (x) = c1 ex + c2 e−x . (4)
Step 2: Choice for yp (x): We look for a particular solution yp (x).
Since taking derivatives of e3x returns multiples of e3x , we try a similar
function
yp (x) = Ae3x , (5)
where the constant A is an undetermined coefficient. Comparing (4)
with (5), the usual trial yp (x) is not a solution to the homogeneous
DE: y ′′ − y = 0, so it WORKS!
9
Step 3: Determine the coefficients in yp (x): We now substitute yp
into the nonhomogeneou DE to determine the constant A. Note
yp′ = 3Ae3x , yp′′ = 9Ae3x ,
and from the equation,
16e3x = yp′′ − yp = 8Ae3x ⇒ A = 2 ⇒ yp (x) = 2e3x .
Therefore, the general solution of (i) is
y(x) = yp (x) + yc (x) = 2e3x + c1 ex + c2 e−x .
10
Solution of (ii): y ′′ − y = 16e−x
As with (i), we try yp (x) = Be−x , but find
16e−x = yp′′ − yp = (Be−x )′′ − (Be−x ) = Be−x − Be−x = 0,
which leads to a contradiction as 16e−x ̸= 0. Why?
We have to modify it and the rule is to multiply the failed one by x. We
choose yp (x) = Bxe−x .1 Then we determine B by substitution:
16e−x = yp′′ − yp = B(x − 2)e−x − (Bxe−x ) = −2Be−x
⇒ B = −8 ⇒ yp (x) = −8xe−x .
The general solution of (ii) is
y(x) = yp (x) + yc (x) = −8xe−x + c1 ex + c2 e−x .
1
The modified yp (x) works, as it cannot be obtained from yc (x) in (4)!
11
Critical Thinking
Question: Can we choose yp (x) = Bx2 e−x ? Any other forms?
Remarks: The method is self-correcting. A false choice for yp (x) or
one with too few terms will lead to a contradiction. A choice with too
many terms will give a correct result, with superfluous coefficients
coming out zero.
12
More Examples
Example
In each case, write an appropriate trial solution. Do not solve
for the coefficients in your proposed solution.
1) y ′′ + 5y ′ = 4x2
2) y ′′ − y = 3xex
3) y ′′ − 4y ′ + 5y = 3e2x sin x
13
Solution: 1) y ′′ + 5y ′ = 4x2
The characteristic equation r2 + 5r = 0 has the roots r = 0, −5, and
hence the complementary function
yc (x) = c1 + c2 e−5x . (6)
In light of f (x) = 4x2 , we choose a full quadratic polynomial
yp (x) = A0 + A1 x + A2 x2 .
Note the first term A0 is a solution of the homogeneous DE (obtained
from (6) by taking c1 = A0 , c2 = 0), so we have to modify it as
yp (x) = x(A0 + A1 x + A2 x2 ) = A0 x + A1 x2 + A2 x3 .
It cannot be obtained from (6), so it works.
Remark: In fact, we can continue to find
8 4 4
yp (x) = x − x2 + x3
125 25 15
14
Solution: 2) y ′′ − y = 3xex
The CE: r2 − 1 = 0 has the roots r = ±1, and hence the GS to the
associated homogeneous equation is
yc (x) = c1 ex + c2 e−x . (7)
The usual trial solution is
yp (x) = (A + Bx)ex = Aex + Bxex
The first term can be obtained from (7), so we modify it as
yp (x) = x(A + Bx)ex = Axex + Bx2 ex .
No term is a solution to the associated homogeneous DE, as it
cannot be derived from (7).
Remark: We can continue to find
3 3
yp (x) = − xex + x2 ex .
4 4
15
Solution: 3) y ′′ − 4y ′ + 5y = 3e2x sin x
The CE: r2 − 4r + 5 = 0 has the roots r = 2 ± i, so
yc (x) = e2x (c1 cos x + c2 sin x). (8)
The usual trial solution corresponding to f (x) = 3e2x sin x is
yp (x) = e2x (A cos x + B sin x),
It is evident that from (8), we must modify it as
yp (x) = xe2x (A cos x + B sin x),
which is now the correct form.
Remark: We can continue to find
3
yp (x) = − xe2x cos x.
2
16
Sum of Different Types
Recall Rule: Let f = f1 + f2 , where f1 , f2 are of different types. Then
we find the corresponding yp1 , yp2 , respectively. The trial solution is
yp (x) = yp1 (x) + yp2 (x).
Example
Determine an appropriate trial solution of
y ′′ − y = 4ex + 5x2 .
Solution:
yp (x) = yp1 (x) + yp2 (x) = A0 xex + (B0 + B1 x + B2 x2 ).
17
Outline
1 Theory for Linear Nonhomogeneuous DE
2 Method of Undetermined Coefficients
3 Variation-of-Parameter Method
4 Reduction of order
18
Variation-of-Parameter Method
Why? Two limitations of Method of Undetermined Coefficients:
Only applicable to DEs with constant coefficients,
f (x) must be special functions.
For example, it can not be applied to
y ′′ + 4y ′ − 6y = x2 ln x.
The variation-of-parameter method can overcome the above
limitations, but it is more complicated to implement.
19
Derivation
Let y1 and y2 are two LI solution to linear homogeneous
DE: y ′′ + py ′ + qy = 0.
Consider the trial solution in the form,
yp (x) = u1 (x)y1 (x) + u2 (x)y2 (x). (9)
Differentiating (9) with respect to x yields
yp′ = u′1 y1 + u1 y1′ + u′2 y2 + u2 y2′
If we differentiate it once more, the resulting expression for
yp′′ will involve second-order derivatives u′′1 and u′′2 , which
will complicate our problem. To eliminate these derivatives,
we set
u′1 y1 + u′2 y2 = 0, (10)
Therefore, the expression yp′ reduces to
yp′ = u1 y1′ + u2 y2′ ,
and so that yp′′ = u′1 y1′ + u1 y1′′ + u′2 y2′ + u2 y2′′ .
20
Derivation (page 2)
Substituting,
yp′ = u1 y1′ + u2 y2′ , yp′′ = u′1 y1′ + u1 y1′′ + u′2 y2′ + u2 y2′′ ,
into the equation yp′′ + pyp′ + qyp = f and collecting the
terms yields,
u1 (y1′′ + py1′ + qy1 )+u2 (y2′′ + py2′ + qy2 )+(u′1 y1′ +u′2 y2′ ) = f (x).
| {z } | {z }
=0 =0
Now we need,
u′1 y1 + u′2 y2 = 0,
" #" # " #
y1 y2 u′1 0
⇐⇒ = . (11)
y1′ u′1 + y2′ u′2 = f. y1′ y2′ u′2 f
By using the Cramer’s rule, we can find
y2 f y1 f
u′1 = − , u′2 = ,
W (y1 , y2 ) W (y1 , y2 )
so that
y2 f y1 f
Z Z
u1 (x) = − dx, u2 (x) = dx. (12)
W (y1 , y2 ) W (y1 , y2 ) 21
Summing up
Theorem (Variation-of-Parameter Method)
Consider
y ′′ + p(x)y ′ + q(x)y = f (x). (13)
Suppose the general solution of associated homogeneous DE:
y ′′ + p(x)y ′ + q(x)y = 0 is yc (x) = c1 y1 (x) + c2 y2 (x). (14)
Then one particular solution of (13) is
y2 (x)f (x) y1 (x)f (x)
Z Z
yp (x) = −y1 (x) dx + y2 (x) dx, (15)
W (y1 , y2 ) W (y1 , y2 )
where W (y1 , y2 ) = y1 y2′ − y1′ y2 is the Wronskian of y1 , y2 .
22
Example
Solve
1
y ′′ + y = sec x =
cos x
23
Example
Solve
1
y ′′ + y = sec x =
cos x
Solution: Two linearly independent solutions to the associated
homogeneous DE are y1 = cos x and y2 = sin x. Thus a particular
solution to the given DE is
yp (x) = u1 y1 + u2 y2 = u1 cos x + u2 sin x,
where u1 and u2 satisfy
cos xu′1 + sin xu′2 = 0,
(16)
− sin xu′1 + cos xu′2 = sec x.
The solution to this system is
u′1 = − sec x sin x, u′2 = sec x cos x.
23
Consequently,
Z Z
sin x
u1 (x) = − sec x sin xdx = − dx = ln | cos x|,
cos x
and Z
u2 (x) = sec x cos xdx = x,
where we have set the integration constants to zero, since we only
require one particular solution. Therefore,
yp (x) = cos x ln | cos x| + x sin x,
and the general solution is
y(x) = cos x ln | cos x| + x sin x + c1 cos x + c2 sin x.
24
Note: You can directly use the formula (15)!
Exercise
(i) Solve
y ′′ + 4y ′ + 4y = e−2x ln x, x > 0.
(ii) Solve the nonhomogeneous DE (Hint: use both methods):
π
y ′′ + y = sec x + 4ex , |x| < .
2
Key: (i) y(x) = e−2x c1 + c2 x + 41 x2 (2 ln x − 3) .
Key: (ii) y(x) = c1 cos x + c2 sin x + 2ex + cos x ln(cos x) + x sin x.
25
Outline
1 Theory for Linear Nonhomogeneuous DE
2 Method of Undetermined Coefficients
3 Variation-of-Parameter Method
4 Reduction of order
26
Reduction of order: Nonhomogeneous DE
Results in reduction of order for homogeneous DE can also be
genearlized to nonhomogeneou DE.
Theorem: Consider the nonhomogeneuous DE:
y ′′ + p(x)y ′ + q(x)y = f (x), (17)
where p, q and f are given continuous functions on I. If y = y1 (x) is a
solution to the associated homogeneous DE:
y ′′ + p(x)y ′ + q(x)y = 0. (18)
Then y2 (x) = u(x)y1 (x) is the (general) solution of (17), where
y′ f
u′ (x) = v(x) and v ′ + 2 1 + p v = , (19)
y1 y1
with the solution
1 Z R
p(x)dx
v(x) = 2 y1 (x)f (x)I1 (x)dx + C , I1 (x) = e .
y1 (x)I1 (x)
Remark: If f (x) = 0, it leads to the formula in homogeneneous case.
Question: Try to prove this theorem.
27
Proof
Substituting y2 = uy1 to original nonhomogeneous DE:
u′′ y1 + 2u′ y1′ + uy1′′ + pu′ y1 + puy1′ + quy1 = f.
Since y1′′ + py1′ + qy1 = 0, and let v = u′ , we have,
v ′ y1 + 2vy1′ + pvy1 = f, ⇒
2y1′ f
v′ + ( + p)v = .
y1 y1
The ingetrating factor,
2y1 (x)′
R R
(x)+p(x)dx
I(x) = e R y1 = y12 (x)e p(x)dx , so let
p(x)dx
I1 (x) = e , we have,
1 Z
v(x) = 2 y1 (x)f (x)I1 (x)dx + C1 .
y1 (x)I1 (x)
R
Hence, u(x) = v(x) + C2 , GS is
1
Z Z
y= y 1 f I1 dx + C 1 dx y1 + C2 y1 . (20)
y12 I1
28