6 Second Order Linear Differential Equations

SECOND ORDER LINEAR DIFFERENTIAL EQUATIONS
6
Second Order Linear Differential Equations
A differential equation for an unknown function y = f (x) that depends on a variable x is
any equation that ties together functions of x with y and its derivatives. It is a second order
d2 y
dy
differential equation if it involves
, possibly together with
, y and functions of x, but
dx2
dx
no higher order derivatives. For example
d2 y
= sin x,
dx2
2
d2 y
+ xy 2 = ex ,
2
dx
d2 y 2
dx2
+ ex
dy
= ln(x2 + 1)
dx
are all second order differential equations in the unknown function y, but
d3 y
dy
+
=0
3
dx
dx
is third order. A linear second order differential equation is one of the form
p(x)
d2 y
dy
+ q(x)
+ r(x)y = f (x)
dx2
dx
(∗)
for functions p, q, r and f of the variable x. It does not feature products of y with its
derivatives, or other such functions. For example
d2 y
= sin x,
dx2
d2 y
dy
+ ex
+ (cos x)y = tan x
2
dx
dx
are both linear, but none of the following are linear:
d2 y
+ xy 2 = 0,
dx2
d2 y
− cos y = ex ,
dx2
y
d2 y dy 2
+
= 0.
dx2
dx
In general, linear equations are easier to solve than nonlinear equations. Indeed, often it is not
known how to obtain an exact solution to a nonlinear equation, so instead one approximates
the solution by studying related linear equations.
The general linear second order differential equation (∗) is called homogeneous if f (x) is
identically zero, i.e. f (x) = 0 for all x ∈ R, otherwise it is nonhomogeneous. This is the same
terminology used earlier for matrix equations, since we have the following result analogous to
the Theorem 3.4:
Theorem 6.1. Consider the linear second order ODE
p(x)y ′′ + q(x)y ′ + r(x)y = f (x)
(N)
and its associated homogeneous equation
p(x)y ′′ + q(x)y ′ + r(x)y = 0.
(H)
(a) If y1 and y2 are solutions of (H) then so are y1 + y2 , ky1 and ky2 for any number k.
(b) If y1 is a solution of (N) and y0 a solution of (H), then y1 + y0 is a solution of (N).
On the other hand, if y2 is another solution of (N) then y1 − y2 is a solution of (H).
Remark. As a consequence of this, we see that to find the general solution of a nonhomogeneous linear ODE it suffices to find one solution, together with all solutions of the associated
homogeneous equation.
109
Homogeneous linear equations with constant coefficients
Proof. The proof is basically the same as that for the corresponding matrix algebra result
(Theorem 3.4). For example if y1 and y2 both satisfy (N) then
d
(y1 − y2 ) = y1′ − y2′
dx
d2
(y1 − y2 ) = y1′′ − y2′′ .
dx2
and
So
p(x)
d2
d
(y1 − y2 ) + q(x) (y1 − y2 ) + r(x)(y1 − y2 )
dx2
dx
= p(x) y1′′ − y2′′ + q(x) y1′ − y2′ + r(x)(y1 − y2 )
= p(x)y1′′ + q(x)y1′ + r(x)y1 − p(x)y2′′ + q(x)y2′ + r(x)y2
= f (x) − f (x) = 0,
hence the difference y1 − y2 solves (H). The other parts can be shown by similarly.
Heuristically speaking, since a second order ODE should in some sense require two integrations to find a solution, two items of information ought to be required to specify a particular
solution. For example:
d2 y
=0 ⇒
dx2
dy
= A ⇒ y = Ax + B,
dx
for constants A and B. To find A and B we could pose an initial value problem:
y(x0 ) = a,
y ′ (x0 ) = b
or a boundary value problem:
y(x1 ) = c,
y(x2 ) = d,
for x1 6= x2 .
For the equation above either case will lead to unique values of A and B, since the functions
y = x and y = 1 are linearly independent — neither is a constant multiple of the other.
6.1
Homogeneous linear equations with constant coefficients
The simplest linear second order ODE is
ay ′′ + by ′ + cy = 0,
(H)
where a, b, c ∈ R are constants, a 6= 0. Since the function y = erx has derivatives y ′ = rerx
and y ′′ = r2 erx , i.e. multiples of the original function, it is a potential candidate for a solution
to (H). Substituting these functions into (H) gives
ar2 erx + brerx + cerx = (ar2 + br + c)erx = 0.
Now erx 6= 0 for all x ∈ R, so the only way this equation can be satisfied is if
ar2 + br + c = 0,
that is, if r is a solution to the auxiliary equation (A), i.e. if
√
−b ± b2 − 4ac
r=
.
2a
Depending on the nature of the solutions r above, we have different types of solution:
110
(A)
SECOND ORDER LINEAR DIFFERENTIAL EQUATIONS
b2 − 4ac > 0
In this case there are two distinct real solutions r1 and r2 to (A). Thus er1 x and er2 x are both
solutions. Since r1 6= r2 these functions are linearly independent, hence the general solution
is
y = A1 er1 x + A2 er2 x
for constants A1 and A2 .
b2 − 4ac = 0
In this case the only solution to (A) is r = −b/2a, but we want two linearly independent
solutions. Another is given by taking y = xerx for this r since then
y ′ = erx + rxerx ,
y ′′ = 2rerx + r2 xerx
and so
ay ′′ + by ′ + cy = (ar2 + br + c)xerx + (2ar + b)erx = 0
because ar2 + br + c = 0 by choice of r, and 2ar + b = 2a × (−b/2a) + b = 0 as well. Hence
the general solution is
y = (A1 + A2 x)erx
for constants A1 and A2 . Note that xerx is a nonconstant multiple of erx , so these are linearly
independent functions.
b2 − 4ac < 0
Since the discriminant of (A) is negative, we will get two distinct complex roots, but since
a, b, c ∈ R we find that the roots are conjugate to each other:
√
4ac − b2
b
r = p ± iq for p = − , and q =
.
2a
2a
Thus the general solution to (H) in this case is
y = A1 epx+iqx + A2 epx−iqx
= A1 epx cos qx + i sin qx + A2 epx cos(−qx) + i sin(−qx)
= epx (A1 + A2 ) cos qx + i(A1 − A2 ) sin qx
= epx B1 cos qx + B2 sin qx
for constants B1 and B2 . Although we have made use of complex exponentials, it is always
possible to choose A1 and A2 so that the numbers B1 and B2 are real, if that is an issue.
Indeed, inverting the equations that define B1 and B2 in terms of A1 and A2 we get
A1 = 12 (B1 − iB2 ),
A2 = 12 (B1 + iB2 ).
Exercise 6.2. Solve the initial value problem y ′′ − 5y ′ + 6y = 0, y(0) = 1, y ′ (0) = 0.
Solution.
111
Homogeneous linear equations with constant coefficients
Exercise 6.3. Solve the boundary value problem y ′′ + 2y ′ + y = 0, y(0) = 1, y(1) = 1.
Solution.
Exercise 6.4. Solve the boundary value problem
Solution.
d2 x
dx
+2 +10x = 0, x(0) = 2, x
dt2
dt
π
6
= −1.
Example 6.5 (S05 7(a i)). Find the general solution to the ordinary differential equation
dy
d2 y
+8
+ 41y = 0.
dx2
dx
112
SECOND ORDER LINEAR DIFFERENTIAL EQUATIONS
Solution. The auxiliary equation is
2
r + 8r + 41 = 0
⇒
r=
−8 ±
√
√
64 − 164
−8 ± −100
=
= −4 ± 5i.
2
2
Hence the general solution is y = e−4x (A cos 5x + B sin 5x), where A and B are constants.
d2 z
dz
Example 6.6. Find the general solution of the ordinary differential equation 16 2 +24 +
dt
dt
9z = 0.
Solution. The auxiliary equation is 16r2 + 24r + 9 = (4r + 3)2 = 0, which has repeated root
− 43 . Thus the general solution is z = (A + Bt)e−3t/4 .
6.2
Nonhomogeneous linear equations with constant coefficients
From Theorem 6.1 we know that to find the general solution to
ay ′′ + by ′ + cy = f (x)
(N)
it is enough to guess one particular solution yP , and then add to this the general solution
yC of the associated homogeneous equation (known as the complementary equation) got by
setting f (x) ≡ 0. What makes an appropriate guess is to some extent found by trial and
error, but there are a number of obvious choices depending on what appears on the right
hand side of (N), as given below:
f (x) =
pxn
p cos qx (or p sin qx)
peqx
n
px cos qx (or pxn sin qx)
pxn eqx
qx
pe cos rx (or peqx sin rx)
Trial solution yP
an xn + · · · + a1 x + a0
k1 cos qx + k2 sin qx
keqx
n
(an x + · · · + a1 x + a0 )(k1 cos qx + k2 sin qx)
(an xn + · · · + a1 x + a0 )eqx
eqx (k1 cos rx + k2 sin rx)
For example if f (x) = x then trying yP = a1 x + a0 we have
yP′ = a1 ,
yP′′ = 0,
and so need
a × 0 + b × a1 + c(a1 x + a0 ) = ca1 x + (ca0 + ba1 ) = x.
Equating coefficients gives the following linear system for a0 and a1 :
ca1 = 1,
ca0 + ba1 = 0
⇒
a1 =
1
,
c
a0 = −
b
c2
provided c 6= 0.
Note that if c = 0 then we cannot solve the system above for a1 and a0 — the linear system
is inconsistent. However, this is not actually a surprise: if c = 0 then the complementary
equation is ay ′′ +by ′ = 0, which has auxiliary equation r(ar+b) = 0, with roots of 0 and −b/a.
As a result, assuming b 6= 0, the solution to the complementary equation is yC = A+Be−bx/a ,
so that the constant term a0 in our trial solution yP is already a solution to the complementary
equation. That is, this part of the trial solution disappears when we calculate ayP′′ + byP′ .
In general, if the usual trial solution yP turns out to be a solution of the complementary
equation then the next step is to try the function xyP as the trial solution instead of yP . So
above we should use
yP = x(a1 x + a0 ) = a1 x2 + a0 x ⇒ yP′ = 2a1 x + a0 ,
113
yP′′ = 2a1 ,
Nonhomogeneous linear equations with constant coefficients
and so we need to solve
a(2a1 ) + b(2a1 x + a0 ) = x ⇒ a1 =
1
,
2b
a0 = −
a
,
b2
where we now have to assume that b 6= 0. If b = 0 as well, then 0 is a repeated root of the
auxiliary equation, and we should try an extra power of x, i.e. yP = x2 (a1 x + a0 ), and then
find that we need to take a1 = 1/6a, a0 = 0 to get ayP′′ = x.
Exercise 6.7 (A04 7(a)). Find the general solution of y ′′ + y ′ − 6y = 7e−2x .
Solution.
Exercise 6.8. Find the general solution of
d2 r
dr
+ 2 + r = sin 2θ.
dθ2
dθ
Solution.
Exercise
6.9 (A04 7(c)). Solve the boundary value problem y ′′ + 4y ′ + 8y = x, y(0) = 1,
π
y 4 = 0.
Solution.
114
SECOND ORDER LINEAR DIFFERENTIAL EQUATIONS
Exercise 6.10 (S03 5(b)). Find a particular solution to
Solution.
115
d2 x
− x = 3et .
dt2
Nonhomogeneous linear equations with constant coefficients
Exercise 6.11. Solve the initial value problem y ′′ − 6y ′ + 9y = 8e3x , y(0) = 1, y ′ (0) = 1.
Solution.
Example 6.12 (S05 7(a ii)). Find the general solution to
d2 y
dy
−4
+ 5y = e−x .
dx2
dx
Solution. The auxiliary equation is
2
r − 4r + 5 = 0
⇒
r=
4±
√
√
16 − 20
4 ± −4
=
= 2 ± i.
2
2
Thus the solution to the complementary equation is yC = e2x (A cos x + B sin x). For a
particular solution to the nonhomogeneous equation try yP = ke−x , then
yP′ = −ke−x, yP′′ = ke−x
⇒
yP′′ − 4yP′ + 5yP = ke−x + 4ke−x + 5ke−x = 10ke−x ,
116
SECOND ORDER LINEAR DIFFERENTIAL EQUATIONS
so we want 10k = 1. Thus the general solution is
y = yP + yC =
1 −x
e + e2x (A cos x + B sin x),
10
where A and B are constants.
Example 6.13 (S05 7(b)). Solve the initial value problem
d2 y
dy
−
= 5 cos 3x,
2
dx
dx
y(0) = 3, y ′ (0) = 1.
Solution. The auxiliary equation is
r2 − r = r(r − 1) = 0
⇒
r = 0, 1.
Thus the solution to the complementary equation is yC = A + Bex , where A and B are
constants. For a particular solution try yP = C cos 3x + D sin 3x, then
yP′ = −3C sin 3x + 3D cos 3x,
yP′′ = −9C cos 3x − 9D sin 3x
and so
yP′′ − yP′ = −9C cos 3x − 9D sin 3x − (−3C sin 3x + 3D cos 3x)
= (−9C − 3D) cos 3x + (3C − 9D) sin 3x.
For yP to be a solution of the nonhomogeneous equation we need
−9C − 3D = 5, and 3C − 9D = 0 ⇒ C = 3D, hence − 27D − 3D = −30D = 5
1
1
⇒
D=− , C=− .
6
2
So the general solution is
y = yC + yP = A + Bex −
1
1
cos 3x − sin 3x
2
6
But now
1
y(0) = 3 = A + B − ,
and
2
3
1
1
y ′ = Bex + sin 3x − cos 3x, so y ′ (0) = 1 = B −
2
2
2
Thus B =
3
and A = 3 − 1 = 2, and so the solution of the initial value problem is
2
3
1
1
y = 2 + ex − cos 3x − sin 3x.
2
2
6
Example 6.14. Find the general solution to
d2 y
dy
−4
− 21y = sin 2x.
dx2
dx
Solution. The auxiliary equation of the complementary equation is r2 − 4r − 21 = 0, i.e.
(r − 7)(r + 3) = 0, which has roots −3, 7. Thus the general solution of the complementary
equation is yC = Ae−3x + Be7x .
For a particular solution to the nonhomogeneous equation try yP = C sin 2x + D cos 2x
⇒ yP′ = 2C cos 2x − 2D sin 2x,
117
yP′′ = −4C sin 2x − 4D cos 2x.
Nonconstant coefficients
So we need
yP′′ − 4yP′ − 21yP = (−4C + 8D − 21C) sin 2x + (−4D − 8C − 21D) cos 2x = sin 2x,
thus we must solve −25C + 8D = 1 and −8C − 25D = 0. From the second equation we get
64
25
8
C; substituting this into the first gives −25C − 25
C = − 689
D = − 25
25 C = 1, hence C = − 689
8
and D = 689 . Thus the general solution is
y = Ae−3x + B 7x −
25
8
sin 2x +
cos 2x
689
689
Example 6.15. Solve the initial value problem
2
d2 y
dy
+ 10
+ 25y = −75,
2
dx
dx
y(0) = 1, y ′ (0) = −4.
Solution. The
complementary equation has auxiliary equation 2m2 + 10m+ 25 = 0,
which has
√
−10± 100−200
5
5
−5x/2
roots
=
−
±
i.
Thus
the
complementary
function
is
y
=
e
A cos 5x
C
2
2
2 +
4
B sin 5x
2 .
For a particular solution try yP = C, a constant. Then yP′ = yP′′ = 0, and so we need
2yP′′ + 10yP′ + 25yP = 25C = −75 ⇒ C = −3.
Thus the general solution is
⇒
5x
5x y = −3 + e−5x/2 A cos
+ B sin
2
2
5 −5x/2 5x
5x 5 −5x/2 5x
5x ′
y =− e
A cos
+ B sin
+ e
−A sin
+ B cos
2
2
2
2
2
2
So y(0) = −3+A = 1 ⇒ A = 4, and y ′ (0) = − 52 ×4+ 52 B = −4 so that B = 52 ×(−4+10) =
12
5 .
12
5x
Hence the solution is y = −3 + e−5x/2 4 cos 5x
2 + 5 sin 2
6.3
Nonconstant coefficients
There are a few circumstances when it is not too difficult to solve the equation
p(x)y ′′ + q(x)y ′ + r(x)y = f (x).
(N)
The first is when r(x) ≡ 0, since if we set u = y ′ , i.e. let u be the first derivative of y, then
u′ = y ′′ and so the equation becomes
p(x)u′ + q(x)u = f (x) ⇒ u′ +
q(x)
f (x)
u=
.
p(x)
p(x)
That is, we can obtain a first order linearR ODE forRthe function u, solve this using standard
techniques, and then recover y since y = y ′ dx = u dx.
Exercise 6.16 (A04 7(d)). Solve x2 y ′′ + 2xy ′ = 0.
Solution.
118
SECOND ORDER LINEAR DIFFERENTIAL EQUATIONS
Exercise 6.17. Solve t
d2 x dx
+
= 1.
dt2
dt
Solution.
dy
Example 6.18. By writing u =
, find the general solution of the second order ordinary
dx
differential equation
d2 y
dy
2 2 + ex = 3 .
dx
dx
Solution. Let u = y ′ , then u′ = y ′′ , so if 2y ′′ + ex = 3y ′ then 2u′ + exR = 3u, and thus
−3
3
u′ − u = −ex . The integrating factor for this first order equation for u is e 2 dx = e−3x/2
2
and so
3
d −3x/2
3
u′ − u = −ex ⇒ e−3x/2 u′ − e−3x/2 u =
(e
u) = −e−3x/2 ex = −e−x/2 .
2
2
dx
119
Nonconstant coefficients
Integrating this last equation we get e−3x/2 u = 2e−x/2 +A, A a constant. So u = 2ex +Ae3x/2 .
dy
But then u = y ′ =
= 2ex + Ae3x/2 , and integrating again gives
dx
y = 2ex + Be3x/2 + C,
where B and C are constants (with B = 23 A).
Note. Above we had constant coefficients, so could have used our earlier methods.
Another straightforward situation is if we have found one solution y1 to the homogeneous
equation
p(x)y ′′ + q(x)y ′ + r(x)y = 0.
(H)
To find the general solution, try y = v(x)y1 , where we want to find v(x). Since
y ′ = v ′ y1 + vy1′ ,
y ′′ = v ′′ y1 + 2v ′ y1′ + vy1′′ ,
substituting these into the equation (H) we get, after some rearrangement,
p v ′′ y1 + 2v ′ y1′ + vy1′′ + q v ′ y1 + vy1′ + rvy1
= v py1′′ + qy1′ + ry1 + py1 v ′′ + 2py1′ + qy1 v ′ = py1 v ′′ + 2py1′ + qy1 v ′ = 0
which is a second order ODE for v, in which the function v does not explicitly appear, only its
derivatives. So we can now set u = v ′ and solve the resulting first order ODE for u, integrate
this to get v, and multiply by y1 to get more solutions of (H).
Exercise 6.19. Verify that y1 = x is a solution of x2 y ′′ − x(x + 2)y ′ + (x + 2)y = 0. Find
the general solution by trying y2 = xv(x).
Solution.
120
SECOND ORDER LINEAR DIFFERENTIAL EQUATIONS
d2 y
3 dy
4
−
+ y = 0, and hence find
Exercise 6.20. Verify that y1 = x2 is a solution of
dx2
x dx x2
the general solution.
Solution.
Finally, suppose we have found two solutions y1 and y2 to the homogeneous equation (H)
and wish to solve (N). We try y = v1 y1 + v2 y2 for functions v1 and v2 . Then
y ′ = v1′ y1 + v2′ y2 + v1 y1′ + v2 y2′ ,
y ′′ = (v1′ y1 + v2′ y2 )′ + v1′ y1′ + v1 y1′′ + v2′ y2′ + v2 y2′′
121
Nonconstant coefficients
Substituting these into (N) yields
py ′′ + qy ′ + ry = v1 py1′′ + qy1′ + ry1 + v2 py2′′ + qy2′ + ry2
+ p(v1′ y1′ + v2′ y2′ ) + p(v1′ y1 + v2′ y2 )′ + q(v1′ y1 + v2′ y2 )
= p(v1′ y1′ + v2′ y2′ ) + p(v1′ y1 + v2′ y2 )′ + q(v1′ y1 + v2′ y2 ) = f (x)
Thus if we can choose v1 and v2 so that
v1′ y1 + v2′ y2 = 0 and p(v1′ y1′ + v2′ y2′ ) = f
then y = v1 y1 + v2 y2 will be a solution of the nonhomogeneous equation (N).
Exercise 6.21. Verify that y1 = x is a solution of x2 y ′′ + xy ′ − y = 0. Find another solution
y2 , and hence find the general solution to
x2 y ′′ + xy ′ − y = x ln x.
Solution.
122
SECOND ORDER LINEAR DIFFERENTIAL EQUATIONS
Exercise 6.22. Given that
tan x.
R
sec x dx = ln | tan x+sec x|, find the general solution of y ′′ +y =
Solution.
123
Exercises
6.4
Exercises
1. Find the general solution of the following differential equations:
(i) y ′′ − y ′ − 6y = 0
(ii) y ′′ − 9y ′ + 20y = 0
(iv) y ′′ + y ′ + y = 0
(iii) y ′′ + 10y ′ + 29y = 0
(v) y ′′ − 10y ′ + 25y = 0
(vi) y ′′ − 4y ′ + y = 0
2. Solve the following initial value problems:
(i) y ′′ + 2y ′ + 4y = 0,
′′
y(0) = 1, y ′ (0) = 0
′
(ii) y + 3y = 0, y(0) = 3, y ′ (0) = 6
(iii) y ′′ − 2y ′ − 5y = 0, y(0) = 0, y ′ (0) = 3
(iv) y ′′ + 4y = 0,
y(0) = −1, y ′ (0) = −8
3. Solve the following boundary value problems:
(i) y ′′ − 16y = 0,
(ii) y ′′ − 2y ′ = 0,
y(0) = 5, y( 14 ) = 5e
y(0) = −1, y( 12 ) = e − 2
(iii) y ′′ − 2y ′ + 2y = 0,
(iv) y ′′ + 4y ′ + 5y = 0,
y(0) = −3, y( π2 ) = 0
−3π
y( π2 ) = 14e−π , y( 3π
2 ) = −14e
4. Find the general solution of the following differential equations:
(ii) y ′′ − 6y ′ + 8y = 3ex
(i) y ′′ − y ′ − 2y = 2x2 + 5
(iii) y ′′ − 4y ′ + 13y = 3e2x − 5e3x
(iv) y ′′ + 2y = 4 cos2 3x
5. Solve the following initial value problems:
(i) y ′′ + 4y ′ = 34 cos x + 8,
(ii) y ′′ + y = 5 sin 2x − 4,
(iii) y ′′ − 3y ′ = 2e2x sin x,
(iv) y ′′ − 6y ′ + 9y = 4e3x ,
y(0) = 3, y ′ (0) = 2
y(0) = 0, y ′ (0) = −3
y(0) = 1, y ′ (0) = 2
y(0) = 1, y ′ (0) = 2
6. Find the general solution of the following differential equations:
(i) xy ′′ = 2 + y ′
(ii) − 3y ′′ − 2y ′ = 8x + 2
124
(iii) y ′′ + x(y ′ )2 = 0
SECOND ORDER LINEAR DIFFERENTIAL EQUATIONS
7. In each of the following, verify that the function y1 is a solution of the given differential
equation. Use the substitution y2 = u(x)y1 to find the general solution.
1 ′
8
y − 2 y = 0, y1 (x) = x4
x
x
2x ′
2
′′
(ii) y +
y −
y = 0, y1 (x) = x
2
1−x
1 − x2
2
1
2
(iii) y ′′ + 1 −
y′ −
− 2 y = 0, y1 (x) = x
x
x x
(i) y ′′ −
8. In each of the following show that the given functions y1 and y2 solve the associated
homogeneous problem, and hence find the general solution of the nonhomogeneous equation.
(i) x2 y ′′ − 2y = 3x2 − 1, y1 (x) = x2 , y2 (x) = x−1 .
(ii) xy ′′ − (1 + x)y ′ + y = x2 e2x , y1 (x) = 1 + x, y2 (x) = ex .
(iii) x2 y ′′ − 3xy ′ + 4y = x2 ln x, y1 (x) = x2 , y2 (x) = x2 ln x.
125