Part 1. Diﬀerential Equations and Laplace Transforms 1
Chapter 1. FirstOrder Ordinary Diﬀerential Equations 3
1.1. Fundamental Concepts 3
1.2. Separable Equations 5
1.3. Equations with Homogeneous Coeﬃcients 7
1.4. Exact Equations 9
1.5. Integrating Factors 15
1.6. FirstOrder Linear Equations 20
1.7. Orthogonal Families of Curves 22
1.8. Direction Fields and Approximate Solutions 24
1.9. Existence and Uniqueness of Solutions 25
Chapter 2. SecondOrder Ordinary Diﬀerential Equations 31
2.1. Linear Homogeneous Equations 31
2.2. Linear Homogeneous Equations 31
2.3. Basis of the Solution Space 32
2.4. Independent Solutions 34
2.5. Modeling in Mechanics 36
2.6. Euler–Cauchy’s Equation 40
Chapter 3. Linear Diﬀerential Equations of Arbitrary Order 45
3.1. Homogeneous Equations 45
3.2. Linear Homogeneous Equations 51
3.3. Linear Nonhomogeneous Equations 55
3.4. Method of Undetermined Coeﬃcients 57
3.5. Particular Solution by Variation of Parameters 60
3.6. Forced Oscillations 67
Chapter 4. Systems of Diﬀerential Equations 71
4.1. Introduction 71
4.2. Existence and Uniqueness Theorem 73
4.3. Fundamental Systems 73
4.4. Homogeneous Linear Systems with Constant Coeﬃcients 76
4.5. Nonhomogeneous Linear Systems 83
Chapter 5. Analytic Solutions 87
5.1. The Method 87
5.2. Foundation of the Power Series Method 88
5.3. Legendre Equation and Legendre Polynomials 95
5.4. Orthogonality Relations for P
n
(x) 98
i
ii CONTENTS
5.5. Fourier–Legendre Series 101
5.6. Derivation of Gaussian Quadratures 103
Chapter 6. Laplace Transform 109
6.1. Deﬁnition 109
6.2. Transforms of Derivatives and Integrals 113
6.3. Shifts in s and in t 117
6.4. Dirac Delta Function 125
6.5. Derivatives and Integrals of Transformed Functions 127
6.6. Laguerre Diﬀerential Equation 131
6.7. Convolution 133
6.8. Partial Fractions 135
6.9. Transform of Periodic Functions 136
Chapter 7. Formulas and Tables 139
7.1. Integrating Factor of M(x, y) dx +N(x, y) dy = 0 139
7.2. Legendre Polynomials P
n
(x) on [−1, 1] 139
7.3. Laguerre Polynomials on 0 ≤ x < ∞ 140
7.4. Fourier–Legendre Series Expansion 141
7.5. Table of Integrals 141
7.6. Table of Laplace Transforms 141
Part 2. Numerical Methods 145
Chapter 8. Solutions of Nonlinear Equations 147
8.1. Computer Arithmetics 147
8.2. Review of Calculus 150
8.3. The Bisection Method 150
8.4. Fixed Point Iteration 154
8.5. Newton’s, Secant, and False Position Methods 159
8.6. Aitken–Steﬀensen Accelerated Convergence 166
8.7. Horner’s Method and the Synthetic Division 168
8.8. M¨ uller’s Method 171
Chapter 9. Interpolation and Extrapolation 173
9.1. Lagrange Interpolating Polynomial 173
9.2. Newton’s Divided Diﬀerence Interpolating Polynomial 175
9.3. Gregory–Newton ForwardDiﬀerence Polynomial 178
9.4. Gregory–Newton BackwardDiﬀerence Polynomial 181
9.5. Hermite Interpolating Polynomial 182
9.6. Cubic Spline Interpolation 183
Chapter 10. Numerical Diﬀerentiation and Integration 187
10.1. Numerical Diﬀerentiation 187
10.2. The Eﬀect of Roundoﬀ and Truncation Errors 189
10.3. Richardson’s Extrapolation 191
10.4. Basic Numerical Integration Rules 193
10.5. The Composite Midpoint Rule 195
10.6. The Composite Trapezoidal Rule 197
10.7. The Composite Simpson’s Rule 199
CONTENTS iii
10.8. Romberg Integration for the Trapezoidal Rule 201
10.9. Adaptive Quadrature Methods 203
10.10. Gaussian Quadratures 204
Chapter 11. Matrix Computations 207
11.1. LU Solution of Ax = b 207
11.2. Cholesky Decomposition 215
11.3. Matrix Norms 219
11.4. Iterative Methods 221
11.5. Overdetermined Systems 223
11.6. Matrix Eigenvalues and Eigenvectors 226
11.7. The QR Decomposition 230
11.8. The QR algorithm 231
11.9. The Singular Value Decomposition 232
Chapter 12. Numerical Solution of Diﬀerential Equations 235
12.1. Initial Value Problems 235
12.2. Euler’s and Improved Euler’s Method 236
12.3. LowOrder Explicit Runge–Kutta Methods 239
12.4. Convergence of Numerical Methods 247
12.5. Absolutely Stable Numerical Methods 248
12.6. Stability of Runge–Kutta methods 249
12.7. Embedded Pairs of Runge–Kutta methods 252
12.8. Multistep PredictorCorrector Methods 257
12.9. Stiﬀ Systems of Diﬀerential Equations 270
Chapter 13. The Matlab ODE Suite 279
13.1. Introduction 279
13.2. The Methods in the Matlab ODE Suite 279
13.3. The odeset Options 282
13.4. Nonstiﬀ Problems of the Matlab odedemo 284
13.5. Stiﬀ Problems of the Matlab odedemo 284
13.6. Concluding Remarks 288
Bibliography 289
Part 3. Exercises and Solutions 291
Exercises for Diﬀerential Equations and Laplace Transforms 293
Exercises for Chapter 1 293
Exercises for Chapter 2 295
Exercises for Chapter 3 296
Exercises for Chapter 4 298
Exercises for Chapter 5 299
Exercises for Chapter 6 301
Exercises for Numerical Methods 305
Exercises for Chapter 8 305
Exercises for Chapter 9 307
Exercises for Chapter 10 308
iv CONTENTS
Exercises for Chapter 11 310
Exercises for Chapter 12 312
Solutions to Exercises for Numerical Methods 315
Solutions to Exercises for Chapter 8 315
Solutions to Exercises for Chapter 9 317
Solutions to Exercises for Chapter 11 318
Solutions to Exercises for Chapter 12 322
Index 329
Part 1
Diﬀerential Equations and Laplace
Transforms
CHAPTER 1
FirstOrder Ordinary Diﬀerential Equations
1.1. Fundamental Concepts
(a) A diﬀerential equation contains one or several derivatives and an equal
sign “=”.
Here are three ordinary diﬀerential equations, where
′
:=
d
dx
:
(1) y
′
= cos x,
(2) y
′′
+ 4y = 0,
(3) x
2
y
′′′
y
′
+ 2 e
x
y
′′
= (x
2
+ 2)y
2
.
Here is a partial diﬀerential equation:
∂
2
u
∂x
2
+
∂
2
u
∂y
2
= 0.
(b) The order of a diﬀerential equation is equal to the highestorder derivative.
The above equations (1), (2) and (3) are of order 1, 2 and 3, respectively.
(c) An explicit solution of a diﬀerential equation with independent variable
x on ]a, b[ is a function y = g(x) of x such that the diﬀerential equation becomes
an identity in x on ]a, b[ when g(x), g
′
(x), etc. are substituted for y, y
′
, etc. in
the diﬀerential equation. The solution y = g(x) describes a curve, or trajectory,
in the xyplane.
We see that the function
y(x) = e
2x
is an explicit solution of the diﬀerential equation
dy
dx
= 2y.
In fact, we have
L.H.S. := y
′
(x) = 2 e
2x
,
R.H.S. := 2y(x) = 2 e
2x
.
Hence
L.H.S. = R.H.S., for all x.
We thus have an identity in x on ] −∞, ∞[.
(d) An implicit solution is a curve which is deﬁned by an equation of the form
G(x, y) = c.
3
4 1. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS
y y
x x
0
0
(a) (b)
1
–2
c = 1
c = –2
c = 1
c = –2
c = 1
c = 0
1
–2
c = – 1
–1
Figure 1.1. (a) Two oneparameter families of curves: (a)
y =sinx +c; (b) y = c exp(x).
We remark that an implicit solution always contains an equal sign, “=”,
followed by a constant. Thus it describes a curve in the xyplane.
We see that the curve in the xyplane,
x
2
+y
2
−1 = 0, y > 0,
is an implicit solution of the diﬀerential equation
yy
′
= −x, on −1 < x < 1.
In fact, letting y be a function of x and diﬀerentiating the equation of the curve
with respect to x,
d
dx
(x
2
+y
2
−1) =
d
dx
0 = 0,
we obtain
2x + 2yy
′
= 0 or yy
′
= −x.
(e) The general solution of a diﬀerential equation of order n contains n arbi
trary constants.
The oneparameter family of functions
y(x) = sin x +c
is the general solution of the ﬁrstorder diﬀerential equation
y
′
(x) = cos x.
Putting c = 1, we have the unique solution,
y(x) = sinx + 1,
which goes through the point (0, 1) of R
2
. Given an arbitrary point (x
0
, y
0
) of
the plane, there is one and only one curve of the family which goes through that
point. (See Fig. 1.1(a)).
Similarly, we see that the oneparameter family of functions
y(x) = c e
x
is the general solution of the diﬀerential equation
y
′
= y.
1.2. SEPARABLE EQUATIONS 5
Setting c = −1, we have the unique solution,
y(x) = −e
x
,
which goes through the point (0, −1) of R
2
. Given an arbitrary point (x
0
, y
0
) of
the plane, there is one and only one curve of the family which goes through that
point. (See Fig. 1.1(b)).
1.2. Separable Equations
Consider a separable diﬀerential equation of the form
g(y)
dy
dx
= f(x). (1.1)
We rewrite the equation using the diﬀerentials dy and dx and separate it by
grouping on the lefthand side all terms containing y and on the righthand side
all terms containing x:
g(y) dy = f(x) dx. (1.2)
The solution of a separated equation is obtained by taking the indeﬁnite integral
(primitive or antiderivative) of both sides and adding an arbitrary constant:
_
g(y) dy =
_
f(x) dx +c, (1.3)
that is
G(y) = F(x) +c, or K(x, y) = −F(x) +G(y) = c.
These two forms of the implicit solution deﬁne y as a function of x or x as a
function of y.
Letting y = y(x) be a function of x, we verify that (1.3) is a solution of (1.1):
d
dx
(LHS) =
d
dx
G(y(x)) = G
′
(y(x)) y
′
(x) = g(y)y
′
,
d
dx
(RHS) =
d
dx
[F(x) +c] = F
′
(x) = f(x).
Example 1.1. Solve y
′
= 1 +y
2
.
Solution. Since the diﬀerential equation is separable, we have
_
dy
1 +y
2
=
_
dx +c =⇒ arctany = x +c.
Thus
y(x) = tan(x +c)
is a general solution, since it contains an arbitrary constant.
Example 1.2. Solve the initial value problem y
′
= −2xy, with y(0) = y
0
.
Solution. Since the diﬀerential equation is separable, the general solution
is
_
dy
y
= −
_
2xdx +c
1
=⇒ ln [y[ = −x
2
+c
1
.
Taking the exponential of the solution, we have
y(x) = e
−x
2
+c1
= e
c1
e
−x
2
which we rewrite in the form
y(x) = c e
−x
2
.
6 1. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS
y
x
0
1
–2
c = 1
c = –2
–1
Figure 1.2. Three bell functions.
We remark that the additive constant c
1
has become a multiplicative constant
after exponentiation. Figure 1.2 shows three bell functions which are members of
the oneparameter family of the general solution.
Finally, the solution which satisﬁes the initial condition, is
y(x) = y
0
e
−x
2
.
This solution is unique.
Example 1.3. According to Newton’s law of cooling, the rate of change of
the temperature T(t) of a body in a surrounding medium of temperature T
0
is
proportional to the temperature diﬀerence T(t) −T
0
,
dT
dt
= −k(T −T
0
).
Let a copper ball be immersed in a large basin containing a liquid whose constant
temperature is 30 degrees. The initial temperature of the ball is 100 degrees. If,
after 3 min, the ball’s temperature is 70 degrees, when will it be 31 degrees?
Solution. Since the diﬀerential equation is separable:
dT
dt
= −k(T −30) =⇒
dT
T −30
= −k dt,
then
ln [T −30[ = −kt +c
1
(additive constant)
T −30 = e
c1−kt
= c e
−kt
(multiplicative constant)
T(t) = 30 +c e
−kt
.
At t = 0,
100 = 30 +c =⇒ c = 70.
At t = 3,
70 = 30 + 70 e
−3k
=⇒ e
−3k
=
4
7
.
When T(t) = 31,
31 = 70
_
e
−3k
_
t/3
+ 30 =⇒
_
e
−3k
_
t/3
=
1
70
.
Taking the logarithm of both sides, we have
t
3
ln
_
4
7
_
= ln
_
1
70
_
.
1.3. EQUATIONS WITH HOMOGENEOUS COEFFICIENTS 7
Hence
t = 3
ln(1/70)
ln(4/7)
= 3
−4.25
−0.56
= 22.78 min
1.3. Equations with Homogeneous Coeﬃcients
Definition 1.1. A function M(x, y) is said to be homogeneous of degree s
simultaneously in x and y if
M(λx, λy) = λ
s
M(x, y), for all x, y, λ. (1.4)
Diﬀerential equations with homogeneous coeﬃcients of the same degree are
separable as follows.
Theorem 1.1. Consider a diﬀerential equation with homogeneous coeﬃcients
of degree s,
M(x, y)dx +N(x, y)dy = 0. (1.5)
Then either substitution y = xu(x) or x = yu(y) makes (1.5) separable.
Proof. Letting
y = xu, dy = xdu +u dx,
and substituting in (1.5), we have
M(x, xu) dx +N(x, xu)[xdu +u dx] = 0,
x
s
M(1, u) dx +x
s
N(1, u)[xdu +u dx] = 0,
[M(1, u) +uN(1, u)] dx +xN(1, u) du = 0.
This equation separates,
N(1, u)
M(1, u) +uN(1, u)
du = −
dx
x
.
Its general solution is
_
N(1, u)
M(1, u) +uN(1, u)
du = −ln [x[ +c.
Example 1.4. Solve 2xyy
′
−y
2
+x
2
= 0.
Solution. We rewrite the equation in diﬀerential form:
(x
2
−y
2
) dx + 2xy dy = 0.
Since the coeﬃcients are homogeneous functions of degree 2 in x and y, let
x = yu, dx = y du +u dy.
Substituting these expressions in the last equation we obtain
(y
2
u
2
−y
2
)[y du +u dy] + 2y
2
u dy = 0,
(u
2
−1)[y du +u dy] + 2u dy = 0,
(u
2
−1)y du + [(u
2
−1)u + 2u] dy = 0,
u
2
−1
u(u
2
+ 1)
du = −
dy
y
.
Since integrating the lefthand side of this equation seems diﬃcult, let us restart
with the substitution
y = xu, dy = xdu +u dx.
8 1. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS
x
y
r
1
r
2
r
3
Figure 1.3. Oneparameter family of circles with centre (r, 0).
Then,
(x
2
−x
2
u
2
) dx + 2x
2
u[xdu +u dx] = 0,
[(1 −u
2
) + 2u
2
] dx + 2uxdu = 0,
_
2u
1 +u
2
du = −
_
dx
x
+c
1
.
Integrating this last equation is easy:
ln(u
2
+ 1) = −ln[x[ +c
1
,
ln [x(u
2
+ 1)[ = c
1
,
x
_
_
y
x
_
2
+ 1
_
= e
c1
= c.
The general solution is
y
2
+x
2
= cx.
Putting c = 2r in this formula and adding r
2
to both sides, we have
(x −r)
2
+y
2
= r
2
.
The general solution describes a oneparameter family of circles with centre (r, 0)
and radius [r[ (see Fig. 1.3).
Example 1.5. Solve the diﬀerential equation
y
′
= g
_
y
x
_
.
Solution. Rewriting this equation in diﬀerential form,
g
_
y
x
_
dx −dy = 0,
we see that this is an equation with homogeneous coeﬃcients of degree zero in x
and y. With the substitution
y = xu, dy = xdu +u dx,
1.4. EXACT EQUATIONS 9
the last equation separates:
g(u) dx −xdu −u dx = 0,
xdu = [g(u) −u] dx,
du
g(u) −u
=
dx
x
.
It can therefore be integrated directly,
_
du
g(u) −u
=
_
dx
x
+c.
Finally one substitute u = y/x in the solution after the integration.
1.4. Exact Equations
Definition 1.2. The ﬁrstorder diﬀerential equation
M(x, y) dx +N(x, y) dy = 0 (1.6)
is exact if its lefthand side is the total, or exact, diﬀerential
du =
∂u
∂x
dx +
∂u
∂y
dy (1.7)
of some function u(x, y).
If equation (1.6) is exact, then
du = 0
and by integration we see that its general solution is
u(x, y) = c. (1.8)
Comparing the expressions (1.6) and (1.7), we see that
∂u
∂x
= M,
∂u
∂y
= N. (1.9)
The following important theorem gives a necessary and suﬃcient condition
for equation (1.6) to be exact.
Theorem 1.2. Let M(x, y) and N(x, y) be continuous functions with contin
uous ﬁrstorder partial derivatives on a connected and simply connected (that is,
of one single piece and without holes) set Ω ∈ R
2
. Then the diﬀerential equation
M(x, y) dx +N(x, y) dy = 0 (1.10)
is exact if and only if
∂M
∂y
=
∂N
∂x
, for all (x, y) ∈ Ω. (1.11)
Proof. Necessity: Suppose (1.10) is exact. Then
∂u
∂x
= M,
∂u
∂y
= N.
Therefore,
∂M
∂y
=
∂
2
u
∂y∂x
=
∂
2
u
∂x∂y
=
∂N
∂x
,
10 1. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS
where exchanging the order of diﬀerentiation with respect to x and y is allowed
by the continuity of the ﬁrst and last terms.
Suﬃciency: Suppose that (1.11) holds. We construct a function F(x, y)
such that
dF(x, y) = M(x, y) dx +N(x, y) dy.
Let the function ϕ(x, y) ∈ C
2
(Ω) be such that
∂ϕ
∂x
= M.
For example, we may take
ϕ(x, y) =
_
M(x, y) dx, y ﬁxed.
Then,
∂
2
ϕ
∂y∂x
=
∂M
∂y
=
∂N
∂x
, by (1.11).
Since
∂
2
ϕ
∂y∂x
=
∂
2
ϕ
∂x∂y
by the continuity of both sides, we have
∂
2
ϕ
∂x∂y
=
∂N
∂x
.
Integrating with respect to x, we obtain
∂ϕ
∂y
=
_
∂
2
ϕ
∂x∂y
dx =
_
∂N
∂x
dx, y ﬁxed,
= N(x, y) +B
′
(y).
Taking
F(x, y) = ϕ(x, y) −B(y),
we have
dF =
∂ϕ
∂x
dx +
∂ϕ
∂y
dy −B
′
(y) dy
= M dx +N dy +B
′
(y) dy −B
′
(y) dy
= M dx +N dy.
A practical method for solving exact diﬀerential equations will be illus
trated by means of examples.
Example 1.6. Find the general solution of
3x(xy −2) dx + (x
3
+ 2y) dy = 0,
and the solution that satisﬁes the initial condition y(1) = −1. Plot that solution
for 1 ≤ x ≤ 4.
1.4. EXACT EQUATIONS 11
Solution. (a) Analytic solution by the practical method.—We verify
that the equation is exact:
M = 3x
2
y −6x, N = x
3
+ 2y,
∂M
∂y
= 3x
2
,
∂N
∂x
= 3x
2
,
∂M
∂y
=
∂N
∂x
.
Indeed, it is exact and hence can be integrated. From
∂u
∂x
= M,
we have
u(x, y) =
_
M(x, y) dx +T(y), y ﬁxed,
=
_
(3x
2
y −6x) dx +T(y)
= x
3
y −3x
2
+T(y),
and from
∂u
∂y
= N,
we have
∂u
∂y
=
∂
∂y
_
x
3
y −3x
2
+T(y)
_
= x
3
+T
′
(y) = N
= x
3
+ 2y.
Thus
T
′
(y) = 2y.
It is essential that T
′
(y) be a function of y only; otherwise there is
an error somewhere: either the equation is not exact or there is a
computational mistake.
We integrate T
′
(y):
T(y) = y
2
.
An integration constant is not needed at this stage since such a constant will
appear in u = c. Hence, we have the surface
u(x, y) = x
3
y −3x
2
+y
2
.
Since du = 0, then u(x, y) = c, and the (implicit) general solution, containing an
arbitrary constant and an equal sign “=” (that is, a curve), is
x
3
y −3x
2
+y
2
= c.
Using the initial condition y(1) = −1 to determine the value of the constant c,
we put x = 1 and y = −1 in the general solution and get
c = −3.
Hence the implicit solution which satisﬁes the initial condition is
x
3
y −3x
2
+y
2
= −3.
12 1. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS
1 2 3 4
−70
−60
−50
−40
−30
−20
−10
0
Plot of solution to initial value problem for Example 1.6
x
y
(
x
)
Figure 1.4. Graph of solution to Example 1.6.
(b) Solution by symbolic Matlab.— The general solution is:
>> y = dsolve(’(x^3+2*y)*Dy=3*x*(x*y2)’,’x’)
y =
[ 1/2*x^3+1/2*(x^6+12*x^2+4*C1)^(1/2)]
[ 1/2*x^31/2*(x^6+12*x^2+4*C1)^(1/2)]
The solution to the initial value problem is the lower branch with C1 = −3, as is
seen by inserting the initial condition ’y(1)=1’, in the preceding command:
>> y = dsolve(’(x^3+2*y)*Dy=3*x*(x*y2)’,’y(1)=1’,’x’)
y = 1/2*x^31/2*(x^6+12*x^212)^(1/2)
(c) Solution to I.V.P. by numeric Matlab.— We use the initial condition
y(1) = −1. The Mﬁle exp1_6.m is
function yprime = exp1_6(x,y); %MAT 2331, Exp 1.6, p. 23.
yprime = 3*x*(x*y2)/(x^3+2*y);
The call to the ode23 solver and the plot command are:
>> xspan = [1 4]; % solution for x=1 to x=4
>> y0 = 1; % initial condition
>> [x,y] = ode23(’exp1_6’,xspan,y0);%Matlab 5 format using xspan
>> subplot(2,2,1); plot(x,y);
>> title(’Plot of solution to initial value problem for Example 1.6’);
>> xlabel(’x’); ylabel(’y(x)’);
>> print Fig.exp1.6
Example 1.7. Find the general solution of
(2x
3
−xy
2
−2y + 3) dx −(x
2
y + 2x) dy = 0
and the solution that satisﬁes the initial condition y(1) = −1. Plot that solution
for 1 ≤ x ≤ 4.
1.4. EXACT EQUATIONS 13
Solution. (a) Analytic solution by the practical method.— First,
note the negative sign in N(x, y) = −(x
2
y + 2x) since the lefthand side of the
diﬀerential equation in standard form is M dx+N dy. We verify that the equation
is exact:
∂M
∂y
= −2xy − 2,
∂N
∂x
= −2xy −2,
∂M
∂y
=
∂N
∂x
.
Hence the equation is exact and can be integrated. From
∂u
∂y
= N,
we have
u(x, y) =
_
N(x, y) dy +T(x), x ﬁxed,
=
_
(−x
2
y −2x) dy +T(x)
= −
x
2
y
2
2
−2xy +T(x),
and from
∂u
∂x
= M,
we have
∂u
∂x
= −xy
2
−2y +T
′
(x) = M
= 2x
3
−xy
2
−2y + 3.
Thus
T
′
(x) = 2x
3
+ 3.
It is essential that T
′
(x) be a function of x only; otherwise there is
an error somewhere: either the equation is not exact or there is a
computational mistake.
We integrate T
′
(x):
T(x) =
x
4
2
+ 3x.
An integration constant is not needed at this stage since such a constant will
appear in u = c. Hence, we have the surface
u(x, y) = −
x
2
y
2
2
−2xy +
x
4
2
+ 3x.
Since du = 0, then u(x, y) = c, and the (implicit) general solution, containing an
arbitrary constant and an equal sign “=” (that is, a curve), is
x
4
−x
2
y
2
−4xy + 6x = c.
Putting x = 1 and y = −1, we have
c = 10.
Hence the implicit solution which satisﬁes the initial condition is
x
4
−x
2
y
2
−4xy + 6x = 10.
14 1. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS
1 2 3 4
1
0
1
2
3
4
Plot of solution to initial value problem for Example 1.7
x
y
(
x
)
Figure 1.5. Graph of solution to Example 1.7.
(b) Solution by symbolic Matlab.— The general solution is:
>> y = dsolve(’(x^2*y+2*x)*Dy=(2*x^3x*y^22*y+3)’,’x’)
y =
[ (2(4+6*x+x^4+2*C1)^(1/2))/x]
[ (2+(4+6*x+x^4+2*C1)^(1/2))/x]
The solution to the initial value problem is the lower branch with C1 = −5,
>> y = dsolve(’(x^2*y+2*x)*Dy=(2*x^3x*y^22*y+3)’,’y(1)=1’,’x’)
y =(2+(6+6*x+x^4)^(1/2))/x
(c) Solution to I.V.P. by numeric Matlab.— We use the initial condition
y(1) = −1. The Mﬁle exp1_7.m is
function yprime = exp1_7(x,y); %MAT 2331, Exp 1.7, p. 23.
yprime = (2*x^3x*y^22*y+3)/(x^2*y+2*x);
The call to the ode23 solver and theplot command:
>> xspan = [1 4]; % solution for x=1 to x=4
>> y0 = 1; % initial condition
>> [x,y] = ode23(’exp1_7’,xspan,y0);
>> subplot(2,2,1); plot(x,y);
>> print Fig.exp1.7
The following example shows that the practical method of solution breaks
down if the equation is not exact.
Example 1.8. Solve
xdy −y dx = 0.
Solution. We rewrite the equation in standard form:
y dx −xdy = 0.
1.5. INTEGRATING FACTORS 15
The equation is not exact since
M
y
= 1 ,= −1 = N
x
.
Anyway, let us try to solve the inexact equation by the proposed method:
u =
_
u
x
dx =
_
M dx =
_
y dx = yx +T(y),
u
y
= x +T
′
(y) = N = −x.
Thus,
T
′
(y) = −2x.
But this is impossible since T(y) must be a function of y only.
Example 1.9. Consider the diﬀerential equation
(ax +by) dx + (kx +ly) dy = 0.
Choose a, b, k, l so that the equation is exact.
Solution.
M
y
= b, N
x
= k =⇒ k = b.
u =
_
u
x
dx =
_
M dx =
_
(ax +by) dx =
ax
2
2
+bxy +T(y),
u
y
= bx +T
′
(y) = N = bx +ly =⇒ T
′
(y) = ly =⇒ T(y) =
ly
2
2
.
Thus,
u(x, y) =
ax
2
2
+bxy +
ly
2
2
, a, b, l arbitrary.
The general solution is
ax
2
2
+bxy +
ly
2
2
= c
1
or ax
2
+ 2bxy +ly
2
= c.
The following convenient notation for partial derivatives will often be used:
u
x
:=
∂u
∂x
, u
y
:=
∂u
∂y
.
1.5. Integrating Factors
If the diﬀerential equation
M(x, y) dx +N(x, y) dy = 0 (1.12)
is not exact, it can be made exact by multiplication by an integrating factor
µ(x, y),
µ(x, y)M(x, y) dx +µ(x, y)N(x, y) dy = 0. (1.13)
Rewriting this equation in the form
M(x, y) dx +
¯
N(x, y) dy = 0,
we have
M
y
= µ
y
M +µM
y
,
¯
N
x
= µ
x
N +µN
x
.
and equation (1.13) will be exact if
µ
y
M +µM
y
= µ
x
N +µN
x
. (1.14)
In general, it is diﬃcult to solve the partial diﬀerential equation (1.14).
16 1. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS
We consider two particular cases, where µ is a function of one variable, that
is, µ = µ(x) or µ = µ(y).
Case 1. If µ = µ(x) is a function of x only, then µ
x
= µ
′
(x) and µ
y
= 0.
Thus, (1.14) reduces to an ordinary diﬀerential equation:
Nµ
′
(x) = µ(M
y
−N
x
). (1.15)
If the lefthand side of the following expression
M
y
−N
x
N
= f(x) (1.16)
is a function of x only, then (1.15) is separable:
dµ
µ
=
M
y
−N
x
N
dx = f(x) dx.
Integrating this separated equation, we obtain the integration factor
µ(x) = e
R
f(x) dx
. (1.17)
Case 2. Similarly, if µ = µ(y) is a function of y only, then µ
x
= 0 and
µ
y
= µ
′
(y). Thus, (1.14) reduces to an ordinary diﬀerential equation:
Mµ
′
(y) = −µ(M
y
− N
x
). (1.18)
If the lefthand side of the following expression
M
y
−N
x
M
= g(y) (1.19)
is a function of y only, then (1.18) is separable:
dµ
µ
= −
M
y
−N
x
M
dy = −g(y) dy.
Integrating this separated equation, we obtain the integration factor
µ(y) = e
−
R
g(y) dy
. (1.20)
One has to notice the presence of the negative sign in (1.20) and its absence in
(1.17).
Example 1.10. Find the general solution of the diﬀerential equation
(4xy + 3y
2
−x) dx +x(x + 2y) dy = 0.
Solution. (a) The analytic solution.— This equation is not exact since
M
y
= 4x + 6y, N
x
= 2x + 2y
and
M
y
,= N
x
.
However, since
M
y
−N
x
N
=
2x + 4y
x(x + 2y)
=
2(x + 2y)
x(x + 2y)
=
2
x
= f(x)
is a function of x only, we have the integrating factor
µ(x) = e
R
(2/x) dx
= e
2 lnx
= e
lnx
2
= x
2
.
Multiplying the diﬀerential equation by x
2
produces the exact equation
x
2
(4xy + 3y
2
−x) dx +x
3
(x + 2y) dy = 0.
1.5. INTEGRATING FACTORS 17
This equation is solved by the practical method:
u(x, y) =
_
(x
4
+ 2x
3
y) dy +T(x)
= x
4
y +x
3
y
2
+T(x),
u
x
= 4x
3
y + 3x
2
y
2
+T
′
(x) = µM
= 4x
3
y + 3x
2
y
2
−x
3
.
Thus,
T
′
(x) = −x
3
=⇒ T(x) = −
x
4
4
.
No constant of integration is needed here; it will come later. Hence,
u(x, y) = x
4
y +x
3
y
2
−
x
4
4
and the general solution is
x
4
y +x
3
y
2
−
x
4
4
= c
1
or 4x
4
y + 4x
3
y
2
−x
4
= c.
(b) The Matlab symbolic solution.— Matlab does not ﬁnd the general solu
tion of the nonexact equation:
>> y = dsolve(’x*(x+2*y)*Dy=(4*x+3*y^2x)’,’x’)
Warning: Explicit solution could not be found.
> In HD2:Matlab5.1:Toolbox:symbolic:dsolve.m at line 200
y = [ empty sym ]
but it solves the exact equation
>> y = dsolve(’x^2*(x^3+2*y)*Dy=3*x^3*(x*y2)’,’x’)
y =
[ 1/2*x^31/2*(x^6+12*x^2+4*C1)^(1/2)]
[ 1/2*x^3+1/2*(x^6+12*x^2+4*C1)^(1/2)]
Example 1.11. Find the general solution of the diﬀerential equation
y(x +y + 1) dx +x(x + 3y + 2) dy = 0.
Solution. (a) The analytic solution.— This equation is not exact since
M
y
= x + 2y + 1 ,= N
x
= 2x + 3y + 2.
Since
M
y
−N
x
N
=
−x −y −1
x(x + 3y + 2)
is not a function of x only, we try
M
y
−N
x
M
=
−(x +y + 1)
y(x +y + 1)
= −
1
y
= g(y),
which is a function of y only. The integrating factor is
µ(y) = e
−
R
g(y) dy
= e
R
(1/y) dy
= e
lny
= y.
Multiplying the diﬀerential equation by y produces the exact equation
(xy
2
+y
3
+y
2
) dx + (x
2
y + 3xy
2
+ 2xy) dy = 0.
18 1. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS
This equation is solved by the practical method:
u(x, y) =
_
(xy
2
+y
3
+y
2
) dx +T(y)
=
x
2
y
2
2
+xy
3
+xy
2
+T(y),
u
y
= x
2
y + 3xy
2
+ 2xy +T
′
(y) = µN
= x
2
y + 3xy
2
+ 2xy.
Thus,
T
′
(y) = 0 =⇒ T(y) = 0
since no constant of integration is needed here. Hence,
u(x, y) =
x
2
y
2
2
+xy
3
+xy
2
and the general solution is
x
2
y
2
2
+ xy
3
+xy
2
= c
1
or x
2
y
2
+ 2xy
3
+ 2xy
2
= c.
(b) The Matlab symbolic solution.—The symbolic Matlab command dsolve
produces a very intricate general solution for both the nonexact and the exact
equations. This solution does not simplify with the commands simplify and
simple.
We therefore repeat the practical method having symbolic Matlab do the
simple algebraic and calculus manipulations.
>> clear
>> syms M N x y u
>> M = y*(x+y+1); N = x*(x+3*y+2);
>> test = diff(M,’y’)  diff(N,’x’) % test for exactness
test = xy1 % equation is not exact
>> syms mu g
>> g = (diff(M,’y’)  diff(N,’x’))/M
g = (xy1)/y/(x+y+1)
>> g = simple(g)
g = 1/y % a function of y only
>> mu = exp(int(g,’y’)) % integrating factor
mu = y
>> syms MM NN
>> MM = mu*M; NN = mu*N; % multiply equation by integrating factor
>> u = int(MM,’x’) % solution u; arbitrary T(y) not included yet
u = y^2*(1/2*x^2+y*x+x)
>> syms DT
>> DT = simple(diff(u,’y’)  NN)
DT = 0 % T’(y) = 0 implies T(y) = 0.
>> u = u
u = y^2*(1/2*x^2+y*x+x) % general solution u = c.
The general solution is
x
2
y
2
2
+xy
3
+xy
2
= c
1
or x
2
y
2
+ 2xy
3
+ 2xy
2
= c.
1.5. INTEGRATING FACTORS 19
Remark 1.1. Note that a separated equation,
f(x) dx +g(y) dy = 0,
is exact. In fact, since M
y
= 0 and N
x
= 0, we have the integrating factors
µ(x) = e
R
0 dx
= 1, µ(y) = e
−
R
0 dy
= 1.
Solving this equation by the practical method for exact equations, we have
u(x, y) =
_
f(x) dx +T(y),
u
y
= T
′
(y) = g(y) =⇒ T(y) =
_
g(y) dy,
u(x, y) =
_
f(x) dx +
_
g(y) dy = c.
This is the solution that was obtained by the method (1.3).
Remark 1.2. The factor which transforms a separable equation into a sepa
rated equation is an integrating factor since the latter equation is exact.
Example 1.12. Consider the separable equation
y
′
= 1 +y
2
, that is,
_
1 +y
2
_
dx −dy = 0.
Show that the factor
_
1 +y
2
_
−1
which separates the equation is an integrating
factor.
Solution. We have
M
y
= 2y, N
x
= 0,
2y −0
1 +y
2
= g(y).
Hence
µ(y) = e
−
R
(2y)/(1+y
2
) dy
= e
ln[(1+y
2
)
−1
]
=
1
1 +y
2
.
In the next example, we easily ﬁnd an integrating factor µ(x, y) which is a
function of x and y.
Example 1.13. Consider the separable equation
y dx +xdy = 0.
Show that the factor
µ(x, y) =
1
xy
,
which makes the equation separable, is an integrating factor.
Solution. The diﬀerential equation
µ(x, y)y dx +µ(x, y)xdy =
1
x
dx +
1
y
dy = 0
is separated; hence it is exact.
20 1. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS
1.6. FirstOrder Linear Equations
Consider the nonhomogeneous ﬁrstorder diﬀerential equation of the form
y
′
+f(x)y = r(x). (1.21)
The lefthand side is a linear expression with respect to the dependent variable y
and its ﬁrst derivative y
′
. In this case, we say that (1.21) is a linear diﬀerential
equation.
In this section, we solve equation (1.21) by transforming the lefthand side into
a total derivative by means of an integrating factor. In Example 3.8 the general
solution will be expressed as the sum of a general solution of the homogeneous
equation (with righthand side equal to zero) and a particular solution of the
nonhomogeneous equation. Power series solutions and numerical solutions will be
considered in Chapters 5 and 12, respectively.
The ﬁrst way is to rewrite (1.21) in diﬀerential form,
f(x)y dx +dy = r(x) dx, or
_
f(x)y −r(x)
_
dx +dy = 0, (1.22)
and make it exact. Since M
y
= f(x) and N
x
= 0, this equation is not exact. As
M
y
−N
x
N
=
f(x) −0
1
= f(x)
is a function of x only, by (1.17) we have the integration factor
µ(x) = e
R
f(x) dx
.
Multiplying (1.21) by µ(x) makes the lefthand side an exact, or total, derivative.
To see this, put
u(x, y) = µ(x)y = e
R
f(x) dx
y.
Taking the diﬀerential of u we have
du = d
_
e
R
f(x) dx
y
_
= e
R
f(x) dx
f(x)y dx +e
R
f(x) dx
dy
= µ[f(x)y dx +dy]
which is the lefthand side of (1.21) multiplied by µ, as claimed. Hence
d
_
e
R
f(x) dx
y(x)
_
= e
R
f(x) dx
r(x) dx.
Integrating both sides with respect to x, we have
e
R
f(x) dx
y(x) =
_
e
R
f(x) dx
r(x) dx +c.
Solving the last equation for y(x), we see that the general solution of (1.21) is
y(x) = e
−
R
f(x) dx
__
e
R
f(x) dx
r(x) dx +c
_
. (1.23)
Example 1.14. Solve the linear ﬁrstorder diﬀerential equation
x
2
y
′
+ 2xy = sinh 3x.
1.6. FIRSTORDER LINEAR EQUATIONS 21
Solution. Rewriting this equation in standard form, we have
y
′
+
2
x
y =
1
x
2
sinh 3x.
This equation is linear in y and y
′
. The integrating factor, which makes the
lefthand side exact, is
µ(x) = e
R
(2/x) dx
= e
lnx
2
= x
2
.
Thus,
d
dx
(x
2
y) = sinh 3x, that is, d(x
2
y) = sinh 3xdx.
Hence,
x
2
y(x) =
_
sinh 3xdx +c =
1
3
cosh3x +c,
or
y(x) =
1
3x
2
cosh3x +
c
x
2
.
Example 1.15. Solve the linear ﬁrstorder diﬀerential equation
y dx + (3x −xy + 2) dy = 0.
Solution. Rewriting this equation in standard form for the dependent vari
able x(y), we have
dx
dy
+
_
3
y
−1
_
x = −
2
y
, y ,= 0.
The integrating factor, which makes the lefthand side exact, is
µ(y) = e
R
[(3/y)−1] dy
= e
lny
3
−y
= y
3
e
−y
.
Then
d
_
y
3
e
−y
x
_
= −2y
2
e
−y
dy, that is,
d
dy
_
y
3
e
−y
x
_
= −2y
2
e
−y
.
Hence,
y
3
e
−y
x = −2
_
y
2
e
−y
dy +c
= 2y
2
e
−y
−4
_
ye
−y
dy +c
= 2y
2
e
−y
+ 4y e
−y
−4
_
e
−y
dy +c
= 2y
2
e
−y
+ 4y e
−y
+ 4 e
−y
+c.
The general solution is
xy
3
= 2y
2
+ 4y + 4 +c e
y
.
22 1. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS
y
0
x
(x, y)
y(x)
y (x)
orth
n = (– b, a) t = (a, b)
Figure 1.6. Two curves orthogonal at the point (x, y).
1.7. Orthogonal Families of Curves
A oneparameter family of curves can be given by an equation
u(x, y) = c,
where the parameter c is explicit, or by an equation
F(x, y, c) = 0,
which is implicit with respect to c.
In the ﬁrst case, the curves satisfy the diﬀerential equation
u
x
dx +u
y
dy = 0, or
dy
dx
= −
u
x
u
y
= m,
where m is the slope of the curve at the point (x, y). Note that this diﬀerential
equation does not contain the parameter c.
In the second case we have
F
x
(x, y, c) dx +F
y
(x, y, c) dy = 0.
To eliminate c from this diﬀerential equation we solve the equation F(x, y, c) = 0
for c as a function of x and y,
c = H(x, y),
and substitute this function in the diﬀerential equation,
dy
dx
= −
F
x
(x, y, c)
F
y
(x, y, c)
= −
F
x
_
x, y, H(x, y)
_
F
y
_
x, y, H(x, y)
_ = m.
Let t = (a, b) be the tangent and n = (−b, a) be the normal to the given
curve y = y(x) at the point (x, y) of the curve. Then, the slope, y
′
(x), of the
tangent is
y
′
(x) =
b
a
= m (1.24)
and the slope, y
′
orth
(x), of the curve y
orth
(x) which is orthogonal to the curve y(x)
at (x, y) is
y
′
orth
(x) = −
a
b
= −
1
m
. (1.25)
(see Fig. 1.6). Thus, the orthogonal family satisﬁes the diﬀerential equation
y
′
orth
(x) = −
1
m(x)
.
1.7. ORTHOGONAL FAMILIES OF CURVES 23
Example 1.16. Consider the oneparameter family of circles
x
2
+ (y −c)
2
= c
2
(1.26)
with centre (0, c) on the yaxis and radius [c[. Find the diﬀerential equation for
this family and the diﬀerential equation for the orthogonal family. Solve the latter
equation and plot a few curves of both families on the same graph.
Solution. We obtain the diﬀerential equation of the given family by diﬀer
entiating (1.26) with respect to x,
2x + 2(y −c)y
′
= 0 =⇒ y
′
= −
x
y −c
,
and solving (1.26) for c,
x
2
+y
2
−2yc +c
2
= c
2
=⇒ c =
x
2
+y
2
2y
.
Substituting this value for c in the diﬀerential equation, we have
y
′
= −
x
y −
x
2
+y
2
2y
= −
2xy
2y
2
−x
2
−y
2
=
2xy
x
2
−y
2
.
The diﬀerential equation of the orthogonal family is
y
′
orth
= −
x
2
−y
2
orth
2xy
orth
.
Rewriting this equation in diﬀerential form M dx + N dy = 0, and omitting the
mention “orth”, we have
(x
2
−y
2
) dx + 2xy dy = 0.
Since M
y
= −2y and N
x
= 2y, this equation is not exact, but
M
y
−N
x
N
=
−2y −2y
2xy
= −
2
x
= f(x)
is a function of x only. Hence
µ(x) = e
−
R
(2/x) dx
= x
−2
is an integrating factor. We multiply the diﬀerential equation by µ(x),
_
1 −
y
2
x
2
_
dx + 2
y
x
dy = 0,
and solve by the practical method:
u(x, y) =
_
2
y
x
dy +T(x) =
y
2
x
+T(x),
u
x
= −
y
2
x
2
+T
′
(x) = 1 −
y
2
x
2
,
T
′
(x) = 1 =⇒ T(x) = x,
u(x, y) =
y
2
x
+x = c
1
,
that is, the solution
x
2
+y
2
= c
1
x
24 1. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS
x
y
c
1
c
2
k
1
k
2
k
3
Figure 1.7. A few curves of each of the orthogonal families.
is a oneparameter family of circles. We may rewrite this equation in the more
explicit form:
x
2
−2
c
1
2
x +
c
2
1
4
+y
2
=
c
2
1
4
,
_
x −
c
1
2
_
2
+y
2
=
_
c
1
2
_
2
,
(x −k)
2
+y
2
= k
2
.
The orthogonal family is a family of circles with centre (k, 0) on the xaxis and
radius [k[. A few curves of each of the orthogonal families are plotted in Fig. 1.7.
1.8. Direction Fields and Approximate Solutions
Approximate solutions of a diﬀerential equation are of practical interest if
the equation has no explicit exact solution formula or if that formula is too com
plicated to be of practical value. In that case, one can use a numerical method
(see Chapter 12), or one may use the method of direction ﬁelds. By this latter
method, one can sketch many solution curves at the same time, without actually
solving the equation.
The method of direction ﬁelds apply to any diﬀerential equation of the form
y
′
= f(x, y). (1.27)
The idea is to take y
′
as the slope of the unknown solution curve. The curve that
passes through the point (x
0
, y
0
) has the slope f(x
0
, y
0
) at that point. Hence one
can draw at various point lineal elements, that is, short segments indicating the
tangent directions of solution curves as determined by (1.27) and then ﬁt solution
curves through this ﬁeld of tangent directions.
First draw curves of constant slopes, f(x, y) = const, called isoclines. Second,
draw along each isocline f(x, y) = k many lineal elements of slope k. Thus one
gets a direction ﬁeld. Third, sketch approximate solutions curves of (1.27).
Example 1.17. Graph the direction ﬁeld of the ﬁrstorder diﬀerential equa
tion
y
′
= xy (1.28)
and an approximation to the solution curve through the point (1, 2).
1.9. EXISTENCE AND UNIQUENESS OF SOLUTIONS 25
y
x
1 –1
2
–1
1
Figure 1.8. Direction ﬁelds for Example 1.17.
Solution. The isoclines are the equilateral hyperbolae xy = k together with
the two coordinate axes as shown in Fig. 1.8
1.9. Existence and Uniqueness of Solutions
Definition 1.3. A function f(y) is said to be Lipschitz continuous on the
open interval ]c, d[ if there exists a constant M > 0, called Lipschitz constant,
such that
[f(z) −f(y)[ ≤ M[z −y[, for all y, z ∈]c, d[. (1.29)
We note that condition (1.29) implies the existence of left and right derivatives
of f(y) of the ﬁrst order, but not their equality. Geometrically, the slope of the
curve f(y) is bounded on ]c, d[.
We state, without proof, the following existence and uniqueness theorem.
Theorem 1.3 (Existence and uniqueness theorem). Consider the initial value
problem
y
′
= f(x, y), y(x
0
) = y
0
. (1.30)
If the function f(x, y) is continuous and bounded,
[f(x, y)[ ≤ K,
on the rectangle
R : [x −x
0
[ < a, [y −y
0
[ < b,
and Lipschitz continuous with respect to y on R, then (1.30) admits one and only
one solution for all x such that
[x −x
0
[ < α, where α = min¦a, b/K¦.
Under the conditions of Theorem 1.3, the solution of problem (1.30) can be
obtained by means of Picard’s method, that is, the sequence y
0
, y
1
, . . . , y
n
, . . .,
deﬁned by the Picard iteration formula,
y
n
(x) = y
0
+
_
x
x0
f
_
t, y
n−1
(t)
_
dt, n = 1, 2, . . . , (1.31)
converges to the solution y(x).
Theorem 1.3 is applied to the following example.
26 1. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS
Example 1.18. Solve the initial value problem
yy
′
+x = 0, y(0) = −2
and plot the solution.
Solution. (a) The analytic solution.— We rewrite the diﬀerential equation
in standard form, that is, y
′
= f(x, y),
y
′
= −
x
y
.
Since the function
f(x, y) = −
x
y
is not continuous at y = 0, there will be a solution for y < 0 and another solution
for y > 0. We separate the equation and integrate:
_
xdx +
_
y dy = c
1
,
x
2
2
+
y
2
2
= c
1
,
x
2
+y
2
= r
2
.
The general solution is a oneparameter family of circles with centre at the origin
and radius r. The two solutions are
y
±
(x) =
_
√
r
2
−x
2
, if y > 0,
−
√
r
2
−x
2
, if y < 0.
Since y(0) = −2, we need to take the second solution. We determine the value of
r by means of the initial condition:
0
2
+ (−2)
2
= r
2
=⇒ r = 2.
Hence the solution, which is unique, is
y(x) = −
_
4 −x
2
, −2 < x < 2.
We see that the slope y
′
(x) of the solution tends to ±∞ as y → 0±. To have a
continuous solution in a neighbourhood of y = 0, we solve for x = x(y).
(b) The Matlab symbolic solution.—
dsolve(’y*Dy=x’,’y(0)=2’,’x’)
y = (x^2+4)^(1/2)
(c) The Matlab numeric solution.— The numerical solution of this initial
value problem is a little tricky because the general solution y
±
has two branches.
We need a function Mﬁle to run the Matlab ode solver. The Mﬁle halfcircle.m
is
function yprime = halfcircle(x,y);
yprime = x/y;
To handle the lower branch of the general solution, we call the ode23 solver and
the plot command as follows.
1.9. EXISTENCE AND UNIQUENESS OF SOLUTIONS 27
−2 −1 0 1 2
−2
−1
0
x
y
Plot of solution
Figure 1.9. Graph of solution of the diﬀerential equation in Example 1.18.
xspan1 = [0 2]; % span from x = 0 to x = 2
xspan2 = [0 2]; % span from x = 0 to x = 2
y0 = [0; 2]; % initial condition
[x1,y1] = ode23(’halfcircle’,xspan1,y0);
[x2,y2] = ode23(’halfcircle’,xspan2,y0);
plot(x1,y1(:,2),x2,y2(:,2))
axis(’equal’)
xlabel(’x’)
ylabel(’y’)
title(’Plot of solution’)
The numerical solution is plotted in Fig. 1.9.
In the following two examples, we ﬁnd an approximate solution to a diﬀer
ential equation by Picard’s method and by the method of Section 1.6. In Exam
ple 5.4, we shall ﬁnd a series solution to the same equation. One will notice that
the three methods produce the same series solution. Also, in Example 12.9, we
shall solve this equation numerically.
Example 1.19. Use Picard’s recursive method to solve the initial value prob
lem
y
′
= xy + 1, y(0) = 1.
Solution. Since the function f(x, y) = 1 +xy has a bounded partial deriv
ative of ﬁrstorder with respect to y,
∂
y
f(x, y) = x,
on any bounded interval 0 ≤ x ≤ a < ∞, Picard’s recursive formula (1.31),
y
n
(x) = y
0
+
_
x
x0
f
_
t, y
n−1
(t)
_
dt, n = 1, 2, . . . ,
28 1. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS
converges to the solution y(x). Here x
0
= 0 and y
0
= 1. Hence,
y
1
(x) = 1 +
_
x
0
(1 +t) dt
= 1 +x +
x
2
2
,
y
2
(x) = 1 +
_
x
0
_
1 +t +t
2
+
t
3
2
_
dt
= 1 +x +
x
2
2
+
x
3
3
+
x
4
8
,
y
3
(x) = 1 +
_
x
0
_
1 +ty
2
(t)
_
dt,
and so on.
Example 1.20. Use the method of Section 1.6 for linear ﬁrstorder diﬀerential
equations to solve the initial value problem
y
′
−xy = 1, y(0) = 1.
Solution. An integrating factor that makes the lefthand side an exact de
rivative is
µ(x) = e
−
R
x dx
= e
−x
2
/2
.
Multiplying the equation by µ(x), we have
d
dx
_
e
−x
2
/2
y
_
= e
−x
2
/2
,
and integrating from 0 to x, we obtain
e
−x
2
/2
y(x) =
_
x
0
e
−t
2
/2
dt +c.
Putting x = 0 and y(0) = 1, we see that c = 1. Hence,
y(x) = e
x
2
/2
_
1 +
_
x
0
e
−t
2
/2
dt
_
.
Since the integral cannot be expressed in closed form, we expand the two expo
nential functions in convergent power series, integrate the second series term by
term and multiply the resulting series term by term:
y(x) = e
x
2
/2
_
1 +
_
x
0
_
1 −
t
2
2
+
t
4
8
−
t
6
48
+−. . .
_
dt
_
=e
x
2
/2
_
1 +x −
x
3
6
+
x
5
40
−
x
7
336
−+. . .
_
=
_
1 +
x
2
2
+
x
4
8
+
x
6
48
+. . .
__
1 +x −
x
3
6
+
x
5
40
−
x
7
336
−+. . .
_
= 1 +x +
x
2
2
+
x
3
3
+
x
4
8
+. . . .
As expected, the symbolic Matlab command dsolve produces the solution in
terms of the Maple error function erf(x):
>> dsolve(’Dy=x*y+1’,’y(0)=1’,’x’)
y=1/2*exp(1/2*x^2)*pi^(1/2)*2^(1/2)*erf(1/2*2^(1/2)*x)+exp(1/2*x^2)
1.9. EXISTENCE AND UNIQUENESS OF SOLUTIONS 29
The following example shows that with continuity, but without Lispschitz
continuity of the function f(x, y) in y
′
= f(x, y), the solution may not be unique.
Example 1.21. Show that the initial value problem
y
′
= 3y
2/3
, y(x
0
) = y
0
,
has nonunique solutions.
Solution. The righthand side of the equation is continuous for all y and
because it is independent of x, it is continuous on the whole xyplane. However,
it is not Lipschitz continuous in y at y = 0 since f
y
(x, y) = 2y
−1/3
is not even
deﬁned at y = 0. It is seen that y(x) ≡ 0 is a solution of the diﬀerential equation.
Moreover, for a ≤ b,
y(x) =
_
¸
_
¸
_
(x −a)
3
, t < a,
0, a ≤ x ≤ b,
(x −b)
3
, t > b,
is also a solution. By properly choosing the value of the parameter a or b, a
solution curve can be made to satisfy the initial conditions. By varying the other
parameter, one gets a family of solution to the initial value problem. Hence the
solution is not unique.
CHAPTER 2
SecondOrder Ordinary Diﬀerential Equations
In this chapter, we introduce basic concepts for linear secondorder diﬀerential
equations. We solve linear constant coeﬃcients equations and Euler–Cauchy’s
equations. Further theory on linear nonhomogeneous equations of arbitrary order
will be developed in Chapter 3.
2.1. Linear Homogeneous Equations
Consider the secondorder linear nonhomogeneous diﬀerential equation
y
′′
+f(x)y
′
+g(x)y = r(x). (2.1)
The equation is linear with respect to y, y
′
and y
′′
. It is nonhomogeneous if the
righthand side, r(x), is not identically zero.
The capital letter L will often be used to denote a linear diﬀerential operator,
L := a
n
(x)D
n
+a
n−1
(x)D
n−1
+ +a
1
(x)D +a
0
(x), D =
′
=
d
dx
.
If the righthand side of (2.1) is zero, we say that the equation
Ly := y
′′
+f(x)y
′
+g(x)y = 0, (2.2)
is homogeneous.
Theorem 2.1. The solutions of (2.2) form a vector space.
Proof. Let y
1
and y
2
be two solutions of (2.2). The result follows from the
linearity of L:
L(αy
1
+βy
2
) = αLy
1
+βLy
2
= 0, α, β ∈ R.
2.2. Linear Homogeneous Equations
Consider the secondorder linear homogeneous diﬀerential equation with con
stant coeﬃcients:
y
′′
+ay
′
+by = 0. (2.3)
To solve this equation we suppose that a solution is of exponential form,
y(x) = e
λx
.
Inserting this function in (2.3), we have
λ
2
e
λx
+aλe
λx
+b e
λx
= 0, (2.4)
e
λx
_
λ
2
+aλ +b
_
= 0. (2.5)
Since e
λx
is never zero, we obtain the characteristic equation
λ
2
+aλ +b = 0 (2.6)
31
32 2. SECONDORDER ORDINARY DIFFERENTIAL EQUATIONS
for λ and the eigenvalues
λ
1,2
=
−a ±
√
a
2
−4b
2
. (2.7)
If λ
1
,= λ
2
, we have two distinct solutions,
y
1
(x) = e
λ1x
, y
2
(x) = e
λ2x
.
In this case, the general solution, which contains two arbitrary constants, is
y = c
1
y
1
+c
2
y
2
.
Example 2.1. Find the general solution of the linear homogeneous diﬀeren
tial equation with constant coeﬃcients
y
′′
+ 5y
′
+ 6y = 0.
Solution. The characteristic equation is
λ
2
+ 5λ + 6 = (λ + 2)(λ + 3) = 0.
Hence λ
1
= −2 and λ
2
= −3, and the general solution is
y(x) = c
1
e
−2x
+c
2
e
−3x
.
2.3. Basis of the Solution Space
We generalize to functions the notion of linear independence for two vectors
of R
2
.
Definition 2.1. The functions f
1
(x) and f
2
(x) are said to be linearly inde
pendent on the interval [a, b] if the identity
c
1
f
1
(x) +c
2
f
2
(x) ≡ 0, for all x ∈ [a, b], (2.8)
implies that
c
1
= c
2
= 0.
Otherwise the functions are said to be linearly dependent.
If f
1
(x) and f
2
(x) are linearly dependent on [a, b], then there exist two num
bers (c
1
, c
2
) ,= (0, 0) such that, if, say, c
1
,= 0, we have
f
1
(x)
f
2
(x)
≡ −
c
2
c
1
= const. (2.9)
If
f
1
(x)
f
2
(x)
,= const. on [a, b], (2.10)
then f
1
and f
2
are linearly independent on [a, b]. This characterization of linear
independence of two functions will often be used.
Definition 2.2. The general solution of the homogeneous equation (2.2)
spans the vector space of solutions of (2.2).
Theorem 2.2. Let y
1
(x) and y
2
(x) be two solutions of (2.2) on [a, b]. Then,
the solution
y(x) = c
1
y
1
(x) +c
2
y
2
(x)
is a general solution of (2.2) if and only if y
1
and y
2
are linearly independent on
[a, b].
2.3. BASIS OF THE SOLUTION SPACE 33
Proof. The proof will be given in Chapter 3 for equations of order n.
The next example illustrates the use of the general solution.
Example 2.2. Solve the following initial value problem:
y
′′
+y
′
−2y = 0, y(0) = 4, y
′
(0) = 1.
Solution. (a) The analytic solution.— The characteristic equation is
λ
2
+λ −2 = (λ −1)(λ + 2) = 0.
Hence λ
1
= 1 and λ
2
= −2. The two solutions
y
1
(x) = e
x
, y
2
(x) = e
−2x
are linearly independent since
y
1
(x)
y
2
(x)
= e
3x
,= const.
Thus, the general solution is
y = c
1
e
x
+c
2
e
−2x
.
The constants are determined by the initial conditions,
y(0) = c
1
+c
2
= 4,
y
′
(x) = c
1
e
x
−2c
2
e
−2x
,
y
′
(0) = c
1
−2c
2
= 1.
We therefore have the linear system
_
1 1
1 −2
_ _
c
1
c
2
_
=
_
4
1
_
, that is, Ac =
_
4
1
_
.
Since
det A = −3 ,= 0,
the solution c is unique. This solution is easily computed by Cramer’s rule,
c
1
=
1
−3
¸
¸
¸
¸
4 1
1 −2
¸
¸
¸
¸
=
−9
−3
= 3, c
2
=
1
−3
¸
¸
¸
¸
1 4
1 1
¸
¸
¸
¸
=
−3
−3
= 1.
The solution of the initial value problem is
y(x) = 3 e
x
+e
−2x
.
This solution is unique.
(b) The Matlab symbolic solution.—
dsolve(’D2y+Dy2*y=0’,’y(0)=4’,’Dy(0)=1’,’x’)
y = 3*exp(x)+exp(2*x)
(c) The Matlab numeric solution.— To rewrite the secondorder diﬀerential
equation as a system of ﬁrstorder equations, we put
y
1
= y,
y
2
= y
′
,
34 2. SECONDORDER ORDINARY DIFFERENTIAL EQUATIONS
0 1 2 3 4
0
50
100
150
200
x
y
Plot of solution
Figure 2.1. Graph of solution of the linear equation in Example 2.2.
Thus, we have
y
′
1
= y
2
,
y
′
2
= 2y
1
−y
2
.
The Mﬁle exp22.m:
function yprime = exp22(x,y);
yprime = [y(2); 2*y(1)y(2)];
The call to the ode23 solver and the plot command:
xspan = [0 4]; % solution for x=0 to x=4
y0 = [4; 1]; % initial conditions
[x,y] = ode23(’exp22’,xspan,y0);
subplot(2,2,1); plot(x,y(:,1))
The numerical solution is plotted in Fig. 2.1.
2.4. Independent Solutions
The form of independent solutions of a homogeneous equation,
Ly := y
′′
+ay
′
+by = 0, (2.11)
depends on the form of the roots
λ
1,2
=
−a ±
√
a
2
−4b
2
(2.12)
of the characteristic equation
λ
2
+aλ +b = 0. (2.13)
There are three cases: λ
1
,= λ
2
real, λ
2
=
¯
λ
1
complex, and λ
1
= λ
2
real.
Case I. In the case of two real distinct eigenvalues, λ
1
,= λ
2
, it was seen in
Section 2.2 that the two solutions,
y
1
(x) = e
λ1x
, y
2
(x) = e
λ2x
,
2.4. INDEPENDENT SOLUTIONS 35
are independent. Therefore, the general solution is
y(x) = c
1
e
λ1x
+ c
2
e
λ2x
. (2.14)
Case II. In the case of two distinct complex conjugate eigenvalues, we have
λ
1
= α + iβ, λ
2
= α −iβ =
¯
λ
1
, where i =
√
−1.
By means of Euler’s identity,
e
iθ
= cos θ +i sinθ, (2.15)
the two complex solutions can be written in the form
u
1
(x) = e
(α+iβ)x
= e
αx
(cos βx +i sin βx),
u
2
(x) = e
(α−iβ)x
= e
αx
(cos βx −i sin βx).
Since λ
1
,= λ
2
, the solutions u
1
and u
2
are independent. To have two real inde
pendent solutions, we use the following change of basis, or, equivalently we take
the real and imaginary parts of u
1
since a and b are real and (2.11) is homoge
neous (since the real and imaginary parts of a complex solution of a homogeneous
equation with real coeﬃcients are also solutions). Thus,
y
1
(x) = ℜu
1
(x) =
1
2
[u
1
(x) +u
2
(x)] = e
αx
cos βx, (2.16)
y
2
(x) = ℑu
1
(x) =
1
2i
[u
1
(x) −u
2
(x)] = e
αx
sin βx. (2.17)
It is clear that y
1
and y
2
are independent. Therefore, the general solution is
y(x) = c
1
e
αx
cos βx +c
2
e
αx
sinβx. (2.18)
Case III. In the case of real double eigenvalues we have
λ = λ
1
= λ
2
= −
a
2
and equation (2.11) admits a solution of the form
y
1
(x) = e
λx
. (2.19)
To obtain a second independent solution, we use the method of variation of pa
rameters, which is described in greater detail in Section 3.5. Thus, we put
y
2
(x) = u(x)y
1
(x). (2.20)
It is important to note that the parameter u is a function of x and that y
1
is a
solution of (2.11). We substitute y
2
in (2.11). This amounts to add the following
three equations,
by
2
(x) = bu(x)y
1
(x)
ay
′
2
(x) = au(x)y
′
1
(x) +ay
1
(x)u
′
(x)
y
′′
2
(x) = u(x)y
′′
1
(x) + 2y
′
1
(x)u
′
(x) +y
1
(x)u
′′
(x)
Ly
2
= u(x)Ly
1
+ [ay
1
(x) + 2y
′
1
(x)]u
′
(x) +y
1
(x)u
′′
(x).
The lefthand side is zero since y
2
is assumed to be a solution of Ly = 0. The
ﬁrst term on the righthand side is also zero since y
1
is a solution of Ly = 0.
The second term on the righthand side is zero since
λ = −
a
2
∈ R,
36 2. SECONDORDER ORDINARY DIFFERENTIAL EQUATIONS
y
y = 0
s
0
m
F
1
F
2
y
Système au repos
System at rest
Système en mouvement
System in motion
Ressort libre
Free spring
m
k
Figure 2.2. Undamped System.
and y
′
1
(x) = λy
1
(x), that is,
ay
1
(x) + 2y
′
1
(x) = a e
−ax/2
−a e
−ax/2
= 0.
It follows that
u
′′
(x) = 0,
whence
u
′
(x) = k
1
and
u(x) = k
1
x +k
2
.
We therefore have
y
2
(x) = k
1
xe
λx
+k
2
e
λx
.
We may take k
2
= 0 since the second term on the righthand side is already
contained in the linear span of y
1
. Moreover, we may take k
1
= 1 since the
general solution contains an arbitrary constant multiplying y
2
.
It is clear that the solutions
y
1
(x) = e
λx
, y
2
(x) = xe
λx
,
are linearly independent. The general solution is
y(x) = c
1
e
λx
+c
2
xe
λx
. (2.21)
2.5. Modeling in Mechanics
We consider elementary models of mechanics.
Example 2.3 (Free Oscillation). Consider a vertical spring attached to a rigid
beam. The spring resists both extension and compression with Hooke’s constant
equal to k. Study the problem of the free vertical oscillation of a mass of mkg
which is attached to the lower end of the spring.
Solution. Let the positive Oy axis point downward. Let s
0
m be the exten
sion of the spring due to the force of gravity acting on the mass at rest at y = 0.
(See Fig. 2.2).
We neglect friction. The force due to gravity is
F
1
= mg, where g = 9.8 m/sec
2
.
2.5. MODELING IN MECHANICS 37
y
y = 0
m
k
c
Figure 2.3. Damped system.
The restoration force exerted by the spring is
F
2
= −k s
0
.
By Newton’s second law of motion, when the system is at rest, in position y = 0,
the resultant is zero,
F
1
+F
2
= 0.
Now consider the system in motion in position y. By the same law, the resultant
is
ma = −k y.
Since the acceleration is a = y
′′
, then
my
′′
+ky = 0, or y
′′
+ ω
2
y = 0, ω =
_
k
m
,
where ω/2π Hz is the frequency of the system. The characteristic equation of this
diﬀerential equation,
λ
2
+ω
2
= 0,
admits the pure imaginary eigenvalues
λ
1,2
= ±iω.
Hence, the general solution is
y(t) = c
1
cos ωt +c
2
sin ωt.
We see that the system oscillates freely without any loss of energy.
The amplitude, A, and period, p, of the previous system are
A =
_
c
2
1
+c
2
2
, p =
2π
ω
.
Example 2.4 (Damped System). Consider a vertical spring attached to a
rigid beam. The spring resists extension and compression with Hooke’s constant
equal to k. Study the problem of the damped vertical motion of a mass of mkg
which is attached to the lower end of the spring. (See Fig. 2.3). The damping
constant is equal to c.
Solution. Let the positive Oy axis point downward. Let s
0
m be the exten
sion of the spring due to the force of gravity on the mass at rest at y = 0. (See
Fig. 2.2).
The force due to gravity is
F
1
= mg, where g = 9.8 m/sec
2
.
38 2. SECONDORDER ORDINARY DIFFERENTIAL EQUATIONS
The restoration force exerted by the spring is
F
2
= −k s
0
.
By Newton’s second law of motion, when the system is at rest, the resultant is
zero,
F
1
+F
2
= 0.
Since damping opposes motion, by the same law, the resultant for the system in
motion is
ma = −c y
′
−k y.
Since the acceleration is a = y
′′
, then
my
′′
+cy
′
+ky = 0, or y
′′
+
c
m
y
′
+
k
m
y = 0.
The characteristic equation of this diﬀerential equation,
λ
2
+
c
m
λ +
k
m
= 0,
admits the eigenvalues
λ
1,2
= −
c
2m
±
1
2m
_
c
2
−4mk =: −α ±β, α > 0.
There are three cases to consider.
Case I: Overdamping. If c
2
> 4mk, the system is overdamped. Both eigen
values are real and negative since
λ
1
= −
c
2m
−
1
2m
_
c
2
−4mk < 0, λ
1
λ
2
=
k
m
> 0.
The general solution,
y(t) = c
1
e
λ1t
+c
2
e
λ2t
,
decreases exponentially to zero without any oscillation of the system.
Case II: Underdamping. If c
2
< 4mk, the system is underdamped. The
two eigenvalues are complex conjugate to each other,
λ
1,2
= −
c
2m
±
i
2m
_
4mk −c
2
=: −α ±iβ, with α > 0.
The general solution,
y(t) = c
1
e
−αt
cos βt +c
2
e
−αt
sin βt,
oscillates while decreasing exponentially to zero.
Case III: Critical damping. If c
2
= 4mk, the system is critically
damped. Both eigenvalues are real and equal,
λ
1,2
= −
c
2m
= −α, with α > 0.
The general solution,
y(t) = c
1
e
−αt
+c
2
t e
−αt
= (c
1
+c
2
t) e
−αt
,
decreases exponentially to zero with an initial increase in y(t) if c
2
> 0.
Example 2.5 (Oscillation of water in a tube in a U form).
Find the frequency of the oscillatory movement of 2 L of water in a tube in a U
form. The diameter of the tube is 0.04 m.
2.5. MODELING IN MECHANICS 39
y
y = 0
Figure 2.4. Vertical movement of a liquid in a U tube.
Solution. We neglect friction between the liquid and the tube wall. The
mass of the liquid is m = 2 kg. The volume, of height h = 2y, responsible for the
restoring force is
V = πr
2
h = π(0.02)
2
2y m
3
= π(0.02)
2
2000y L
(see Fig. 2.4). The mass of volume V is
M = π(0.02)
2
2000y kg
and the restoration force is
Mg = π(0.02)
2
9.8 2000y N, g = 9.8 m/s
2
.
By Newton’s second law of motion,
my
′′
= −Mg,
that is,
y
′′
+
π(0.02)
2
9.8 2000
2
y = 0, or y
′′
+ω
2
0
y = 0,
where
ω
2
0
=
π(0.02)
2
9.8 2000
2
= 12.3150.
Hence, the frequency is
ω
0
2π
=
√
12.3150
2π
= 0.5585 Hz.
Example 2.6 (Oscillation of a pendulum). Find the frequency of the oscil
lations of small amplitude of a pendulum of mass mkg and length L = 1 m.
Solution. We neglect air resistance and the mass of the rod. Let θ be the
angle, in radian measure, made by the pendulum measured from the vertical axis.
(See Fig. 2.5).
The tangential force is
ma = mLθ
′′
.
Since the length of the rod is ﬁxed, the orthogonal component of the force is zero.
Hence it suﬃces to consider the tangential component of the restoring force due
to gravity, that is,
mLθ
′′
= −mg sin θ ≈ −mgθ, g = 9.8,
40 2. SECONDORDER ORDINARY DIFFERENTIAL EQUATIONS
y
mg
θ
tangente
tangent
Figure 2.5. Pendulum in motion.
where sinθ ≈ θ if θ is suﬃciently small. Thus,
θ
′′
+
g
L
θ = 0, or θ
′′
+ω
2
0
θ = 0, where ω
2
0
=
g
L
= 9.8.
Therefore, the frequency is
ω
0
2π
=
√
9.8
2π
= 0.498 Hz.
2.6. Euler–Cauchy’s Equation
Consider the homogeneous Euler–Cauchy equation
Ly := x
2
y
′′
+axy
′
+by = 0, x > 0 (2.22)
Because of the particular form of the diﬀerential operator of this equation with
variable coeﬃcients,
L = x
2
D
2
+axD +bI, D =
′
=
d
dx
,
where each term is of the form a
k
x
k
D
k
, with a
k
a constant, we can solve (2.22)
by setting
y(x) = x
m
(2.23)
in (2.22),
m(m−1)x
m
+amx
m
+bx
m
= x
m
[m(m−1) +am+b] = 0.
We can divide by x
m
if x > 0. We thus obtain the characteristic equation
m
2
+ (a −1)m+b = 0. (2.24)
The eigenvalues are
m
1,2
=
1 −a
2
±
1
2
_
(a −1)
2
−4b. (2.25)
There are three cases: m
1
,= m
2
real, m
1
and m
2
= m
1
complex and distinct,
and m
1
= m
2
real.
Case I. If both roots are real and distinct, the general solution of (2.22) is
y(x) = c
1
x
m1
+ c
2
x
m2
. (2.26)
2.6. EULER–CAUCHY’S EQUATION 41
Case II. If the roots are complex conjugates of one another,
m
1
= α +iβ, m
2
= α − iβ, β ,= 0,
we have two independent complex solutions of the form
u
1
= x
α
x
iβ
= x
α
e
iβ ln x
= x
α
[cos(β ln x) +i sin(β ln x)]
and
u
2
= x
α
x
−iβ
= x
α
e
−iβ ln x
= x
α
[cos(β ln x) −i sin(β ln x)].
For x > 0, we obtain two real independent solutions by adding and subtracting
u
1
and u
2
, and dividing the sum and the diﬀerence by 2 and 2i, respectively, or,
equivalently, by taking the real and imaginary parts of u
1
since a and b are real
and (2.22) is homogeneous.
y
1
(x) = x
α
cos(β ln x), y
2
(x) = x
α
sin(β ln x).
The general solution of (2.22) is
y(x) = c
1
x
α
cos(β ln x) +c
2
x
α
sin(β ln x). (2.27)
Case III. If both roots are real and equal,
m = m
1
= m
2
=
1 −a
2
,
one solution is of the form
y
1
(x) = x
m
.
We ﬁnd a second independent solution by variation of parameters by putting
y
2
(x) = u(x)y
1
(x)
in (2.22). Adding the left and righthand sides of the following three expressions,
we have
by
2
(x) = bu(x)y
1
(x)
axy
′
2
(x) = axu(x)y
′
1
(x) +axy
1
(x)u
′
(x)
x
2
y
′′
2
(x) = x
2
u(x)y
′′
1
(x) + 2x
2
y
′
1
(x)u
′
(x) +x
2
y
1
(x)u
′′
(x)
Ly
2
= u(x)Ly
1
+ [axy
1
(x) + 2x
2
y
′
1
(x)]u
′
(x) +x
2
y
1
(x)u
′′
(x).
The lefthand side is zero since y
2
is assumed to be a solution of Ly = 0. The
ﬁrst term on the righthand side is also zero since y
1
is a solution of Ly = 0.
The coeﬃcient of u
′
is
axy
1
(x) + 2x
2
y
′
1
(x) = axx
m
+ 2mx
2
x
m−1
= ax
m+1
+ 2mx
m+1
= (a + 2m)x
m+1
=
_
a + 2
1 −a
2
_
x
m+1
= x
m+1
.
Hence we have
x
2
y
1
(x)u
′′
+x
m+1
u
′
= x
m+1
(xu
′′
+u
′
) = 0, x > 0,
and dividing by x
m+1
, we have
xu
′′
+ u
′
= 0.
Since u is absent from this diﬀerential equation, we can reduce the order by
putting
v = u
′
, v
′
= u
′′
.
42 2. SECONDORDER ORDINARY DIFFERENTIAL EQUATIONS
The resulting equation is separable,
x
dv
dx
+v = 0, that is,
dv
v
= −
dx
x
,
and can be integrated,
ln [v[ = ln x
−1
=⇒ u
′
= v =
1
x
=⇒ u = ln x.
No constant of integration is needed here. The second independent solution is
y
2
= (ln x)x
m
.
Therefore, the general solution of (2.22) is
y(x) = c
1
x
m
+c
2
(ln x)x
m
. (2.28)
Example 2.7. Find the general solution of the Euler–Cauchy equation
x
2
y
′′
−6y = 0.
Solution. (a) The analytic solution.— Putting y = x
m
in the diﬀerential
equation, we have
m(m−1)x
m
−6x
m
= 0.
The characteristic equation is
m
2
−m−6 = (m−3)(m+ 2) = 0.
The eigenvalues,
m
1
= 3, m
2
= −2,
are real and distinct. The general solution is
y(x) = c
1
x
3
+c
2
x
−2
.
(b) The Matlab symbolic solution.—
dsolve(’x^2*D2y=6*y’,’x’)
y = (C1+C2*x^5)/x^2
Example 2.8. Solve the initial value problem
x
2
y
′′
−6y = 0, y(1) = 2, y
′
(1) = 1.
Solution. (a) The analytic solution.— The general solution as found in
Example 2.7 is
y(x) = c
1
x
3
+c
2
x
−2
.
From the initial conditions, we have the linear system in c
1
and c
2
:
y(1) = c
1
+ c
2
= 2
y
′
(1) = 3c
1
−2c
2
= 1
whose solution is
c
1
= 1, c
2
= 1.
Hence the unique solution is
y(x) = x
3
+x
−2
.
(b) The Matlab symbolic solution.—
2.6. EULER–CAUCHY’S EQUATION 43
1 2 3 4
0
10
20
30
40
50
60
70
x
y
=
y
(
1
)
Plot of solution
Figure 2.6. Graph of solution of the Euler–Cauchy equation in Example 2.8.
dsolve(’x^2*D2y=6*y’,’y(1)=2’,’Dy(1)=1’,’x’)
y = (1+x^5)/x^2
(c) The Matlab numeric solution.— To rewrite the secondorder diﬀerential
equation as a system of ﬁrstorder equations, we put
y
1
= y,
y
2
= y
′
,
with initial conditions at x = 1:
y
1
(1) = 2, y
2
(1) = 1.
Thus, we have
y
′
1
= y
2
,
y
′
2
= 6y
1
/x
2
.
The Mﬁle euler2.m:
function yprime = euler2(x,y);
yprime = [y(2); 6*y(1)/x^2];
The call to the ode23 solver and the plot command:
xspan = [1 4]; % solution for x=1 to x=4
y0 = [2; 1]; % initial conditions
[x,y] = ode23(’euler2’,xspan,y0);
subplot(2,2,1); plot(x,y(:,1))
The numerical solution is plotted in Fig. 2.6.
Example 2.9. Find the general solution of the Euler–Cauchy equation
x
2
y
′′
+ 7xy
′
+ 9y = 0.
44 2. SECONDORDER ORDINARY DIFFERENTIAL EQUATIONS
Solution. The characteristic equation
m
2
+ 6m+ 9 = (m + 3)
2
= 0
admits a double root m = −3. Hence the general solution is
y(x) = (c
1
+c
2
ln x)x
−3
.
Example 2.10. Find the general solution of the Euler–Cauchy equation
x
2
y
′′
+ 1.25y = 0.
Solution. The characteristic equation
m
2
−m+ 1.25 = 0
admits a pair of complex conjuguate roots
m
1
=
1
2
+i, m
2
=
1
2
−i.
Hence the general solution is
y(x) = x
1/2
[c
1
cos(ln x) +c
2
sin(ln x)].
The existence and uniqueness of solutions of initial value problems will be
considered in the next chapter.
CHAPTER 3
Linear Diﬀerential Equations of Arbitrary Order
3.1. Homogeneous Equations
Consider the linear nonhomogeneous diﬀerential equation of order n,
y
(n)
+a
n−1
(x)y
(n−1)
+ +a
1
(x)y
′
+a
0
(x)y = r(x), (3.1)
with variable coeﬃcients, a
0
(x), a
1
(x), . . . , a
n−1
(x). Let L denote the diﬀerential
operator on the lefthand side,
L := D
n
+a
n−1
(x)D
n−1
+ +a
1
(x)D +a
0
(x)I, D :=
′
=
d
dx
. (3.2)
Then the nonhomogeneous equation (3.1) is written in the form
Lu = r(x).
If r ≡ 0, equation (3.1) is said to be homogeneous,
y
(n)
+a
n−1
(x)y
(n−1)
+ +a
1
(x)y
′
+a
0
(x)y = 0, (3.3)
that is,
Ly = 0.
Definition 3.1. A solution of (3.1) or (3.3) on the interval ]a, b[ is a function
y(x) n times continuously diﬀerentiable on ]a, b[ which satisﬁes identically the
diﬀerential equation.
Theorem 2.1 proved in the previous chapter generalizes to linear homogeneous
equations of arbitrary order n.
Theorem 3.1. The solutions of (3.3) form a vector space.
Proof. Let y
1
, y
2
, . . . , y
k
be k solutions of Ly = 0. The linearity of the
operator L implies that
L(c
1
y
1
+c
2
y
2
+ +c
k
y
k
) = c
1
Ly
1
+c
2
Ly
2
+ +c
k
Ly
k
= 0, c
i
∈ R.
Definition 3.2. We say that n functions, f
1
, f
2
, . . . , f
n
, are linearly depen
dent on the interval ]a, b[ if and only if there exist n constants not all zero,
(k
1
, k
2
, . . . , k
n
) ,= (0, 0, . . . , 0),
such that
k
1
f
1
(x) +k
2
f
2
(x) + +k
n
f
n
(x) = 0, for all x ∈]a, b[. (3.4)
Otherwise, they are said to be linearly independent.
45
46 3. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER
Remark 3.1. Let f
1
, f
2
, . . . , f
n
be n linearly dependent functions. Without
loss of generality, we may suppose that k
1
,= 0 in (3.4). Then f
1
is a linear
combination of f
2
, f
3
, . . . , f
n
.
f
1
(x) = −
1
k
1
[k
2
f
2
(x) + +k
n
f
n
(x)].
We have the following existence and uniqueness theorem.
Theorem 3.2. If the functions a
0
(x), a
1
(x), . . . , a
n−1
(x) are continuous on
the interval ]a, b[ and x
0
∈]a, b[, then the initial value problem
Ly = 0, y(x
0
) = k
1
, y
′
(x
0
) = k
2
, . . . , y
(n−1)
(x
0
) = k
n
, (3.5)
admits one and only one solution.
Proof. One can prove the theorem by reducing the diﬀerential equation of
order n to a system of n diﬀerential equations of the ﬁrst order. To do this, deﬁne
the n dependent variables
u
1
= y, u
2
= y
′
, . . . , u
n
= y
(n−1)
.
Then the initial value problem becomes
_
¸
¸
¸
¸
¸
_
u
1
u
2
.
.
.
u
n−1
u
n
_
¸
¸
¸
¸
¸
_
′
=
_
¸
¸
¸
¸
¸
_
0 1 0 0
0 0 1 0
.
.
.
.
.
.
.
.
.
.
.
. 0
0 0 0 1
−a
0
−a
1
−a
2
−a
n−1
_
¸
¸
¸
¸
¸
_
_
¸
¸
¸
¸
¸
_
u
1
u
2
.
.
.
u
n−1
u
n
_
¸
¸
¸
¸
¸
_
,
_
¸
¸
¸
¸
¸
_
u
1
(x
0
)
u
2
(x
0
)
.
.
.
u
n−1
(x
0
)
u
n
(x
0
)
_
¸
¸
¸
¸
¸
_
=
_
¸
¸
¸
¸
¸
_
k
1
k
2
.
.
.
k
n−1
k
n
_
¸
¸
¸
¸
¸
_
,
or, in matrix and vector notation,
u
′
(x) = A(x)u(x), u(x
0
) = k.
The matrix A(x) is called a companion matrix. Using Picard’s method, one
can show that this system admits one and only one solution. Picard’s iterative
procedure is as follows:
u
[n]
(x) = u
[0]
(x
0
) +
_
x
x0
A(t)u
[n−1]
(t) dt, u
[0]
(x
0
) = k.
Definition 3.3. The Wronskian of n functions, f
1
(x), f
2
(x), . . . , f
n
(x), n−1
times diﬀerentiable on the interval ]a, b[ is the following determinant of order n:
W(f
1
, f
2
, . . . , f
n
)(x) :=
¸
¸
¸
¸
¸
¸
¸
¸
¸
f
1
(x) f
2
(x) f
n
(x)
f
′
1
(x) f
′
2
(x) f
′
n
(x)
.
.
.
.
.
.
f
(n−1)
1
(x) f
(n−1)
2
(x) f
(n−1)
n
(x)
¸
¸
¸
¸
¸
¸
¸
¸
¸
. (3.6)
The linear dependence of n solutions of the linear homogeneous diﬀerential
equation (3.3) is characterized by means of their Wronskian.
First, let us prove Abel’s Lemma.
Lemma 3.1 (Abel). Let y
1
, y
2
, . . . , y
n
be n solutions of (3.3) on the interval
]a, b[. Then the Wronskian W(x) = W(y
1
, y
2
, . . . , y
n
)(x) satisﬁes the following
identity:
W(x) = W(x
0
) e
−
R
x
x
0
an−1(t) dt
, x
0
∈]a, b[. (3.7)
3.1. HOMOGENEOUS EQUATIONS 47
Proof. For simplicity of writing, let us take n = 3; the general case is treated
as easily. Let W(x) be the Wronskian of three solutions y
1
, y
2
, y
3
. The derivative
W
′
(x) of the Wronskian is of the form
W
′
(x) =
¸
¸
¸
¸
¸
¸
y
1
y
2
y
3
y
′
1
y
′
2
y
′
3
y
′′
1
y
′′
2
y
′′
3
¸
¸
¸
¸
¸
¸
′
=
¸
¸
¸
¸
¸
¸
y
′
1
y
′
2
y
′
3
y
′
1
y
′
2
y
′
3
y
′′
1
y
′′
2
y
′′
3
¸
¸
¸
¸
¸
¸
+
¸
¸
¸
¸
¸
¸
y
1
y
2
y
3
y
′′
1
y
′′
2
y
′′
3
y
′′
1
y
′′
2
y
′′
3
¸
¸
¸
¸
¸
¸
+
¸
¸
¸
¸
¸
¸
y
1
y
2
y
3
y
′
1
y
′
2
y
′
3
y
′′′
1
y
′′′
2
y
′′′
3
¸
¸
¸
¸
¸
¸
=
¸
¸
¸
¸
¸
¸
y
1
y
2
y
3
y
′
1
y
′
2
y
′
3
y
′′′
1
y
′′′
2
y
′′′
3
¸
¸
¸
¸
¸
¸
=
¸
¸
¸
¸
¸
¸
y
1
y
2
y
3
y
′
1
y
′
2
y
′
3
−a
0
y
1
−a
1
y
′
1
−a
2
y
′′
1
−a
0
y
2
−a
1
y
′
2
−a
2
y
′′
2
−a
0
y
3
−a
1
y
′
3
−a
2
y
′′
3
¸
¸
¸
¸
¸
¸
,
since the ﬁrst two determinants of the second line are zero because two rows are
equal, and in the last determinant we have used the fact that y
k
, k = 1, 2, 3, is a
solution of the homogeneous equation (3.3).
Adding to the third row a
0
times the ﬁrst row and a
1
times the second row,
we obtain the separable diﬀerential equation
W
′
(x) = −a
2
(x)W(x),
namely,
dW
W
= −a
2
(x) dx.
The solution is
ln [W[ = −
_
a
2
(x) dx +c,
that is
W(x) = W(x
0
) e
−
R
x
x
0
a2(t) dt
, x
0
∈]a, b[.
Theorem 3.3. If the coeﬃcients a
0
(x), a
1
(x), . . . , a
n−1
(x) of (3.3) are con
tinuous on the interval ]a, b[, then n solutions, y
1
, y
2
, . . . , y
n
, of (3.3) are linearly
dependent if and only if their Wronskian is zero at a point x
0
∈]a, b[,
W(y
1
, y
2
, . . . , y
n
)(x
0
) :=
¸
¸
¸
¸
¸
¸
¸
¸
¸
y
1
(x
0
) y
n
(x
0
)
y
′
1
(x
0
) y
′
n
(x
0
)
.
.
.
.
.
.
y
(n−1)
1
(x
0
) y
(n−1)
n
(x
0
)
¸
¸
¸
¸
¸
¸
¸
¸
¸
= 0. (3.8)
Proof. If the solutions are linearly dependent, then by Deﬁnition 3.2 there
exist n constants not all zero,
(k
1
, k
2
, . . . , k
n
) ,= (0, 0, . . . , 0),
such that
k
1
y
1
(x) +k
2
y
2
(x) + +k
n
y
n
(x) = 0, for all x ∈]a, b[.
48 3. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER
Diﬀerentiating this identity n −1 times, we obtain
k
1
y
1
(x) +k
2
y
2
(x) + +k
n
y
n
(x) = 0,
k
1
y
′
1
(x) +k
2
y
′
2
(x) + +k
n
y
′
n
(x) = 0,
.
.
.
k
1
y
(n−1)
1
(x) +k
2
y
(n−1)
2
(x) + +k
n
y
(n−1)
n
(x) = 0.
We rewrite this homogeneous algebraic linear system, in the n unknowns k
1
, k
2
, . . . , k
n
in matrix form,
_
¸
¸
¸
_
y
1
(x) y
n
(x)
y
′
1
(x) y
′
n
(x)
.
.
.
.
.
.
y
(n−1)
1
(x) y
(n−1)
n
(x)
_
¸
¸
¸
_
_
¸
¸
¸
_
k
1
k
2
.
.
.
k
n
_
¸
¸
¸
_
=
_
¸
¸
¸
_
0
0
.
.
.
0
_
¸
¸
¸
_
, (3.9)
that is,
Ak = 0.
Since, by hypothesis, the solution k is nonzero, the determinant of the system
must be zero,
det A = W(y
1
, y
2
, . . . , y
n
)(x) = 0, for all x ∈]a, b[.
On the other hand, if the Wronskian of n solutions is zero at an arbitrary point
x
0
,
W(y
1
, y
2
, . . . , y
n
)(x
0
) = 0,
then it is zero for all x ∈]a, b[ by Abel’s Lemma 3.1. Hence the determinant
W(x) of system (3.9) is zero for all x ∈]a, b[. Therefore this system admits a
nonzero solution k. Consequently, the solutions, y
1
, y
2
, . . . , y
n
, of (3.3) are linearly
dependent.
Remark 3.2. The Wronskian of n linearly dependent functions, which are
suﬃciently diﬀerentiable on ]a, b[, is necessarily zero on ]a, b[, as can be seen
from the ﬁrst part of the proof of Theorem 3.3. But for functions which are not
solutions of the same linear homogeneous diﬀerential equation, a zero Wronskian
on ]a, b[ is not a suﬃcient condition for the linear dependence of these functions.
For instance, u
1
= x
3
and u
2
= [x[
3
are of class C
1
in the interval [−1, 1] and are
linearly independent, but satisfy W(x
3
, [x[
3
) = 0 identically.
Corollary 3.1. If the coeﬃcients a
0
(x), a
1
(x), . . . , a
n−1
(x) of (3.3) are con
tinuous on ]a, b[, then n solutions, y
1
, y
2
, . . . , y
n
, of (3.3) are linearly indepen
dent if and only if their Wronskian is not zero at a single point x
0
∈]a, b[.
Corollary 3.2. Suppose f
1
(x), f
2
(x), . . . , f
n
(x) are n functions which pos
sess continuous nthorder derivatives on a real interval I, and W(f
1
, . . . , f
n
)(x) ,=
0 on I. Then there exists a unique homogeneous diﬀerential equation of order n
(with coeﬃcient of y
(n)
one) for which these functions are linearly independent
solutions, namely
(−1)
n
W(y, f
1
, . . . , f
n
)
W(f
1
, . . . , f
n
)
= 0.
3.1. HOMOGENEOUS EQUATIONS 49
Example 3.1. Show that the functions
y
1
(x) = coshx and y
2
(x) = sinh x
are linearly independent.
Solution. Since y
1
and y
2
are twice continuously diﬀerentiable and
W(y
1
, y
2
)(x) =
¸
¸
¸
¸
coshx sinh x
sinh x coshx
¸
¸
¸
¸
= cosh
2
x −sinh
2
x = 1,
for all x, then, by Corollary 3.2, y
1
and y
2
are linearly independent. Incidently,
it is easy to see that y
1
and y
2
are solutions of the diﬀerential equation
y
′′
−y = 0.
In the previous solution we have used the following identity:
cosh
2
x −sinh
2
x =
_
e
x
+e
−x
2
_
2
−
_
e
x
−e
−x
2
_
2
=
1
4
_
e
2x
+e
−2x
+ 2 e
x
e
−x
−e
2x
−e
−2x
+ 2 e
x
e
−x
_
= 1.
Example 3.2. Use the Wronskian of the functions
y
1
(x) = x
m
and y
2
(x) = x
m
ln x
to show that they are linearly independent for x > 0 and construct a secondorder
diﬀerential equation for which they are solutions.
Solution. We verify that the Wronskian of y
1
and y
2
does not vanish for
x > 0:
W(y
1
, y
2
)(x) =
¸
¸
¸
¸
x
m
x
m
ln x
mx
m−1
mx
m−1
ln x +x
m−1
¸
¸
¸
¸
= x
m
x
m−1
¸
¸
¸
¸
1 ln x
m mln x + 1
¸
¸
¸
¸
= x
2m−1
(1 +m ln x −m ln x) = x
2m−1
,= 0, for all x > 0.
Hence, by Corollary 3.2, y
1
and y
2
are linearly independent. By the same corollary
W(y, x
m
, x
m
ln x)(x) =
¸
¸
¸
¸
¸
¸
y x
m
x
m
ln x
y
′
mx
m−1
mx
m−1
ln x +x
m−1
y
′′
m(m− 1)x
m−2
m(m−1)x
m−2
ln x + (2m−1)x
m−2
¸
¸
¸
¸
¸
¸
= 0.
Multiplying the second and third rows by x and x
2
, respectively, dividing the
second and third columns by x
m
, subtracting m times the ﬁrst row from the
second row and m(m − 1) times the ﬁrst row from the third row, one gets the
equivalent simpliﬁed determinantal equation
¸
¸
¸
¸
¸
¸
y 1 ln x
xy
′
−my 0 1
x
2
y
′′
−m(m−1)y 0 2m−1
¸
¸
¸
¸
¸
¸
= 0,
50 3. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER
which upon expanding by the second column produces the Euler–Cauchy equation
x
2
y
′′
+ (1 −2m)xy
′
+m
2
y = 0.
Definition 3.4. We say that n linearly independent solutions, y
1
, y
2
, . . . , y
n
,
of (3.3) on ]a, b[ form a fundamental system or basis on ]a, b[.
Definition 3.5. Let y
1
, y
2
, . . . , y
n
be a fundamental system for (3.3). A
solution of (3.3) on ]a, b[ of the form
y(x) = c
1
y
1
(x) +c
2
y
2
(x) + +c
n
y
n
(x), (3.10)
where c
1
, c
2
, . . . , c
n
are n arbitrary constants, is said to be a general solution of
(3.3) on ]a, b[.
Theorem 3.4. If the functions a
0
(x), a
1
(x), . . . , a
n−1
(x) are continuous on
]a, b[, then the linear homogeneous equation (3.3) admits a general solution on
]a, b[.
Proof. By Theorem 3.2, for each i, i = 1, 2, . . . , n, the initial value problem
(3.5),
Ly = 0, with y
(i−1)
(x
0
) = 1, y
(j−1)
(x
0
) = 0, j ,= i,
admits one (and only one) solution y
i
(x) such that
y
(i−1)
i
(x
0
) = 1, y
(j−1)
i
(x
0
) = 0, j = 1, 2, . . . , i −1, i + 1, . . . , n.
Then the Wronskian W satisﬁes the following relation
W(y
1
, y
2
, . . . , y
n
)(x
0
) =
¸
¸
¸
¸
¸
¸
¸
¸
¸
y
1
(x
0
) y
n
(x
0
)
y
′
1
(x
0
) y
′
n
(x
0
)
.
.
.
.
.
.
y
(n−1)
1
(x
0
) y
(n−1)
n
(x
0
)
¸
¸
¸
¸
¸
¸
¸
¸
¸
= [I
n
[ = 1,
where I
n
is the identity matrix of order n. It follows from Corollary 3.1 that the
solutions are independent.
Theorem 3.5. If the functions a
0
(x), a
1
(x), . . . , a
n−1
(x) are continuous on
]a, b[, then the solution of the initial value problem (3.5) on ]a, b[ is obtained from
a general solution.
Proof. Let
y = c
1
y
1
+c
2
y
2
+ +c
n
y
n
be a general solution of (3.3). The system
_
¸
¸
¸
_
y
1
(x
0
) y
n
(x
0
)
y
′
1
(x
0
) y
′
n
(x
0
)
.
.
.
.
.
.
y
(n−1)
1
(x
0
) y
(n−1)
n
(x
0
)
_
¸
¸
¸
_
_
¸
¸
¸
_
c
1
c
2
.
.
.
c
n
_
¸
¸
¸
_
=
_
¸
¸
¸
_
k
1
k
2
.
.
.
k
n
_
¸
¸
¸
_
admits a unique solution c since the determinant of the system is nonzero.
3.2. LINEAR HOMOGENEOUS EQUATIONS 51
3.2. Linear Homogeneous Equations
Consider the linear homogeneous diﬀerential equation of order n,
y
(n)
+a
n−1
y
(n−1)
+ +a
1
y
′
+a
0
y = 0, (3.11)
with constant coeﬃcients, a
0
, a
1
, . . . , a
n−1
. Let L denote the diﬀerential operator
on the lefthand side,
L := D
n
+a
n−1
D
n−1
+ +a
1
D +a
0
I, D :=
′
=
d
dx
. (3.12)
Putting y(x) = e
λx
in (3.11), we obtain the characteristic equation
p(λ) := λ
n
+a
n−1
λ
n−1
+ +a
1
λ +a
0
= 0. (3.13)
If the n roots of p(λ) = 0 are distinct, we have n independent solutions,
y
1
(x) = e
λ1x
, y
2
(x) = e
λ2x
, . . . , y
n
(x) = e
λnx
, (3.14)
and the general solution is of the form
y(x) = c
1
e
λ1x
+c
2
e
λ2x
+ +c
n
e
λnx
. (3.15)
If (3.13) has a double root, say, λ
1
= λ
2
, we have two independent solutions
of the form
y
1
(x) = e
λ1x
, y
2
(x) = xe
λ1x
.
Similarly, if there is a triple root, say, λ
1
= λ
2
= λ
3
, we have three independent
solutions of the form
y
1
(x) = e
λ1x
, y
2
(x) = xe
λ1x
, y
3
(x) = x
2
e
λ1x
.
We prove the following theorem.
Theorem 3.6. Let µ be a root of multiplicity m of the characteristic equation
(3.13). Then the diﬀerential equation (3.11) has m independent solutions of the
form
y
1
(x) = e
µx
, y
2
(x) = xe
µx
, . . . , y
m
(x) = x
m−1
e
µx
. (3.16)
Proof. Let us write
p(D)y = (D
n
+a
n−1
D
n−1
+ + a
1
D +a
0
)y = 0.
Since, by hypothesis,
p(λ) = q(λ)(λ −µ)
m
,
and the coeﬃcients are constant, the diﬀerential operator p(D) can be factored
in the form
p(D) = q(D)(D −µ)
m
.
We see by recurrence that the m functions (3.16),
x
k
e
µx
, k = 0, 1, . . . , m−1,
52 3. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER
satisfy the following equations:
(D −µ)
_
x
k
e
µx
_
= kx
k−1
e
µx
+µx
k
e
µx
−µx
k
e
µx
= kx
k−1
e
µx
,
(D−µ)
2
_
x
k
e
µx
_
= (D−µ)
_
kx
k−1
e
µx
_
= k(k −1)x
k−2
e
µx
,
.
.
.
(D −µ)
k
_
x
k
e
µx
_
= k! e
µx
,
(D −µ)
k+1
_
x
k
e
µx
_
= k! (e
µx
−e
µx
) = 0.
Since m ≥ k + 1, we have
(D −µ)
m
_
x
k
e
µx
_
= 0, k = 0, 1, . . . , m−1.
Hence, by Lemma 3.2 below, the functions (3.16) are m independent solutions of
(3.11).
Lemma 3.2. Let
y
1
(x) = e
µx
, y
2
(x) = xe
µx
, . . . , y
m
(x) = x
m−1
e
µx
,
be m solutions of a linear homogeneous diﬀerential equation. Then they are in
dependent.
Proof. By Corollary 3.1, it suﬃces to show that the Wronskian of the solu
tions is nonzero at x = 0. We have seen, in the proof of the preceding theorem,
that
(D −µ)
k
_
x
k
e
µx
_
= k! e
µx
,
that is,
D
k
_
x
k
e
µx
_
= k! e
µx
+ terms in x
l
e
µx
, l = 1, 2, . . . , k −1.
Hence
D
k
_
x
k
e
µx
_ ¸
¸
x=0
= k!, D
k
_
x
k+l
e
µx
_ ¸
¸
x=0
= 0, l ≥ 1.
It follows that the matrix M of the Wronskian is lower triangular with m
i,i
=
(i −1)!,
W(0) =
¸
¸
¸
¸
¸
¸
¸
¸
¸
¸
¸
¸
0! 0 0 . . . 0
1! 0 0
2! 0
.
.
.
.
.
.
.
.
.
.
.
. 0
. . . (m−1)!
¸
¸
¸
¸
¸
¸
¸
¸
¸
¸
¸
¸
=
m−1
k=0
k! ,= 0.
Example 3.3. Find the general solution of
(D
4
−13D
2
+ 36I)y = 0.
Solution. The characteristic polynomial is easily factored,
λ
4
−13λ
2
+ 36 = (λ
2
−9)(λ
2
−4)
= (λ + 3)(λ −3)(λ + 2)(λ −2).
Hence,
y(x) = c
1
e
−3x
+c
2
e
3x
+ c
3
e
−2x
+c
4
e
2x
.
3.2. LINEAR HOMOGENEOUS EQUATIONS 53
The Matlab polynomial solver.— To ﬁnd the zeros of the characteristic poly
nomial
λ
4
−13λ
2
+ 36
with Matlab, one represents the polynomial by the vector of its coeﬃcients,
p =
_
1 0 −13 0 36
¸
and uses the command roots on p.
>> p = [1 0 13 0 36]
p = 1 0 13 0 36
>> r = roots(p)
r =
3.0000
3.0000
2.0000
2.0000
In fact the command roots constructs a matrix C of p (see the proof of Theo
rem 3.2)
C =
_
¸
¸
_
0 13 0 −36
1 0 0 0
0 1 0 0
0 0 1 0
_
¸
¸
_
and uses the QR algorithm to ﬁnd the eigenvalues of C which, in fact, are the
zeros of p.
>> p = [1 0 13 0 36];
>> C = compan(p)
C =
0 13 0 36
1 0 0 0
0 1 0 0
0 0 1 0
>> eigenvalues = eig(C)’
eigenvalues = 3.0000 3.0000 2.0000 2.0000
Example 3.4. Find the general solution of the diﬀerential equation
(D −I)
3
y = 0.
Solution. The characteristic polynomial (λ −1)
3
admit a triple zero:
λ
1
= λ
2
= λ
3
= 1,
Hence:
y(x) = c
1
e
x
+c
2
xe
x
+c
3
x
2
e
x
.
Example 3.5. Find the general solution of the Euler–Cauchy equation
x
3
y
′′′
−3x
2
y
′′
+ 6xy
′
−6y = 0.
54 3. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER
Solution. (a) The analytic solution.— Putting
y(x) = x
m
in the diﬀerential equation, we have
m(m− 1)(m−2)x
m
−3m(m−1)x
m
+ 6mx
m
−6x
m
= 0,
and dividing by x
m
, we obtain the characteristic equation,
m(m−1)(m−2) −3m(m−1) + 6m−6 = 0.
Noting that m−1 is a common factor, we have
(m−1)[m(m−2) −3m+ 6] = (m−1)(m
2
−5m+ 6)
= (m−1)(m−2)(m−3) = 0.
Thus,
y(x) = c
1
x +c
2
x
2
+c
3
x
3
.
(b) The Matlab symbolic solution.—
dsolve(’x^3*D3y3*x^2*D2y+6*x*Dy6*y=0’,’x’)
y = C1*x+C2*x^2+C3*x^3
Example 3.6. Given that
y
1
(x) = e
x
2
is a solution of the secondorder diﬀerential equation
Ly := y
′′
−4xy
′
+ (4x
2
−2)y = 0,
ﬁnd a second independent solution.
Solution. (a) The analytic solution.— Following the method of variation of
parameters, we put
y
2
(x) = u(x)y
1
(x)
in the given diﬀerential equation and obtain
(4x
2
−2)y
2
= (4x
2
−2)uy
1
,
−4xy
′
2
= −4xuy
′
1
−4xu
′
y
1
,
y
′′
2
= uy
′′
1
+ 2u
′
y
′
1
+u
′′
y
1
.
Upon addition of the left and righthand sides, respectively, we have
Ly
2
= uLy
1
+ (2y
′
1
−4xy
1
)u
′
+y
1
u
′′
.
We note that Ly
1
= 0 and Ly
2
= 0 since y
1
is a solution and we want y
2
to be a
solution. Replacing y
1
by its value in the diﬀerential equation for u, we obtain
e
x
2
u
′′
+
_
4xe
x
2
−4xe
x
2
_
u
′
= 0.
It follows that
u
′′
= 0 =⇒ u
′
= k
1
=⇒ u = k
1
x +k
2
and
y
2
(x) = (k
1
x +k
2
)e
x
2
.
3.3. LINEAR NONHOMOGENEOUS EQUATIONS 55
It suﬃces to take k
2
= 0 since k
2
e
x
2
is contained in y
1
, and k
1
= 1 since the
solution xe
x
2
will be multiplied by an arbitrary constant in the general solution.
Thus, the general solution is
y(x) = (c
1
+c
2
x) e
x
2
.
(b) The Matlab symbolic solution.—
dsolve(’D2y4*x*Dy+(4*x^22)*y=0’,’x’)
y = C1*exp(x^2)+C2*exp(x^2)*x
3.3. Linear Nonhomogeneous Equations
Consider the linear nonhomogeneous diﬀerential equation of order n,
Ly := y
(n)
+a
n−1
(x)y
(n−1)
+ +a
1
(x)y
′
+a
0
(x)y = r(x). (3.17)
Let
y
h
(x) = c
1
y
1
(x) +c
2
y
2
(x) + +c
n
y
n
(x), (3.18)
be a general solution of the homogeneous equation
Ly = 0.
Moreover, let y
p
(x) be a particular solution of the nonhomogeneous equation
(3.17). Then,
y
g
(x) = y
h
(x) +y
p
(x)
is a general solution of (3.17). In fact,
Ly
g
= Ly
h
+Ly
p
= 0 +r(x).
Example 3.7. Find a general solution y
g
(x) of
y
′′
−y = 3 e
2x
if
y
p
(x) = e
2x
is a particular solution.
Solution. (a) The analytic solution.— It is easy to see that e
2x
is a partic
ular solution. Since
y
′′
−y = 0 =⇒ λ
2
−1 = 0 =⇒ λ = ±1,
a general solution to the homogeneous equation is
y
h
(x) = c
1
e
x
+c
2
e
−x
and a general solution of the nonhomogeneous equation is
y
g
(x) = c
1
e
x
+c
2
e
−x
+e
2x
.
(b) The Matlab symbolic solution.—
dsolve(’D2yy3*exp(2*x)’,’x’)
y = (exp(2*x)*exp(x)+C1*exp(x)^2+C2)/exp(x)
z = expand(y)
z = exp(x)^2+exp(x)*C1+1/exp(x)*C2
56 3. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER
Here is a second method for solving linear ﬁrstorder diﬀerential equations.
Example 3.8. Find the general solution of the ﬁrstorder linear nonhomoge
neous equation
Ly := y
′
+f(x)y = r(x). (3.19)
Solution. The homogeneous equation Ly = 0 is separable:
dy
y
= −f(x) dx =⇒ ln [y[ = −
_
f(x) dx =⇒ y
h
(x) = e
−
R
f(x) dx
.
No arbitrary constant is needed here. To ﬁnd a particular solution by variation
of parameters we put
y
p
(x) = u(x)y
h
(x)
in the nonhomogeneous equation Ly = r(x):
y
′
p
= uy
′
h
+u
′
y
h
f(x)y
p
= uf(x)y
h
.
Adding the left and righthand sides of these expressions we have
Ly
p
= uLy
h
+u
′
y
h
= u
′
y
h
= r(x).
Since the diﬀerential equation u
′
y
h
= r is separable,
du = e
R
f(x) dx
r(x) dx,
it can be integrated directly,
u(x) =
_
e
R
f(x) dx
r(x) dx.
No arbitrary constant is needed here. Thus,
y
p
(x) = e
−
R
f(x) dx
_
e
R
f(x) dx
r(x) dx.
Hence, the general solution of (3.19) is
y(x) = cy
h
(x) +y
p
(x)
= e
−
R
f(x) dx
__
e
R
f(x) dx
r(x) dx +c
_
.
In the next two sections we present two methods to ﬁnd particular solutions,
namely, the method of undetermined coeﬃcients and the method of variation of
parameters. The ﬁrst method, which is more restrictive than the second, does not
always require the general solution of the homogeneous equation, but the second
always does.
3.4. METHOD OF UNDETERMINED COEFFICIENTS 57
3.4. Method of Undetermined Coeﬃcients
Consider the linear nonhomogeneous diﬀerential equation of order n,
y
(n)
+a
n−1
y
(n−1)
+ +a
1
y
′
+a
0
y = r(x), (3.20)
with constant coeﬃcients, a
0
, a
1
, . . . , a
n−1
.
If the dimension of the space spanned by the derivatives of the functions on
the righthand side of (3.20) is ﬁnite, we can use the method of undetermined
coeﬃcients.
Here is a list of usual functions r(x) which have a ﬁnite number of linearly
independent derivatives. We indicate the dimension of the space of derivatives.
r(x) = x
2
+ 2x + 1, r
′
(x) = 2x + 2, r
′′
(x) = 2,
r
(k)
(x) = 0, k = 3, 4, . . . , =⇒ dim. = 3;
r(x) = cos 2x + sin 2x, r
′
(x) = −2 sin2x + 2 cos 2x,
r
′′
(x) = −4r(x), =⇒ dim. = 2;
r(x) = xe
x
, r
′
(x) = e
x
+xe
x
,
r
′′
(x) = 2r
′
(x) −r(x), =⇒ dim. = 2.
The method of undetermined coeﬃcients consists in choosing for a particular
solution a linear combination,
y
p
(x) = c
1
p
1
(x) +c
2
p
2
(x) + +c
l
p
l
(x), (3.21)
of the independent derivatives of the function r(x) on the righthand side. We
determine the coeﬃcients c
k
by substituting y
p
(x) in (3.20) and equating coeﬃ
cients. A bad choice or a mistake leads to a contradiction.
Example 3.9. Find a general solution y
g
(x) of
Ly := y
′′
+y = 3x
2
by the method of undetermined coeﬃcients.
Solution. (a) The analytic solution.— Put
y
p
(x) = ax
2
+bx +c
in the diﬀerential equation and add the terms on the left and the righthand
sides, respectively,
y
p
= ax
2
+bx +c
y
′′
p
= 2a
Ly
p
= ax
2
+bx + (2a +c)
= 3x
2
.
Identifying the coeﬃcients of 1, x and x
2
on both sides, we have
a = 3, b = 0, c = −2a = −6.
The general solution of Ly = 0 is
y
h
(x) = Acos x +Bsinx.
Hence, the general solution of Ly = 3x
2
is
y
g
(x) = Acos x +Bsin x + 3x
2
− 6.
58 3. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER
(b) The Matlab symbolic solution.—
dsolve(’D2y+y=3*x^2’,’x’)
y = 6+3*x^2+C1*sin(x)+C2*cos(x)
Important remark. If for a chosen term p
j
(x) in (3.21), x
k
p
j
(x) is a solution
of the homogeneous equation, but x
k+1
p
j
(x) is not, then p
j
(x) must be replaced
by x
k+1
p
j
(x). Naturally, we exclude from y
p
the terms which are in the space of
solution of the homogeneous equation since they contribute zero to the righthand
side.
Example 3.10. Find the form of a particular solution for solving the equation
y
′′
−4y
′
+ 4y = 3 e
2x
+ 32 sinx
by undetermined coeﬃcients.
Solution. Since the general solution of the homogeneous equation is
y
h
(x) = c
1
e
2x
+c
2
xe
2x
,
a particular solution is of the form
y
p
(x) = ax
2
e
2x
+b cos x +c sinx.
Example 3.11. Solve the initial value problem
y
′′′
−y
′
= 4 e
−x
+ 3 e
2x
, y(0) = 0, y
′
(0) = −1, y
′′
(0) = 2
and plot the solution.
Solution. (a) The analytic solution.— The characteristic equation is
λ
3
−λ = λ(λ −1)(λ + 1) = 0.
The general solution of the homogeneous equation is
y
h
(x) = c
1
+c
2
e
x
+c
3
e
−x
.
Considering that e
−x
is contained in the righthand side of the diﬀerential equa
tion, we take a particular solution of the form
y
p
(x) = axe
−x
+b e
2x
.
Then,
y
′
= −axe
−x
+a e
−x
+ 2b e
2x
,
y
′′
= axe
−x
−2a e
−x
+ 4b e
2x
,
y
′′′
= −axe
−x
+ 3a e
−x
+ 8b e
2x
.
Hence,
y
′′′
−y
′
= 2a e
−x
+ 6b e
2x
= 4 e
−x
+ 3 e
2x
, for all x.
Identifying the coeﬃcients of e
−x
and e
2x
, we have
a = 2, b =
1
2
.
3.4. METHOD OF UNDETERMINED COEFFICIENTS 59
Thus, a particular solution of the nonhomogeneous equation is
y
p
(x) = 2xe
−x
+
1
2
e
2x
and the general solution of the nonhomogeneous equation is
y(x) = c
1
+c
2
e
x
+c
3
e
−x
+ 2xe
−x
+
1
2
e
2x
.
The arbitrary constants c
1
, c
2
and c
3
are determined by the initial conditions:
y(0) = c
1
+c
2
+c
3
+
1
2
= 0,
y
′
(0) = c
2
−c
3
+3 = −1,
y
′′
(0) = c
2
+c
3
−2 = 2,
yielding the linear algebraic system
c
1
+c
2
+c
3
= −
1
2
,
c
2
−c
3
= −4,
c
2
+c
3
= 4,
whose solution is
c
1
= −
9
2
, c
2
= 0, c
3
= 4,
and the unique solution is
y(x) = −
9
2
+ 4 e
−x
+ 2xe
−x
+
1
2
e
2x
.
(b) The Matlab symbolic solution.—
dsolve(’D3yDy=4*exp(x)+3*exp(2*x)’,’y(0)=0’,’Dy(0)=1’,’D2y(0)=2’,’x’)
y = 1/2*(8+exp(3*x)+4*x9*exp(x))/exp(x)
z =expand(y)
z = 4/exp(x)+1/2*exp(x)^2+2/exp(x)*x9/2
(c) The Matlab numeric solution.— To rewrite the thirdorder diﬀerential
equation as a system of ﬁrstorder equations, we put
y(1) = y,
y(2) = y
′
,
y(3) = y
′′
.
Thus, we have
y(1)
′
= y(2),
y(2)
′
= y(3),
y(3)
′
= y(2) + 4 ∗ exp(−x) + 3 ∗ exp(2 ∗ x).
The Mﬁle exp39.m:
function yprime = exp39(x,y);
yprime=[y(2); y(3); y(2)+4*exp(x)+3*exp(2*x)];
The call to the ode23 solver and the plot command:
60 3. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER
0 0.5 1 1.5 2
−5
0
5
10
15
20
25
Plot of solution
y
x
Figure 3.1. Graph of solution of the linear equation in Example 3.11.
xspan = [0 2]; % solution for x=0 to x=2
y0 = [0;1;2]; % initial conditions
[x,y] = ode23(’exp39’,xspan,y0);
plot(x,y(:,1))
The numerical solution is plotted in Fig. 3.1.
3.5. Particular Solution by Variation of Parameters
Consider the linear nonhomogeneous diﬀerential equation of order n,
Ly := y
(n)
+a
n−1
(x)y
(n−1)
+ +a
1
(x)y
′
+a
0
(x)y = r(x), (3.22)
in standard form, that is, the coeﬃcient of y
n
is equal to 1.
Let
y
h
(x) = c
1
y
1
(x) +c
2
y
2
(x) + +c
n
y
n
(x), (3.23)
be a general solution of the homogeneous equation
Ly = 0.
For simplicity, we derive the method of variation of parameters in the case
n = 3,
Ly := y
′′′
+a
2
(x)y
′′
+a
1
(x)y
′
+a
0
(x)y = r(x), (3.24)
The general case follows in the same way.
Following an idea due to Lagrange, we take a particular solution of the form
y
p
(x) = c
1
(x)y
1
(x) +c
2
(x)y
2
(x) +c
3
(x)y
3
(x), (3.25)
where we let the parameters c
1
, c
2
and c
3
of the general solution y
h
vary, thus
giving us three degrees of freedom.
We diﬀerentiate y
p
(x):
y
′
p
(x) =
_
c
′
1
(x)y
1
(x) +c
′
2
(x)y
2
(x) +c
′
3
(x)y
3
(x)
¸
+c
1
(x)y
′
1
(x) +c
2
(x)y
′
2
(x) +c
3
(x)y
′
3
(x)
= c
1
(x)y
′
1
(x) + c
2
(x)y
′
2
(x) +c
3
(x)y
′
3
(x),
3.5. PARTICULAR SOLUTION BY VARIATION OF PARAMETERS 61
where, using one degree of freedom, we let the term in square brackets be zero,
c
′
1
(x)y
1
(x) +c
′
2
(x)y
2
(x) +c
′
3
(x)y
3
(x) = 0. (3.26)
We diﬀerentiate y
′
p
(x):
y
′′
p
(x) =
_
c
′
1
(x)y
′
1
(x) +c
′
2
(x)y
′
2
(x) +c
′
3
(x)y
′
3
(x)
¸
+c
1
(x)y
′′
1
(x) +c
2
(x)y
′′
2
(x) +c
3
(x)y
′′
3
(x)
= c
1
(x)y
′′
1
(x) +c
2
(x)y
′′
2
(x) +c
3
(x)y
′′
3
(x),
where, using another degree of freedom, we let the term in square brackets be
zero,
c
′
1
(x)y
′
1
(x) +c
′
2
(x)y
′
2
(x) +c
′
3
(x)y
′
3
(x) = 0. (3.27)
Lastly, we diﬀerentiate y
′′
p
(x):
y
′′′
p
(x) =
_
c
′
1
(x)y
′′
1
(x) +c
′
2
(x)y
′′
2
(x) +c
′
3
(x)y
′′
3
(x)
¸
+
_
c
1
(x)y
′′′
1
(x) +c
2
(x)y
′′′
2
(x) +c
3
(x)y
′′′
3
(x)
¸
.
Using the expressions obtained for y
p
, y
′
p
, y
′′
p
and y
′′′
p
, we have
Ly
p
= y
′′′
p
+a
2
y
′′
p
+a
1
y
′
p
+a
0
y
p
= c
′
1
y
′′
1
+c
′
2
y
′′
2
+c
′
3
y
′′
3
+
_
c
1
Ly
1
+c
2
Ly
2
+c
3
Ly
3
¸
= c
′
1
y
′′
1
+c
′
2
y
′′
2
+c
′
3
y
′′
3
= r(x),
since y
1
, y
2
and y
3
are solutions of Ly = 0 and hence the term in square brackets
is zero. Moreover, we want y
p
to satisfy Ly
p
= r(x), which we can do by our third
and last degree of freedom. Hence we have
c
′
1
y
′′
1
+c
′
2
y
′′
2
+c
′
3
y
′′
3
= r(x). (3.28)
We rewrite the three equations (3.26)–(3.28) in the unknowns c
′
1
(x), c
′
2
(x) and
c
′
3
(x) in matrix form,
_
_
y
1
(x) y
2
(x) y
3
(x)
y
′
1
(x) y
′
2
(x) y
′
3
(x)
y
′′
1
(x) y
′′
2
(x) y
′′
3
(x)
_
_
_
_
c
′
1
(x)
c
′
2
(x)
c
′
3
(x)
_
_
=
_
_
0
0
r(x)
_
_
, (3.29)
that is,
M(x)c
′
(x) =
_
_
0
0
r(x)
_
_
.
Since y
1
, y
2
and y
3
form a fundamental system, by Corollary 3.1 their Wronskian
does not vanish,
W(y
1
, y
2
, y
3
) = det M ,= 0.
We solve the linear system for c
′
(x) and integrate the solution
c(x) =
_
c
′
(x) dx.
No constants of integrations are needed here since the general solution will contain
three arbitrary constants. The general solution is (3.24) is
y
g
(x) = Ay
1
+By
2
+Cy
3
+c
1
(x)y
1
+c
2
(x)y
2
+c
3
(x)y
3
. (3.30)
62 3. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER
Because of the particular form of the righthand side of system (3.29), Cramer’s
rule leads to nice formulae for the solution of this system in two and three dimen
sions. In 2D, we have
y
p
(x) = −y
1
(x)
_
y
2
(x)r(x)
W(x)
dx +y
2
(x)
_
y
1
(x)r(x)
W(x)
dx. (3.31)
In 3D, solve (3.29) for c
′
1
, c
′
2
and c
′
3
by Cramer’s rule:
c
′
1
(x) =
r
W
¸
¸
¸
¸
y
2
y
3
y
′
2
y
′
3
¸
¸
¸
¸
, c
′
2
(x) = −
r
W
¸
¸
¸
¸
y
1
y
3
y
′
1
y
′
3
¸
¸
¸
¸
, c
′
3
(x) =
r
W
¸
¸
¸
¸
y
1
y
2
y
′
1
y
′
1
¸
¸
¸
¸
,
(3.32)
integrate the c
′
i
with respect to x and form y
p
(x) as in (3.25).
Remark 3.3. If the coeﬃcient a
n
(x) of y
(n)
is not equal to 1, we must divide
the righthand side of (3.29) by a
n
(x), that is, replace r(x) by r(x)/a
n
(x).
Example 3.12. Find the general solution of the diﬀerential equation
(D
2
+ 1)y = sec xtan x,
by the method of variation of parameters.
Solution. (a) The analytic solution.— Since the space of derivatives of the
righthand side is inﬁnite, the method of undetermined coeﬃcients is not useful
in this case.
We know that the general solution of the homogeneous equation is
y
h
(x) = c
1
cos x +c
2
sin x.
Looking for a particular solution of the nonhomogeneous equation by the method
of variation of parameters, we put
y
p
(x) = c
1
(x) cos x +c
2
(x) sin x,
and have
_
cos x sin x
−sinx cos x
_ _
c
′
1
(x)
c
′
2
(x)
_
=
_
0
sec xtan x
_
,
that is,
Q(x)c
′
(x) =
_
0
sec xtan x
_
. (3.33)
In this particular case, the matrix Q is orthogonal, that is,
QQ
T
=
_
cos x sin x
−sinx cos x
_ _
cos x −sin x
sin x cos x
_
=
_
1 0
0 1
_
.
It then follows that the inverse Q
−1
of Q is the transpose Q
T
of Q,
Q
−1
= Q
T
.
In this case, we obtain c
′
by left multiplication of (3.33) by Q
T
,
c
′
= Q
T
Qc
′
= Q
T
_
0
sec xtan x
_
,
that is,
_
c
′
1
(x)
c
′
2
(x)
_
=
_
cos x −sinx
sinx cos x
_ _
0
sec xtan x
_
.
3.5. PARTICULAR SOLUTION BY VARIATION OF PARAMETERS 63
Hence,
c
′
1
= −
sinx
cos x
tan x = −tan
2
x,
c
′
2
=
cos x
cos x
tan x = tan x =
sin x
cos x
,
which, after integration, become
c
1
= −
_
(sec
2
x −1) dx = x −tan x,
c
2
= −ln[ cos x[ = ln [ sec x[.
Thus, the particular solution is
y
p
(x) = (x −tan x) cos x + (ln [ sec x[) sin x
and the general solution is
y(x) = y
h
(x) +y
p
(x)
= Acos x + Bsin x + (x −tan x) cos x + (ln [ sec x[) sin x.
(b) The Matlab symbolic solution.—
dsolve(’D2y+y=sec(x)*tan(x)’,’x’)
y = log(cos(x))*sin(x)sin(x)+x*cos(x)+C1*sin(x)+C2*cos(x)
Example 3.13. Find the general solution of the diﬀerential equation
y
′′′
−y
′
= coshx
by the method of variation of parameters.
Solution. The characteristic equation is
λ
3
−λ = λ(λ
2
−1) = 0 =⇒ λ
1
= 0, λ
2
= 1, λ
3
= −1.
The general solution of the homogeneous equation is
y
h
(x) = c
1
+c
2
e
x
+c
3
e
−x
.
By variation of parameters, the particular solution of the nonhomogeneous equa
tion is
y
p
(x) = c
1
(x) +c
2
(x) e
x
+c
3
(x) e
−x
.
Thus, we have the system
_
_
1 e
x
e
−x
0 e
x
−e
−x
0 e
x
e
−x
_
_
_
_
c
′
1
(x)
c
′
2
(x)
c
′
3
(x)
_
_
=
_
_
0
0
cosh x
_
_
.
We solve this system by Gaussian elimination:
_
_
1 e
x
e
−x
0 e
x
−e
−x
0 0 2e
−x
_
_
_
_
c
′
1
(x)
c
′
2
(x)
c
′
3
(x)
_
_
=
_
_
0
0
cosh x
_
_
.
64 3. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER
Hence
c
′
3
=
1
2
e
x
cosh x =
1
2
e
x
_
e
x
+e
−x
2
_
=
1
4
_
e
2x
+ 1
_
,
c
′
2
= e
−2x
c
′
3
=
1
4
_
1 +e
−2x
_
,
c
′
1
= −e
x
c
′
2
−e
−x
c
′
3
= −
1
2
_
e
x
+e
−x
_
= −coshx,
and after integration, we have
c
1
= −sinh x
c
2
=
1
4
_
x −
1
2
e
−2x
_
c
3
=
1
4
_
1
2
e
2x
+x
_
.
The particular solution is
y
p
(x) = −sinh x +
1
4
_
xe
x
−
1
2
e
−x
_
+
1
4
_
1
2
e
x
+xe
−x
_
= −sinh x +
1
4
x
_
e
x
+e
−x
_
+
1
8
_
e
x
−e
−x
_
=
1
2
xcoshx −
3
4
sinh x.
The general solution of the nonhomogeneous equation is
y
g
(x) = A +B
′
e
x
+C
′
e
−x
+
1
2
xcoshx −
3
4
sinh x
= A +Be
x
+C e
−x
+
1
2
xcosh x,
where we have used the fact that the function
sinh x =
e
x
−e
−x
2
is already contained in the general solution y
h
of the homogeneous equation.
Symbolic Matlab does not produce a general solution in such a simple form.
If one uses the method of undetermined coeﬃcients to solve this problem, one
has to take a particular solution of the form
y
p
(x) = axcoshx +bxsinh x,
since coshx and sinh x are linear combinations of e
x
and e
−x
which are solutions
of the homogeneous equation. In fact, putting
y
p
(x) = axcosh x +bxsinh x
in the equation y
′′′
−y
′
= coshx, we obtain
y
′′′
p
−y
′
p
= 2a coshx + 2b sinhx
= coshx,
whence
a =
1
2
and b = 0.
3.5. PARTICULAR SOLUTION BY VARIATION OF PARAMETERS 65
Example 3.14. Find the general solution of the diﬀerential equation
Ly := y
′′
+ 3y
′
+ 2y =
1
1 +e
x
.
Solution. Since the dimension of the space of derivatives of the righthand
side is inﬁnite, one has to use the method of variation of parameters.
It is to be noted that the symbolic Matlab command dsolve produces a
severallinelong solution that is unusable. We therefore follow the theoretical
method of Lagrange but do the simple algebraic and calculus manipulations by
symbolic Matlab.
The characteristic polynomial of the homogeneous equation Ly = 0 is
λ
2
+ 3λ + 2 = (λ + 1)(λ + 2) = 0 =⇒ λ
1
= −1, λ
2
= −2.
Hence, the general solution y
h
(x) to Ly = 0 is
y
h
(x) = c
1
e
−x
+c
2
e
−2x
.
By variation of parameters, a particular solution of the inhomogeneous equation
is searched in the form
y
p
(x) = c
1
(x) e
−x
+c
2
(x) e
−2x
.
The functions c
1
(x) and c
2
(x) are the integrals of the solutions c
′
1
(x) and c
′
2
(x)
of the algebraic system Ac
′
= b,
_
e
−x
e
−2x
−e
−x
−2 e
−2x
_ _
c
′
1
c
′
2
_
=
_
0
1/(1 +e
x
)
_
.
We use symbolic Matlab to solve this simple system.
>> clear
>> syms x real; syms c dc A b yp;
>> A = [exp(x) exp(2*x); exp(x) 2*exp(2*x)];
>> b=[0 1/(1+exp(x))]’;
>> dc = A\b % solve for c’(x)
dc =
[ 1/exp(x)/(1+exp(x))]
[ 1/exp(2*x)/(1+exp(x))]
>> c = int(dc) % get c(x) by integrating c’(x)
c =
[ log(1+exp(x))]
[ exp(x)+log(1+exp(x))]
>> yp=c’*[exp(x) exp(2*x)]’
yp =
log(1+exp(x))*exp(x)+(exp(x)+log(1+exp(x)))*exp(2*x)
Since −e
−x
is contained in y
h
(x), the general solution of the inhomogeneous
equation is
y(x) = Ae
−x
+Be
−2x
+ [ln (1 +e
x
)] e
−x
+ [ln (1 +e
x
)] e
−2x
.
Example 3.15. Solve the nonhomogeneous Euler–Cauchy diﬀerential equa
tion with given initial values:
Ly := 2x
2
y
′′
+xy
′
−3y = x
−3
, y(1) = 0, y
′
(1) = 2.
66 3. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER
Solution. Putting y = x
m
in the homogeneous equation Ly = 0 we obtain
the characteristic polynomial:
2m
2
−m−3 = 0 =⇒ m
1
=
3
2
, m
2
= −1.
Thus, general solution, y
h
(x), of Ly = 0 is
y
h
(x) = c
1
x
3/2
+c
2
x
−1
.
To ﬁnd a particular solution, y
p
(x), to the nonhomogeneous equation, we use the
method of variation of parameters since the dimension of the space of derivatives
of the righthand side is inﬁnite. We put
y
p
(x) = c
1
(x)x
3/2
+c
2
(x)x
−1
.
We need to solve the linear system
_
x
3/2
x
−1
3
2
x
1/2
−x
−2
_ _
c
′
1
c
′
2
_
=
_
0
1
2
x
−5
_
,
where the righthand side of the linear system has been divided by the coeﬃcient
2x
2
of y
′′
to have the equation in standard form with the coeﬃcient of y
′′
equal
to 1. Solving this system for c
′
1
and c
′
2
, we obtain
c
′
1
=
1
5
x
−11/2
, c
′
2
= −
1
5
x
−3
.
Thus, after integration,
c
1
(x) = −
2
45
x
−9/2
, c
2
(x) =
1
10
x
−2
,
and the general solution is
y(x) = Ax
3/2
+Bx
−1
−
2
45
x
−3
+
1
10
x
−3
= Ax
3/2
+Bx
−1
+
1
18
x
−3
.
The constants A and B are uniquely determined by the initial conditions. For
this we need the derivative, y
′
(x), of y(x),
y
′
(x) =
3
2
Ax
1/2
−Bx
−2
−
1
6
x
−4
.
Thus,
y(1) = A +B +
1
18
= 0,
y
′
(1) =
3
2
A −B −
1
6
= 2.
Solving for A and B, we have
A =
38
45
, B = −
9
10
.
The (unique) solution is
y(x) =
38
45
x
3/2
−
9
10
x
−1
+
1
18
x
−3
.
3.6. FORCED OSCILLATIONS 67
y
y = 0
m
r(t)
k
c
Amortisseur/Dashpot
Ressort/Spring
Masse/Mass
Poutre/Beam
Asservissement/External force
Figure 3.2. Forced damped system.
3.6. Forced Oscillations
We present two examples of forced vibrations of mechanical systems.
Consider a vertical spring attached to a rigid beam. The spring resists both
extension and compression with Hooke’s constant equal to k. Study the problem
of the forced damped vertical oscillation of a mass of mkg which is attached at
the lower end of the spring. (See Fig. 3.2). The damping constant is c and the
external force is r(t).
We refer to Example 2.4 for the derivation of the diﬀerential equation gov
erning the nonforced system, and simply add the external force to the righthand
side,
y
′′
+
c
m
y
′
+
k
m
y =
1
m
r(t).
Example 3.16 (Forced oscillation without resonance). Solve the initial value
problem with external force
Ly := y
′′
+ 9y = 8 sint, y(0) = 1, y
′
(0) = 1,
and plot the solution.
Solution. (a) The analytic solution.— The general solution of Ly = 0 is
y
h
(t) = Acos 3t +Bsin 3t.
Following the method of undetermined coeﬃcients, we choose y
p
of the form
y
p
(t) = a cos t +b sint.
Substituting this in Ly = 8 sint we obtain
y
′′
p
+ 9y
p
= (−a + 9a) cos t + (−b + 9b) sint
= 8 sint.
Identifying coeﬃcients on both sides, we have
a = 0, b = 1.
The general solution of Ly = 8 sint is
y(t) = Acos 3t +Bsin 3t + sin t.
68 3. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER
We determine A and B by means of the initial conditions:
y(0) = A = 1,
y
′
(t) = −3Asin3t + 3Bcos 3t + cos t,
y
′
(0) = 3B + 1 = 1 =⇒ B = 0.
The (unique) solution is
y(t) = cos 3t + sin t.
(b) The Matlab symbolic solution.—
dsolve(’D2y+9*y=8*sin(t)’,’y(0)=1’,’Dy(0)=1’,’t’)
y = sin(t)+cos(3*t)
(c) The Matlab numeric solution.— To rewrite the secondorder diﬀerential
equation as a system of ﬁrstorder equations, we put
y
1
= y,
y
2
= y
′
,
Thus, we have
y
′
1
= y
2
,
y
′
2
= −9y
1
+ 8 sint.
The Mﬁle exp312.m:
function yprime = exp312(t,y);
yprime = [y(2); 9*y(1)+8*sin(t)];
The call to the ode23 solver and the plot command:
tspan = [0 7]; % solution for t=0 to t=7
y0 = [1; 1]; % initial conditions
[x,y] = ode23(’exp312’,tspan,y0);
plot(x,y(:,1))
The numerical solution is plotted in Fig. 3.3.
Example 3.17 (Forced oscillation with resonance). Solve the initial value
problem with external force
Ly := y
′′
+ 9y = 6 sin 3t, y(0) = 1, y
′
(0) = 2,
and plot the solution.
Solution. (a) The analytic solution.— The general solution of Ly = 0 is
y
h
(t) = Acos 3t +Bsin 3t.
Since the righthand side of Ly = 6 sin3t is contained in the solution y
h
, following
the method of undetermined coeﬃcients, we choose y
p
of the form
y
p
(t) = at cos 3t +bt sin3t.
Then we obtain
y
′′
p
+ 9y
p
= −6a sin3t + 6b cos 3t
= 6 sin3t.
3.6. FORCED OSCILLATIONS 69
0 2 4 6 8
−2
−1
0
1
2
x
y
Plot of solution
Figure 3.3. Graph of solution of the linear equation in Example 3.16.
Identifying coeﬃcients on both sides, we have
a = −1, b = 0.
The general solution of Ly = 6 sin3t is
y(t) = Acos 3t +Bsin 3t −t cos 3t.
We determine A and B by means of the initial conditions,
y(0) = A = 1,
y
′
(t) = −3Asin3t + 3Bcos 3t −cos 3t + 3t sin3t,
y
′
(0) = 3B −1 = 2 =⇒ B = 1.
The (unique) solution is
y(t) = cos 3t + sin 3t −t cos 3t.
The term −t cos 3t, whose amplitude is increasing, comes from the resonance of
the system because the frequency of the external force coincides with the natural
frequency of the system.
(b) The Matlab symbolic solution.—
dsolve(’D2y+9*y=6*sin(3*t)’,’y(0)=1’,’Dy(0)=2’,’t’)
y = sin(3*t)cos(3*t)*t+cos(3*t)
(c) The Matlab numeric solution.— To rewrite the secondorder diﬀerential
equation as a system of ﬁrstorder equations, we put
y
1
= y,
y
2
= y
′
,
Thus, we have
y
′
1
= y
2
,
y
′
2
= −9y
1
+ 6 sin3t.
The Mﬁle exp313.m:
70 3. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER
0 2 4 6 8
−6
−4
−2
0
2
4
6
x
y
Plot of solution
Figure 3.4. Graph of solution of the linear equation in Example 3.17.
function yprime = exp313(t,y);
yprime = [y(2); 9*y(1)+6*sin(3*t)];
The call to the ode23 solver and the plot command:
tspan = [0 7]; % solution for t=0 to t=7
y0 = [1; 1]; % initial conditions
[x,y] = ode23(’exp313’,tspan,y0);
plot(x,y(:,1))
The numerical solution is plotted in Fig. 3.4.
CHAPTER 4
Systems of Diﬀerential Equations
4.1. Introduction
In Section 3.1, it was seen that a linear diﬀerential equation of order n,
y
(n)
+a
n−1
(x)y
(n−1)
+ +a
1
(x)y
′
+a
0
(x)y = r(x),
can be written as a linear system of n ﬁrstorder equations in the form
_
¸
¸
¸
¸
¸
_
u
1
u
2
.
.
.
u
n−1
u
n
_
¸
¸
¸
¸
¸
_
′
=
_
¸
¸
¸
¸
¸
_
0 1 0 0
0 0 1 0
.
.
.
.
.
.
.
.
.
.
.
. 0
0 0 0 1
−a
0
−a
1
−a
2
−a
n−1
_
¸
¸
¸
¸
¸
_
_
¸
¸
¸
¸
¸
_
u
1
u
2
.
.
.
u
n−1
u
n
_
¸
¸
¸
¸
¸
_
+
_
¸
¸
¸
¸
¸
_
0
0
.
.
.
0
r(x)
_
¸
¸
¸
¸
¸
_
,
where the dependent variables are deﬁned as
u
1
= y, u
2
= y
′
, . . . , u
n
= y
(n−1)
.
In this case, the n initial values,
y(x
0
) = k
1
, y
′
(x
0
) = k
2
, . . . , y
(n−1)
(x
0
) = k
n
,
and the righthand side, r(x), become
_
¸
¸
¸
¸
¸
_
u
1
(x
0
)
u
2
(x
0
)
.
.
.
u
n−1
(x
0
)
u
n
(x
0
)
_
¸
¸
¸
¸
¸
_
=
_
¸
¸
¸
¸
¸
_
k
1
k
2
.
.
.
k
n−1
k
n
_
¸
¸
¸
¸
¸
_
, g(x) =
_
¸
¸
¸
¸
¸
_
0
0
.
.
.
0
r(x)
_
¸
¸
¸
¸
¸
_
,
respectively. In matrix and vector notation, this system is written as
u
′
(x) = A(x)u(x) +g(x), u(x
0
) = k,
where the matrix A(x) is a companion matrix.
In this chapter, we shall consider linear systems of n equations where the
matrix A(x) is a general nn matrix, not necessarily of the form of a companion
matrix. An example of such systems follows.
Example 4.1. Set up a system of diﬀerential equations for the mechanical
system shown in Fig. 4.1
Solution. Consider a mechanical system in which two masses m
1
and m
2
are connected to each other by three springs as shown in Fig. 4.1 with Hooke’s
constants k
1
, k
2
and k
3
, respectively. Let x
1
(t) and x
2
(t) be the positions of the
centers of mass of m
1
and m
2
away from their points of equilibrium, the positive
xdirection pointing to the right. Then, x
′′
1
(t) and x
′′
2
(t) measure the acceleration
71
72 4. SYSTEMS OF DIFFERENTIAL EQUATIONS
m
1
m
2
1
k
2
k
3
k
Figure 4.1. Mechanical system for Example 4.1.
of each mass. The resulting force acting on each mass is exerted on it by the
springs that are attached to it, each force being proportional to the distance the
spring is stretched or compressed. For instance, when mass m
1
has moved a
distance x
1
to the right of its equilibrium position, the spring to the left of m
1
exerts a restoring force −k
1
x
1
on this mass, attempting to return the mass back
to its equilibrium position. The spring to the right of m
1
exerts a restoring force
−k
2
(x
2
− x
1
) on it; the part k
2
x
1
reﬂects the compression of the middle spring
due to the movement of m
1
, while −k
2
x
2
is due to the movement of m
2
and its
inﬂuence on the same spring. Following Newton’s second law of motion, we arrive
at the two coupled secondorder equations:
m
1
x
′′
1
= −k
1
x
1
+k
2
(x
2
−x
1
), m
2
x
′′
2
= −k
2
(x
2
−x
1
) −k
3
x
2
. (4.1)
We convert each equation in (4.1) to a ﬁrstorder system of equations by intro
ducing two new variables y
1
and y
2
representing the velocities of each mass:
y
1
= x
′
1
, y
2
= x
′
2
. (4.2)
Using these new dependent variables, we rewrite (4.1) as the following four simul
taneous equations in the four unknowns x
1
, y
1
, x
2
and y
2
:
x
′
1
= y
1
,
y
′
1
=
−k
1
x
1
+k
2
(x
2
−x
1
)
m
1
,
x
′
2
= y
2
,
y
′
2
=
−k
2
(x
2
−x
1
) −k
3
x
2
m
2
,
(4.3)
which, in matrix form, become
_
¸
¸
_
x
′
1
y
′
1
x
′
2
y
′
2
_
¸
¸
_
=
_
¸
¸
_
0 1 0 0
−
k1+k2
m1
0
k2
m1
0
0 0 0 1
k2
m2
0 −
k2+k3
m2
0
_
¸
¸
_
_
¸
¸
_
x
1
y
1
x
2
y
2
_
¸
¸
_
. (4.4)
Using the following notation for the unknown vector, the coeﬃcient matrix and
given initial conditions,
u =
_
¸
¸
_
x
1
y
1
x
2
y
2
_
¸
¸
_
, A =
_
¸
¸
_
0 1 0 0
−
k1+k2
m1
0
k2
m1
0
0 0 0 1
k2
m2
0 −
k2+k3
m2
0
_
¸
¸
_
u
0
=
_
¸
¸
_
x
1
(0)
y
1
(0)
x
2
(0)
y
2
(0)
_
¸
¸
_
,
the initial value problem becomes
u
′
= Au, u(0) = u
0
. (4.5)
It is to be noted that the matrix A is not in the form of a companion matrix.
4.3. FUNDAMENTAL SYSTEMS 73
4.2. Existence and Uniqueness Theorem
In this section, we recall results which have been quoted for systems in the
previous chapters. In particular, the existence and uniqueness Theorem 1.3 holds
for general ﬁrstorder systems of the form
y
′
= f(x, y), y(x
0
) = y
0
, (4.6)
provided, in Deﬁnition 1.3, norms replace absolute values in the Lipschitz condi
tion
f(z) −f(y) ≤ Mz −y, for all y, z ∈ R
n
,
and in the statement of the theorem.
A similar remark holds for the existence and uniqueness Theorem 3.2 for
linear system of the form
y
′
= A(x)y +g(x), y(x
0
) = y
0
, (4.7)
provided the matrix A(x) and the vectorvalued function f(x) are continuous
on the interval (x
0
, x
f
). The Picard iteration method used in the proof of this
theorem has been stated for systems of diﬀerential equations and needs no change
for the present systems.
4.3. Fundamental Systems
It is readily seen that the solutions to the linear homogeneous system
y
′
= A(x)y, x ∈]a, b[, (4.8)
form a vector space since diﬀerentiation and matrix multiplication are linear op
erators.
As before, m vectorvalued functions, y
1
(x), y
2
(x), . . . , y
m
(x), are said to be
linearly independent on an interval ]a, b[ if the identity
c
1
y
1
(x) +c
2
y
2
(x) + +y
m
(x) = 0, for all x ∈]a, b[,
implies that
c
1
= c
2
= = c
m
= 0.
Otherwise, this set of functions is said to be linearly dependent.
For general system, the determinant W(x) of n columnvector functions,
y
1
(x), y
2
(x), . . . , y
n
(x), with values in R
n
,
W(y
1
, y
2
, . . . , y
n
)(x) = det
_
¸
¸
¸
_
y
11
(x) y
12
(x) y
1n
(x)
y
21
(x) y
22
(x) y
2n
(x)
.
.
.
.
.
.
.
.
.
.
.
.
y
n1
(x) y
n2
(x) y
nn
(x)
_
¸
¸
¸
_
,
is a generalization of the Wronskian for a linear scalar equation.
We restate and prove Liouville’s or Abel’s Lemma 3.1 for general linear sys
tems. For this purpose, we deﬁne the trace of a matrix A, denoted by tr A, to be
the sum of the diagonal elements, a
ii
, of A,
tr A = a
11
+a
22
+ +a
nn
.
74 4. SYSTEMS OF DIFFERENTIAL EQUATIONS
Lemma 4.1 (Abel). Let y
1
(x), y
2
(x), . . . , y
n
(x), be n solutions of the system
y
′
= A(x)y on the interval ]a, b[. Then the determinant W(y
1
, y
2
, . . . , y
n
)(x)
satisﬁes the following identity:
W(x) = W(x
0
) e
−
R
x
x
0
tr A(t) dt
, x
0
∈]a, b[. (4.9)
Proof. For simplicity of writing, let us take n = 3; the general case is treated
as easily. Let W(x) be the determinant of three solutions y
1
, y
2
, y
3
. Then its
derivative W
′
(x) is of the form
W
′
(x) =
¸
¸
¸
¸
¸
¸
y
11
y
12
y
13
y
21
y
22
y
23
y
31
y
32
y
33
¸
¸
¸
¸
¸
¸
′
=
¸
¸
¸
¸
¸
¸
y
′
11
y
′
12
y
′
13
y
21
y
22
y
23
y
31
y
32
y
33
¸
¸
¸
¸
¸
¸
+
¸
¸
¸
¸
¸
¸
y
11
y
12
y
13
y
′
21
y
′
22
y
′
23
y
31
y
32
y
33
¸
¸
¸
¸
¸
¸
+
¸
¸
¸
¸
¸
¸
y
11
y
12
y
13
y
21
y
22
y
23
y
′
31
y
′
32
y
′
33
¸
¸
¸
¸
¸
¸
.
We consider the ﬁrst of the last three determinants. We see that the ﬁrst row of
the diﬀerential system
_
_
y
′
11
y
′
12
y
′
13
y
′
21
y
′
22
y
′
23
y
′
31
y
′
32
y
′
33
_
_
=
_
_
a
11
a
12
a
13
a
21
a
22
a
23
a
31
a
32
a
33
_
_
_
_
y
11
y
12
y
13
y
21
y
22
y
23
y
31
y
32
y
33
_
_
is
y
′
11
= a
11
y
11
+a
12
y
21
+a
13
y
31
,
y
′
12
= a
11
y
12
+a
12
y
22
+a
13
y
32
,
y
′
13
= a
11
y
13
+a
12
y
23
+a
13
y
33
.
Substituting these expressions in the ﬁrst row of the ﬁrst determinant and sub
tracting a
12
times the second row and a
13
times the third row from the ﬁrst row,
we obtain a
11
W(x). Similarly, for the second and third determinants we obtain
a
22
W(x) and a
33
W(x), respectively. Thus W(x) satisﬁes the separable equation
W
′
(x) = tr
_
A(x)
_
W(x)
whose solution is
W(x) = W(x
0
) e
R
x
x
0
tr A(t) dt
.
The following corollary follows from Abel’s lemma.
Corollary 4.1. If n solutions to the homogeneous diﬀerential system (4.8)
are independent at one point, then they are independent on the interval ]a, b[. If,
on the other hand, these solutions are linearly dependent at one point, then their
determinant, W(x), is identically zero, and hence they are everywhere dependent.
Remark 4.1. It is worth emphasizing the diﬀerence between linear indepen
dence of vectorvalued functions and solutions of linear systems. For instance,
the two vectorvalued functions
f
1
(x) =
_
x
0
_
, f
2
(x) =
_
1 +x
0
_
,
are linearly independent. Their determinant, however, is zero. This does not
contradict Corollary 4.1 since f
1
and f
2
cannot be solutions to a system (4.8).
4.3. FUNDAMENTAL SYSTEMS 75
Definition 4.1. A set of n linearly independent solutions of a linear homoge
neous system y
′
= A(x)y is called a fundamental system, and the corresponding
invertible matrix
Y (x) =
_
¸
¸
¸
_
y
11
(x) y
12
(x) y
1n
(x)
y
21
(x) y
22
(x) y
2n
(x)
.
.
.
.
.
.
.
.
.
.
.
.
y
n1
(x) y
n2
(x) y
nn
(x)
_
¸
¸
¸
_
,
is called a fundamental matrix.
Lemma 4.2. If Y (x) is a fundamental matrix, then Z(x) = Y (x)Y
−1
(x
0
) is
also a fundamental matrix such that Z(x
0
) = I.
Proof. Let C be any constant matrix. Since Y
′
= AY , it follows that
(Y C)
′
= Y
′
C = (AY )C = A(Y C). The lemma follows by letting C = Y
−1
(x
0
).
Obviously, Z(x
0
) = I.
In the following, we shall often assume that a fundamental matrix satisﬁes
the condition Y (x
0
) = I. We have the following theorem for linear homogeneous
systems.
Theorem 4.1. Let Y (x) be a fundamental matrix for y
′
= A(x)y. Then the
general solution is
y(x) = Y (x)c,
where c is an arbitrary vector. If Y (x
0
) = I, then
y(x) = Y (x)y
0
is the unique solution of the initial value problem
y
′
= A(x)y, y(x
0
) = y
0
.
Proof. The proof of both statements rely on the uniqueness theorem. To
prove the ﬁrst part, let Y (x) be a fundamental matrix and z(x) be any solution
of the system. Let x
0
be in the domain of z(x) and deﬁne c by
c = Y
−1
(x
0
)z(x
0
).
Deﬁne y(x) = Y (x)c. Since both y(x) and z(x) satisfy the same diﬀerential
equation and the same initial conditions, they must be the same solution by the
uniqueness theorem. The proof of the second part is similar.
The following lemma will be used to obtain a formula for the solution of the
initial value problem (4.7) in terms of a fundamental solution.
Lemma 4.3. Let Y (x) be a fundamental matrix for the system (4.8). Then,
(Y
T
)
−1
(x) is a fundamental solution for the adjoint system
y
′
= −A
T
(x)y. (4.10)
Proof. Diﬀerentiating the identity
Y
−1
(x)Y (x) = I,
we have
(Y
−1
)
′
(x)Y (x) +Y
−1
(x)Y
′
(x) = 0.
76 4. SYSTEMS OF DIFFERENTIAL EQUATIONS
Since the matrix Y (x) is a solution of (4.8), we can replace Y
′
(x) in the previous
identity with A(x)Y (x) and obtain
(Y
−1
)
′
(x)Y (x) = −Y
−1
(x)A(x)Y (x).
Multiplying this equation on the right by Y
−1
(x) and taking the transpose of
both sides lead to (4.10).
Theorem 4.2 (Solution formula). Let Y (x) be a fundamental solution matrix
of the homogeneous linear system (4.8). Then the unique solution to the initial
value problem (4.7) is
y(x) = Y (x)Y
−1
(x
0
)y
0
+Y (x)
_
x
x0
Y
−1
(t)g(t) dt. (4.11)
Proof. Multiply both sides of (4.7) by Y
−1
(x) and use the result of Lemma 4.3
to get
_
Y
−1
(x)y(x)
_
′
= Y
−1
(x)g(x).
The proof of the theorem follows by integrating the previous expression with
respect to x from x
0
to x.
4.4. Homogeneous Linear Systems with Constant Coeﬃcients
A solution of a linear system with constant coeﬃcients can be expressed in
terms of the eigenvalues and eigenvectors of the coeﬃcient matrix A. Given a
linear homogeneous system of the form
y
′
= Ay, (4.12)
where the nn matrix A has real constant entries, we seek solutions of the form
y(x) = e
λx
v, (4.13)
where the number λ and the vector v are to be determined. Substituting (4.13)
into (4.12) and dividing by e
λx
we obtain the eigenvalue problem
(A −λI)v = 0, v ,= 0. (4.14)
This equation has a nonzero solution v if and only if
det(A −λI) = 0.
The lefthand side of this determinental equation is a polynomial of degree n
and the n roots of this equation are called the eigenvalues of the matrix A. The
corresponding nonzero vectors v are called the eigenvectors of A.
It is known that for each distinct eigenvalue, A has a corresponding eigenvec
tor and the set of such eigenvectors are linearly independent. If A is symmetric,
A
T
= A, that is, A and its transpose are equal, then the eigenvalues are real and
A has n eigenvectors which can be chosen to be orthonormal.
Example 4.2. Find the general solution of the symmetric system y
′
= Ay:
y
′
=
_
2 1
1 2
_
y.
4.4. HOMOGENEOUS LINEAR SYSTEMS WITH CONSTANT COEFFICIENTS 77
Solution. The eigenvalues are obtained from the characteristic polynomial
of A,
det(A −λI) = det
_
2 −λ 1
1 2 −λ
_
= λ
2
−4λ + 3 = (λ −1)(λ −3) = 0.
Hence the eigenvalues are
λ
1
= 1, λ
2
= 3.
The eigenvector corresponding to λ
1
is obtained from the singular system
(A −I)u =
_
1 1
1 1
_ _
u
1
u
2
_
= 0.
Taking u
1
= 1 we have the eigenvector
u =
_
1
−1
_
.
Similarly, the eigenvector corresponding to λ
2
is obtained from the singular system
(A −3I)v =
_
−1 1
1 −1
_ _
v
1
v
2
_
= 0.
Taking v
1
= 1 we have the eigenvector
v =
_
1
1
_
.
Since λ
1
,= λ
2
, we have two independent solutions
y
1
= e
x
_
1
−1
_
, y
2
= e
3x
_
1
1
_
,
and the fundamental system and general solution are
Y (x) =
_
e
x
e
3x
−e
x
e
3x
_
, y = Y (x)c.
The Matlab solution is
A = [2 1; 1 2];
[Y,D] = eig(A);
syms x c1 c2
z = Y*diag(exp(diag(D*x)))*[c1; c2]
z =
[ 1/2*2^(1/2)*exp(x)*c1+1/2*2^(1/2)*exp(3*x)*c2]
[ 1/2*2^(1/2)*exp(x)*c1+1/2*2^(1/2)*exp(3*x)*c2]
Note that Matlab normalizes the eigenvectors in the l
2
norm. Hence, the matrix
Y is orthogonal since the matrix A is symmetric. The solution y
y = simplify(sqrt(2)*z)
y =
[ exp(x)*c1+exp(3*x)*c2]
[ exp(x)*c1+exp(3*x)*c2]
is produced by the nonnormalized eigenvectors u and v.
78 4. SYSTEMS OF DIFFERENTIAL EQUATIONS
If the constant matrix A of the system y
′
= Ay has a full set of independent
eigenvectors, then it is diagonalizable
Y
−1
AY = D,
where the columns of the matrix Y are eigenvectors of A and the corresponding
eigenvalues are the diagonal elements of the diagonal matrix D. This fact can be
used to solve the initial value problem
y
′
= Ay, y(0) = y
0
.
Set
y = Y x, or x = Y
−1
y.
Since A is constant, then Y is constant and x
′
= Y
−1
y
′
. Hence the given system
y
′
= Ay becomes
Y
−1
y
′
= Y
−1
AY Y
−1
y,
that is,
x
′
= Dx.
Componentwise, we have
x
′
1
(t) = λ
1
x
1
(t), x
′
2
(t) = λ
2
x
2
(t), . . . , x
n
(t)
′
= λ
n
x
n
(t),
with solutions
x
1
(t) = c
1
e
λ1t
, x
2
(t) = c
2
e
λ2t
, . . . , x
n
(t) = c
n
e
λnt
,
where the constants c
1
, . . . , c
n
are determined by the initial conditions. Since
y
0
= Y x(0) = Y c,
it follows that
c = Y
−1
y
0
.
These results are used in the following example.
Example 4.3. Solve the system of Example 4.1 with
m
1
= 10, m
2
= 20, k
1
= k
2
= k
3
= 1,
and initial values
x
1
= 0.8, x
2
= y
0
= y
1
= 0,
and plot the solution.
Solution. The matrix A takes the form
A =
_
¸
¸
_
0 1 0 0
−0.2 0 0.1 0
0 0 0 1
0.05 0 −0.1 0
_
¸
¸
_
The Matlab solution for x(t) and y(t) and their plot are
A = [0 1 0 0; 0.2 0 0.1 0; 0 0 0 1; 0.05 0 0.1 0];
y0 = [0.8 0 0 0]’;
[Y,D] = eig(A);
t = 0:1/5:60; c = inv(Y)*y0; y = y0;
for i = 1:length(t)1
yy = Y*diag(exp(diag(D)*t(i+1)))*c;
y = [y,yy];
4.4. HOMOGENEOUS LINEAR SYSTEMS WITH CONSTANT COEFFICIENTS 79
0 20 40 60
−1
−0.5
0
0.5
1
Figure 4.2. Graph of solution x
1
(t) (solid line) and x
2
(t)
(dashed line) to Example 4.3.
end
ry = real(y); % the solution is real; here the imaginary part is zero
subplot(2,2,1); plot(t,ry(1,:),t,ry(3,:),’’);
The Matlab ode45 command from the ode suite produces the same numerical
solution. Using the Mﬁle spring.m,
function yprime = spring(t,y); % MAT 2331, Example 3a.4.2.
A = [0 1 0 0; 0.2 0 0.1 0; 0 0 0 1; 0.05 0 0.1 0];
yprime = A*y;
we have
y0 = [0.8 0 0 0]; tspan=[0 60];
[t,y]=ode45(’spring’,tspan,y0);
subplot(2,2,1); plot(t,y(:,1),t,y(:,3));
The plot is shown in Fig. 4.2.
The case of multiple eigenvalues may lead to a lack of eigenvectors in the
construction of a fundamental solution. In this situation, one has recourse to
generalized eigenvectors.
Definition 4.2. Let A be an n n matrix. We say that λ is a deﬁcient
eigenvalue of A if it has multiplicity m > 1 and fewer than m eigenvectors asso
ciated with it. If there are k < m linearly independent eigenvectors associated
with λ, then the integer
r = m−k
is called the degree of deﬁciency of λ. A vector u is called a generalized eigenvector
of A associated with λ if there is an integer s > 0 such that
(A −λI)
s
u = 0,
but
(A −λI)
s−1
u ,= 0.
80 4. SYSTEMS OF DIFFERENTIAL EQUATIONS
In general, given a matrix A with an eigenvalue λ of degree of deﬁciency r
and corresponding eigenvector u
1
, we construct a set of generalized eigenvectors
¦u
2
, . . . , u
r
¦ as solutions of the systems
(A −λI)u
2
= u
1
, (A −λI)u
3
= u
2
, . . . , (A −λI)u
r
= u
r−1
.
The eigenvector u
1
and the set of generalized eigenvectors, in turn, generate the
following set of linearly independent solutions of (4.12):
y
1
(x) = e
λx
u
1
, y
2
(x) = e
λx
(xu
1
+u
2
), y
3
(x) = e
λx
_
x
2
2
u
1
+xu
2
+u
3
_
, . . . .
It is a result of linear algebra that any n n matrix has n linearly independent
generalized eigenvectors.
Example 4.4. Solve the system y
′
= Ay:
y
′
=
_
_
0 1 0
0 0 1
1 −3 3
_
_
y.
Solution. One ﬁnds that the matrix A has a triple eigenvalue λ = 1. Row
reducing the matrix A − I, we obtain a matrix of rank 2; hence A − I admits a
single eigenvector e
1
:
A −I ∼
_
_
−1 1 0
0 −1 1
0 0 0
_
_
, e
1
=
_
_
1
1
1
_
_
.
Thus, one solution is
y
1
(x) =
_
_
1
1
1
_
_
e
x
.
To construct a ﬁrst generalized eigenvector, we solve the equation
(A −I)e
2
= e
1
.
Thus,
e
2
=
_
_
−2
−1
0
_
_
and
y
2
(x) = (xe
1
+e
2
) e
x
=
_
_
x
_
_
1
1
1
_
_
+
_
_
−2
−1
0
_
_
_
_
e
x
is a second linearly independent solution.
To construct a second generalized eigenvector, we solve the equation
(A −I)e
3
= e
2
.
Thus,
e
3
=
_
_
3
1
0
_
_
4.4. HOMOGENEOUS LINEAR SYSTEMS WITH CONSTANT COEFFICIENTS 81
and
y
3
(x) =
_
x
2
2
e
1
+ xe
2
+e
2
_
e
x
=
_
_
x
2
2
_
_
1
1
1
_
_
+x
_
_
−2
−1
0
_
_
+
_
_
3
1
0
_
_
_
_
e
x
is a third linearly independent solution.
In the previous example, the invariant subspace associated with the triple
eigenvalue is onedimensional. Hence the construction of two generalized eigen
vectors is straightforward. In the next example, this invariant subspace associated
with the triple eigenvalue is twodimensional. Hence the construction of a gener
alized eigenvector is a bit more complex.
Example 4.5. Solve the system y
′
= Ay:
y
′
=
_
_
1 2 1
−4 7 2
4 −4 1
_
_
y.
Solution. (a) The analytic solution.— One ﬁnds that the matrix A has a
triple eigenvalue λ = 3. Rowreducing the matrix A − 3I, we obtain a matrix of
rank 1; hence A −3I two independent eigenvectors, e
1
and e
2
:
A −3I ∼
_
_
−2 2 1
0 0 0
0 0 0
_
_
, e
1
=
_
_
1
1
0
_
_
, e
2
=
_
_
1
0
2
_
_
.
Thus, two independent solutions are
y
1
(x) =
_
_
1
1
0
_
_
e
3x
, y
2
(x) =
_
_
1
0
2
_
_
e
3x
.
To obtain a third independent solution we construct a generalized eigenvector by
solving the equation
(A −3I)e
3
= αe
1
+βe
2
,
where the parameters α and β are to be chosen so that the righthand side,
e
4
= αe
1
+βe
2
=
_
_
α +β
α
2β
_
_
,
is in the space V spanned by the columns of the matrix (A−3I). Since rank(A−
3I) = 1, then
V = span
_
_
1
2
−2
_
_
and we may take
_
_
α +β
α
2β
_
_
=
_
_
1
2
−2
_
_
.
Thus, α = 2 and β = −1, It follows that
e
4
=
_
_
1
2
−2
_
_
, e
3
=
_
_
0
0
1
_
_
82 4. SYSTEMS OF DIFFERENTIAL EQUATIONS
and
y
3
(x) = (xe
4
+e
3
) e
3x
=
_
_
x
_
_
1
2
−2
_
_
+
_
_
0
0
1
_
_
_
_
e
x
is a third linearly independent solution.
(b) The Matlab symbolic solution.— To solve the problem with symbolic
Matlab, one uses the Jordan normal form, J = X
−1
AX, of the matrix A. If we
let
y = Xw,
the equation simpliﬁes to
w
′
= Jw.
A = 1 2 1
4 7 2
4 4 1
[X,J] = jordan(A)
X = 2.0000 1.5000 0.5000
4.0000 0 0
4.0000 1.0000 1.0000
J = 3 1 0
0 3 0
0 0 3
The matrix J −3I admits the two eigenvectors
u
1
=
_
_
1
0
0
_
_
, u
3
=
_
_
0
0
1
_
_
,
and the generalized eigenvector
u
2
=
_
_
0
1
0
_
_
,
the latter being a solution of the equation
(J −3I)u
2
= u
1
.
Thus three independent solutions are
y
1
= e
3x
Xu
1
, y
2
= e
3x
X(xu
1
+u
2
), y
3
= e
3x
Xu
3
,
that is
u1=[1 0 0]’; u2=[0 1 0]’; u3=[0 0 1]’;
syms x; y1 = exp(3*x)*X*u1
y1 = [ 2*exp(3*x)]
[ 4*exp(3*x)]
[ 4*exp(3*x)]
4.5. NONHOMOGENEOUS LINEAR SYSTEMS 83
y2 = exp(3*x)*X*(x*u1+u2)
y2 = [ 2*exp(3*x)*x+3/2*exp(3*x)]
[ 4*exp(3*x)*x]
[ 4*exp(3*x)*x+exp(3*x)]
y3 = exp(3*x)*X*u3
y3 = [ 1/2*exp(3*x)]
[ 0]
[ exp(3*x)]
4.5. Nonhomogeneous Linear Systems
In Chapter 3, the method of undetermined coeﬃcients and the method of
variation of parameters have been used for ﬁnding particular solutions of nonho
mogeneous diﬀerential equations. In this section, we generalize these methods to
linear systems of the form
y
′
= Ay +f(x). (4.15)
We recall that once a particular solution y
p
of this system has been found, the
general solution is the sum of y
p
and the solution y
h
of the homogeneous system
y
′
= Ay.
4.5.1. Method of undetermined coeﬃcients. The method of undeter
mined coeﬃcients can be used when the matrix A in (4.15) is constant and the
dimension of the vector space spanned by the derivatives of the righthand side
f(x) of (4.15) is ﬁnite. This is the case when the components of f(x) are com
binations of cosines, sines, exponentials, hyperbolic sines and cosines, and poly
nomials. For such problems, the appropriate choice of y
p
is a linear combination
of vectors in the form of the functions that appear in f(x) together with all their
derivatives.
Example 4.6. Find the general solution of the nonhomogeneous linear system
y
′
=
_
0 1
−1 0
_
y +
_
4 e
−3x
e
−2x
_
:= Ay +f(x).
Solution. The eigenvalues of the matrix A of the system are
λ
1
= i, λ
2
= −i,
and the corresponding eigenvectors are
u
1
=
_
1
i
_
, u
2
=
_
1
−i
_
.
Hence the general solution of the homogeneous system is
y
h
(x) = k
1
e
ix
_
1
i
_
+k
2
e
−ix
_
1
−i
_
,
where k
1
and k
2
are complex constants. To obtain real independent solutions we
use the fact that the real and imaginary parts of a solution of a real homogeneous
84 4. SYSTEMS OF DIFFERENTIAL EQUATIONS
linear equation are solutions. We see that the real and imaginary parts of the
ﬁrst solution,
u
1
=
_
1
i
_
e
ix
=
__
1
0
_
+i
_
0
1
__
(cos x +i sinx)
=
_
cos x
−sinx
_
+i
_
sinx
cos x
_
,
are independent solutions. Hence, we obtain the following realvalued general
solution of the homogeneous system
y
h
(x) = c
1
_
cos x
−sin x
_
+c
2
_
sin x
cos x
_
.
The function f(x) can be written in the form
f(x) = 4
_
1
0
_
e
−3x
+
_
0
1
_
e
−2x
= 4e
1
e
−3x
+e
2
e
−2x
with obvious deﬁnitions for e
1
and e
2
. Note that f(x) and y
h
(x) do not have
any part in common. We therefore choose y
p
(x) in the form
y
p
(x) = ae
−3x
+b e
−2x
.
Substituting y
p
(x) in the given system, we obtain
0 = (3a +Aa + 4e
1
) e
−3x
+ (2b +Ab +e
2
) e
−2x
.
Since the functions e
−3x
and e
−2x
are linearly independent, their coeﬃcients must
be zero, from which we obtain two equations for a and b,
(A + 3I)a = −4e
1
, (A + 2I)b = −e
2
.
Hence,
a = −(A + 3I)
−1
(4e
1
) = −
1
5
_
6
2
_
b = −(A + 2I)
−1
(e
2
) =
1
5
_
1
−2
_
.
Finally,
y
h
(x) = −
_
¸
_
6
5
e
−3x
−
1
5
e
−2x
2
5
e
−3x
+
2
5
e
−2x
_
¸
_.
The general solution is
y(x) = y
h
(x) +y
p
(x).
4.5. NONHOMOGENEOUS LINEAR SYSTEMS 85
4.5.2. Method of variation of parameters. The method of variation of
parameters can be applied, at least theoretically, to nonhomogeneous systems
with nonconstant matrix A(x) and general righthand side f(x). A fundamental
matrix solution
Y (x) = [y
1
, y
2
, . . . , y
n
],
of the homogeneous system
y
′
= A(x)y
satisﬁes the equation
Y
′
(x) = A(x)Y (x).
Since the columns of Y (x) are linearly independent, the general solution y
h
(x) of
the homogeneous system is a linear combinations of these columns,
y
h
(x) = Y (x)c,
where c is an arbitrary nvector. The method of variation of parameter seeks a
particular solution y
p
(x) to the nonhomogeneous system
y
′
= A(x)y +f(x)
in the form
y
p
(x) = Y (x)c(x).
Substituting this expression in the nonhomogeneous system, we obtain
Y
′
c +Y c
′
= AY c +f.
Since Y
′
= AY , therefore Y
′
c = AY c. Thus, the previous expression reduces to
Y c
′
= f.
The fundamental matrix solution being invertible, we have
c
′
(x) = Y
−1
(x)f(x), or c(x) =
_
x
Y
−1
(s)f(s) ds.
It follows that
y
p
(x) = Y (x)
_
x
Y
−1
(s)f(s) ds.
In the case of an initial value problem with
y(0) = y
0
,
the unique solution is
y(x) = Y (x)Y
−1
(0)y
0
+Y (x)
_
x
0
Y
−1
(s)f(s) ds.
It is left to the reader to solve Example 4.6 by the method of variation of param
eters.
CHAPTER 5
Analytic Solutions
5.1. The Method
We illustrate the method by a very simple example.
Example 5.1. Find a power series solution of the form
y(x) = a
0
+a
1
x +a
2
x
2
+. . .
to the initial value problem
y
′′
+ 25y = 0, y(0) = 3, y
′
(0) = 13.
Solution. In this simple case, we already know the general solution,
y(x) = a cos 5x +b sin5x,
of the ordinary diﬀerential equation. The arbitrary constants a and b are deter
mined by the initial conditions,
y(0) = a = 3 =⇒ a = 3,
y
′
(0) = 5b = 13 =⇒ b =
13
5
.
We also know that
cos 5x = 1 −
(5x)
2
2!
+
(5x)
4
4!
−
(5x)
6
6!
+−. . .
and
sin 5x = 5x −
(5x)
3
3!
+
(5x)
5
5!
−
(5x)
7
7!
+−. . .
To obtain the series solution, we substitute
y(x) = a
0
+a
1
x +a
2
x
2
+a
3
x
3
+. . .
in
y
′′
+ 25y = 0.
Hence
y
′′
(x) = 2a
2
+ 3 2a
3
x + 4 3a
4
x
2
+ 5 4a
5
x
3
+ 6 5a
6
x
4
+. . .
25y(x) = 25a
0
+ 25a
1
x + 25a
2
x
2
+ 25a
3
x
3
+ 25a
4
x
4
+. . .
Adding each side, we have
0 = (2a
2
+ 25a
0
) + (3 2a
3
+ 25a
1
)x + (4 3a
4
+ 25a
2
)x
2
+. . . , for all x.
Since this is an identity in
1, x, x
2
, x
3
, . . . ,
87
88 5. ANALYTIC SOLUTIONS
we can identify the coeﬃcients of the same powers of x on the left and righthand
sides. It thus follows that all the coeﬃcients are zero. Hence with undetermined
values for a
0
and a
1
, we have
2a
2
+ 25a
0
= 0 =⇒ a
2
= −
5
2
2!
a
0
,
3 2a
3
+ 25a
1
= 0 =⇒ a
3
= −
5
2
3!
a
1
,
4 3a
4
+ 25a
2
= 0 =⇒ a
4
=
5
4
4!
a
0
,
5 4a
5
+ 25a
3
= 0 =⇒ a
5
=
5
4
5!
a
1
,
etc. We therefore have the following expansion for y(x),
y(x) = a
0
_
1 −
1
2!
(5x)
2
+
1
4!
(5x)
4
−
1
6!
(5x)
6
+. . .
_
+
a
1
5
_
5x −
1
3!
(5x)
3
+
1
5!
(5x)
5
−. . .
_
= a
0
cos 5x +
a
1
5
sin 5x.
The parameter a
0
is determined by the initial condition y(0) = 3,
a
0
= 3.
To determine a
1
, we diﬀerentiate y(x),
y
′
(x) = −5a
0
sin 5x +a
1
cos 5x,
and set x = 0. Thus, we have
y
′
(0) = a
1
= 13
by the initial condition y
′
(0) = 13.
5.2. Foundation of the Power Series Method
It will be convenient to consider power series in the complex plane. We recall
that a point z in the complex plane C admits the following representations:
• Cartesian or algebraic:
z = x +iy, i
2
= −1,
• trigonometric:
z = r(cos θ +i sinθ),
• polar or exponential:
z = r e
iθ
,
where
r =
_
x
2
+y
2
, θ = arg z = arctan
y
x
.
As usual, ¯ z = x −iy denotes the complex conjugate of z and
[z[ =
_
x
2
+y
2
=
√
z¯ z = r
denotes the modulus of z (see Fig. 5.1).
5.2. FOUNDATION OF THE POWER SERIES METHOD 89
0
x
y
z=x+iy = re
r
θ
i θ
Figure 5.1. A point z = x +iy = r e
iθ
in the complex plane C.
Example 5.2. Extend the function
f(x) =
1
1 −x
,
to the complex plane and expand in power series with centres at z
0
= 0, z
0
= −1,
and z
0
= i, respectively.
Solution. We extend the function
f(x) =
1
1 −x
, x ∈ R ¸ ¦1¦,
of a real variable to the complex plane
f(z) =
1
1 −z
, z = x +iy ∈ C.
This is a rational function with a simple pole at z = 0. We say that z = 1 is a
pole of f(z) since [f(z)[ tends to +∞ as z →1. Moreover, z = 1 is a simple pole
since 1 −z appears to the ﬁrst power in the denominator.
We expand f(z) in a Taylor series around 0,
f(z) = f(0) +
1
1!
f
′
(0)z +
1
2!
f
′′
(0)z
2
+. . .
Since
f(z) =
1
(1 −z)
=⇒ f(0) = 1,
f
′
(z) =
1!
(1 −z)
2
=⇒ f
′
(0) = 1!,
f
′′
(z) =
2!
(1 −z)
3
=⇒ f
′′
(0) = 2!,
.
.
.
f
(n)
(z) =
n!
(1 −z)
n+1
=⇒ f
(n)
(0) = n!,
it follows that
f(z) =
1
1 −z
= 1 +z +z
2
+z
3
+. . .
=
∞
n=0
z
n
.
90 5. ANALYTIC SOLUTIONS
The series converges absolutely for [z[ ≡
_
x
2
+y
2
< 1, that is,
∞
n=0
[z[
n
< ∞, for all [z[ < 1,
and uniformly for [z[ ≤ ρ < 1, that is, given ǫ > 0 there exists N
ǫ
such that
¸
¸
¸
¸
∞
n=N
z
n
¸
¸
¸
¸
< ǫ, for all N > N
ǫ
and all [z[ ≤ ρ < 1.
Thus, the radius of convergence R of the series
∞
n=0
z
n
is 1.
Now, we expand f(z) in a neighbourhood of z = −1,
f(z) =
1
1 −z
=
1
1 −(z + 1 −1)
=
1
2 −(z + 1)
=
1
2
1
1 −(
z+1
2
)
=
1
2
_
1 +
z + 1
2
+
_
z + 1
2
_
2
+
_
z + 1
2
_
3
+
_
z + 1
2
_
4
+. . .
_
.
The series converges absolutely for
¸
¸
¸
¸
z + 1
2
¸
¸
¸
¸
< 1, that is [z + 1[ < 2, or [z −(−1)[ < 2.
The centre of the disk of convergence is z = −1 and the radius of convergence is
R = 2.
Finally, we expand f(z) in a neighbourhood of z = i,
f(z) =
1
1 −z
=
1
1 −(z −i +i)
=
1
(1 −i) −(z −i)
=
1
1 −i
1
1 −(
z−i
1−i
)
=
1
1 −i
_
1 +
z −i
1 −i
+
_
z −i
1 −i
_
2
+
_
z −i
1 −i
_
3
+
_
z −i
1 −i
_
4
+. . .
_
.
The series converges absolutely for
¸
¸
¸
¸
z −i
1 −i
¸
¸
¸
¸
< 1, that is [z −i[ < [1 −i[ =
√
2.
We see that the centre of the disk of convergence is z = i and the radius of
convergence is R =
√
2 = [1 −i[ (see Fig. 5.2).
This example shows that the Taylor series expansion of a function f(z), with
centre z = a and radius of convergence R, stops being convergent as soon as
[z − a[ ≥ R, that is, as soon as [z − a[ is bigger than the distance from a to the
nearest singularity z
1
of f(z) (see Fig. 5.3).
We shall use the following result.
Theorem 5.1 (Convergence Criteria). The reciprocal of the radius of con
vergence R of a power series with centre z = a,
∞
m=0
a
m
(z −a)
m
, (5.1)
5.2. FOUNDATION OF THE POWER SERIES METHOD 91
y
x 0
i
1
R=√2
Figure 5.2. Distance from the centre a = i to the pole z = 1.
y
x 0
a
z
R
1
Figure 5.3. Distance R from the centre a to the nearest singu
larity z
1
.
is equal to the following limit superior,
1
R
= limsup
m→∞
[a
m
[
1/m
. (5.2)
The following criterion also holds,
1
R
= lim
m→∞
¸
¸
¸
¸
a
m+1
a
m
¸
¸
¸
¸
, (5.3)
if this limit exists.
Proof. The root test, also called Cauchy’s criterion, states that the series
∞
m=0
c
m
converges if
lim
m→∞
[c
m
[
1/m
< 1.
By the root test, the power series converges if
lim
m→∞
[a
m
(z −a)
m
[
1/m
= lim
m→∞
[a
m
[
1/m
[z −a[ < 1.
Let R be maximum of [z −a[ such that the equality
lim
m→∞
[a
m
[
1/m
R = 1
92 5. ANALYTIC SOLUTIONS
is satisﬁed. If there are several limits, one must take the limit superior, that is
the largest limit. This establishes criterion (5.2).
The second criterion follows from the ratio test, also called d’Alembert’s cri
terion, which states that the series
∞
m=0
c
m
converges if
lim
m→∞
[c
m+1
[
[c
m
[
< 1.
By the ratio test, the power series converges if
lim
m→∞
[a
m+1
(z −a)
m+1
[
[a
m
(z −a)
m
[
= lim
m→∞
[a
m+1
[
[a
m
[
[z −a[ < 1.
Let R be maximum of [z −a[ such that the equality
lim
m→∞
[a
m+1
[
[a
m
[
R = 1
is satisﬁed. This establishes criterion (5.3).
Example 5.3. Find the radius of convergence of the series
∞
m=0
1
k
m
x
3m
and of its ﬁrst termbyterm derivative.
Solution. By the root test,
1
R
= limsup
m→∞
[a
m
[
1/m
= lim
m→∞
¸
¸
¸
¸
1
k
m
¸
¸
¸
¸
1/3m
=
1
[k[
1/3
.
Hence the radius of convergence of the series is
R = [k[
1/3
.
To use the ratio test, we put
w = z
3
in the series, which becomes
∞
0
1
k
m
w
m
.
Then the radius of convergence, R
1
, of the new series is given by
1
R
1
= lim
m→∞
¸
¸
¸
¸
k
m
k
m+1
¸
¸
¸
¸
=
¸
¸
¸
¸
1
k
¸
¸
¸
¸
.
Therefore the original series converges for
[z
3
[ = [w[ < [k[, that is [z[ < [k[
1/3
.
The radius of convergence R
′
of the diﬀerentiated series,
∞
m=0
3m
k
m
x
3m−1
,
5.2. FOUNDATION OF THE POWER SERIES METHOD 93
is obtained in a similar way:
1
R
′
= lim
m→∞
¸
¸
¸
¸
3m
k
m
¸
¸
¸
¸
1/(3m−1)
= lim
m→∞
[3m[
1/(3m−1)
lim
m→∞
¸
¸
¸
¸
1
k
m
¸
¸
¸
¸
(1/m)(m/(3m−1)
= lim
m→∞
_
1
[k[
_
1/(3−1/m)
=
1
[k[
1/3
,
since
lim
m→∞
[3m[
1/(3m−1)
= 1.
One sees by induction that all termbyterm derivatives of a given series have
the same radius of convergence R.
Definition 5.1. We say that a function f(z) is analytic inside a disk D(a, R),
of centre a and radius R > 0, if it has a power series with centre a,
f(z) =
∞
n=0
a
n
(z −a)
n
,
which is uniformly convergent in every closed subdisk strictly contained inside
D(a, R).
The following theorem follows from the previous deﬁnition.
Theorem 5.2. A function f(z) analytic in D(a, R) admits the power series
representation
f(z) =
∞
n=0
f
(n)
(a)
n!
(z −a)
n
uniformly and absolutely convergent in D(a, R). Moreover f(z) is inﬁnitely often
diﬀerentiable, the series is termwise inﬁnitely often diﬀerentiable, and
f
(k)
(z) =
∞
n=k
f
(n)
(a)
(n −k)!
(z −a)
n−k
, k = 0, 1, 2, . . . ,
in D(a, R).
Proof. Since the radius of convergence of the termwise diﬀerentiated series
is still R, the result follows from the facts that the diﬀerentiated series converges
uniformly in every closed disk strictly contained inside D(a, R) and f(z) is diﬀer
entiable in D(a, R).
The following general theorem holds for ordinary diﬀerential equations with
analytic coeﬃcients.
Theorem 5.3 (Existence of Series Solutions). Consider the secondorder or
dinary diﬀerential equation
y
′′
+f(x)y
′
+g(x)y = r(x),
94 5. ANALYTIC SOLUTIONS
where f(z), g(z) and r(z) are analytic functions in a circular neighbourhood of
the point a. If R is equal to the minimum of the radii of convergence of the power
series expansions of f(z), g(z) and r(z) with centre z = a, then the diﬀerential
equation admits an analytic solution in a disk of centre a and radius of convergence
R. This general solution contains two undetermined coeﬃcients.
Proof. The proof makes use of majorizing series in the complex plane C.
This method consists in ﬁnding a series with nonnegative coeﬃcients which con
verges absolutely in D(a, R),
∞
n=0
b
n
(x −a)
n
, b
n
≥ 0,
and whose coeﬃcients majorizes the absolute value of the coeﬃcients of the solu
tion,
y(x) =
∞
n=0
a
n
(x −a)
n
,
that is,
[a
n
[ ≤ b
n
.
We shall use Theorems 5.2 and 5.3 to obtain power series solutions of ordinary
diﬀerential equations. In the next two sections, we shall obtain the power series
solution of the Legendre equation and prove the orthogonality relation satisﬁed
by the Legendre polynomials P
n
(x).
In closing this section, we revisit Examples 1.19 and 1.20.
Example 5.4. Use the power series method to solve the initial value problem
y
′
−xy −1 = 0, y(0) = 1.
Solution. Putting
y(x) = a
0
+a
1
x +a
2
x
2
+a
3
x
3
+. . .
in the diﬀerential equation, we have
y
′
−xy
−1
_
_
_
=
_
_
_
1a
1
+ 2a
2
x + 3a
3
x
2
+ 4a
4
x
3
+. . .
− a
0
x − a
1
x
2
− a
2
x
3
−. . .
−1
The sum of the lefthand side is zero since y(x) is assumed to be a solution of the
diﬀerential equation. Hence, summing the righthand side, we have
0 = (a
1
−1) + (2a
2
−a
0
)x + (3a
3
−a1)x
2
+ (4a
4
−a2)x
3
+. . . .
Since this is an identity in x, the coeﬃcient of each x
s
, for s = 0, 1, 2, . . . , is zero.
Moreover, since the diﬀerential equation is of the ﬁrst order, one of the coeﬃcients
5.3. LEGENDRE EQUATION AND LEGENDRE POLYNOMIALS 95
will be undetermined. Hence, we have
a
1
−1 = 0 =⇒a
1
= 1,
2a
2
−a
0
= 0 =⇒a
2
=
a
0
2
, a
0
arbitrary,
3a
3
−a
1
= 0 =⇒a
3
=
a
1
3
=
1
3
,
4a
4
−a
2
= 0 =⇒a
4
=
a
2
4
=
a
0
8
,
5a
5
−a
3
= 0 =⇒a
5
=
a
3
5
=
1
15
,
and so on. The initial condition y(0) = 1 implies that a
0
= 1. Hence the solution
is
y(x) = 1 +x +
x
2
2
+
x
3
3
+
x
4
8
+
x
5
15
+. . . ,
which coincides with the solutions of Examples 1.19 and 1.20.
5.3. Legendre Equation and Legendre Polynomials
We look for the general solution of the Legendre equation:
(1 −x
2
)y
′′
−2xy
′
+n(n + 1)y = 0, −1 < x < 1, (5.4)
in the form of a power series with centre a = 0. We rewrite the equation in
standard form y
′′
+f(x)y
′
+g(x)y = r(x),
y
′′
−
2x
1 −x
2
y
′
+
n(n + 1)
1 −x
2
y = 0.
Since the coeﬃcients,
f(x) =
2x
(x −1)(x + 1)
, g(x) = −
n(n + 1)
(x −1)(x + 1)
,
have simple poles at x = ±1, they have convergent power series with centre a = 0
and radius of convergence R = 1:
f(x) = −
2x
1 −x
2
= −2x[1 +x
2
+x
4
+x
6
+. . . ], −1 < x < 1,
g(x) =
n(n + 1)
1 −x
2
= n(n + 1)[1 +x
2
+x
4
+x
6
+. . . ], −1 < x < 1.
Moreover
r(x) = 0, −∞< x < ∞.
Hence, we see that f(x) and g(x) are analytic for −1 < x < 1, and r(x) is
everywhere analytic.
By Theorem 5.3, we know that (5.4) has two linearly independent analytic
solutions for −1 < x < 1.
Set
y(x) =
∞
m=0
a
m
x
m
(5.5)
96 5. ANALYTIC SOLUTIONS
and substitute in (5.4), with k = n(n + 1),
y
′′
−x
2
y
′′
−2xy
′
ky
_
¸
¸
_
¸
¸
_
=
_
¸
¸
_
¸
¸
_
2 1a
2
+ 3 2a
3
x + 4 3a
4
x
2
+ 5 4a
5
x
3
+. . .
−2 1a
2
x
2
−3 2a
3
x
3
−. . .
− 2a
1
x −2 2a
2
x
2
−2 3a
3
x
3
−. . .
ka
0
+ ka
1
x + ka
2
x
2
+ ka
3
x
3
+. . .
The sum of the lefthand side is zero since (5.5) is assumed to be a solution of
the Legendre equation. Hence, summing the righthand side, we have
0 = (2 1a
2
+ka
0
)
+ (3 2a
3
−2a
1
+ka
1
)x
+ (4 3a
4
−2 1a
2
−2 2a
2
+ka
2
)x
2
+. . .
+ [(s + 2)(s + 1)a
s+2
−s(s −1)a
s
−2sa
s
+ka
s
]x
s
+. . . , for all x.
Since we have an identity in x, the coeﬃcient of x
s
, for s = 0, 1, 2, . . . , is zero.
Moreover, since (5.4) is an equation of the second order, two of the coeﬃcients
will be undetermined. Hence, we have
2!a
2
+ka
0
= 0 =⇒ a
2
= −
n(n + 1)
2!
a
0
, a
0
is undetermined,
(3 2)a
3
+ (−2 + k)a
1
= 0 =⇒ a
3
=
2 −n(n + 1)
3!
a
1
, a
1
is undetermined,
(s + 2)(s + 1)a
s+2
+ [−s(s −1) −2s +n(n + 1)]a
s
= 0
=⇒ a
s+2
= −
(n −s)(n +s + 1)
(s + 2)(s + 1)
a
s
, s = 0, 1, 2, . . .
Therefore,
a
2
= −
n(n + 1)
2!
a
0
, a
3
= −
(n −1)(n + 2)
3!
a
1
, (5.6)
a
4
=
(n −2)n(n + 1)(n + 3)
4!
a
0
, a
5
=
(n −3)(n −1)(n + 2)(n + 4)
5!
a
1
, (5.7)
etc. The solution can be written in the form
y(x) = a
0
y
1
(x) + a
1
y
2
(x), (5.8)
where
y
1
(x) = 1 −
n(n + 1)
2!
x
2
+
(n −2)n(n + 1)(n + 3)
4!
x
4
−+. . . ,
y
2
(x) = x −
(n −1)(n + 2)
3!
x
3
+
(n −3)(n −1)(n + 2)(n + 4)
5!
x
5
−+. . .
Each series converges for [x[ < R = 1. We remark that y
1
(x) is even and y
2
(x) is
odd. Since
y
1
(x)
y
2
(x)
,= const,
it follows that y
1
(x) and y
2
(x) are two independent solutions and (5.8) is the
general solution.
5.3. LEGENDRE EQUATION AND LEGENDRE POLYNOMIALS 97
−1 −0.5 0.5 1
x
−1
−0.5
0.5
1
P (x)
p
n
2
P
1
P
0
P
4
P
3
Figure 5.4. The ﬁrst ﬁve Legendre polynomials.
Corollary 5.1. For n even, y
1
(x) is an even polynomial,
y
1
(x) = k
n
P
n
(x).
Similarly, for n odd, y
2
(x) is an odd polynomial,
y
2
(x) = k
n
P
n
(x),
The polynomial P
n
(x) is the Legendre polynomial of degree n, normalized such
that P
n
(1) = 1.
The ﬁrst six Legendre polynomials are:
P
0
(x) = 1, P
1
(x) = x,
P
2
(x) =
1
2
_
3x
2
−1
_
, P
3
(x) =
1
2
_
5x
3
−3x
_
,
P
4
(x) =
1
8
_
35x
4
−30x
2
+ 3
_
, P
5
(x) =
1
8
_
63x
5
−70x
3
+ 15x
_
.
The graphs of the ﬁrst ﬁve P
n
(x) are shown in Fig. 5.4.
We notice that the n zeros of the polynomial P
n
(x), of degree n, lie in the
open interval ] − 1, 1[. These zeros are simple and interlace the n − 1 zeros of
P
n−1
(x), two properties that are ordinarily possessed by the zeros of orthogonal
functions.
Remark 5.1. It can be shown that the series for y
1
(x) and y
2
(x) diverge at
x = ±1 if n ,= 0, 2, 4, . . . , and n ,= 1, 3, 5, . . . , respectively.
Symbolic Matlab can be used to obtain the Legendre polynomials if we use
the condition P
n
(1) = 1 as follows.
>> dsolve(’(1x^2)*D2y2*x*Dy=0’,’y(1)=1’,’x’)
y = 1
>> dsolve(’(1x^2)*D2y2*x*Dy+2*y=0’,’y(1)=1’,’x’)
y = x
98 5. ANALYTIC SOLUTIONS
>> dsolve(’(1x^2)*D2y2*x*Dy+6*y=0’,’y(1)=1’,’x’)
y = 1/2+3/2*x^2
and so on. With the extended symbolic toolbox and the professional Matlab, the
Legendre polynomials P
n
(x) can be obtained from the full Maple kernel by using
the command orthopoly[L](n,x), which is referenced by the command mhelp
orthopoly[L].
5.4. Orthogonality Relations for P
n
(x)
Theorem 5.4. The Legendre polynomials P
n
(x) satisfy the following orthog
onality relation,
_
1
−1
P
m
(x)P
n
(x) dx =
_
0, m ,= n,
2
2n+1
, m = n.
(5.9)
Proof. We give below two proofs of the second part (m = n) of the or
thogonality relation. The ﬁrst part (m ,= n) follows simply from the Legendre
equation
(1 −x
2
)y
′′
−2xy
′
+n(n + 1)y = 0,
rewritten in divergence form,
L
n
y := [(1 −x
2
)y
′
]
′
+n(n + 1)y = 0.
Since P
m
(x) and P
n
(x) are solutions of L
m
y = 0 and L
n
y = 0, respectively, we
have
P
n
(x)L
m
(P
m
) = 0, P
m
(x)L
n
(P
n
) = 0.
Integrating these two expressions from −1 to 1, we have
_
1
−1
P
n
(x)[(1 −x
2
)P
′
m
(x)]
′
dx +m(m + 1)
_
1
−1
P
n
(x)P
m
(x) dx = 0,
_
1
−1
P
m
(x)[(1 −x
2
)P
′
n
(x)]
′
dx +n(n + 1)
_
1
−1
P
m
(x)P
n
(x) dx = 0.
Now integrating by parts the ﬁrst term of these expressions, we have
P
n
(x)(1 −x
2
)P
′
m
(x)
¸
¸
¸
1
−1
−
_
1
−1
P
′
n
(x)(1 −x
2
)P
′
m
(x) dx
+m(m + 1)
_
1
−1
P
n
(x)P
m
(x) dx = 0,
P
m
(x)(1 −x
2
)P
′
n
(x)
¸
¸
¸
1
−1
−
_
1
−1
P
′
m
(x)(1 −x
2
)P
′
n
(x) dx
+n(n + 1)
_
1
−1
P
m
(x)P
n
(x) dx = 0.
The integrated terms are zero and the next term is the same in both equations.
Hence, subtracting these equations, we obtain the orthogonality relation
[m(m + 1) −n(n + 1)]
_
1
−1
P
m
(x)P
n
(x) dx = 0
=⇒
_
1
−1
P
m
(x)P
n
(x) dx = 0 for m ,= n.
5.4. ORTHOGONALITY RELATIONS FOR Pn(x) 99
The second part (m = n) follows from Rodrigues’ formula:
P
n
(x) =
1
2
n
n!
d
n
dx
n
_
_
x
2
−1
_
n
_
. (5.10)
In fact,
_
1
−1
P
2
n
(x) dx =
1
2
n
1
n!
1
2
n
1
n!
_
1
−1
_
d
n
dx
n
_
x
2
−1
_
n
_ _
d
n
dx
n
_
x
2
−1
_
n
_
dx
¦and integrating by parts n times¦
=
1
2
n
1
n!
1
2
n
1
n!
_
d
n−1
dx
n−1
_
x
2
−1
_
n d
n
dx
n
_
x
2
−1
_
¸
¸
¸
¸
1
−1
+ (−1)
1
_
1
−1
d
n−1
dx
n−1
(x
2
−1)
n
d
n+1
dx
n+1
_
x
2
−1
_
n
dx
_
+. . .
=
1
2
n
1
n!
1
2
n
1
n!
(−1)
n
_
1
−1
_
x
2
−1
_
n d
2n
dx
2n
_
x
2
−1
_
n
dx
¦and diﬀerentiating 2n times¦
=
1
2
n
1
n!
1
2
n
1
n!
(−1)
n
(2n)!
_
1
−1
1
_
x
2
−1
_
n
dx
¦and integrating by parts n times¦
=
(−1)
n
(2n)!
2
n
n!2
n
n!
_
x
1
_
x
2
−1
_
n
¸
¸
¸
1
−1
+
(−1)
1
1!
2n
_
1
−1
x
2
_
x
2
−1
_
n−1
dx
_
+. . .
=
(−1)
n
(2n)!
2
n
n!2
n
n!
(−1)
n
2n2(n −1)2(n −2) 2(n −(n −1))
1 3 5 (2n −1)
_
1
−1
x
2n
dx
=
(−1)
n
(−1)
n
(2n)!
2
n
n!2
n
n!
2
n
n!
1 3 5 (2n −1)
1
(2n + 1)
x
2n+1
¸
¸
¸
¸
1
−1
=
2
2n + 1
.
Remark 5.2. Rodrigues’ formula can be obtained by direct computation with
n = 0, 1, 2, 3, . . . , or otherwise. We compute P
4
(x) using Rodrigues’ formula with
the symbolic Matlab command diff.
>> syms x
>> p4 = (1/(2^4*prod(1:4)))*diff(f,x,4)
p4 = x^4+3*(x^21)*x^2+3/8*(x^21)^2
>> p4 = expand(p4)
p4 = 3/815/4*x^2+35/8*x^4
We ﬁnally present a second proof of the formula for the norm of P
n
,
P
n

2
:=
_
1
−1
[P
n
(x)]
2
dx =
2
2n + 1
,
100 5. ANALYTIC SOLUTIONS
by means of the generating function for P
n
(x),
∞
k=0
P
k
(x)t
k
=
1
√
1 −2xt +t
2
. (5.11)
Proof. Squaring both sides of (5.11),
∞
k=0
P
2
k
(x)t
2k
+
j=k
P
j
(x)P
k
(x)t
j+k
=
1
1 −2xt +t
2
,
and integrating from −1 to 1, we have
∞
k=0
__
1
−1
P
2
k
(x) dx
_
t
2k
+
j=k
__
1
−1
P
j
(x)P
k
(x) dx
_
t
j+k
=
_
1
−1
dx
1 −2xt +t
2
.
Since P
j
(x) and P
k
(x) are orthogonal for j ,= k, the second term on the lefthand
side is zero. Hence, after integration of the righthand side, we obtain
∞
k=0
P
k

2
t
2k
= −
1
2t
ln
_
1 −2xt +t
2
_
¸
¸
¸
x=1
x=−1
= −
1
t
_
ln (1 −t) −ln (1 +t)
¸
.
Multiplying by t,
∞
k=0
P
k

2
t
2k+1
= −ln (1 −t) + ln (1 +t)
and diﬀerentiating with respect to t, we have
∞
k=0
(2k + 1)P
k

2
t
2k
=
1
1 −t
+
1
1 +t
=
2
1 −t
2
= 2
_
1 +t
2
+t
4
+t
6
+. . .
_
for all t, [t[ < 1.
Since we have an identity in t, we can identify the coeﬃcients of t
2k
on both sides,
(2k + 1)P
k

2
= 2 =⇒ P
k

2
=
2
2k + 1
.
Remark 5.3. The generating function (5.11) can be obtained by expanding
its righthand side in a Taylor series in t, as is easily done with symbolic Matlab
by means of the command taylor.
>> syms t x; f = 1/(12*x*t+t^2)^(1/2);
>> g = taylor(f,3,t)
g = 1+t*x+(1/2+3/2*x^2)*t^2
+(3/2*x+5/2*x^3)*t^3+(3/815/4*x^2+35/8*x^4)*t^4
5.5. FOURIER–LEGENDRE SERIES 101
0 3 5 7
−1 0 1
x
s
Figure 5.5. Aﬃne mapping of x ∈ [3, 7] onto s ∈ [−1, 1].
5.5. Fourier–Legendre Series
We present simple examples of expansions in Fourier–Legendre series.
Example 5.5. Expand the polynomial
p(x) = x
3
−2x
2
+ 4x + 1
over [−1, 1] in terms of the Legendre polynomials P
0
(x), P
1
(x),. . .
Solution. We express the powers of x in terms of the basis of Legendre
polynomials:
P
0
(x) = 1 =⇒ 1 = P
0
(x),
P
1
(x) = x =⇒ x = P
1
(x),
P
2
(x) =
1
2
(3x
2
−1) =⇒ x
2
=
2
3
P
2
(x) +
1
3
P
0
(x),
P
3
(x) =
1
2
(5x
3
−3x) =⇒ x
3
=
2
5
P
3
(x) +
3
5
P
1
(x).
This way, one avoids computing integrals. Thus
p(x) =
2
5
P
3
(x) +
3
5
P
1
(x) −
4
3
P
2
(x) −
2
3
P
0
(x) + 4P
1
(x) +P
0
(x)
=
2
5
P
3
(x) −
4
3
P
2
(x) +
23
5
P
1
(x) +
1
3
P
0
(x).
.
Example 5.6. Expand the polynomial
p(x) = 2 + 3x + 5x
2
over [3, 7] in terms of the Legendre polynomials P
0
(x), P
1
(x),. . .
Solution. To map the segment x ∈ [3, 7] onto the segment s ∈ [−1, 1] (see
Fig. 5.5) we consider the aﬃne transformation
s →x = αs +β, such that −1 →3 = −α +β, 1 →7 = α +β.
Solving for α and β, we have
x = 2s + 5. (5.12)
102 5. ANALYTIC SOLUTIONS
Then
p(x) = p(2s + 5)
= 2 + 3(2s + 5) + 5(2s + 5)
2
= 142 + 106s + 20s
2
= 142P
0
(s) + 106P
1
(s) + 20
_
2
3
P
2
(s) +
1
3
P
0
(s)
_
;
consequently, we have
p(x) =
_
142 +
20
3
_
P
0
_
x −5
2
_
+ 106P
1
_
x −5
2
_
+
40
3
P
2
_
x −5
2
_
.
.
Example 5.7. Compute the ﬁrst three terms of the Fourier–Legendre expan
sion of the function
f(x) =
_
0, −1 < x < 0,
x, 0 < x < 1.
Solution. Putting
f(x) =
∞
m=0
a
m
P
m
(x), −1 < x < 1,
we have
a
m
=
2m+ 1
2
_
1
−1
f(x)P
m
(x) dx.
Hence
a
0
=
1
2
_
1
−1
f(x)P
0
(x) dx =
1
2
_
1
0
xdx =
1
4
,
a
1
=
3
2
_
1
−1
f(x)P
1
(x) dx =
3
2
_
1
0
x
2
dx =
1
2
,
a
2
=
5
2
_
1
−1
f(x)P
2
(x) dx =
5
2
_
1
0
x
1
2
(3x
2
−1) dx =
5
16
.
Thus we have the approximation
f(x) ≈
1
4
P
0
(x) +
1
2
P
1
(x) +
5
16
P
2
(x).
Example 5.8. Compute the ﬁrst three terms of the Fourier–Legendre expan
sion of the function
f(x) = e
x
, 0 ≤ x ≤ 1.
Solution. To use the orthogonality of the Legendre polynomials, we trans
form the domain of f(x) from [0, 1] to [−1, 1] by the substitution
s = 2
_
x −
1
2
_
, that is x =
s
2
+
1
2
.
Then
f(x) = e
x
= e
(1+s)/2
=
∞
m=0
a
m
P
m
(s), −1 ≤ s ≤ 1,
5.6. DERIVATION OF GAUSSIAN QUADRATURES 103
where
a
m
=
2m+ 1
2
_
1
−1
e
(1+s)/2
P
m
(s) ds.
We ﬁrst compute the following three integrals by recurrence:
I
0
=
_
1
−1
e
s/2
ds = 2
_
e
1/2
− e
−1/2
_
,
I
1
=
_
1
−1
s e
s/2
ds = 2s e
s/2
¸
¸
¸
¸
1
−1
−2
_
1
−1
e
s/2
ds
= 2
_
e
1/2
+ e
−1/2
_
−2I
0
= −2 e
1/2
+ 6 e
−1/2
,
I
2
=
_
1
−1
s
2
e
s/2
ds = 2s
2
e
s/2
¸
¸
¸
¸
1
−1
−4
_
1
−1
s e
s/2
ds
= 2
_
e
1/2
− e
−1/2
_
−4I
1
= 10 e
1/2
−26 e
−1/2
.
Thus
a
0
=
1
2
e
1/2
I
0
= e −1 ≈ 1.7183,
a
1
=
3
2
e
1/2
I
1
= −3 e + 9 ≈ 0.8452,
a
2
=
5
2
e
1/2
1
2
(3I
2
−I
0
) = 35 e −95 ≈ 0.1399.
We ﬁnally have the approximation
f(x) ≈ 1.7183P
0
(2x −1) + 0.8452P
1
(2x −1) + 0.1399P
2
(2x −1).
5.6. Derivation of Gaussian Quadratures
We easily obtain the npoint Gaussian quadrature formula by means of the
Legendre polynomials. We restrict ourselves to the cases n = 2 and n = 3. We
immediately remark that the number of points n refers to the n points at which we
need to evaluate the integrand over the interval [−1, 1], and not to the numbers of
subintervals into which one usually breaks the whole interval of integration [a, b]
in order to have a smaller error in the numerical value of the integral.
Example 5.9. Determine the four parameters of the twopoint Gaussian
quadrature formula,
_
1
−1
f(x) dx = af(x
1
) +bf(x
2
).
Solution. By symmetry, it is expected that the nodes will be negative to
each other, x
1
= −x
2
, and the weights will be equal, a = b. Since there are four
free parameters, the formula will be exact for polynomials of degree three or less.
By Example 5.5, it suﬃces to consider the polynomials P
0
(x), . . . , P
3
(x). Since
104 5. ANALYTIC SOLUTIONS
P
0
(x) = 1 is orthogonal to P
n
(x), n = 1, 2, . . . , we have
2 =
_
1
−1
P
0
(x) dx = aP
0
(x
1
) +bP
0
(x
2
) = a +b, (5.13)
0 =
_
1
−1
1 P
1
(x) dx = aP
1
(x
1
) +bP
1
(x
2
) = ax
1
+bx
2
, (5.14)
0 =
_
1
−1
1 P
2
(x) dx = aP
2
(x
1
) +bP
2
(x
2
), (5.15)
0 =
_
1
−1
1 P
3
(x) dx = aP
3
(x
1
) +bP
3
(x
2
), (5.16)
To satisfy (5.15) we choose x
1
and x
2
such that
P
2
(x
1
) = P
2
(x
2
) = 0,
that is,
P
2
(x) =
1
2
(3x
2
−1) = 0 ⇒−x
1
= x
2
=
1
√
3
= 0.577 350 27.
Hence, by (5.14), we have
a = b.
Moreover, (5.16) is automatically satisﬁed since P
3
(x) is odd. Finally, by (5.13),
we have
a = b = 1.
Thus, the twopoint Gaussian quadrature formula is
_
1
−1
f(x) dx = f
_
−
1
√
3
_
+f
_
1
√
3
_
. (5.17)
Example 5.10. Determine the six parameters of the threepoint Gaussian
quadrature formula,
_
1
−1
f(x) dx = af(x
1
) +bf(x
2
) +cf(x
3
).
Solution. By symmetry, it is expected that the two extremal nodes are
negative to each other, x
1
= −x
3
, and the middle node is at the origin, x
2
= 0,
Moreover, the extremal weights should be equal, a = c, and the central one be
larger that the other two, b > a = c. Since there are six free parameters, the
formula will be exact for polynomials of degree ﬁve or less. By Example 5.5, it
5.6. DERIVATION OF GAUSSIAN QUADRATURES 105
suﬃces to consider the basis P
0
(x), . . . , P
5
(x). Thus,
2 =
_
1
−1
P
0
(x) dx = aP
0
(x
1
) +bP
0
(x
2
) +cP
0
(x
3
), (5.18)
0 =
_
1
−1
P
1
(x) dx = aP
1
(x
1
) +bP
1
(x
2
) +cP
1
(x
3
), (5.19)
0 =
_
1
−1
P
2
(x) dx = aP
2
(x
1
) +bP
2
(x
2
) +cP
2
(x
3
), (5.20)
0 =
_
1
−1
P
3
(x) dx = aP
3
(x
1
) +bP
3
(x
2
) +cP
3
(x
3
), (5.21)
0 =
_
1
−1
P
4
(x) dx = aP
4
(x
1
) +bP
4
(x
2
) +cP
4
(x
3
), (5.22)
0 =
_
1
−1
P
5
(x) dx = aP
5
(x
1
) +bP
5
(x
2
) +cP
5
(x
3
). (5.23)
To satisfy (5.21), we let x
1
, x
2
, x
3
be the three zeros of
P
3
(x) =
1
2
(5x
3
−3x) =
1
2
x(5x
2
−3)
that is,
−x
1
= x
3
=
_
3
5
= 0.774 596 7, x
2
= 0.
Hence (5.19) implies
−
_
3
5
a +
_
3
5
c = 0 ⇒a = c.
We immediately see that (5.23) is satisﬁed since P
5
(x) is odd. Moreover, by
substituting a = c in (5.20), we have
a
1
2
_
3
3
5
−1
_
+b
_
−
1
2
_
+a
1
2
_
3
3
5
−1
_
= 0,
that is,
4a −5b + 4a = 0 or 8a −5b = 0. (5.24)
Now, it follows from (5.18) that
2a +b = 2 or 10a + 5b = 10. (5.25)
Adding the second expressions in (5.24) and (5.25), we have
a =
10
18
=
5
9
= 0.555.
Thus
b = 2 −
10
9
=
8
9
= 0.888.
Finally, we verify that (5.22) is satisﬁed. Since
P
4
(x) =
1
8
(35x
4
−30x
2
+ 3),
106 5. ANALYTIC SOLUTIONS
we have
2
5 1
9 8
_
35
9
25
−30
3
5
+ 3
_
+
8
9
3
8
=
2 5
9 8
_
315 −450 + 75
25
_
+
8
9
3
8
=
2 5
9 8
(−60)
25
+
8 3
9 8
=
−24 + 24
9 8
= 0.
Therefore, the threepoint Gaussian quadrature formula is
_
1
−1
f(x) dx =
5
9
f
_
−
_
3
5
_
+
8
9
f(0) +
5
9
f
_
_
3
5
_
. (5.26)
Remark 5.4. The interval of integration in the Gaussian quadrature formulas
is normalized to [−1, 1]. To integrate over the interval [a, b] we use the change of
independent variable from x ∈ [a, b] to t ∈ [−1, 1] (see Example 5.8):
t →x = αt +β, such that −1 →a = −α +β, 1 →b = α +β.
Solving for α and β, we have
x =
(b −a)t +b +a
2
, dx =
_
b −a
2
_
dt.
Thus, the integral becomes
_
b
a
f(x) dx =
b −a
2
_
1
−1
f
_
(b −a)t +b +a
2
_
dt.
Example 5.11. Evaluate
I =
_
π/2
0
sinxdx
by applying the twopoint Gaussian quadrature formula once over the interval
[0, π/2] and over the halfintervals [0, π/4] and [π/4, π/2].
Solution. Let
x =
(π/2)t +π/2
2
, dx =
π
4
dt.
At t = −1, x = 0 and, at t = 1, x = π/2. Hence
I =
π
4
_
1
−1
sin
_
πt +π
4
_
dt
≈
π
4
[1.0 sin(0.105 66π) + 1.0 sin (0.394 34π)]
= 0.998 47.
5.6. DERIVATION OF GAUSSIAN QUADRATURES 107
The error is 1.53 10
−3
. Over the halfintervals, we have
I =
π
8
_
1
−1
sin
_
πt +π
8
_
dt +
π
8
_
1
−1
sin
_
πt + 3π
8
_
dt
≈
π
8
_
sin
π
8
_
−
1
√
3
+ 1
_
+ sin
π
8
_
1
√
3
+ 1
_
+ sin
π
8
_
−
1
√
3
+ 3
_
+ sin
π
8
_
1
√
3
+ 3
__
= 0.999 910 166 769 89.
The error is 8.983 10
−5
. The Matlab solution is as follows. For generality, it is
convenient to set up a function Mﬁle exp5_10.m,
function f=exp5_10(t)
f=sin(t); % evaluate the function f(t)
The twopoint Gaussian quadrature is programmed as follows.
>> clear
>> a = 0; b = pi/2; c = (ba)/2; d= (a+b)/2;
>> weight = [1 1]; node = [1/sqrt(3) 1/sqrt(3)];
>> syms x t
>> x = c*node+d;
>> nv1 = c*weight*exp5_10(x)’ % numerical value of integral
nv1 = 0.9985
>> error1 = 1  nv1 % error in solution
error1 = 0.0015
The other part is done in a similar way.
Remark 5.5. The Gaussian quadrature formulae are the most accurate in
tegration formulae for a given number of nodes. The error in the npoint formula
is
E
n
(f) =
2
(2n + 1)!
_
2
n
(n!)
2
(2n)!
_
2
f
(2n)
(ξ), −1 < ξ < 1.
This formula is therefore exact for polynomials of degree 2n −1 or less.
The nodes of the four and ﬁvepoint Gaussian quadratures can be expressed
in terms of radicals. See Exercises 5.35 and 5.37.
CHAPTER 6
Laplace Transform
6.1. Deﬁnition
Definition 6.1. Let f(t) be a function deﬁned on [0, ∞). The Laplace trans
form F(s) of f(t) is deﬁned by the integral
L(f)(s) := F(s) =
_
∞
0
e
−st
f(t) dt, (6.1)
provided the integral exists for s > γ. In this case, we say that f(t) is trans
formable and that it is the original of F(s).
We see that the exponential function
f(t) = e
t
2
is not transformable since the integral (6.1) does not exist for any s > 0.
We illustrate the deﬁnition of Laplace transform by means of a few examples.
Example 6.1. Find the Laplace transform of the function f(t) = 1.
Solution. (a) The analytic solution.—
L(1)(s) =
_
∞
0
e
−st
dt, s > 0,
= −
1
s
e
−st
¸
¸
¸
∞
0
= −
1
s
(0 −1)
=
1
s
.
(b) The Matlab symbolic solution.—
>> f = sym(’Heaviside(t)’);
>> F = laplace(f)
F = 1/s
The function Heaviside is a Maple function. Help for Maple functions is obtained
by the command mhelp.
Example 6.2. Show that
L
_
e
at
_
(s) =
1
s −a
, s > a. (6.2)
109
110 6. LAPLACE TRANSFORM
Solution. (a) The analytic solution.— Assuming that s > a, we have
L
_
e
at
_
(s) =
_
∞
0
e
−st
e
at
dt
=
_
∞
0
e
−(s−a)t
dt
= −
1
s −a
_
e
−(s−a)t
¸
¸
¸
∞
0
=
1
s −a
.
(b) The Matlab symbolic solution.—
>> syms a t;
>> f = exp(a*t);
>> F = laplace(f)
F = 1/(sa)
Theorem 6.1. The Laplace transform
L : f(t) → F(s)
is a linear operator.
Proof.
L(af +bg) =
_
∞
0
e
−st
_
af(t) +bg(t)
¸
dt
= a
_
∞
0
e
−st
f(t) dt +b
_
∞
0
e
−st
g(t) dt
= aL(f)(s) +bL(g)(s).
Example 6.3. Find the Laplace transform of the function f(t) = coshat.
Solution. (a) The analytic solution.— Since
coshat =
1
2
_
e
at
+e
−at
_
,
we have
L(coshat)(s) =
1
2
_
L
_
e
at
_
+L
_
e
−at
_¸
=
1
2
_
1
s −a
+
1
s +a
_
=
s
s
2
−a
2
.
(b) The Matlab symbolic solution.—
>> syms a t;
>> f = cosh(a*t);
>> F = laplace(f)
F = s/(s^2a^2)
6.1. DEFINITION 111
Example 6.4. Find the Laplace transform of the function f(t) = sinh at.
Solution. (a) The analytic solution.— Since
sinh at =
1
2
_
e
at
−e
−at
_
,
we have
L(sinh at)(s) =
1
2
_
L
_
e
at
_
−L
_
e
−at
_¸
=
1
2
_
1
s −a
−
1
s +a
_
=
a
s
2
−a
2
.
(b) The Matlab symbolic solution.—
>> syms a t;
>> f = sinh(a*t);
>> F = laplace(f)
F = a/(s^2a^2)
Remark 6.1. We see that L(cosh at)(s) is an even function of a and L(sinh at)(s)
is an odd function of a.
Example 6.5. Find the Laplace transform of the function f(t) = t
n
.
Solution. We proceed by induction. Suppose that
L(t
n−1
)(s) =
(n −1)!
s
n
.
This formula is true for n = 1,
L(1)(s) =
0!
s
1
=
1
s
.
If s > 0, by integration by parts, we have
L(t
n
)(s) =
_
∞
0
e
−st
t
n
dt
= −
1
s
_
t
n
e
−st
¸
¸
¸
∞
0
+
n
s
_
∞
0
e
−st
t
n−1
dt
=
n
s
L(t
n−1
)(s).
Now, the induction hypothesis gives
L(t
n
)(s) =
n
s
(n −1)!
s
n
=
n!
s
n+1
, s > 0.
Symbolic Matlab ﬁnds the Laplace transform of, say, t
5
by the commands
112 6. LAPLACE TRANSFORM
>> syms t
>> f = t^5;
>> F = laplace(f)
F = 120/s^6
or
>> F = laplace(sym(’t^5’))
F = 120/s^6
or
>> F = laplace(sym(’t’)^5)
F = 120/s^6
Example 6.6. Find the Laplace transform of the functions cos ωt and sin ωt.
Solution. (a) The analytic solution.— Using Euler’s identity,
e
iωt
= cos ωt +i sinωt, i =
√
−1,
and assuming that s > 0, we have
L
_
e
iωt
_
(s) =
_
∞
0
e
−st
e
iωt
dt (s > 0)
=
_
∞
0
e
−(s−iω)t
dt
= −
1
s −iω
_
e
−(s−iω)t
¸
¸
¸
∞
0
= −
1
s −iω
_
e
−st
e
iωt
¸
¸
¸
t→∞
−1
_
=
1
s −iω
=
1
s −iω
s +iω
s +iω
=
s +iω
s
2
+ω
2
.
By the linearity of L, we have
L
_
e
iωt
_
(s) = L(cos ωt +i sinωt)
= L(cos ωt) +iL(sin ωt)
=
s
s
2
+ω
2
+i
ω
s
2
+ω
2
Hence,
L(cos ωt) =
s
s
2
+ ω
2
, (6.3)
which is an even function of ω, and
L(sin ωt) =
ω
s
2
+ω
2
, (6.4)
which is an odd function of ω.
(b) The Matlab symbolic solution.—
>> syms omega t;
>> f = cos(omega*t);
>> g = sin(omega*t);
>> F = laplace(f)
6.2. TRANSFORMS OF DERIVATIVES AND INTEGRALS 113
F = s/(s^2+omega^2)
>> G = laplace(g)
G = omega/(s^2+omega^2)
In the sequel, we shall implicitly assume that the Laplace transforms of the
functions considered in this chapter exist and can be diﬀerentiated and integrated
under additional conditions. The basis of these assumptions are found in the
following deﬁnition and theorem. The general formula for the inverse transform,
which is not introduced in this chapter, also requires the following results.
Definition 6.2. A function f(t) is said to be of exponential type of order γ
if there are constants γ, M > 0 and T > 0, such that
[f(t)[ ≤ M e
γt
, for all t > T. (6.5)
The least upper bound γ
0
of all values of γ for which (6.5) holds is called the
abscissa of convergence of f(t).
Theorem 6.2. If the function f(t) is piecewise continuous on the interval
[0, ∞) and if γ
0
is the abscissa of convergence of f(t), then the integral
_
∞
0
e
−st
f(t) dt
is absolutely and uniformly convergent for all s > γ
0
.
Proof. We prove only the absolute convergence:
¸
¸
¸
¸
_
∞
0
e
−st
f(t) dt
¸
¸
¸
¸
≤
_
∞
0
M e
−(s−γ0)t
dt
= −
M
s −γ
0
e
−(s−γ0)t
¸
¸
¸
¸
∞
0
=
M
s −γ
0
.
6.2. Transforms of Derivatives and Integrals
In view of applications to ordinary diﬀerential equations, one needs to know
how to transform the derivative of a function.
Theorem 6.3.
L(f
′
)(s) = sL(f) −f(0). (6.6)
Proof. Integrating by parts, we have
L(f
′
)(s) =
_
∞
0
e
−st
f
′
(t) dt
= e
−st
f(t)
¸
¸
¸
∞
0
−(−s)
_
∞
0
e
−st
f(t) dt
= sL(f)(s) −f(0).
Remark 6.2. The following formulae are obtained by induction.
L(f
′′
)(s) = s
2
L(f) −sf(0) −f
′
(0), (6.7)
L(f
′′′
)(s) = s
3
L(f) −s
2
f(0) −sf
′
(0) −f
′′
(0). (6.8)
114 6. LAPLACE TRANSFORM
In fact,
L(f
′′
)(s) = sL(f
′
)(s) −f
′
(0)
= s[sL(f)(s) −f(0)] −f
′
(0)
= s
2
L(f) −sf(0) −f
′
(0)
and
L(f
′′′
)(s) = sL(f
′′
)(s) −f
′′
(0)
= s[s
2
L(f) −sf(0) −f
′
(0)] −f
′′
(0)
= s
3
L(f) − s
2
f(0) −sf
′
(0) −f
′′
(0).
The following general theorem follows by induction.
Theorem 6.4. Let the functions f(t), f
′
(t), . . . , f
(n−1)
(t) be continuous for
t ≥ 0 and f
(n)
(t) be transformable for s ≥ γ. Then
L
_
f
(n)
_
(s) = s
n
L(f) −s
n−1
f(0) −s
n−2
f
′
(0) − −f
(n−1)
(0). (6.9)
Proof. The proof is by induction as in Remark 6.2 for the cases n = 2 and
n = 3.
Example 6.7. Use Laplace transform to solve the following initial value prob
lem for a damped oscillator:
y
′′
+ 4y
′
+ 3y = 0, y(0) = 3, y
′
(0) = 1,
and plot the solution.
Solution. (a) The analytic solution.— Letting
L(y)(s) = Y (s),
we transform the diﬀerential equation,
L(y
′′
) + 4L(y
′
) + 3L(y) = s
2
Y (s) −sy(0) −y
′
(0) + 4[sY (s) −y(0)] + 3Y (s)
= 0.
Then we have
(s
2
+ 4s + 3)Y (s) −(s + 4)y(0) −y
′
(0) = 0,
in which we replace y(0) and y
′
(0) by their values,
(s
2
+ 4s + 3)Y (s) = (s + 4)y(0) +y
′
(0)
= 3(s + 4) + 1
= 3s + 13.
We solve for the unknown Y (s) and expand the righthand side in partial fractions,
Y (s) =
3s + 13
s
2
+ 4s + 3
=
3s + 13
(s + 1)(s + 3)
=
A
s + 1
+
B
s + 3
.
6.2. TRANSFORMS OF DERIVATIVES AND INTEGRALS 115
To compute A and B, we get rid of denominators by rewriting the last two
expressions in the form
3s + 13 = (s + 3)A+ (s + 1)B
= (A +B)s + (3A+B).
We rewrite the ﬁrst and third terms as a linear system,
_
1 1
3 1
_ _
A
B
_
=
_
3
13
_
=⇒
_
A
B
_
=
_
5
−2
_
,
which one can solve. However, in this simple case, we can get the values of A and
B by ﬁrst setting s = −1 and then s = −3 in the identity
3s + 13 = (s + 3)A + (s + 1)B.
Thus
−3 + 13 = 2A =⇒ A = 5, −9 + 13 = −2B =⇒ B = −2.
Therefore
Y (s) =
5
s + 1
−
2
s + 3
.
We ﬁnd the original by means of the inverse Laplace transform given by formula
(6.2):
y(t) = L
−1
(Y ) = 5L
−1
_
1
s + 1
_
−2L
−1
_
1
s + 3
_
= 5 e
−t
−2 e
−3t
.
(b) The Matlab symbolic solution.— Using the expression for Y (s), we have
>> syms s t
>> Y = (3*s+13)/(s^2+4*s+3);
>> y = ilaplace(Y,s,t)
y = 2*exp(3*t)+5*exp(t)
(c) The Matlab numeric solution.— The function Mﬁle exp77.m is
function yprime = exp77(t,y);
yprime = [y(2); 3*y(1)4*y(2)];
and numeric Matlab solver ode45 produces the solution.
>> tspan = [0 4];
>> y0 = [3;1];
>> [t,y] = ode45(’exp77’,tspan,y0);
>> subplot(2,2,1); plot(t,y(:,1));
>> xlabel(’t’); ylabel(’y’); title(’Plot of solution’)
The command subplot is used to produce Fig. 6.1 which, after reduction, still
has large enough lettering.
Remark 6.3. We notice that the characteristic polynomial of the original
homogeneous diﬀerential equation multiplies the function Y (s) of the transformed
equation.
116 6. LAPLACE TRANSFORM
0 1 2 3 4
0
0.5
1
1.5
2
2.5
3
3.5
t
y
Plot of solution
Figure 6.1. Graph of solution of the diﬀerential equation in Example 6.7.
Remark 6.4. Solving a diﬀerential equation by the Laplace transform in
volves the initial values. This is equivalent to the method of undetermined coef
ﬁcients or the method of variation of parameters.
Since integration is the inverse of diﬀerentiation and the Laplace transform of
f
′
(t) is essentially the transform of f(t) multiplied by s, one can foresee that the
transform of the indeﬁnite integral of f(t) will be the transform of f(t) divided
by s since division is the inverse of multiplication.
Theorem 6.5. Let f(t) be transformable for s ≥ γ. Then
L
__
t
0
f(τ) dτ
_
=
1
s
L(f), (6.10)
or, in terms of the inverse Laplace transform,
L
−1
_
1
s
F(s)
_
=
_
t
0
f(τ) dτ. (6.11)
Proof. Letting
g(t) =
_
t
0
f(τ) dτ,
we have
L
_
f(t)
_
= L
_
g
′
(t)
_
= sL
_
g(t)
_
−g(0).
Since g(0) = 0, we have L(f) = sL(g), whence (6.10).
Example 6.8. Find f(t) if
L(f) =
1
s(s
2
+ω
2
)
.
Solution. (a) The analytic solution.— Since
L
−1
_
1
s
2
+ω
2
_
=
1
ω
sin ωt,
6.3. SHIFTS IN s AND IN t 117
F(s)
s
F(s – a)
a
F
0
Figure 6.2. Function F(s) and shifted function F(s −a) for a > 0.
by (6.11) we have
L
−1
_
1
s
_
1
s
2
+ω
2
__
=
1
ω
_
t
0
sin ωτ dτ =
1
ω
2
(1 −cos ωt).
(b) The Matlab symbolic solution.—
>> syms s omega t
>> F = 1/(s*(s^2+omega^2));
>> f = ilaplace(F)
f = 1/omega^21/omega^2*cos(omega*t)
6.3. Shifts in s and in t
In the applications, we need the original of F(s − a) and the transform of
u(t −a)f(t −a) where u(t) is the Heaviside function,
u(t) =
_
0, if t < 0,
1, if t > 0.
(6.12)
Theorem 6.6. Let
L(f)(s) = F(s), s > γ.
Then
L
_
e
at
f(t)
_
(s) = F(s −a), s −a > γ. (6.13)
Proof. (See Fig. 6.2)
F(s −a) =
_
∞
0
e
−(s−a)t
f(t) dt
=
_
∞
0
e
−st
_
e
at
f(t)
¸
dt
= L
_
e
at
f(t)
_
(s).
Example 6.9. Apply Theorem 6.6 to the three simple functions t
n
, cos ωt
and sin ωt.
Solution. (a) The analytic solution.— The results are obvious and are pre
sented in the form of a table.
118 6. LAPLACE TRANSFORM
f(t) F(s) e
at
f(t) F(s −a)
t
n
n!
s
n+1
e
at
t
n
n!
(s −a)
n+1
cos ωt
s
s
2
+ω
2
e
at
cos ωt
(s −a)
(s −a)
2
+ω
2
sin ωt
ω
s
2
+ω
2
e
at
sin ωt
ω
(s −a)
2
+ω
2
(b) The Matlab symbolic solution.— For the second and third functions,
Matlab gives:
>> syms a t omega s;
>> f = exp(a*t)*cos(omega*t);
>> g = exp(a*t)*sin(omega*t);
>> F = laplace(f,t,s)
F = (sa)/((sa)^2+omega^2)
>> G = laplace(g,t,s)
G = omega/((sa)^2+omega^2)
Example 6.10. Find the solution of the damped system:
y
′′
+ 2y
′
+ 5y = 0, y(0) = 2, y
′
(0) = −4,
by means of Laplace transform.
Solution. Setting
L(y)(s) = Y (s),
we have
s
2
Y (s) −sy(0) −y
′
(0) + 2[sY (s) −y(0)] + 5Y (s) = 0.
We group the terms containing Y (s) on the lefthand side,
(s
2
+ 2s + 5)Y (s) = sy(0) + y
′
(0) + 2y(0)
= 2s −4 + 4
= 2s.
We solve for Y (s) and rearrange the righthand side,
Y (s) =
2s
s
2
+ 2s + 1 + 4
=
2(s + 1) −2
(s + 1)
2
+ 2
2
=
2(s + 1)
(s + 1)
2
+ 2
2
−
2
(s + 1)
2
+ 2
2
.
Hence, the solution is
y(t) = 2 e
−t
cos 2t −e
−t
sin 2t.
Definition 6.3. The translate u
a
(t) = u(t − a) of the Heaviside function
u(t), called unit step function, is the function (see Fig. 6.3)
u
a
(t) := u(t −a) =
_
0, if t < a,
1, if t > a,
a ≥ 0. (6.14)
6.3. SHIFTS IN s AND IN t 119
t
u
0
t
u
0 a
1 1
u(t) u(t – a)
Figure 6.3. The Heaviside function u(t) and its translate u(t −
a), a > 0.
f(t)
t
f(t – a)
f
0
a
Figure 6.4. Shift f(t −a) of the function f(t) for a > 0.
The notation α(t) or H(t) is also used for u(t). In symbolic Matlab, the
Maple Heaviside function is accessed by the commands
>> sym(’Heaviside(t)’)
>> u = sym(’Heaviside(t)’)
u = Heaviside(t)
Help to Maple functions is obtained by the command mhelp.
Theorem 6.7. Let
L(f)(s) = F(s).
Then
L
−1
_
e
−as
F(s)
_
= u(t −a)f(t −a), (6.15)
that is,
L
_
u(t −a)f(t −a)
_
(s) = e
−as
F(s), (6.16)
or, equivalently,
L
_
u(t −a)f(t)
_
(s) = e
−as
L
_
f(t +a)
_
(s). (6.17)
Proof. (See Fig. 6.4)
120 6. LAPLACE TRANSFORM
e
−as
F(s) = e
−as
_
∞
0
e
−sτ
f(τ) dτ
=
_
∞
0
e
−s(τ+a)
f(τ) dτ
(setting τ +a = t, dτ = dt)
=
_
∞
a
e
−st
f(t −a) dt
=
_
a
0
e
−st
0f(t −a) dt +
_
∞
a
e
−st
1f(t −a) dt
=
_
∞
0
e
−st
u(t −a)f(t −a) dt
= L
_
u(t −a)f(t −a)
_
(s).
The equivalent formula (6.17) is obtained by a similar change of variable:
L
_
u(t −a)f(t)
_
(s) =
_
∞
0
e
−st
u(t −a)f(t) dt
=
_
∞
a
e
−st
f(t) dt
(setting t = τ +a, dτ = dt)
=
_
∞
0
e
−s(τ+a)
f(τ +a) dτ
= e
−as
_
∞
0
e
−st
f(t +a) dt
= e
−as
L
_
f(t +a)
_
(s).
The equivalent formula (6.17) may simplify computation as will be seen in
some of the following examples.
As a particular case, we see that
L
_
u(t −a)
_
=
e
−as
s
, s > 0.
This formula is a direct consequence of the deﬁnition,
L
_
u(t −a)
_
=
_
∞
0
e
−st
u(t −a) dt
=
_
a
0
e
−st
0 dt +
_
∞
a
e
−st
1 dt
= −
1
s
e
−st
¸
¸
¸
∞
a
=
e
−as
s
.
Example 6.11. Find F(s) if
f(t) =
_
¸
_
¸
_
2, if 0 < t < π,
0, if π < t < 2π,
sint, if 2π < t.
(See Fig. 6.5).
6.3. SHIFTS IN s AND IN t 121
t
f
0 π 2π
3π
4π
u(t – 2π) sin (t – 2π)
2
2 – 2 u(t – π)
Figure 6.5. The function f(t) of example 6.11.
t
0 π
2π
Figure 6.6. The function f(t) of example 6.12.
Solution. We rewrite f(t) using the Heaviside function and the 2πperiodicity
of sin t:
f(t) = 2 −2u(t −π) +u(t −2π) sin(t −2π).
Then
F(s) = 2L(1) −2L
_
u(t −π)1(t −π)
_
+L
_
u(t −2π) sin(t −2π)
_
=
2
s
−e
−πs
2
s
+e
−2πs
1
s
2
+ 1
.
Example 6.12. Find F(s) if
f(t) =
_
2t, if 0 < t < π,
2π, if π < t.
(See Fig. 6.6).
Solution. We rewrite f(t) using the Heaviside function:
f(t) = 2t −u(t −π)(2t) +u(t −π)2π
= 2t −2u(t −π)(t −π).
Then, by (6.16)
F(s) =
2 1!
s
2
−2 e
−πs
1
s
2
.
Example 6.13. Find F(s) if
f(t) =
_
0, if 0 ≤ t < 2,
t, if 2 < t.
122 6. LAPLACE TRANSFORM
t
0
2
2
f(t) = t
Figure 6.7. The function f(t) of example 6.13.
t
0
4
2
f(t) = t
2
Figure 6.8. The function f(t) of example 6.14.
(See Fig. 6.7).
Solution. We rewrite f(t) using the Heaviside function:
f(t) = u(t −2)t
= u(t −2)(t −2) +u(t −2)2.
Then, by (6.16),
F(s) = e
−2s
1!
s
2
+ 2 e
−2s
0!
s
= e
−2s
_
1
s
2
+
2
s
_
.
Equivalently, by (6.17),
L
_
u(t −2)f(t)
_
(s) = e
−2s
L
_
f(t + 2)
_
(s)
= e
−2s
L
_
t + 2
_
(s)
= e
−2s
_
1
s
2
+
2
s
_
.
Example 6.14. Find F(s) if
f(t) =
_
0, if 0 ≤ t < 2,
t
2
, if 2 < t.
(See Fig. 6.8).
6.3. SHIFTS IN s AND IN t 123
t
0
1
π 2π
Figure 6.9. The function f(t) of example 6.15.
Solution. (a) The analytic solution.— We rewrite f(t) using the Heav
iside function:
f(t) = u(t −2)t
2
= u(t −2)
_
(t −2) + 2
¸
2
= u(t −2)
_
(t −2)
2
+ 4(t −2) + 4
¸
.
Then, by (6.16),
F(s) = e
−2s
_
2!
s
3
+
4
s
2
+
4
s
_
.
Equivalently, by (6.17),
L
_
u(t −2)f(t)
_
(s) = e
−2s
L
_
f(t + 2)
_
(s)
= e
−2s
L
_
(t + 2)
2
_
(s)
= e
−2s
L
_
t
2
+ 4t + 4
_
(s)
= e
−2s
_
2!
s
3
+
4
s
2
+
4
s
_
.
(b) The Matlab symbolic solution.—
syms s t
F = laplace(’Heaviside(t2)’*((t2)^2+4*(t2)+4))
F = 4*exp(2*s)/s+4*exp(2*s)/s^2+2*exp(2*s)/s^3
Example 6.15. Find f(t) if
F(s) = e
−πs
s
s
2
+ 4
.
Solution. (a) The analytic solution.— We see that
L
−1
¦F(s)¦(t) = u(t −π) cos
_
2(t − π)
_
=
_
0, if 0 ≤ t < π,
cos
_
2(t −π)
_
= cos 2t, if π < t.
We plot f(t) in ﬁgure 6.9.
(b) The Matlab symbolic solution.—
124 6. LAPLACE TRANSFORM
t
0 π /2
π /2
Figure 6.10. The function g(t) of example 6.16.
>> syms s;
>> F = exp(pi*s)*s/(s^2+4);
>> f = ilaplace(F)
f = Heaviside(tpi)*cos(2*t)
Example 6.16. Solve the following initial value problem:
y
′′
+ 4y = g(t) =
_
t, if 0 ≤ t < π/2,
π/2, if π/2 < t,
y(0) = 0, y
′
(0) = 0,
by means of Laplace transform.
Solution. Setting
L(y) = Y (s) and L(g) = G(s)
we have
L(y
′′
+ 4y) = s
2
Y (s) −sy(0) −y
′
(0) + 4Y (s)
= (s
2
+ 4)Y (s)
= G(s),
where we have used the given values of y(0) and y
′
(0). Thus
Y (s) =
G(s)
s
2
+ 4
.
Using the Heaviside function, we rewrite g(t), shown in Fig. 6.10, in the form
g(t) = t −u(t −π/2)t +u(t −π/2)
π
2
= t −u(t −π/2)(t −π/2),
Thus, the Laplace transform of g(t) is
G(s) =
1
s
2
−e
−(π/2)s
1
s
2
=
_
1 −e
−(π/2)s
_
1
s
2
.
It follows that
Y (s) =
_
1 −e
−(π/2)s
_
1
(s
2
+ 4)s
2
.
6.4. DIRAC DELTA FUNCTION 125
We expand the second factor on the righthand side in partial fractions,
1
(s
2
+ 4)s
2
=
A
s
+
B
s
2
+
Cs +D
s
2
+ 4
.
We get rid of denominators,
1 = (s
2
+ 4)sA+ (s
2
+ 4)B +s
2
(Cs +D)
= (A +C)s
3
+ (B +D)s
2
+ 4As + 4B.
and identify coeﬃcients,
4A = 0 =⇒ A = 0,
4B = 1 =⇒ B =
1
4
,
B +D = 0 =⇒ D = −
1
4
,
A +C = 0 =⇒ C = 0,
whence
1
(s
2
+ 4)s
2
=
1
4
1
s
2
−
1
4
1
s
2
+ 4
.
Thus
Y (s) =
1
4
1
s
2
−
1
8
2
s
2
+ 2
2
−
1
4
e
−(π/2)s
1
s
2
+
1
8
e
−(π/2)s
2
s
2
+ 2
2
and, taking the inverse Laplace transform, we have
y(t) =
1
4
t −
1
8
sin2t −
1
4
u(t −π/2)(t −π/2) +
1
8
u(t −π/2) sin
_
2[t −π/2]
_
.
A second way of ﬁnding the inverse Laplace transform of the function
Y (s) =
1
2
_
1 −e
−(π/2)s
_
2
(s
2
+ 4)s
2
of previous example 6.16 is a double integration by means of formula (6.11) of
Theorem 6.5, that is,
L
−1
_
1
s
2
s
2
+ 2
2
_
=
_
t
0
sin 2τ dτ =
1
2
−
1
2
cos(2t),
L
−1
_
1
s
_
1
s
2
s
2
+ 2
2
__
=
1
2
_
t
0
(1 −cos 2τ) dτ =
t
2
−
1
4
sin(2t).
The inverse Laplace transform y(t) is obtained by (6.15) of Theorem 6.7.
6.4. Dirac Delta Function
Consider the function
f
k
(t; a) =
_
1/k, if a ≤ t ≤ a +k,
0, otherwise.
(6.18)
We see that the integral of f
k
(t; a) is equal to 1,
I
k
=
_
∞
0
f
k
(t; a) dt =
_
a+k
a
1
k
dt = 1. (6.19)
We denote by
δ(t −a)
126 6. LAPLACE TRANSFORM
the limit of f
k
(t; a) as k →0 and call this limit Dirac’s delta function.
We can represent f
k
(t; a) by means of the diﬀerence of two Heaviside func
tions,
f
k
(t; a) =
1
k
[u(t −a) −u(t −(a +k))].
From (6.17) we have
L
_
f
k
(t; a)
_
=
1
ks
_
e
−as
−e
−(a+k)s
_
= e
−as
1 −e
−ks
ks
. (6.20)
The quotient in the last term tends to 1 as k → 0 as one can see by L’Hˆ opital’s
rule. Thus,
L
_
δ(t −a)
_
= e
−as
. (6.21)
Symbolic Matlab produces the Laplace transform of the symbolic function
δ(t) by the following commands.
>> f = sym(’Dirac(t)’);
>> F = laplace(f)
F = 1
Example 6.17. Solve the damped system
y
′′
+ 3y
′
+ 2y = δ(t −a), y(0) = 0, y
′
(0) = 0,
at rest for 0 ≤ t < a and hit at time t = a.
Solution. By (6.21), the transform of the diﬀerential equation is
s
2
Y + 3sY + 2Y = e
−as
.
We solve for Y (s),
Y (s) = e
−as
F(s),
where
F(s) =
1
(s + 1)(s + 2)
=
1
s + 1
−
1
s + 2
.
Then
f(t) = L
−1
(F) = e
−t
−e
−2t
.
Hence, by (6.15), we have
y(t) = L
−1
_
e
−as
F(s)
_
= u(t −a)f(t −a)
=
_
0, if 0 ≤ t < a,
e
−(t−a)
−e
−2(t−a)
, if t > a.
The solution for a = 1 is shown in ﬁgure 6.11.
6.5. DERIVATIVES AND INTEGRALS OF TRANSFORMED FUNCTIONS 127
t
0
1 2 3 4
0.1
0.2
0.3
y(t )
Figure 6.11. Solution y(t) of example 6.17.
6.5. Derivatives and Integrals of Transformed Functions
We derive the following formulae.
Theorem 6.8. If F(s) = L¦f(t)¦(s), then
L¦tf(t)¦(s) = −F
′
(s), (6.22)
or, in terms of the inverse Laplace transform,
L
−1
¦F
′
(s)¦ = −tf(t). (6.23)
Moreover, if the limit
lim
t→0+
f(t)
t
exists, then
L
_
f(t)
t
_
(s) =
_
∞
s
F(˜ s) d˜ s, (6.24)
or, in terms of the inverse Laplace transform,
L
−1
__
∞
s
F(˜ s) d˜ s
_
=
1
t
f(t). (6.25)
Proof. Let
F(s) =
_
∞
0
e
−st
f(t) dt.
Then, by Theorem 6.2, (6.22) follows by diﬀerentiation,
F
′
(s) = −
_
∞
0
e
−st
[tf(t)] dt
= −L¦tf(t)¦(s).
128 6. LAPLACE TRANSFORM
On the other hand, by Theorem 6.2, (6.24) follows by integration,
_
∞
s
F(˜ s) d˜ s =
_
∞
s
_
∞
0
e
−˜ st
f(t) dt d˜ s
=
_
∞
0
f(t)
__
∞
s
e
−˜ st
d˜ s
_
dt
=
_
∞
0
f(t)
_
−
1
t
e
−˜ st
_¸
¸
¸
¸
˜ s=∞
˜ s=s
dt
=
_
∞
0
e
−st
_
1
t
f(t)
_
dt
= L
_
1
t
f(t)
_
.
The following theorem generalizes formula (6.22).
Theorem 6.9. If t
n
f(t) is transformable, then
L¦t
n
f(t)¦(s) = (−1)
n
F
(n)
(s), (6.26)
or, in terms of the inverse Laplace transform,
L
−1
¦F
(n)
(s)¦ = (−1)
n
t
n
f(t). (6.27)
Example 6.18. Use (6.23) to obtain the original of
1
(s + 1)
2
.
Solution. Setting
1
(s + 1)
2
= −
d
ds
_
1
s + 1
_
=: −F
′
(s),
by (6.23) we have
L
−1
¦−F
′
(s)¦ = tf(t) = t L
−1
_
1
s + 1
_
= t e
−t
.
Example 6.19. Use (6.22) to ﬁnd F(s) for the given functions f(t).
f(t) F(s)
1
2β
3
[sin βt −βt cos βt]
1
(s
2
+ β
2
)
2
, (6.28)
t
2β
sin βt
s
(s
2
+ β
2
)
2
, (6.29)
1
2β
[sin βt +βt cos βt]
s
2
(s
2
+ β
2
)
2
. (6.30)
Solution. (a) The analytic solution.— We apply (6.22) to the ﬁrst term of
(6.29),
L
_
t sin βt
_
(s) = −
d
ds
_
β
s
2
+β
2
_
=
2βs
(s
2
+β
2
)
2
,
6.5. DERIVATIVES AND INTEGRALS OF TRANSFORMED FUNCTIONS 129
whence, after division by 2β, we obtain the second term of (6.29).
Similarly, using (6.22) we have
L
_
t cos βt
_
(s) = −
d
ds
_
s
s
2
+β
2
_
= −
s
2
+β
2
−2s
2
(s
2
+β
2
)
2
=
s
2
− β
2
(s
2
+β
2
)
2
.
Then
L
_
1
β
sin βt ±t cos βt
_
(s) =
1
s
2
+β
2
±
s
2
−β
2
(s
2
+β
2
)
2
=
(s
2
+β
2
) ±(s
2
−β
2
)
(s
2
+β
2
)
2
.
Taking the + sign and dividing by two, we obtain (6.30). Taking the − sign and
dividing by 2β
2
, we obtain (6.28).
(b) The Matlab symbolic solution.—
>> syms t beta s
>> f = (sin(beta*t)beta*t*cos(beta*t))/(2*beta^3);
>> F = laplace(f,t,s)
F = 1/2/beta^3*(beta/(s^2+beta^2)beta*(1/(s^2+beta^2)+2*s^2/(s^2+beta^2)^2))
>> FF = simple(F)
FF = 1/(s^2+beta^2)^2
>> g = t*sin(beta*t)/(2*beta);
>> G = laplace(g,t,s)
G = 1/(s^2+beta^2)^2*s
>> h = (sin(beta*t)+beta*t*cos(beta*t))/(2*beta);
>> H = laplace(h,t,s)
H = 1/2/beta*(beta/(s^2+beta^2)+beta*(1/(s^2+beta^2)+2*s^2/(s^2+beta^2)^2))
>> HH = simple(H)
HH = s^2/(s^2+beta^2)^2
Example 6.20. Find
L
−1
_
ln
_
1 +
ω
2
s
2
__
(t).
130 6. LAPLACE TRANSFORM
Solution. (a) The analytic solution.— We have
−
d
ds
ln
_
1 +
ω
2
s
2
_
= −
d
ds
ln
_
s
2
+ω
2
s
2
_
= −
s
2
s
2
+ω
2
2s
3
−2s(s
2
+ω
2
)
s
4
=
2ω
2
s(s
2
+ω
2
)
= 2
(ω
2
+s
2
) −s
2
s(s
2
+ω
2
)
=
2
s
−2
s
s
2
+ω
2
=: F(s).
Thus
f(t) = L
−1
(F) = 2 −2 cos ωt.
Since
f(t)
t
= 2ω
1 −cos ωt
ωt
→0 as t →0,
and using the fact that
_
∞
s
F(˜ s) d˜ s = −
_
∞
s
d
d˜ s
ln
_
1 +
ω
2
˜ s
2
_
d˜ s
= −ln
_
1 +
ω
2
˜ s
2
_¸
¸
¸
¸
∞
s
= −ln1 + ln
_
1 +
ω
2
˜ s
2
_
= ln
_
1 +
ω
2
˜ s
2
_
,
by (6.25) we have
L
−1
_
ln
_
1 +
ω
2
s
2
__
= L
−1
__
∞
s
F(˜ s) d˜ s
_
=
1
t
f(t)
=
2
t
(1 −cos ωt).
(b) The Matlab symbolic solution.—
>> syms omega t s
>> F = log(1+(omega^2/s^2));
>> f = ilaplace(F,s,t)
f = 2/t2/t*cos(omega*t)
6.6. LAGUERRE DIFFERENTIAL EQUATION 131
6.6. Laguerre Diﬀerential Equation
We can solve diﬀerential equations with variable coeﬃcients of the form at+b
by means of Laplace transform. In fact, by (6.22), (6.6) and (6.7), we have
L
_
ty
′
(t)
_
= −
d
ds
[sY (s) −y(0)]
= −Y (s) −sY
′
(s), (6.31)
L
_
ty
′′
(t)
_
= −
d
ds
[s
2
Y (s) −sy(0) −y
′
(0)]
= −2sY (s) −s
2
Y
′
(s) +y(0). (6.32)
Example 6.21. Find the polynomial solutions L
n
(t) of the Laguerre equation
ty
′′
+ (1 −t)y
′
+ny = 0, n = 0, 1, . . . . (6.33)
Solution. The Laplace transform of equation (6.33) is
−2sY (s) −s
2
Y
′
(s) +y(0) +sY (s) −y(0) +Y (s) +sY
′
(s) +nY (s)
= (s −s
2
)Y
′
(s) + (n + 1 −s)Y (s) = 0.
This equation is separable:
dY
Y
=
n + 1 −s
(s −1)s
ds
=
_
n
s −1
−
n + 1
s
_
ds,
whence its solution is
ln [Y (s)[ = nln [s −1[ −(n + 1) ln s
= ln
¸
¸
¸
¸
(s −1)
n
s
n+1
¸
¸
¸
¸
,
that is,
Y (s) =
(s −1)
n
s
n+1
.
Set
L
n
(t) = L
−1
(Y )(t),
where exceptionally capital L in L
n
is a function of t. In fact, L
n
(t) denotes the
Laguerre polynomial of degree n. We show that
L
0
(t) = 1, L
n
(t) =
e
t
n!
d
n
dt
n
_
t
n
e
−t
_
, n = 1, 2, . . . .
We see that L
n
(t) is a polynomial of degree n since the exponential functions
cancel each other after diﬀerentiation. Since by Theorem 6.4,
L
_
f
(n)
_
(s) = s
n
F(s) −s
n−1
f(0) −s
n−2
f
′
(0) − −f
(n−1)
(0),
we have
L
_
_
t
n
e
−t
_
(n)
_
(s) = s
n
n!
(s + 1)
n+1
,
132 6. LAPLACE TRANSFORM
2
2
4 6 8
6
4
2
2
4
6
8
L
1
L (x)
n
L
0
L
2
L
3
Figure 6.12. The ﬁrst four Laguerre polynomials.
and, consequently,
L
_
e
t
n!
_
t
n
e
−t
_
(n)
_
=
n!
n!
(s −1)
n
s
n+1
= Y (s) = L(L
n
) .
The ﬁrst four Laguerre polynomials are (see Fig. 6.12):
L
0
(x) = 1, L
1
(x) = 1 −x,
L
2
(x) = 1 −2x +
1
2
x
2
, L
3
(x) = 1 −3x +
3
2
x
2
−
1
6
x
3
.
We can obtain L
n
(x) by the recurrence formula
(n + 1)L
n+1
(x) = (2n + 1 −x)L
n
(x) −nL
n−1
(x).
The Laguerre polynomials satisfy the following orthogonality relations with
the weight p(x) = e
−x
:
_
∞
0
e
−x
L
m
(x)L
n
(x) dx =
_
0, m ,= n,
1, m = n.
Symbolic Matlab obtains the Laguerre polynomials as follows.
>>L0 = dsolve(’t*D2y+(1t)*Dy=0’,’y(0)=1’,’t’)
L0 = 1
>>L1 = dsolve(’t*D2y+(1t)*Dy+y=0’,’y(0)=1’,’t’);
>> L1 = simple(L1)
L1 = 1t
>> L2 = dsolve(’t*D2y+(1t)*Dy+2*y=0’,’y(0)=1’,’t’);
6.7. CONVOLUTION 133
>> L2 = simple(L2)
L2 = 12*t+1/2*t^2
and so on. The symbolic Matlab command simple has the mathematically un
orthodox goal of ﬁnding a simpliﬁcation of an expression that has the fewest
number of characters.
6.7. Convolution
The original of the product of two transforms is the convolution of the two
originals.
Definition 6.4. The convolution of f(t) with g(t), denoted by (f ∗ g)(t), is
the function
h(t) =
_
t
0
f(τ)g(t −τ) dτ. (6.34)
We say “f(x) convolved with g(x)”.
We verify that convolution is commutative:
(f ∗ g)(t) =
_
t
0
f(τ)g(t −τ) dτ
(setting t −τ = σ, dτ = −dσ)
= −
_
0
t
f(t −σ)g(σ) dσ
=
_
t
0
g(σ)f(t −σ) dσ
= (g ∗ f)(t).
Theorem 6.10. Let
F(s) = L(f), G(s) = L(g), H(s) = F(s)G(s), h(t) = L
−1
(H).
Then
h(t) = (f ∗ g)(t) = L
−1
_
F(s)G(s)
_
. (6.35)
Proof. By deﬁnition and by (6.16), we have
e
−sτ
G(s) = L
_
g(t −τ)u(t −τ)
_
=
_
∞
0
e
−st
g(t −τ)u(t −τ) dt
=
_
∞
τ
e
−st
g(t −τ) dt, s > 0.
134 6. LAPLACE TRANSFORM
t
0
τ
τ = t
Figure 6.13. Region of integration in the tτplane used in the
proof of Theorem 6.10.
Whence, by the deﬁnition of F(s) we have
F(s)G(s) =
_
∞
0
e
−sτ
f(τ)G(s) dτ
=
_
∞
0
f(τ)
__
∞
τ
e
−st
g(t −τ) dt
_
dτ, (s > γ)
=
_
∞
0
e
−st
__
t
0
f(τ)g(t −τ) dτ
_
dt
= L
_
(f ∗ g)(t)
¸
(s)
= L(h)(s).
Figure 6.13 shows the region of integration in the tτplane used in the proof of
Theorem 6.10.
Example 6.22. Find (1 ∗ 1)(t).
Solution.
(1 ∗ 1)(t) =
_
t
0
1 1 dτ = t.
Example 6.23. Find e
t
∗ e
t
.
Solution.
e
t
∗ e
t
=
_
t
0
e
τ
e
t−τ
dτ
=
_
t
0
e
t
dτ = t e
t
.
Example 6.24. Find the original of
1
(s −a)(s −b)
, a ,= b,
by means of convolution.
6.8. PARTIAL FRACTIONS 135
Solution.
L
−1
_
1
(s −a)(s −b)
_
= e
at
∗ e
bt
=
_
t
0
e
aτ
e
b(t−τ)
dτ
= e
bt
_
t
0
e
(a−b)τ
dτ
= e
bt
1
a −b
e
(a−b)τ
¸
¸
¸
t
0
=
e
bt
a −b
_
e
(a−b)t
−1
_
=
e
at
−e
bt
a −b
.
Some integral equations can be solved by means of Laplace transform.
Example 6.25. Solve the integral equation
y(t) = t +
_
t
0
y(τ) sin(t −τ) dτ. (6.36)
Solution. Since the last term of (6.36) is a convolution, then
y(t) = t +y ∗ sin t.
Hence
Y (s) =
1
s
2
+Y (s)
1
s
2
+ 1
,
whence
Y (s) =
s
2
+ 1
s
4
=
1
s
2
+
1
s
4
.
Thus,
y(t) = t +
1
6
t
3
.
6.8. Partial Fractions
Expanding a rational function in partial fractions has been studied in elemen
tary calculus.
We only mention that if p(λ) is the characteristic polynomial of a diﬀerential
equation, Ly = r(t) with constant coeﬃcients, the factorization of p(λ) needed to
ﬁnd the zeros of p and consequently the independent solutions of Ly = 0, is also
needed to expand 1/p(s) in partial fractions when one uses the Laplace transform.
Resonance corresponds to multiple zeros.
The extended symbolic toolbox of the professional Matlab gives access to the
complete Maple kernel. In this case, partial fractions can be obtained by using
the Maple convert command. This command is referenced by entering mhelp
convert[parfrac].
136 6. LAPLACE TRANSFORM
t
0
1
2π /ω 4π /ω π /ω
Figure 6.14. Halfwave rectiﬁer of example 6.26.
6.9. Transform of Periodic Functions
Definition 6.5. A function f(t) deﬁned for all t > 0 is said to be periodic
of period p, p > 0, if
f(t +p) = f(t), for all t > 0. (6.37)
Theorem 6.11. Let f(t) be a periodic function of period p. Then
L(f)(s) =
1
1 −e
−ps
_
p
0
e
−st
f(t) dt, s > 0. (6.38)
Proof. To use the periodicity of f(t), we write
L(f)(s) =
_
∞
0
e
−st
f(t) dt
=
_
p
0
e
−st
f(t) dt +
_
2p
p
e
−st
f(t) dt +
_
3p
2p
e
−st
f(t) dt +. . . .
Substituting
t = τ +p, t = τ + 2p, . . . ,
in the second, third integrals, etc., changing the limits of integration to 0 and p,
and using the periodicity of f(t), we have
L(f)(s) =
_
p
0
e
−st
f(t) dt +
_
p
0
e
−s(t+p)
f(t) dt +
_
p
0
e
−s(t+2p)
f(t) dt +. . .
=
_
1 +e
−sp
+e
−2sp
+
_
_
p
0
e
−st
f(t) dt
=
1
1 −e
−ps
_
p
0
e
−st
f(t) dt.
Example 6.26. Find the Laplace transform of the halfwave rectiﬁcation of
the sine function
sin ωt
(see Fig. 6.14).
Solution. (a) The analytic solution.— The halfrectiﬁed wave of period
p = 2π/ω is
f(t) =
_
sin ωt, if 0 < t < π/ω,
0, if π/ω < t < 2π/ω,
f(t + 2π/ω) = f(t).
6.9. TRANSFORM OF PERIODIC FUNCTIONS 137
t
0
1
2π /ω
4π /ω
Figure 6.15. Fullwave rectiﬁer of example 6.27.
By (6.38),
L(f)(s) =
1
1 −e
−2πs/ω
_
π/ω
0
e
−st
sin ωt dt.
Integrating by parts or, more simply, noting that the integral is the imaginary
part of the following integral, we have
_
π/ω
0
e
(−s+iω)t
dt =
1
−s +iω
e
(−s+iω)t
¸
¸
¸
π/ω
0
=
−s −iω
s
2
+ω
2
_
−e
−sπ/ω
−1
_
.
Using the formula
1 −e
−2πs/ω
=
_
1 +e
−πs/ω
__
1 −e
−πs/ω
_
,
we have
L(f)(s) =
ω
_
1 +e
−πs/ω
_
(s
2
+ω
2
)
_
1 −e
−2πs/ω
_ =
ω
(s
2
+ω
2
)
_
1 −e
−πs/ω
_.
(b) The Matlab symbolic solution.—
syms pi s t omega
G = int(exp(s*t)*sin(omega*t),t,0,pi/omega)
G = omega*(exp(pi/omega*s)+1)/(s^2+omega^2)
F = 1/(1exp(2*pi*s/omega))*G
F = 1/(1exp(2*pi/omega*s))*omega*(exp(pi/omega*s)+1)/(s^2+omega^2)
Example 6.27. Find the Laplace transform of the fullwave rectiﬁcation of
f(t) = sin ωt
(see Fig. 6.15).
Solution. The fully rectiﬁed wave of period p = 2π/ω is
f(t) = [ sin ωt[ =
_
sinωt, if 0 < t < πω,
−sinωt, if π < t < 2πω,
f(t + 2π/ω) = f(t).
By the method used in example 6.26, we have
L(f)(s) =
ω
s
2
+ω
2
coth
πs
2ω
.
CHAPTER 7
Formulas and Tables
7.1. Integrating Factor of M(x, y) dx +N(x, y) dy = 0
Consider the ﬁrstorder homogeneous diﬀerential equation
M(x, y) dx +N(x, y) dy = 0. (7.1)
If
1
N
_
∂M
∂y
−
∂N
∂x
_
= f(x)
is a function of x only, then
µ(x) = e
R
f(x) dx
is an integrating factor of (7.1).
If
1
M
_
∂M
∂y
−
∂N
∂x
_
= g(y)
is a function of y only, then
µ(y) = e
−
R
g(y) dy
is an integrating factor of (7.1).
7.2. Legendre Polynomials P
n
(x) on [−1, 1]
1. The Legendre diﬀerential equation is
(1 −x
2
)y
′′
−2xy
′
+n(n + 1)y = 0, −1 ≤ x ≤ 1.
2. The solution y(x) = P
n
(x) is given by the series
P
n
(x) =
1
2
n
[n/2]
m=0
(−1)
m
_
n
m
__
2n −2m
n
_
x
n−2m
,
where [n/2] denotes the greatest integer smaller than or equal to n/2.
3. The threepoint recurrence relation is
(n + 1)P
n+1
(x) = (2n + 1)xP
n
(x) −nP
n−1
(x).
4. The standardization is
P
n
(1) = 1.
5. The square of the norm of P
n
(x) is
_
1
−1
[P
n
(x)]
2
dx =
2
2n + 1
.
139
140 7. FORMULAS AND TABLES
−1 −0.5 0.5 1
x
−1
−0.5
0.5
1
P (x)
p
n
2
P
1
P
0
P
4
P
3
Figure 7.1. Plot of the ﬁrst ﬁve Legendre polynomials.
6. Rodrigues’s formula is
P
n
(x) =
(−1)
n
2
n
n!
d
n
dx
n
_
_
1 −x
2
_
n
_
.
7. The generating function is
1
√
1 −2xt +t
2
=
∞
n=0
P
n
(x)t
n
, −1 < x < 1, [t[ < 1.
8. The P
n
(x) satisfy the inequality
[P
n
(x)[ ≤ 1, −1 ≤ x ≤ 1.
9. The ﬁrst six Legendre polynomials are:
P
0
(x) = 1, P
1
(x) = x,
P
2
(x) =
1
2
_
3x
2
−1
_
, P
3
(x) =
1
2
_
5x
3
−3x
_
,
P
4
(x) =
1
8
_
35x
4
−30x
2
+ 3
_
, P
5
(x) =
1
8
_
63x
5
−70x
3
+ 15x
_
.
The graphs of the ﬁrst ﬁve P
n
(x) are shown in Fig. 7.1.
7.3. Laguerre Polynomials on 0 ≤ x < ∞
Laguerre polynomials on 0 ≤ x < ∞ are deﬁned by the expression
L
n
(x) =
e
x
n!
d
n
(x
n
e
−x
)
dx
n
, n = 0, 1, . . .
The ﬁrst four Laguerre polynomials are (see ﬁgure 7.2)
L
0
(x) = 1, L
1
(x) = 1 −x,
L
2
(x) = 1 −2x +
1
2
x
2
, L
3
(x) = 1 −3x +
3
2
x
2
−
1
6
x
3
.
The L
n
(x) can be obtained by the threepoint recurrence formula
(n + 1)L
n+1
(x) = (2n + 1 −x)L
n
(x) −nL
n−1
(x).
7.6. TABLE OF LAPLACE TRANSFORMS 141
2
2
4 6 8
6
4
2
2
4
6
8
L
1
L (x)
n
L
0
L
2
L
3
Figure 7.2. Plot of the ﬁrst four Laguerre polynomials.
The L
n
(x) are solutions of the diﬀerential equation
xy
′′
+ (1 −x)y
′
+ny = 0
and satisfy the orthogonality relations with weight p(x) = e
−x
_
∞
0
e
−x
L
m
(x)L
n
(x) dx =
_
0, m ,= n,
1, m = n.
7.4. Fourier–Legendre Series Expansion
The FourierLegendre series expansion of a function f(x) on [−1, 1] is
f(x) =
∞
n=0
a
n
P
n
(x), −1 ≤ x ≤ 1,
where
a
n
=
2n + 1
2
_
1
−1
f(x)P
n
(x) dx, n = 0, 1, 2, . . .
This expansion follows from the orthogonality relations
_
1
−1
P
m
(x)P
n
(x) dx =
_
0, m ,= n,
2
2n+1
, m = n.
7.5. Table of Integrals
7.6. Table of Laplace Transforms
L¦f(t)¦ =
_
∞
0
e
−st
f(t) dt = F(s)
142 7. FORMULAS AND TABLES
Table 7.1. Table of integrals.
1.
_
tan u du = ln [ sec u[ +c
2.
_
cot u du = ln [ sin u[ +c
3.
_
sec u du = ln [ sec u + tanu[ +c
4.
_
csc u du = ln [ csc u −cot u[ +c
5.
_
tanh u du = ln coshu +c
6.
_
coth u du = ln sinh u +c
7.
_
du
√
a
2
−u
2
= arcsin
u
a
+c
8.
_
du
√
a
2
+u
2
= ln
_
u +
_
u
2
+a
2
_
+c = arcsinh
u
a
+c
9.
_
du
√
u
2
−a
2
= ln
_
u +
_
u
2
−a
2
_
+c = arccosh
u
a
+c
10.
_
du
a
2
+u
2
=
1
a
arctan
u
a
+c
11.
_
du
u
2
−a
2
=
1
2a
ln
¸
¸
¸
¸
u −a
u +a
¸
¸
¸
¸
+c
12.
_
du
a
2
−u
2
=
1
2a
ln
¸
¸
¸
¸
u +a
u −a
¸
¸
¸
¸
+c
13.
_
du
u(a +bu)
=
1
a
ln
¸
¸
¸
¸
u
a +bu
¸
¸
¸
¸
+c
14.
_
du
u
2
(a +bu)
= −
1
au
+
b
a
2
ln
¸
¸
¸
¸
a +bu
u
¸
¸
¸
¸
+c
15.
_
du
u(a +bu)
2
=
1
a(a +bu)
−
1
a
2
ln
¸
¸
¸
¸
a +bu
u
¸
¸
¸
¸
+c
16.
_
x
n
ln axdx =
x
n+1
n + 1
ln ax −
x
n+1
(n + 1)
2
+c
7.6. TABLE OF LAPLACE TRANSFORMS 143
Table 7.2. Table of Laplace transforms.
F(s) = L¦f(t)¦ f(t)
1. F(s −a) e
at
f(t)
2. F(as +b)
1
a
e
−bt/a
f
_
t
a
_
3.
1
s
e
−cs
, c > 0 u(t −c) :=
_
0, 0 ≤ t < c
1, t ≥ c
4. e
−cs
F(s), c > 0 f(t −c)u(t −c)
5. F
1
(s)F
2
(s)
_
t
0
f
1
(τ)f
2
(t −τ) dτ
6.
1
s
1
7.
1
s
n+1
t
n
n!
8.
1
s
a+1
t
a
Γ(a + 1)
9.
1
√
s
1
√
πt
10.
1
s + a
e
−at
11.
1
(s +a)
n+1
t
n
e
−at
n!
12.
k
s
2
+k
2
sinkt
13.
s
s
2
+k
2
cos kt
14.
k
s
2
−k
2
sinh kt
15.
s
s
2
−k
2
coshkt
16.
2k
3
(s
2
+k
2
)
2
sinkt −kt cos kt
17.
2ks
(s
2
+k
2
)
2
t sinkt
18.
1
1 −e
−ps
_
p
0
e
−st
f(t) dt f(t +p) = f(t), for all t
Part 2
Numerical Methods
CHAPTER 8
Solutions of Nonlinear Equations
8.1. Computer Arithmetics
8.1.1. Deﬁnitions. The following notation and terminology will be used.
1. If a is the exact value of a computation and ˜ a is an approximate value
for the same computation, then
ǫ = ˜ a −a
is the error in ˜ a and [ǫ[ is the absolute error. If a ,= 0,
ǫ
r
=
˜ a −a
a
=
ǫ
a
is the relative error in ˜ a.
2. Upper bounds for the absolute and relative errors in ˜ a are numbers
B
a
and B
r
such that
[ǫ[ = [˜ a −a[ < B
a
, [ǫ
r
[ =
¸
¸
¸
¸
˜ a −a
a
¸
¸
¸
¸
< B
r
,
respectively.
3. A roundoﬀ error occurs when a computer approximates a real number
by a number with only a ﬁnite number of digits to the right of the decimal
point (see Subsection 8.1.2).
4. In scientiﬁc computation, the ﬂoating point representation of a num
ber c of length d in the base β is
c = ±0.b
1
b
2
b
d
β
N
,
where b
1
,= 0, 0 ≤ b
i
< β. We call b
1
b
2
b
d
the mantissa or decimal
part and N the exponent of c. For instance, with d = 5 and β = 10,
0.27120 10
2
, −0.31224 10
3
.
5. The number of signiﬁcant digits of a ﬂoating point number is the
number of digits counted from the ﬁrst to the last nonzero digits. For
example, with d = 4 and β = 10, the number of signiﬁcant digits of the
three numbers:
0.1203 10
2
, 0.1230 10
−2
, 0.1000 10
3
,
is 4, 3, and 1, respectively.
6. The term truncation error is used for the error committed when an
inﬁnite series is truncated after a ﬁnite number of terms.
147
148 8. SOLUTIONS OF NONLINEAR EQUATIONS
Remark 8.1. For simplicity, we shall often write ﬂoating point numbers
without exponent and with zeros immediately to the right of the decimal point
or with nonzero numbers to the left of the decimal point:
0.001203, 12300.04
8.1.2. Rounding and chopping numbers. Real numbers are rounded
away from the origin. The ﬂoatingpoint number, say in base 10,
c = ±0.b
1
b
2
. . . b
d
10
N
is rounded to k digits as follows:
(i) If 0.b
k+1
b
k+2
. . . b
m
≥ 0.5, round c to
(0.b
1
b
2
. . . b
k−1
b
k
+ 0.1 10
−k+1
) 10
N
.
(ii) If 0.b
k+1
b
k+2
. . . b
m
< 0.5, round c to
0.b
1
b
2
. . . b
k−1
b
k
10
N
.
Example 8.1. Numbers rounded to three digits:
1.9234542 ≈ 1.92
2.5952100 ≈ 2.60
1.9950000 ≈ 2.00
−4.9850000 ≈ −4.99
Floatingpoint numbers are chopped to k digits by replacing the digits to the
right of the kth digit by zeros.
8.1.3. Cancellation in computations. Cancellation due to the subtrac
tion of two almost equal numbers leads to a loss of signiﬁcant digits. It is better
to avoid cancellation than to try to estimate the error due to cancellation. Ex
ample 8.2 illustrates these points.
Example 8.2. Use 10digit rounded arithmetic to solve the quadratic equa
tion
x
2
−1634x + 2 = 0.
Solution. The usual formula yields
x = 817 ±
√
2 669 948.
Thus,
x
1
= 817 + 816.998 776 0 = 1.633 998 776 10
3
,
x
2
= 817 −816.998 776 0 = 1.224 000 000 10
−3
.
Four of the six zeros at the end of the fractional part of x
2
are the result of
cancellation and thus are meaningless. A more accurate result for x
2
can be
obtained if we use the relation
x
1
x
2
= 2.
In this case
x
2
= 1.223 991 125 10
−3
,
where all digits are signiﬁcant.
8.1. COMPUTER ARITHMETICS 149
From Example 8.2, it is seen that a numerically stable formula for solving the
quadratic equation
ax
2
+bx +c = 0, a ,= 0,
is
x
1
=
1
2a
_
−b −sign (b)
_
b
2
−4ac
_
, x
2
=
c
ax
1
,
where the signum function is
sign(x) =
_
+1, if x ≥ 0,
−1, if x < 0.
Example 8.3. If the value of x rounded to three digits is 4.81 and the value
of y rounded to ﬁve digits is 12.752, ﬁnd the smallest interval which contains the
exact value of x −y.
Solution. Since
4.805 ≤ x < 4.815 and 12.7515 ≤ y < 12.7525,
then
4.805 −12.7525 < x −y < 4.815 −12.7515 ⇔−7.9475 < x −y < −7.9365.
Example 8.4. Find the error and the relative error in the commonly used
rational approximations 22/7 and 355/113 to the transcendental number π and
express your answer in threedigit ﬂoating point numbers.
Solution. The error and the relative error in 22/7 are
ǫ = 22/7 −π, ǫ
r
= ǫ/π,
which Matlab evaluates as
pp = pi
pp = 3.14159265358979
r1 = 22/7.
r1 = 3.14285714285714
abserr1 = r1 pi
abserr1 = 0.00126448926735
relerr1 = abserr1/pi
relerr1 = 4.024994347707008e04
Hence, the error and the relative error in 22/7 rounded to three digits are
ǫ = 0.126 10
−2
and ǫ
r
= 0.402 10
−3
,
respectively. Similarly, Matlab computes the error and relative error in 355/113
as
r2 = 355/113.
r2 = 3.14159292035398
abserr2 = r2  pi
abserr2 = 2.667641894049666e07
relerr2 = abserr2/pi
relerr2 = 8.491367876740610e08
150 8. SOLUTIONS OF NONLINEAR EQUATIONS
Hence, the error and the relative error in 355/113 rounded to three digits are
ǫ = 0.267 10
−6
and ǫ
r
= 0.849 10
−7
.
8.2. Review of Calculus
The following results from elementary calculus are needed to justify the meth
ods of solution presented here.
Theorem 8.1 (Intermediate Value Theorem). Let a < b and f(x) be a con
tinuous function on [a, b]. If w is a number strictly between f(a) and f(b), then
there exists a number c such that a < c < b and f(c) = w.
Corollary 8.1. Let a < b and f(x) be a continuous function on [a, b]. If
f(a)f(b) < 0, then there exists a zero of f(x) in the open interval ]a, b[.
Proof. Since f(a) and f(b) have opposite signs, 0 lies between f(a) and
f(b). The result follows from the intermediate value theorem with w = 0.
Theorem 8.2 (Extreme Value Theorem). Let a < b and f(x) be a continuous
function on [a, b]. Then there exist numbers α ∈ [a, b] and β ∈ [a, b] such that, for
all x ∈ [a, b], we have
f(α) ≤ f(x) ≤ f(β).
Theorem 8.3 (Mean Value Theorem). Let a < b and f(x) be a continuous
function on [a, b] which is diﬀerentiable on ]a, b[. Then there exists a number c
such that a < c < b and
f
′
(c) =
f(b) −f(a)
b −a
.
Theorem 8.4 (Mean Value Theorem for Integrals). Let a < b and f(x) be a
continuous function on [a, b]. If g(x) is an integrable function on [a, b] which does
not change sign on [a, b], then there exists a number c such that a < c < b and
_
b
a
f(x) g(x) dx = f(c)
_
b
a
g(x) dx.
A similar theorem holds for sums.
Theorem 8.5 (Mean Value Theorem for Sums). Let ¦w
i
¦, i = 1, 2, . . . , n, be a
set of n distinct real numbers and let f(x) be a continuous function on an interval
[a, b]. If the numbers w
i
all have the same sign and all the points x
i
∈ [a, b], then
there exists a number c ∈ [a, b] such that
n
i=1
w
i
f(x
i
) = f(c)
n
i=1
w
i
.
8.3. The Bisection Method
The bisection method constructs a sequence of intervals of decreasing length
which contain a root p of f(x) = 0. If
f(a) f(b) < 0 and f is continuous on [a, b],
then, by Corollary 8.1, f(x) = 0 has a root between a and b. The root is either
between
a and
a +b
2
, if f(a) f
_
a +b
2
_
< 0,
8.3. THE BISECTION METHOD 151
y
0 x p
b
n
a
n
y = f (x)
x
n+1
(a , f (a ))
n n
(b , f (b ))
n n
Figure 8.1. The nth step of the bisection method.
or between
a +b
2
and b, if f
_
a +b
2
_
f(b) < 0,
or exactly at
a +b
2
, if f
_
a +b
2
_
= 0.
The nth step of the bisection method is shown in Fig. 8.1.
The algorithm of the bisection method is as follows.
Algorithm 8.1 (Bisection Method). Given that f(x) is continuous on [a, b]
and f(a) f(b) < 0:
(1) Choose a
0
= a, b
0
= b; tolerance TOL; maximum number of iteration
N
0
.
(2) For n = 0, 1, 2, . . . , N
0
, compute
x
n+1
=
a
n
+b
n
2
.
(3) If f(x
n+1
) = 0 or (b
n
−a
n
)/2 < TOL, then output p (= x
n+1
) and stop.
(4) Else if f(x
n+1
) and f(a
n
) have opposite signs, set a
n+1
= a
n
and b
n+1
=
x
n+1
.
(5) Else set a
n+1
= x
n+1
and b
n+1
= b
n
.
(6) Repeat (2), (3), (4) and (5).
(7) Ouput ’Method failed after N
0
iterations’ and stop.
Other stopping criteria are described in Subsection 8.4.1. The rate of conver
gence of the bisection method is low but the method always converges.
The bisection method is programmed in the following Matlab function Mﬁle
which is found in ftp://ftp.cs.cornell.edu/pub/cv.
function root = Bisection(fname,a,b,delta)
%
% Pre:
% fname string that names a continuous function f(x) of
% a single variable.
%
% a,b define an interval [a,b]
% f is continuous, f(a)f(b) < 0
152 8. SOLUTIONS OF NONLINEAR EQUATIONS
%
% delta nonnegative real number.
%
% Post:
% root the midpoint of an interval [alpha,beta]
% with the property that f(alpha)f(beta)<=0 and
% betaalpha <= delta+eps*max(alpha,beta)
%
fa = feval(fname,a);
fb = feval(fname,b);
if fa*fb > 0
disp(’Initial interval is not bracketing.’)
return
end
if nargin==3
delta = 0;
end
while abs(ab) > delta+eps*max(abs(a),abs(b))
mid = (a+b)/2;
fmid = feval(fname,mid);
if fa*fmid<=0
% There is a root in [a,mid].
b = mid;
fb = fmid;
else
% There is a root in [mid,b].
a = mid;
fa = fmid;
end
end
root = (a+b)/2;
Example 8.5. Find an approximation to
√
2 using the bisection method.
Stop iterating when [x
n+1
−x
n
[ < 10
−2
.
Solution. We need to ﬁnd a root of f(x) = x
2
−2 = 0. Choose a
0
= 1 and
b
0
= 2, and obtain recursively
x
n+1
=
a
n
+b
n
2
by the bisection method. The results are listed in Table 8.1. The answer is
√
2 ≈ 1.414063 with an accuracy of 10
−2
. Note that a root lies in the interval
[1.414063, 1.421875].
Example 8.6. Show that the function f(x) = x
3
+4 x
2
−10 has a unique root
in the interval [1, 2] and give an approximation to this root using eight iterations
of the bisection method. Give a bound for the absolute error.
Solution. Since
f(1) = −5 < 0 and f(2) = 14 > 0,
8.3. THE BISECTION METHOD 153
Table 8.1. Results of Example 8.5.
n x
n
a
n
b
n
[x
n−1
−x
n
[ f(x
n
) f(a
n
)
0 1 2 −
1 1.500000 1 1.500000 .500000 + −
2 1.250000 1.250000 1.500000 .250000 − −
3 1.375000 1.375000 1.500000 .125000 − −
4 1.437500 1.375000 1.437500 .062500 + −
5 1.406250 1.406250 1.437500 .031250 − −
6 1.421875 1.406250 1.421875 .015625 + −
7 1.414063 1.414063 1.421875 .007812 − −
Table 8.2. Results of Example 8.6.
n x
n
a
n
b
n
f(x
n
) f(a
n
)
0 1 2 −
1 1.500000000 1 1.500000000 + −
2 1.250000000 1.250000000 1.500000000 − −
3 1.375000000 1.250000000 1.375000000 + −
4 1.312500000 1.312500000 1.375000000 − −
5 1.343750000 1.343750000 1.375000000 − −
6 1.359375000 1.359375000 1.375000000 − −
7 1.367187500 1.359375000 1.367187500 + −
8 1.363281250 1.363281250 1.367187500 − −
then f(x) has a root, p, in [1, 2]. This root is unique since f(x) is strictly increasing
on [1, 2]; in fact
f
′
(x) = 3 x
2
+ 4 x > 0 for all x between 1 and 2.
The results are listed in Table 8.2.
After eight iterations, we ﬁnd that p lies between 1.363281250 and 1.367187500.
Therefore, the absolute error in p is bounded by
1.367187500 −1.363281250 = 0.00390625.
Example 8.7. Find the number of iterations needed in Example 8.6 to have
an absolute error less than 10
−4
.
Solution. Since the root, p, lies in each interval [a
n
, b
n
], after n iterations
the error is at most b
n
−a
n
. Thus, we want to ﬁnd n such that b
n
−a
n
< 10
−4
.
Since, at each iteration, the length of the interval is halved, it is easy to see that
b
n
−a
n
= (2 −1)/2
n
.
Therefore, n satisﬁes the inequality
2
−n
< 10
−4
,
that is,
ln 2
−n
< ln 10
−4
, or −nln 2 < −4 ln10.
154 8. SOLUTIONS OF NONLINEAR EQUATIONS
Thus,
n > 4 ln10/ln 2 = 13.28771238 =⇒ n = 14.
Hence, we need 14 iterations.
8.4. Fixed Point Iteration
Let f(x) be a realvalued function of a real variable x. In this section, we
present iterative methods for solving equations of the form
f(x) = 0. (8.1)
A root of the equation f(x) = 0, or a zero of f(x), is a number p such that
f(p) = 0.
To ﬁnd a root of equation (8.1), we rewrite this equation in an equivalent
form
x = g(x), (8.2)
for instance, g(x) = x −f(x).
We say that (8.1) and (8.2) are equivalent (on a given interval) if any root
of (8.1) is a ﬁxed point for (8.2) and viceversa.
Conversely, if, for a given initial value x
0
, the sequence x
0
, x
1
, . . . , deﬁned
by the recurrence
x
n+1
= g(x
n
), n = 0, 1, . . . , (8.3)
converges to a number p, we say that the ﬁxed point method converges. If g(x)
is continuous, then p = g(p). This is seen by taking the limit in equation (8.3) as
n →∞. The number p is called a ﬁxed point for the function g(x) of the ﬁxed
point iteration (8.2).
It is easily seen that the two equations
x
3
+ 9 x −9 = 0, x = (9 −x
3
)/9
are equivalent. The problem is to choose a suitable function g(x) and a suitable
initial value x
0
to have convergence. To treat this question we need to deﬁne the
diﬀerent types of ﬁxed points.
Definition 8.1. A ﬁxed point, p = g(p), of an iterative scheme
x
n+1
= g(x
n
),
is said to be attractive, repulsive or indiﬀerent if the multiplier, g
′
(p), of g(x)
satisﬁes
[g
′
(p)[ < 1, [g
′
(p)[ > 1, or [g
′
(p)[ = 1,
respectively.
Theorem 8.6 (Fixed Point Theorem). Let g(x) be a realvalued function
satisfying the following conditions:
1. g(x) ∈ [a, b] for all x ∈ [a, b].
2. g(x) is diﬀerentiable on [a, b].
3. There exists a number K, 0 < K < 1, such that [g
′
(x)[ ≤ K for all
x ∈ (a, b).
Then g(x) has a unique attractive ﬁxed point p ∈ [a, b]. Moreover, for arbitrary
x
0
∈ [a, b], the sequence x
0
, x
1
, x
2
, . . . deﬁned by
x
n+1
= g(x
n
), n = 0, 1, 2, . . . ,
converges to p.
8.4. FIXED POINT ITERATION 155
Proof. If g(a) = a or g(b) = b, the existence of an attractive ﬁxed point
is obvious. Suppose not, then it follows that g(a) > a and g(b) < b. Deﬁne the
auxiliary function
h(x) = g(x) −x.
Then h is continuous on [a, b] and
h(a) = g(a) −a > 0, h(b) = g(b) −b < 0.
By Corollary 8.1, there exists a number p ∈]a, b[ such that h(p) = 0, that is,
g(p) = p and p is a ﬁxed point for g(x).
To prove uniqueness, suppose that p and q are distinct ﬁxed points for g(x)
in [a, b]. By the Mean Value Theorem 8.3, there exists a number c between p and
q (and hence in [a, b]) such that
[p −q[ = [g(p) −g(q)[ = [g
′
(c)[ [p −q[ ≤ K[p −q[ < [p −q[,
which is a contradiction. Thus p = q and the attractive ﬁxed point in [a, b] is
unique.
We now prove convergence. By the Mean Value Theorem 8.3, for each pair
of numbers x and y in [a, b], there exists a number c between x and y such that
g(x) −g(y) = g
′
(c)(x −y).
Hence,
[g(x) −g(y)[ ≤ K[x −y[.
In particular,
[x
n+1
−p[ = [g(x
n
) −g(p)[ ≤ K[x
n
−p[.
Repeating this procedure n + 1 times, we have
[x
n+1
−p[ ≤ K
n+1
[x
0
−p[ →0, as n →∞,
since 0 < K < 1. Thus the sequence ¦x
n
¦ converges to p.
Example 8.8. Find a root of the equation
f(x) = x
3
+ 9x −9 = 0
in the interval [0, 1] by a ﬁxed point iterative scheme.
Solution. Solving this equation is equivalent to ﬁnding a ﬁxed point for
g(x) = (9 −x
3
)/9.
Since
f(0)f(1) = −9 < 0,
Corollary 8.1 implies that f(x) has a root, p, between 0 and 1. Condition (3) of
Theorem 8.6 is satisﬁed with K = 1/3 since
[g
′
(x)[ = [ −x
2
/3[ ≤ 1/3
for all x between 0 and 1. The other conditions are also satisﬁed.
Five iterations are performed with Matlab starting with x
0
= 0.5. The func
tion Mﬁle exp8_8.m is
function x1 = exp8_8(x0); % Example 8.8.
x1 = (9x0^3)/9;
156 8. SOLUTIONS OF NONLINEAR EQUATIONS
Table 8.3. Results of Example 8.8.
n x
n
error ǫ
n
ǫ
n
/ǫ
n−1
0 0.50000000000000 −0.41490784153366 1.00000000000000
1 0.98611111111111 0.07120326957745 −0.17161225325185
2 0.89345451579409 −0.02145332573957 −0.30129691890395
3 0.92075445888550 0.00584661735184 −0.27252731920515
4 0.91326607850598 −0.00164176302768 −0.28080562295762
5 0.91536510274262 0.00045726120896 −0.27851839836463
The exact solution
0.914 907 841 533 66
is obtained by means of some 30 iterations. The following iterative procedure
solves the problem.
xexact = 0.91490784153366;
N = 5; x=zeros(N+1,4);
x0 = 0.5; x(1,:) = [0 x0 (x0xexact), 1];
for i = 1:N
xt=exp8_8(x(i,2));
x(i+1,:) = [i xt (xtxexact), (xtxexact)/x(i,3)];
end
The iterates, their errors and the ratios of successive errors are listed in Table 8.3.
One sees that the ratios of successive errors are nearly constant; therefore the
order of convergence, deﬁned in Subsection 8.4.2, is one.
In Example 8.9 below, we shall show that the convergence of an iterative
scheme x
n+1
= g(x
n
) to an attractive ﬁxed point depends upon a judicious re
arrangement of the equation f(x) = 0 to be solved. In fact, besides ﬁxed points,
an iterative scheme may have cycles which are deﬁned in Deﬁnition 8.2, where
g
2
(x) = g(g(x)), g
3
(x) = g(g
2
(x)) etc.
Definition 8.2. Given an iterative scheme
x
n+1
= g(x
n
),
a kcycle of g(x) is a set of k distinct points,
x
0
, x
1
, x
2
, . . . , x
k−1
,
satisfying the relations
x
1
= g(x
0
), x
2
= g
2
(x
0
), . . . , x
k−1
= g
k−1
(x
0
), x
0
= g
k
(x
0
).
The multiplier of a k cycle is
(g
k
)
′
(x
j
) = g
′
(x
k−1
) g
′
(x
0
), j = 0, 1, . . . , k −1.
A kcycle is attractive, repulsive, or indiﬀerent as
[(g
k
)
′
(x
j
)[ < 1, > 1, = 1.
A ﬁxed point is a 1cycle.
The multiplier of a cycle is seen to be the same at every point of the cycle.
8.4. FIXED POINT ITERATION 157
Example 8.9. Find a root of the equation
f(x) = x
3
+ 4 x
2
−10 = 0
in the interval [1, 2] by ﬁxed point iterative schemes and study their convergence
properties.
Solution. Since f(1)f(2) = −70 < 0, the equation f(x) = 0 has a root in
the interval [1, 2]. The exact roots are given by the Matlab command roots
p=[1 4 0 10]; % the polynomial f(x)
r =roots(p)
r =
2.68261500670705 + 0.35825935992404i
2.68261500670705  0.35825935992404i
1.36523001341410
There is one real root, which we denote by x
∞
, in the interval [1, 2], and a pair
of complex conjugate roots.
Six iterations are performed with the following ﬁve rearrangements x = g
j
(x),
j = 1, 2, 3, 4, 5, of the given equation f(x) = 0. The derivative of g
′
j
(x) is evaluated
at the real root x
∞
≈ 1.365.
x = g
1
(x) =: 10 +x −4x
2
−x
3
, g
′
1
(x
∞
) ≈ −15.51,
x = g
2
(x) =:
_
(10/x) −4x, g
′
2
(x
∞
) ≈ −3.42,
x = g
3
(x) =:
1
2
_
10 −x
3
, g
′
3
(x
∞
) ≈ −0.51,
x = g
4
(x) =:
_
10/(4 +x), g
′
4
(x
∞
) ≈ −0.13
x = g
5
(x) =: x −
x
3
+ 4x
2
−10
3x
2
+ 8x
, g
′
5
(x
∞
) = 0.
The Matlab function Mﬁle exp1_9.m is
function y = exp1_9(x); % Example 1.9.
y = [10+x(1)4*x(1)^2x(1)^3; sqrt((10/x(2))4*x(2));
sqrt(10x(3)^3)/2; sqrt(10/(4+x(4)));
x(5)(x(5)^3+4*x(5)^210)/(3*x(5)^2+8*x(5))]’;
The following iterative procedure is used.
N = 6; x=zeros(N+1,5);
x0 = 1.5; x(1,:) = [0 x0 x0 x0 x0];
for i = 1:N
xt=exp1_9(x(i,2:5));
x(i+1,:) = [i xt];
end
The results are summarized in Table 8.4. We see from the table that x
∞
is an
attractive ﬁxed point of g
3
(x), g
4
(x) and g
5
(x). Moreover, g
4
(x
n
) converges more
quickly to the root 1.365 230 013 than g
3
(x
n
), and g
5
(x) converges even faster. In
fact, these three ﬁxed point methods need 30, 15 and 4 iterations, respectively,
158 8. SOLUTIONS OF NONLINEAR EQUATIONS
Table 8.4. Results of Example 8.9.
g
1
(x) g
2
(x) g
3
(x) g
4
(x) g
5
(x)
n 10 +x −4x
2
−x
3
_
(10/x) −4x 0.5
√
10 −x
3
_
10/(4 +x) x −
x
3
+4x
2
−10
2x
2
+8x
0 1.5 1.5 1.5 1.5 1.5
1 −0.8750 0.816 1.286953 1.348399 1.373333333
2 6.732421875 2.996 1.402540 1.367376 1.365262015
3 −4.6972001 10
2
0.00 −2.94 i 1.345458 1.364957 1.365230014
4 1.0275 10
8
2.75 −2.75 i 1.375170 1.365264 1.365230013
5 −1.08 10
24
1.81 −3.53 i 1.360094 1.365225
6 1.3 10
72
2.38 −3.43 i 1.367846 1.365230
to produce a 10digit correct answer. On the other hand, the sequence g
2
(x
n
) is
trapped in an attractive twocycle,
z
±
= 2.27475487839820 ±3.60881272309733 i,
with multiplier
g
′
2
(z
+
)g
′
2
(z
−
) = 0.19790433047378
which is smaller than one in absolute value. Once in an attractive cycle, an
iteration cannot converge to a ﬁxed point. Finally x
∞
is a repulsive ﬁxed point
of g
1
(x) and x
n+1
= g(x
n
) diverges to −∞.
Remark 8.2. An iteration started in the basin of attraction of an attractive
ﬁxed point (or cycle) will converge to that ﬁxed point (or cycle). An iteration
started near a repulsive ﬁxed point (or cycle) will not converge to that ﬁxed point
(or cycle). Convergence to an indiﬀerent ﬁxed point is very slow, but can be
accelerated by diﬀerent acceleration processes.
8.4.1. Stopping criteria. Three usual criteria that are used to decide when
to stop an iteration procedure to ﬁnd a zero of f(x) are:
(1) Stop after N iterations (for a given N).
(2) Stop when [x
n+1
−x
n
[ < ǫ (for a given ǫ).
(3) Stop when [f(x
n
)[ < η (for a given η).
The usefulness of any of these criteria is problem dependent.
8.4.2. Order and rate of convergence of an iterative method. We are
often interested in the rate of convergence of an iterative scheme. Suppose that
the function g(x) for the iterative method
x
n+1
= g(x
n
)
has a Taylor expansion about the ﬁxed point p (p = g(p)) and let
ǫ
n
= x
n
−p.
Then, we have
x
n+1
= g(x
n
) = g(p + ǫ
n
) = g(p) +g
′
(p)ǫ
n
+
g
′′
(p)
2!
ǫ
2
n
+. . .
= p +g
′
(p)ǫ
n
+
g
′′
(p)
2!
ǫ
2
n
+. . . .
8.5. NEWTON’S, SECANT, AND FALSE POSITION METHODS 159
y
0 x
(x , f (x ))
p x
n
x
n+1
Tangent y = f (x)
n n
Figure 8.2. The nth step of Newton’s method.
Hence,
ǫ
n+1
= x
n+1
−p = g
′
(p)ǫ
n
+
g
′′
(p)
2!
ǫ
2
n
+. . . . (8.4)
Definition 8.3. The order of an iterative method x
n+1
= g(x
n
) is the
order of the ﬁrst nonzero derivative of g(x) at p. A method of order p is said to
have a rate of convergence p.
In Example 8.9, the iterative schemes g
3
(x) and g
4
(x) converge to ﬁrst order,
while g
5
(x) converges to second order.
Note that, for a secondorder iterative scheme, we have
ǫ
n+1
ǫ
2
n
≈
g
′′
(p)
2
= constant.
8.5. Newton’s, Secant, and False Position Methods
8.5.1. Newton’s method. Let x
n
be an approximation to a root, p, of
f(x) = 0. Draw the tangent line
y = f(x
n
) +f
′
(x
n
)(x −x
n
)
to the curve y = f(x) at the point (x
n
, f(x
n
)) as shown in Fig. 8.2. Then x
n+1
is determined by the point of intersection, (x
n+1
, 0), of this line with the xaxis,
0 = f(x
n
) +f
′
(x
n
) (x
n+1
−x
n
).
If f
′
(x
n
) ,= 0, solving this equation for x
n+1
we obtain Newton’s method, also
called the Newton–Raphson method,
x
n+1
= x
n
−
f(x
n
)
f
′
(x
n
)
. (8.5)
Note that Newton’s method is a ﬁxed point method since it can be rewritten in
the form
x
n+1
= g(x
n
), where g(x) = x −
f(x)
f
′
(x)
.
Example 8.10. Approximate
√
2 by Newton’s method. Stop when [x
n+1
−
x
n
[ < 10
−4
.
Solution. We wish to ﬁnd a root to the equation
f(x) = x
2
−2 = 0.
160 8. SOLUTIONS OF NONLINEAR EQUATIONS
Table 8.5. Results of Example 8.10.
n x
n
[x
n
−x
n−1
[
0 2
1 1.5 0.5
2 1.416667 0.083333
3 1.414216 0.002451
4 1.414214 0.000002
Table 8.6. Results of Example 8.11.
n x
n
[x
n
−x
n−1
[
0 1.5
1 1.37333333333333 0.126667
2 1.36526201487463 0.00807132
3 1.36523001391615 0.000032001
4 1.3652300134141 5.0205 10
−10
5 1.3652300134141 2.22045 10
−16
6 1.3652300134141 2.22045 10
−16
In this case, Newton’s method becomes
x
n+1
= x
n
−
f(x
n
)
f
′
(x
n
)
= x
n
−
x
2
n
−2
2 x
n
=
x
2
n
+ 2
2x
n
.
With x
0
= 2, we obtain the results listed in Table 8.5. Therefore,
√
2 ≈ 1.414214.
Note that the number of zeros in the errors roughly doubles as it is the case with
methods of second order.
Example 8.11. Use six iterations of Newton’s method to approximate a root
p ∈ [1, 2] of the polynomial
f(x) = x
3
+ 4 x
2
−10 = 0
given in Example 8.9.
Solution. In this case, Newton’s method becomes
x
n+1
= x
n
−
f(x
n
)
f
′
(x
n
)
= x
n
−
x
3
n
+ 4x
2
n
−10
3x
2
n
+ 8x
n
=
2(x
3
n
+ 2x
2
n
+ 5)
3x
2
n
+ 8x
n
.
We take x
0
= 1.5. The results are listed in Table 8.6.
Theorem 8.7. Let p be a simple root of f(x) = 0, that is, f(p) = 0 and
f
′
(p) ,= 0. If f
′′
(p) exists, then Newton’s method is at least of second order near
p.
Proof. Diﬀerentiating the function
g(x) = x −
f(x)
f
′
(x)
8.5. NEWTON’S, SECANT, AND FALSE POSITION METHODS 161
Table 8.7. Results of Example 8.12.
Newton
′
s Method ModiﬁedNewton
n x
n
ǫ
n+1
/ǫ
n
x
n
ǫ
n+1
/ǫ
2
n
0 0.000 0.00000000000000
1 0.400 0.600 0.80000000000000 −0.2000
2 0.652 2.245 0.98461538461538 −0.3846
3 0.806 0.143 0.99988432620012 −0.4887
4 0.895 0.537 0.99999999331095 −0.4999
5 0.945 0.522 1
6 0.972 0.512 1
we have
g
′
(x) = 1 −
(f
′
(x))
2
−f(x) f
′′
(x)
(f
′
(x))
2
=
f(x) f
′′
(x)
(f
′
(x))
2
.
Since f(p) = 0, we have
g
′
(p) = 0.
Therefore, Newton’s method is of order two near a simple zero of f.
Remark 8.3. Taking the second derivative of g(x) in Newton’s method, we
have
g
′′
(x) =
(f
′
(x))
2
f
′′
(x) +f(x)f
′
(x)f
′′′
(x) −2f(x)(f
′′
(x))
2
(f
′
(x))
3
.
If f
′′′
(p) exists, we obtain
g
′′
(p) = −
f
′′
(p)
f
′
(p)
.
Thus, by (8.4), the successive errors satisfy the approximate relation
ǫ
n+1
≈ −
1
2
f
′′
(p)
f
′
(p)
ǫ
2
n
,
which explains the doubling of the number of leading zeros in the error of Newton’s
method near a simple root of f(x) = 0.
Example 8.12. Use six iterations of the ordinary and modiﬁed Newton’s
methods
x
n+1
= x
n
−
f(x
n
)
f
′
(x
n
)
, x
n+1
= x
n
−2
f(x
n
)
f
′
(x
n
)
to approximate the double root, x = 1, of the polynomial
f(x) = (x −1)
2
(x −2).
Solution. The two methods have iteration functions
g
1
(x) = x −
(x −1)(x −2)
2(x −2) + (x −1)
, g
2
(x) = x −
(x −1)(x −2)
(x −2) + (x −1)
,
respectively. We take x
0
= 0. The results are listed in Table 8.7. One sees that
Newton’s method has ﬁrstorder convergence near a double zero of f(x), but one
162 8. SOLUTIONS OF NONLINEAR EQUATIONS
y
0 x p x
n
x
n1
Secant
y = f (x)
x
n+1
(x , f (x ))
n1 n1
(x , f (x ))
n n
Figure 8.3. The nth step of the secant method.
can verify that the modiﬁed Newton method has secondorder convergence. In
fact, near a root of multiplicity m the modiﬁed Newton method
x
n+1
= x
n
−m
f(x
n
)
f
′
(x
n
)
has secondorder convergence.
In general, Newton’s method may converge to the desired root, to another
root, or to an attractive cycle, especially in the complex plane.
8.5.2. The secant method. Let x
n−1
and x
n
be two approximations to a
root, p, of f(x) = 0. Draw the secant to the curve y = f(x) through the points
(x
n−1
, f(x
n−1
)) and (x
n
, f(x
n
)). The equation of this secant is
y = f(x
n
) +
f(x
n
) −f(x
n−1
)
x
n
−x
n−1
(x −x
n
).
The (n + 1)st iterate x
n+1
is determined by the point of intersection (x
n+1
, 0) of
the secant with the xaxis as shown in Fig. 8.3,
0 = f(x
n
) +
f(x
n
) −f(x
n−1
)
x
n
−x
n−1
(x
n+1
−x
n
).
Solving for x
n+1
, we obtain the secant method:
x
n+1
= x
n
−
x
n
−x
n−1
f(x
n
) −f(x
n−1
)
f(x
n
). (8.6)
The algorithm for the secant method is as follows.
Algorithm 8.2 (Secant Method). Given that f(x) is continuous on [a, b]
and has a root in [a, b].
(1) Choose x
0
and x
1
near the root p that is sought.
(2) Given x
n−1
and x
n
, x
n+1
is obtained by the formula
x
n+1
= x
n
−
x
n
−x
n−1
f(x
n
) −f(x
n−1
)
f(x
n
),
provided that f(x
n
) − f(x
n−1
) ,= 0. If f(x
n
) − f(x
n−1
) = 0, try other
starting values x
0
and x
1
.
(3) Repeat (2) until the selected stopping criterion is satisﬁed (see Subsec
tion 8.4.1).
8.5. NEWTON’S, SECANT, AND FALSE POSITION METHODS 163
y
0 x
p
b
n
a
n
Secant
y = f (x)
x
n+1
(a , f (a ))
n n
(b , f (b ))
n n
Figure 8.4. The nth step of the method of false position.
This method converges to a simple root to order 1.618 and may not converge
to a multiple root. Thus it is generally slower than Newton’s method. However,
it does not require the derivative of f(x). In general applications of Newton’s
method, the derivative of the function f(x) is approximated numerically by the
slope of a secant to the curve.
8.5.3. The method of false position. The method of false position, also
called regula falsi, is similar to the secant method, but with the additional con
dition that, for each n = 0, 1, 2, . . ., the pair of approximate values, a
n
and b
n
,
to the root, p, of f(x) = 0 be such that f(a
n
) f(b
n
) < 0. The next iterate,
x
n+1
, is determined by the intersection of the secant passing through the points
(a
n
, f(a
n
)) and (b
n
, f(b
n
)) with the xaxis.
The equation for the secant through (a
n
, f(a
n
)) and (b
n
, f(b
n
)), shown in
Fig. 8.4, is
y = f(a
n
) +
f(b
n
) − f(a
n
)
b
n
− a
n
(x −a
n
).
Hence, x
n+1
satisﬁes the equation
0 = f(a
n
) +
f(b
n
) −f(a
n
)
b
n
−a
n
(x
n+1
−a
n
),
which leads to the method of false position:
x
n+1
=
a
n
f(b
n
) −b
n
f(a
n
)
f(b
n
) −f(a
n
)
. (8.7)
The algorithm for the method of false position is as follows.
Algorithm 8.3 (False Position Method). Given that f(x) is continuous on
[a, b] and that f(a) f(b) < 0.
(1) Pick a
0
= a and b
0
= b.
(2) Given a
n
and b
n
such that f(a
n
)f(b
n
) < 0, compute
x
n+1
=
a
n
f(b
n
) −b
n
f(a
n
)
f(b
n
) −f(a
n
)
.
(3) If f(x
n+1
) = 0, stop.
(4) Else if f(x
n+1
) and f(a
n
) have opposite signs, set a
n+1
= a
n
and b
n+1
=
x
n+1
;
(5) Else set a
n+1
= x
n+1
and b
n+1
= b
n
.
164 8. SOLUTIONS OF NONLINEAR EQUATIONS
Table 8.8. Results of Example 8.13.
n x
n
a
n
b
n
[x
n−1
−x
n
[ f(x
n
) f(a
n
)
0 1 2 −
1 1.333333 1.333333 2 − −
2 1.400000 1.400000 2 0.066667 − −
3 1.411765 1.411765 2 0.011765 − −
4 1.413793 1.413793 2 0.002028 − −
5 1.414141 1.414141 2 0.000348 − −
(6) Repeat (2)–(5) until the selected stopping criterion is satisﬁed (see Sub
section 8.4.1).
This method is generally slower than Newton’s method, but it does not require
the derivative of f(x) and it always converges to a nested root. If the approach
to the root is onesided, convergence can be accelerated by replacing the value of
f(x) at the stagnant end position with f(x)/2.
Example 8.13. Find an approximation to
√
2 using the method of false
position. Stop iterating when [x
n+1
−x
n
[ < 10
−3
.
Solution. This problem is equivalent to the problem of ﬁnding a root of the
equation
f(x) = x
2
−2 = 0.
We have
x
n+1
=
a
n
(b
2
n
−2) −b
n
(a
2
n
−2)
(b
2
n
−2) −(a
2
n
−2)
=
a
n
b
n
+ 2
a
n
+b
n
.
Choose a
0
= 1 and b
0
= 2. Notice that f(1) < 0 and f(2) > 0. The results are
listed in Table 8.8. Therefore,
√
2 ≈ 1.414141.
8.5.4. A global Newtonbisection method. The many diﬃculties that
can occur with Newton’s method can be handled with success by combining the
Newton and bisection ideas in a way that captures the best features of each
framework. At the beginning, it is assumed that we have a bracketing interval
[a, b] for f(x), that is, f(a)f(b) < 0, and that the initial value x
c
is one of the
endpoints. If
x
+
= x
c
−
f(x
c
)
f
′
(x
c
)
∈ [a, b],
we proceed with either [a, x
+
] or [x+, b], whichever is bracketing. The new x
c
equals x
+
. If the Newton step falls out of [a, b], we take a bisection step setting
the new x
c
to (a + b)/2. In a typical situation, a number of bisection steps are
taken before the Newton iteration takes over. This globalization of the Newton
iteration is programmed in the following Matlab function Mﬁle which is found
in ftp://ftp.cs.cornell.edu/pub/cv.
function [x,fx,nEvals,aF,bF] = ...
GlobalNewton(fName,fpName,a,b,tolx,tolf,nEvalsMax)
% Pre:
% fName string that names a function f(x).
8.5. NEWTON’S, SECANT, AND FALSE POSITION METHODS 165
% fpName string that names the derivative function f’(x).
% a,b A root of f(x) is sought in the interval [a,b]
% and f(a)*f(b)<=0.
% tolx,tolf Nonnegative termination criteria.
% nEvalsMax Maximum number of derivative evaluations.
%
% Post:
% x An approximate zero of f.
% fx The value of f at x.
% nEvals The number of derivative evaluations required.
% aF,bF The final bracketing interval is [aF,bF].
%
% Comments:
% Iteration terminates as soon as x is within tolx of a true zero
% or if f(x)<= tolf or after nEvalMax fevaluations
fa = feval(fName,a);
fb = feval(fName,b);
if fa*fb>0
disp(’Initial interval not bracketing.’)
return
end
x = a;
fx = feval(fName,x);
fpx = feval(fpName,x);
disp(sprintf(’%20.15f %20.15f %20.15f’,a,x,b))
nEvals = 1;
while (abs(ab) > tolx ) & (abs(fx) > tolf) &
((nEvals<nEvalsMax)  (nEvals==1))
%[a,b] brackets a root and x = a or x = b.
if StepIsIn(x,fx,fpx,a,b)
%Take Newton Step
disp(’Newton’)
x = xfx/fpx;
else
%Take a Bisection Step:
disp(’Bisection’)
x = (a+b)/2;
end
fx = feval(fName,x);
fpx = feval(fpName,x);
nEvals = nEvals+1;
if fa*fx<=0
% There is a root in [a,x]. Bring in right endpoint.
b = x;
fb = fx;
else
166 8. SOLUTIONS OF NONLINEAR EQUATIONS
% There is a root in [x,b]. Bring in left endpoint.
a = x;
fa = fx;
end
disp(sprintf(’%20.15f %20.15f %20.15f’,a,x,b))
end
aF = a;
bF = b;
8.5.5. The Matlab fzero function. The Matlab fzero function is a
generalpurpose root ﬁnder that does not require derivatives. A simple call in
volves only the name of the function and a starting value x
0
. For example
aroot = fzero(’function_name’, x0)
The value returned is near a point where the function changes sign, or NaN if the
search fails. Other options are described in help fzero.
8.6. Aitken–Steﬀensen Accelerated Convergence
The linear convergence of an iterative method can be accelerated by Aitken’s
process. Suppose that the sequence ¦x
n
¦ converges to a ﬁxed point p to ﬁrst
order. Then the following ratios are approximately equal:
x
n+1
−p
x
n
−p
≈
x
n+2
−p
x
n+1
−p
.
We make this an equality by substituting a
n
for p,
x
n+1
−a
n
x
n
−a
n
=
x
n+2
−a
n
x
n+1
−a
n
and solve for a
n
which, after some algebraic manipulation, becomes
a
n
= x
n
−
(x
n+1
−x
n
)
2
x
n+2
−2x
n+1
+x
n
.
This is Aitken’s process which accelerates convergence in the sense that
lim
n→∞
a
n
−p
x
n
−p
= 0.
If we introduce the ﬁrst and secondorder forward diﬀerences:
∆x
n
= x
n+1
−x
n
, ∆
2
x
n
= ∆(∆x
n
) = x
n+2
−2x
n+1
+x
n
,
then Aitken’s process becomes
a
n
= x
n
−
(∆x
n
)
2
∆
2
x
n
. (8.8)
Steﬀensen’s process assumes that s
1
= a
0
is a better value than x
2
. Thus
s
0
= x
0
, z
1
= g(s
0
) and z
2
= g(z
1
) are used to produce s
1
. Next, s
1
, z
1
= g(s
1
)
and z
2
= g(z
2
) are used to produce s
2
. And so on. The algorithm is as follows.
Algorithm 8.4 (Steﬀensen’s Algorithm). Set
s
0
= x
0
,
8.6. AITKEN–STEFFENSEN ACCELERATED CONVERGENCE 167
5 0 5
5
0
5
x
y
Figure 8.5. The three real roots of x = 2 sinx in Example 8.14.
and, for n = 0, 1, 2, . . .,
z
1
= g(s
n
),
z
2
= g(z
1
),
s
n+1
= s
n
−
(z
1
−s
n
)
2
z
2
−2z
1
+s
n
.
Steﬀensen’s process applied to a ﬁrstorder ﬁxed point method produces a
secondorder method.
Example 8.14. Consider the ﬁxed point iteration x
n+1
= g(x
n
):
x
n+1
= 2 sin x
n
, x
0
= 1.
Do seven iterations and perform Aitken’s and Steﬀensen’s accelerations.
Solution. The three real roots of x = 2 sinx can be seen in Fig. 8.5. The
Matlab function fzero produces the ﬁxed point near x = 1:
p = fzero(’x2*sin(x)’,1.)
p = 1.89549426703398
The convergence is linear since
g
′
(p) = −0.63804504828524 ,= 0.
The following Matlab M function and script produce the results listed in Ta
ble 8.9. The second, third, and fourth columns are the iterates x
n
, Aitken’s
and Steﬀensen’s accelerated sequences a
n
and s
n
, respectively. The ﬁfth column,
which lists ǫ
n+1
/ǫ
2
n
= (s
n+2
−s
n+1
)/(s
n+1
−s
n
)
2
tending to a constant, indicates
that the Steﬀensen sequence s
n
converges to second order.
The M function function is:
function f = twosine(x);
f = 2*sin(x);
168 8. SOLUTIONS OF NONLINEAR EQUATIONS
Table 8.9. Results of Example 8.14.
n x
n
a
n
s
n
ǫ
n+1
/ǫ
2
n
0 1.00000000000000 2.23242945471637 1.00000000000000 −0.2620
1 1.68294196961579 1.88318435428750 2.23242945471637 0.3770
2 1.98743653027215 1.89201364327283 1.83453173271065 0.3560
3 1.82890755262358 1.89399129067379 1.89422502453561 0.3689
4 1.93374764234016 1.89492839486397 1.89549367325365 0.3691
5 1.86970615363078 1.89525656226218 1.89549426703385
6 1.91131617912526 1.89549426703398
7 1.88516234821223 NaN
The M script function is:
n = 7;
x = ones(1,n+1);
x(1) = 1.0;
for k = 1:n
x(k+1)=twosine(x(k)); % iterating x(k+1) = 2*sin(x(k))
end
a = ones(1,n1);
for k = 1:n1
a(k) = x(k)  (x(k+1)x(k))^2/(x(k+2)2*x(k+1)+x(k)); % Aitken
end
s = ones(1,n+1);
s(1) = 1.0;
for k = 1:n
z1=twosine(s(k));
z2=twosine(z1);
s(k+1) = s(k)  (z1s(k))^2/(z22*z1+s(k)); % Steffensen
end
d = ones(1,n2);
for k = 1:n2
d(k) = (s(k+2)s(k+1))/(s(k+1)s(k))^2; % 2nd order convergence
end
Note that the Matlab program produced NaN (not a number) for s
7
because
of a division by zero.
8.7. Horner’s Method and the Synthetic Division
8.7.1. Horner’s method. To reduce the number of products in the evalu
ation of polynomials, these should be expressed in nested form. For instance,
p(x) = a
3
x
3
+a
2
x
2
+a
1
x +a
0
=
_
(a
3
x +a
2
)x +a
1
_
x +a
0
.
8.7. HORNER’S METHOD AND THE SYNTHETIC DIVISION 169
In this simple case, the reduction is from 8 to 3 products.
The Matlab command horner transforms a symbolic polynomial into its
Horner, or nested, representation.
syms x
p = x^36*x^2+11*x6
p = x^36*x^2+11*x6
hp = horner(p)
hp = 6+(11+(6+x)*x)*x
Horner’s method incorporates this nesting technique.
Theorem 8.8 (Horner’s Method). Let
p(x) = a
n
x
n
+a
n−1
x
n−1
+ +a
1
x +a
0
.
If b
n
= a
n
and
b
k
= a
k
+b
k+1
x
0
, for k = n −1, n −2, . . . , 1, 0,
then
b
0
= p(x
0
).
Moreover, if
q(x) = b
n
x
n−1
+b
n−1
x
n−2
+ +b
2
x +b
1
,
then
p(x) = (x −x
0
)q(x) +b
0
.
Proof. By the deﬁnition of q(x),
(x −x
0
)q(x) +b
0
= (x −x
0
)(b
n
x
n−1
+b
n−1
x
n−2
+ + b
2
x +b
1
) +b
0
= (b
n
x
n
+b
n−1
x
n−1
+ +b
2
x
2
+b
1
x)
−(b
n
x
0
x
n−1
+b
n−1
x
0
x
n−2
+ + b
2
x
0
x +b
1
x
0
) +b
0
= b
n
x
n
+ (b
n−1
−b
n
x
0
)x
n−1
+ + (b
1
−b
2
x
0
)x + (b
0
−b
1
x
0
)
= a
n
x
n
+a
n−1
x
n−1
+ +a
1
x +a
0
= p(x)
and
b
0
= p(x
0
).
8.7.2. Synthetic division. Evaluating a polynomial at x = x
0
by Horner’s
method is equivalent to applying the synthetic division as shown in Example 8.15.
Example 8.15. Find the value of the polynomial
p(x) = 2x
4
−3x
2
+ 3x −4
at x
0
= −2 by Horner’s method.
Solution. By successively multiplying the elements of the third line of the
following tableau by x
0
= −2 and adding to the ﬁrst line, one gets the value of
p(−2).
a
4
= 2 a
3
= 0 a
2
= −3 a
1
= 3 a
0
= −4
−4 8 −10 14
ր ր ր ր
b
4
= 2 b
3
= −4 b
2
= 5 b
1
= −7 b
0
= 10
170 8. SOLUTIONS OF NONLINEAR EQUATIONS
Thus
p(x) = (x + 2)(2x
3
−4x
2
+ 5x −7) + 10
and
p(−2) = 10.
Horner’s method can be used eﬃciently with Newton’s method to ﬁnd zeros
of a polynomial p(x). Diﬀerentiating
p(x) = (x −x
0
)q(x) +b
0
we obtain
p
′
(x) = (x −x
0
)q
′
(x) +q(x).
Hence
p
′
(x
0
) = q(x
0
).
Putting this in Newton’s method we have
x
n
= x
n−1
−
p(x
n−1
)
p
′
(x
n−1
)
= x
n−1
−
p(x
n−1
)
q(x
n−1
)
.
This procedure is shown in Example 8.16.
Example 8.16. Compute the value of the polynomial
p(x) = 2x
4
= 3x
3
+ 3x −4
and of its derivative p
′
(x) at x
0
= −2 by Horner’s method and apply the results
to Newton’s method to ﬁnd the ﬁrst iterate x
1
.
Solution. By successively multiplying the elements of the third line of the
following tableau by x
0
= −2 and adding to the ﬁrst line, one gets the value
of p(−2). Then by successively multiplying the elements of the ﬁfth line of the
tableau by x
0
= −2 and adding to the third line, one gets the value of p
′
(−2).
2 0 −3 = 3 −4
−4 8 −10 14
ր ր ր ր
2 −4 5 −7 10 = p(−2)
−4 16 −42
ր ր ր
2 −8 21 −49 = p
′
(−2)
Thus
p(−2) = 10, p
′
(−2) = −49,
and
x
1
= −2 −
10
−49
≈ −1.7959.
8.8. M
¨
ULLER’S METHOD 171
8.8. M¨ uller’s Method
M¨ uller’s, or the parabola, method ﬁnds the real or complex roots of an equa
tion
f(x) = 0.
This method uses three initial approximations, x
0
, x
1
, and x
2
, to construct a
parabola,
p(x) = a(x −x
2
)
2
+b(x −x
2
) +c,
through the three points (x
0
, f(x
0
)), (x
1
, f(x
1
)), and (x
2
, f(x
2
)) on the curve
f(x) and determines the next approximation x
3
as the point of intersection of the
parabola with the real axis closer to x
2
.
The coeﬃcients a, b and c deﬁning the parabola are obtained by solving the
linear system
f(x
0
) = a(x
0
−x
2
)
2
+b(x
0
−x
2
) +c,
f(x
1
) = a(x
1
−x
2
)
2
+b(x
1
−x
2
) +c,
f(x
2
) = c.
We immediately have
c = f(x
2
)
and obtain a and b from the linear system
_
(x
0
−x
2
)
2
(x
0
−x
2
)
(x
1
−x
2
)
2
(x
1
−x
2
)
_ _
a
b
_
=
_
f(x
0
) −f(x
2
)
f(x
1
) −f(x
2
)
_
.
Then, we set
p(x
3
) = a(x
3
−x
2
)
2
+b(x
3
−x
2
) +c = 0
and solve for x
3
−x
2
:
x
3
−x
2
=
−b ±
√
b
2
−4ac
2a
=
−b ±
√
b
2
−4ac
2a
−b ∓
√
b
2
−4ac
−b ∓
√
b
2
−4ac
=
−2c
b ±
√
b
2
−4ac
.
To ﬁnd x
3
closer to x
2
, we maximize the denominator:
x
3
= x
2
−
2c
b + sign(b)
√
b
2
−4ac
.
M¨ uller’s method converges approximately to order 1.839 to a simple or double
root. It may not converge to a triple root.
Example 8.17. Find the four zeros of the polynomial
16x
4
−40x
3
+ 5x
2
+ 20x + 6,
whose graph is shown in Fig. 8.6, by means of M¨ uller’s method.
Solution. The following Matlab commands do one iteration of M¨ uller’s
method on the given polynomial which is transformed into its nested form:
172 8. SOLUTIONS OF NONLINEAR EQUATIONS
1 0 1 2 3
10
5
0
5
10
15
20
25
x
y
16 x
4
40 x
3
+5 x
2
+20 x+6
Figure 8.6. The graph of the polynomial 16x
4
−40x
3
+ 5x
2
+
20x + 6 for Example 8.17.
syms x
pp = 16*x^440*x^3+5*x^2+20*x+6
pp = 16*x^440*x^3+5*x^2+20*x+6
pp = horner(pp)
pp = 6+(20+(5+(40+16*x)*x)*x)*x
The polynomial is evaluated by the Matlab M function:
function pp = mullerpol(x);
pp = 6+(20+(5+(40+16*x)*x)*x)*x;
M¨ uller’s method obtains x
3
with the given three starting values:
x0 = 0.5; x1 = 0.5; x2 = 0; % starting values
m = [(x0x2)^2 x0x2; (x1x2)^2 x1x2];
rhs = [mullerpol(x0)mullerpol(x2); mullerpol(x1) mullerpol(x2)];
ab = m\rhs; a = ab(1); b = ab(2); % coefficients a and b
c = mullerpol(x2); % coefficient c
x3 = x2 (2*c)/(b+sign(b)*sqrt(b^24*a*c))
x3 = 0.5556 + 0.5984i
The method is iterated until convergence. The four roots of this polynomial
are
rr = roots([16 40 5 20 6])’
rr = 1.9704 1.2417 0.3561  0.1628i 0.3561 + 0.1628i
The two real roots can be obtained by M¨ uller’s method with starting values
[0.5, 1.0, 1.5] and [2.5, 2.0, 2.25], respectively.
CHAPTER 9
Interpolation and Extrapolation
Quite often, experimental results provide only a few values of an unknown
function f(x), say,
(x
0
, f
0
), (x
1
, f
1
), (x
2
, f
2
), . . . , (x
n
, f
n
), (9.1)
where f
i
is the observed value for f(x
i
). We would like to use these data to
approximate f(x) at an arbitrary point x ,= x
i
.
When we want to estimate f(x) for x between two of the x
i
’s, we talk about
interpolation of f(x) at x. When x is not between two of the x
i
’s, we talk about
extrapolation of f(x) at x.
The idea is to construct an interpolating polynomial, p
n
(x), of degree n whose
graph passes through the n + 1 points listed in (9.1). This polynomial will be
used to estimate f(x).
9.1. Lagrange Interpolating Polynomial
The Lagrange interpolating polynomial, p
n
(x), of degree n through the n+1
points
_
x
k
, f(x
k
)
_
, k = 0, 1, . . . , n, is expressed in terms of the following Lagrange
basis:
L
k
(x) =
(x −x
0
)(x −x
1
) (x −x
k−1
)(x −x
k+1
) (x −x
n
)
(x
k
−x
0
)(x
k
−x
1
) (x
k
−x
k−1
)(x
k
−x
k+1
) (x
k
−x
n
)
.
Clearly, L
k
(x) is a polynomial of degree n and
L
k
(x) =
_
1, x = x
k
,
0, x = x
j
, j ,= k.
Then the Lagrange interpolating polynomial of f(x) is
p
n
(x) = f(x
0
)L
0
(x) +f(x
1
)L
1
(x) + +f(x
n
)L
n
(x). (9.2)
It is of degree n and interpolates f(x) at the points listed in (9.1).
Example 9.1. Interpolate f(x) = 1/x at the nodes x
0
= 2, x
1
= 2.5 and
x
2
= 4 with the Lagrange interpolating polynomial of degree 2.
Solution. The Lagrange basis, in nested form, is
L
0
(x) =
(x −2.5)(x −4)
(2 −2.5)(2 −4)
=(x −6.5)x + 10,
L
1
(x) =
(x −2)(x −4)
(2.5 −2)(2.5 −4)
=
(−4x + 24)x −32
3
,
L
2
(x) =
(x −2)(x −2.5)
(4 −2)(4 −2.5)
=
(x −4.5)x + 5
3
.
173
174 9. INTERPOLATION AND EXTRAPOLATION
Thus,
p(x) =
1
2
[(x −6.5)x + 10] +
1
2.5
(−4x + 24)x −32
3
+
1
4
(x −4.5)x + 5
3
= (0.05x −0.425)x + 1.15.
Theorem 9.1. Suppose x
0
, x
1
, . . . , x
n
are n+1 distinct points in the interval
[a, b] and f ∈ C
n+1
[a, b]. Then there exits a number ξ(x) ∈ [a, b] such that
f(x) −p
n
(x) =
f
(n+1)
(ξ(x))
(n + 1)!
(x −x
0
) (x − x
1
) (x −x
n
), (9.3)
where p
n
(x) is the Lagrange interpolating polynomial. In particular, if
m
n+1
= min
a≤x≤b
[f
(n+1)
(x)[ and M
n+1
= max
a≤x≤b
[f
(n+1)
(x)[,
then the absolute error in p
n
(x) is bounded by the inequalities:
m
n+1
(n + 1)!
[(x −x
0
) (x −x
1
) (x −x
n
)[ ≤ [f(x) −p
n
(x)[
≤
M
n+1
(n + 1)!
[(x −x
0
) (x −x
1
) (x −x
n
)[
for a ≤ x ≤ b.
Proof. First, note that the error is 0 at x = x
0
, x
1
, . . . , x
n
since
p
n
(x
k
) = f(x
k
), k = 0, 1, . . . , n,
from the interpolating property of p
n
(x). For x ,= x
k
, deﬁne the auxiliary function
g(t) = f(t) −p
n
(t) −[f(x) −p
n
(x)]
(t −x
0
)(t −x
1
) (t −x
n
)
(x −x
0
)(x −x
1
) (x −x
n
)
= f(t) −p
n
(t) −[f(x) −p
n
(x)]
n
i=0
t −x
i
x −x
i
.
For t = x
k
,
g(x
k
) = f(x
k
) −p
n
(x
k
) −[f(x) −p
n
(x)] 0 = 0
and for t = x,
g(x) = f(x) −p
n
(x) −[f(x) −p
n
(x)] 1 = 0.
Thus g ∈ C
n+1
[a, b] and it has n + 2 zeros in [a, b]. By the generalized Rolle
theorem, g
′
(t) has n + 1 zeros in [a, b], g
′′
(t) has n zeros in [a, b], . . . , g
(n+1)
(t)
has 1 zero, ξ ∈ [a, b],
g
(n+1)
(ξ) = f
(n+1)
(ξ) −p
(n+1)
n
(ξ) −[f(x) −p
n
(x)]
d
n+1
dt
n+1
_
n
i−0
t −x
i
x −x
i
¸
¸
¸
¸
¸
t=ξ
= f
(n+1)
(ξ) −0 −[f(x) −p
n
(x)]
(n + 1)!
n
i=0
(x −x
i
)
= 0
9.2. NEWTON’S DIVIDED DIFFERENCE INTERPOLATING POLYNOMIAL 175
since p
n
(x) is a polynomial of degree n so that its (n +1)st derivative is zero and
only the top term, t
n+1
, in the product
n
i=0
(t −x
i
) contributes to (n+1)! in its
(n + 1)st derivative. Hence
f(x) = p
n
(x) +
f
(n+1)
(ξ(x))
(n + 1)!
(x −x
0
) (x −x
1
) (x −x
n
).
From a computational point of view, (9.2) is not the best representation of
p
n
(x) because it is computationally costly and has to be redone from scratch if
we want to increase the degree of p
n
(x) to improve the interpolation.
If the points x
i
are distinct, this polynomial is unique, For, suppose p
n
(x)
and q
n
(x) of degree n both interpolate f(x) at n + 1 distinct points, then
p
n
(x) −q
n
(x)
is a polynomial of degree n which admits n+1 distinct zeros, hence it is identically
zero.
9.2. Newton’s Divided Diﬀerence Interpolating Polynomial
Newton’s divided diﬀerence interpolating polynomials, p
n
(x), of degree n use
a factorial basis in the form
p
n
(x) = a
0
+a
1
(x−x
0
)+a
2
(x−x
0
)(x−x
1
)+ +a
n
(x−x
0
)(x−x
1
) (x−x
n−1
).
The values of the coeﬃcients a
k
are determined by recurrence. We denote
f
k
= f(x
k
).
Let x
0
,= x
1
and consider the two data points: (x
0
, f
0
) and (x
1
, f
1
). Then the
interpolating property of the polynomial
p
1
(x) = a
0
+a
1
(x −x
0
)
implies that
p
1
(x
0
) = a
0
= f
0
, p
1
(x
1
) = f
0
+a
1
(x
1
−x
0
) = f
1
.
Solving for a
1
we have
a
1
=
f
1
−f
0
x
1
−x
0
.
If we let
f[x
0
, x
1
] =
f
1
−f
0
x
1
−x
0
be the ﬁrst divided diﬀerence, then the divided diﬀerence interpolating poly
nomial of degree one is
p
1
(x) = f
0
+ (x −x
0
) f[x
0
, x
1
].
Example 9.2. Consider a function f(x) which passes through the points
(2.2, 6.2) and (2.5, 6.7). Find the divided diﬀerence interpolating polynomial of
degree one for f(x) and use it to interpolate f at x = 2.35.
Solution. Since
f[2.2, 2.5] =
6.7 −6.2
2.5 −2.2
= 1.6667,
then
p
1
(x) = 6.2 + (x −2.2) 1.6667 = 2.5333 + 1.6667 x.
In particular, p
1
(2.35) = 6.45.
176 9. INTERPOLATION AND EXTRAPOLATION
Example 9.3. Approximate cos 0.2 linearly using the values of cos 0 and
cos π/8.
Solution. We have the points
(0, cos 0) = (0, 1) and
_
π
8
, cos
π
8
_
=
_
π
8
,
1
2
_
√
2 + 2
_
(Substitute θ = π/8 into the formula
cos
2
θ =
1 + cos(2 θ)
2
to get
cos
π
8
=
1
2
_
√
2 + 2
since cos(π/4) =
√
2/2.) Thus
f[0, π/8] =
_
_
√
2 + 2
_
_
2 −1
π/8 −0
=
4
π
__
√
2 + 2 −2
_
.
This leads to
p
1
(x) = 1 +
4
π
__
√
2 + 2 −2
_
x.
In particular,
p
1
(0.2) = 0.96125.
Note that cos 0.2 = 0.98007 (rounded to ﬁve digits). The absolute error is 0.01882.
Consider the three data points
(x
0
, f
0
), (x
1
, f
1
), (x
2
, f
2
), where x
i
,= x
j
for i ,= j.
Then the divided diﬀerence interpolating polynomial of degree two through these
points is
p
2
(x) = f
0
+ (x −x
0
) f[x
0
, x
1
] + (x −x
0
) (x −x
1
) f[x
0
, x
1
, x
2
]
where
f[x
0
, x
1
] :=
f
1
−f
0
x
1
−x
0
and f[x
0
, x
1
, x
2
] :=
f[x
1
, x
2
] −f[x
0
, x
1
]
x
2
−x
0
are the ﬁrst and second divided diﬀerences, respectively.
Example 9.4. Interpolate a given function f(x) through the three points
(2.2, 6.2), (2.5, 6.7), (2.7, 6.5),
by means the divided diﬀerence interpolating polynomial of degree two, p
2
(x),
and interpolate f(x) at x = 2.35 by means of p
2
(2.35).
Solution. We have
f[2.2, 2.5] = 1.6667, f[2.5, 2.7] = −1
and
f[2.2, 2.5, 2.7] =
f[2.5, 2.7] −f[2.2, 2.5]
2.7 −2.2
=
−1 −1.6667
2.7 −2.2
= −5.3334.
9.2. NEWTON’S DIVIDED DIFFERENCE INTERPOLATING POLYNOMIAL 177
Therefore,
p
2
(x) = 6.2 + (x −2.2) 1.6667 + (x −2.2) (x −2.5) (−5.3334).
In particular, p
2
(2.35) = 6.57.
Example 9.5. Construct the divided diﬀerence interpolating polynomial of
degree two for cos x using the values cos 0, cos π/8 and cos π/4, and approximate
cos 0.2.
Solution. It was seen in Example 9.3 that
cos
π
8
=
1
2
_
√
2 + 2.
Hence, from the three data points
(0, 1), (π/8, cos π/8), (π/4,
√
2/2),
we obtain the divided diﬀerences
f[0, π/8] =
4
π
__
√
2 + 2 −2
_
, f[π/8, π/4] =
4
π
_
√
2 −
_
√
2 + 2
_
,
and
f[0, π/8, π/4] =
f[π/8, π/4] − f[0, π/8]
π/4 − 0
=
4
π
_
√
2/2 −(
_
√
2 + 2)/2
π/4 −π/8
−
4
_
√
2 + 2 −8
π
_
=
16
π
2
_
√
2 −2
_
√
2 + 2
_
.
Hence,
p
2
(x) = 1 +x
4
π
__
√
2 + 2 −2
_
+x
_
x −
π
8
_
16
π
2
_
√
2 −2
_
√
2 + 2 ,
_
.
Evaluating this polynomial at x = 0.2, we obtain
p
2
(0.2) = 0.97881.
The absolute error is 0.00189.
In general, given n + 1 data points
(x
0
, f
0
), (x
1
, f
1
), . . . , (x
n
, f
n
),
where x
i
,= x
j
for i ,= j, Newton’s divided diﬀerence interpolating polynomial of
degree n is
p
n
(x) = f
0
+ (x −x
0
) f[x
0
, x
1
] + (x −x
0
) (x −x
1
) f[x
0
, x
1
, x
2
] +
+ (x −x
0
) (x −x
1
) (x −x
n−1
) f[x
0
, x
1
, . . . , x
n
], (9.4)
where, by deﬁnition,
f[x
j
, x
j+1
, . . . , x
k
] =
f[x
j+1
, . . . , x
k
] −f[x
j
, x
j+1
, . . . , x
k−1
]
x
k
−x
j
is a (k −j)th divided diﬀerence. This formula can be obtained by recurrence.
A divided diﬀerence table is shown in Table 9.1.
178 9. INTERPOLATION AND EXTRAPOLATION
Table 9.1. Ddivided diﬀerence table
First Second Third
x f(x) divided diﬀerences divided diﬀerences divided diﬀerences
x
0
f[x
0
]
f[x
0
, x
1
]
x
1
f[x
1
] f[x
0
, x
1
, x
2
]
f[x
1
, x
2
] f[x
0
, x
1
, x
2
, x
3
]
x
2
f[x
2
] f[x
1
, x
2
, x
3
]
f[x
2
, x
3
] f[x
1
, x
2
, x
3
, x
4
]
x
3
f[x
3
] f[x
2
, x
3
, x
4
]
f[x
3
, x
4
] f[x
2
, x
3
, x
4
, x
5
]
x
4
f[x
4
] f[x
3
, x
4
, x
5
]
f[x
4
, x
5
]
x
5
f[x
5
]
Example 9.6. Construct the cubic interpolating polynomial through the four
unequally spaced points
(1.0, 2.4), (1.3, 2.2), (1.5, 2.3), (1.7, 2.4),
on the graph of a certain function f(x) and approximate f(1.4).
Solution. Newton’s divided diﬀerence table is
x
i
f(x
i
) f[x
i
, x
i+1
] f[x
i
, x
i+1
, x
i+2
] f[x
i
, x
i+1
, x
i+2
, x
i+3
]
1.0 2.4
−0.66667
1.3 2.2 2.33333
0.500000 −3.33333
1.5 2.3 0.00000
0.500000
1.7 2.4
Therefore,
p
3
(x) = 2.4 + (x −1.0) (−0.66667) + (x −1.0) (x −1.3) 2.33333
+ (x −1.0) (x −1.3) (x −1.5) (−3.33333).
The approximation to f(1.4) is
p
3
(1.4) = 2.2400.
9.3. Gregory–Newton ForwardDiﬀerence Polynomial
We rewrite (9.4) in the special case where the nodes x
i
are equidistant,
x
i
= x
0
+i h.
The ﬁrst and second forward diﬀerences of f(x) at x
j
are
∆f
j
:= f
j+1
−f
j
, ∆
2
f
j
:= ∆f
j+1
−∆f
j
,
9.3. GREGORY–NEWTON FORWARDDIFFERENCE POLYNOMIAL 179
respectively, and in general, the kth forward diﬀerence of f(x) at x
j
is
∆
k
f
j
:= ∆
k−1
f
j+1
−∆
k−1
f
j
.
It is seen by mathematical induction that
f[x
0
, . . . , x
k
] :=
1
k! h
k
∆
k
f
0
.
If we set
r =
x −x
0
h
,
then, for equidistant nodes,
x −x
k
= x −x
0
−(x
k
−x
0
) = hr −hk = h(r −k)
and
(x −x
0
)(x −x
1
) (x −x
k−1
) = h
k
r(r −1)(r −2) (r −k + 1).
Thus (9.4) becomes
p
n
(r) = f
0
+
n
k=1
r (r −1) (r −k + 1)
k!
∆
k
f
0
=
n
k=0
_
r
k
_
∆
k
f
0
, (9.5)
where
_
r
k
_
=
_
_
_
r (r −1) (r −k + 1)
k!
if k > 0,
1 if k = 0.
Polynomial (9.5) is the Gregory–Newton forwarddiﬀerence interpolating
polynomial.
Example 9.7. Suppose that we are given the following equally spaced data:
x 1988 1989 1990 1991 1992 1993
y 35000 36000 36500 37000 37800 39000
Extrapolate the value of y in year 1994.
Solution. The forward diﬀerence table is
i x
i
y
i
∆y
i
∆
2
y
i
∆
3
y
i
∆
4
y
i
∆
5
y
i
0 1988 35000
1000
1 1989 36000 −500
500 500
2 1990 36500 0 −200
500 300 0
3 1991 37000 300 −200
800 100
4 1992 37800 400
1200
5 1993 39000
180 9. INTERPOLATION AND EXTRAPOLATION
Setting r = (x −1988)/1, we have
p
5
(r) = 35000 +r (1000) +
r(r −1)
2
(−500) +
r(r −1)(r −2)
6
(500)
+
r(r −1)(r −2)(r −3)
24
(−200) +
r(r −1)(r −2)(r −3)(r −4)
120
(0).
Extrapolating the data at 1994 we have r = 6 and
p
5
(6) = 40500.
An iterative use of the Matlab diff(y,n) command produces a diﬀerence table.
y = [35000 36000 36500 37000 37800 39000]
dy = diff(y);
dy = 1000 500 500 800 1200
d2y = diff(y,2)
d2y = 500 0 300 400
d3y = diff(y,3)
d3y = 500 300 100
d4y = diff(y,4)
d4y = 200 200
d5y = diff(y,5)
d5y = 0
Example 9.8. Use the following equally spaced data to approximate f(1.5).
x 1.0 1.3 1.6 1.9 2.2
f(x) 0.7651977 0.6200860 0.4554022 0.2818186 0.1103623
Solution. The forward diﬀerence table is
i x
i
y
i
∆y
i
∆
2
y
i
∆
3
y
i
∆
4
y
i
0 1.0 0.7651977
−0.145112
1 1.3 0.6200860 −0.0195721
0.164684 0.0106723
2 1.6 0.4554022 0.0088998 0.0003548
0.173584 0.0110271
3 1.9 0.2818186 0.0021273
0.170856
4 2.2 0.1103623
Setting r = (x −1.0)/0.3, we have
p
4
(r) = 0.7651977 +r (−0.145112) +
r(r −1)
2
(−0.0195721)
+
r(r −1)(r −2)
6
(0.0106723) +
r(r −1)(r −2)(r −3)
24
(0.0003548).
Interpolating f(x) at x = 1, we have r = 5/3 and and
p
4
(5/3) = 0.511819.
9.4. GREGORY–NEWTON BACKWARDDIFFERENCE POLYNOMIAL 181
9.4. Gregory–Newton BackwardDiﬀerence Polynomial
To interpolate near the bottom of a diﬀerence table with equidistant nodes,
one uses the Gregory–Newton backwarddiﬀerence interpolating polynomial for
the data
(x
−n
, f
−n
), (x
−n+1
, f
−n+1
), . . . , (x
0
, f
0
).
If we set
r =
x −x
0
h
,
then, for equidistant nodes,
x −x
−k
= x −x
0
−(x
−k
−x
0
) = hr +hk = h(r +k)
and
(x −x
0
)(x −x
−1
) (x −x
−(k−1
)) = h
k
r(r + 1)(r + 2) (r +k −1).
Thus (9.5) becomes
p
n
(r) = f
0
+
n
k=1
r (r + 1) (r +k −1)
k!
∆
k
f
−k
=
n
k=0
_
r + k −1
k
_
∆
k
f
−k
, (9.6)
The polynomial (9.6) is the Gregory–Newton backwarddiﬀerence interpo
lating polynomial.
Example 9.9. Interpolate the equally spaced data of Example 9.8 at x = 2.1
Solution. The diﬀerence table is
i x
i
y
i
∆y
i
∆
2
y
i
∆
3
y
i
∆
4
y
i
−4 1.0 0.7651977
0.145112
−3 1.3 0.6200860 0.0195721
0.164684 0.0106723
−2 1.6 0.4554022 0.0088998 0.0003548
0.173584 0.0110271
−1 1.9 0.2818186 0.0021273
−0.170856
0 2.2 0.1103623
Setting r = (x −2.2)/0.3, we have
p
4
(r) = 0.1103623 +r (−0.170856) +
r(r + 1)
2
(0.0021273)
+
r(r + 1)(r + 2)
6
(0.0110271) +
r(r + 1)(r + 2)(r + 3)
24
(0.0003548).
Since
r =
2.1 −2.2
0.3
= −
1
3
,
then
p
4
(−1/3) = 0.115904.
182 9. INTERPOLATION AND EXTRAPOLATION
9.5. Hermite Interpolating Polynomial
Given n + 1 distinct nodes x
0
, x
1
,. . . ,x
n
and 2n + 2 values f
k
= f(x
k
) and
f
′
k
= f
′
(x
k
), the Hermite interpolating polynomial p
2n+1
(x) of degree 2n + 1,
p
2n+1
(x) =
n
m=0
h
m
(x)f
m
+
n
m=0
´
h
m
(x)f
′
m
,
takes the values
p
2n+1
(x
k
) = f
k
, p
′
2n+1
(x
k
) = f
′
k
, k = 0, 1, . . . , n.
We look for polynomials h
m
(x) and
´
h
m
(x) of degree at most 2n+1 satisfying the
following conditions:
h
m
(x
k
) = h
′
m
(x
k
) = 0, k ,= m,
h
m
(x
m
) = 1,
h
′
m
(x
m
) = 0,
and
´
h
m
(x
k
) =
´
h
′
m
(x
k
) = 0, k ,= m,
´
h
m
(x
m
) = 0,
´
h
′
m
(x
m
) = 1.
These conditions are satisﬁed by the polynomials
h
m
(x) = [1 −2(x −x
m
)L
′
m
(x
m
)]L
2
m
(x)
and
´
h
m
(x) = (x −x
m
)L
2
m
(x),
where
L
m
(x) =
n
k=0,k=m
x −x
k
x
m
−x
k
are the elements of the Lagrange basis of degree n.
A practical method of constructing a Hermite interpolating polynomial over
the n + 1 distinct nodes x
0
, x
1
,. . . ,x
n
is to set
z
2i
= z
2i+1
= x
i
, i = 0, 1, . . . , n,
and take
f
′
(x
0
) for f[z
0
, z
1
], f
′
(x
1
) for f[z
2
, z
3
], . . . , f
′
(x
j
) for f[z
2n
z
2n+1
]
in the divided diﬀerence table for the Hermite interpolating polynomial of degree
2n + 1. Thus,
p
2n+1
(x) = f[z
0
] +
2n+1
k=1
f[z
0
, z
1
, . . . , z
k
](x −z
0
)(x −z
1
) (x − z
k−1
).
A divided diﬀerence table for a Hermite interpolating polynomial is as follows.
9.6. CUBIC SPLINE INTERPOLATION 183
First Second Third
z f(z) divided diﬀerences divided diﬀerences divided diﬀerences
z
0
= x
0
f[z
0
] = f(x
0
)
f[z
0
, z
1
] = f
′
(x
0
)
z
1
= x
0
f[z
1
] = f(x
0
) f[z
0
, z
1
, z
2
]
f[z
1
, z
2
] f[z
0
, z
1
, z
2
, z
3
]
z
2
= x
1
f[z
2
] = f(x
1
) f[z
1
, z
2
, z
3
]
f[z
2
, z
3
] = f
′
(x
1
) f[z
1
, z
2
, z
3
, z
4
]
z
3
= x
1
f[z
3
] = f(x
1
) f[z
2
, z
3
, z
4
]
f[z
3
, z
4
] f[z
2
, z
3
, z
4
, z
5
]
z
4
= x
2
f[z
4
] = f(x
2
) f[z
3
, z
4
, z
5
]
f[z
4
, z
5
] = f
′
(x
2
)
z
5
= x
2
f[z
5
] = f(x
2
)
Example 9.10. Interpolate the underlined data, given in the table below, at
x = 1.5 by a Hermite interpolating polynomial of degree ﬁve.
Solution. In the diﬀerence table the underlined entries are the given data.
The remaining entries are generated by standard divided diﬀerences.
1.3 0.6200860
−0.5220232
1.3 0.6200860 −0.0897427
−0.5489460 0.0663657
1.6 0.4554022 −0.0698330 0.0026663
−0.5698959 0.0679655 −0.0027738
1.6 0.4554022 −0.0290537 0.0010020
−0.5786120 0.0685667
1.9 0.2818186 −0.0084837
−0.5811571
1.9 0.2818186
Taking the elements along the top downward diagonal, we have
P(1.5) = 0.6200860 + (1.5 −1.3)(−0.5220232) + (1.5 −1.3)
2
(−0.0897427)
+ (1.5 −1.3)
2
(1.5 −1.6)(0.0663657) + (1.5 −1.3)
2
(1.5 −1.6)
2
(0.0026663)
+ (1.5 −1.3)
2
(1.5 −1.6)
2
(1.5 −1.9)(−0.0027738)
= 0.5118277.
9.6. Cubic Spline Interpolation
In this section, we interpolate functions by piecewise cubic polynomials which
satisfy some global smoothness conditions. Piecewise polynomials avoid the os
cillatory nature of highdegree polynomials over a large interval.
Definition 9.1. Given a function f(x) deﬁned on the interval [a, b] and a
set of nodes
a = x
0
< x
1
< < x
n
= b,
184 9. INTERPOLATION AND EXTRAPOLATION
a cubic splines interpolant S for f is a piecewise cubic polynomial that satisﬁes
the following conditions:
(a) S(x) is a cubic polynomial, denoted S
j
(x), on the subinterval [x
j
, x
j+1
]
for each j = 0, 1, . . . , n −1;
(b) S(x
j
) = f(x
j
) for each j = 0, 1, . . . , n;
(c) S
j+1
(x
j+1
) = S
j
(x
j+1
) for each j = 0, 1, . . . , n −2;
(d) S
′
j+1
(x
j+1
) = S
′
j
(x
j+1
) for each j = 0, 1, . . . , n −2;
(e) S
′′
j+1
(x
j+1
) = S
′′
j
(x
j+1
) for each j = 0, 1, . . . , n −2;
(f) One of the sets of boundary conditions is satisﬁed:
(i) S
′′
(x
0
) = S
′′
(x
n
) = 0 (free or natural boundary);
(ii) S
′
(x
0
) = f
′
(x
0
) and S
′
(x
n
) = f
′
(x
n
) (clamped boundary).
Other boundary conditions can be used in the deﬁnition of splines. When
free or clamped boundary conditions occur, the spline is called a natural spline
or a clamped spline, respectively.
To construct the cubic spline interpolant for a given function f, the conditions
in the deﬁnition are applied to the cubic polynomials
S
j
(x) = a
j
+b
j
(x −x
j
) +c
j
(x −x
j
)
2
+d
j
(x −x
j
)
3
,
for each j = 0, 1, . . . , n −1.
The following existence and uniqueness theorems hold for natural and clamped
spline interpolants, respectively.
Theorem 9.2 (Natural Spline). If f is deﬁned at a = x
0
< x
1
< < x
n
=
b, then f has a unique natural spline interpolant S on the nodes x
0
, x
1
, . . . , x
n
with boundary conditions S
′′
(a) = 0 and S
′′
(b) = 0.
Theorem 9.3 (Clamped Spline). If f is deﬁned at a = x
0
< x
1
< <
x
n
= b and is diﬀerentiable at a and b, then f has a unique clamped spline
interpolant S on the nodes x
0
, x
1
, . . . , x
n
with boundary conditions S
′
(a) = f
′
(a)
and S
′
(b) = f
′
(b).
The following Matlab commands generate a sine curve and sample the spline
over a ﬁner mesh:
x = 0:10; y = sin(x);
xx = 0:0.25:10;
yy = spline(x,y,xx);
subplot(2,2,1); plot(x,y,’o’,xx,yy);
The result is shown in Fig 9.1.
The following Matlab commands illustrate the use of clamped spline inter
polation where the end slopes are prescribed. Zero slopes at the ends of an
interpolant to the values of a certain distribution are enforced:
x = 4:4; y = [0 .15 1.12 2.36 2.36 1.46 .49 .06 0];
cs = spline(x,[0 y 0]);
xx = linspace(4,4,101);
plot(x,y,’o’,xx,ppval(cs,xx),’’);
The result is shown in Fig 9.2.
9.6. CUBIC SPLINE INTERPOLATION 185
0 2 4 6 8 10
1
0.5
0
0.5
1
x
y
Spline interpolant to sine curve
Figure 9.1. Spline interpolant of sine curve.
4 2 0 2 4
0.5
0
0.5
1
1.5
2
2.5
3
x
y
Clamped spline approximation to data
Figure 9.2. Clamped spline approximation to data.
CHAPTER 10
Numerical Diﬀerentiation and Integration
10.1. Numerical Diﬀerentiation
10.1.1. Twopoint formula for f
′
(x). The Lagrange interpolating poly
nomial of degree 1 for f(x) at x
0
and x
1
= x
0
+h is
f(x) = f(x
0
)
x −x
1
−h
+f(x
1
)
x −x
0
h
+
(x −x
0
)(x −x
1
)
2!
f
′′
(ξ(x)), x
0
< ξ(x) < x
0
+h.
Diﬀerentiating this polynomial, we have
f
′
(x) = f(x
0
)
1
−h
+f(x
1
)
1
h
+
(x −x
1
) + (x −x
0
)
2!
f
′′
(ξ(x))
+
(x −x
0
)(x −x
1
)
2!
d
dx
_
f
′′
(ξ(x))
¸
.
Putting x = x
0
in f
′
(x), we obtain the ﬁrstorder twopoint formula
f
′
(x
0
) =
f(x
0
+h) −f(x
0
)
h
−
h
2
f
′′
(ξ). (10.1)
If h > 0, this is a forward diﬀerence formula and, if h < 0, this is a backward
diﬀerence formula.
10.1.2. Threepoint formula for f
′
(x). The Lagrange interpolating poly
nomial of degree 2 for f(x) at x
0
, x
1
= x
0
+h and x
2
= x
0
+ 2h is
f(x) = f(x
0
)
(x −x
1
)(x −x
2
)
(x
0
−x
1
)(x
0
−x
2
)
+f(x
1
)
(x −x
0
)(x −x
2
)
(x
1
−x
0
)(x
1
−x
2
)
+f(x
2
)
(x −x
0
)(x −x
1
)
(x
2
−x
0
)(x
2
−x
1
)
+
(x −x
0
)(x −x
1
)(x −x
2
)
3!
f
′′′
(ξ(x)),
where x
0
< ξ(x) < x
2
. Diﬀerentiating this polynomial and substituting x = x
j
,
we have
f
′
(x
j
) = f(x
0
)
2x
j
−x
1
−x
2
(x
0
−x
1
)(x
0
−x
2
)
+f(x
1
)
2x
j
−x
0
−x
2
(x
1
−x
0
)(x
1
−x
2
)
+f(x
2
)
2x
j
−x
0
−x
1
(x
2
−x
0
)(x
2
−x
1
)
+
1
6
f
′′′
(ξ(x
j
))
2
k=0,k=j
(x
j
−x
k
).
187
188 10. NUMERICAL DIFFERENTIATION AND INTEGRATION
With j = 0, 1, 2, f
′
(x
j
) gives three secondorder threepoint formulae:
f
′
(x
0
) = f(x
0
)
−3h
2h
2
+f(x
1
)
−2h
−h
2
+f(x
2
)
−h
2h
2
+
2h
2
6
f
′′′
(ξ
0
)
=
1
h
_
−
3
2
f(x
0
) + 2f(x
1
) −
1
2
f(x
2
)
_
+
h
2
3
f
′′′
(ξ
0
),
f
′
(x
1
) = f(x
0
)
−h
2h
2
+ f(x
1
)
0
−h
2
+f(x
2
)
h
2h
2
−
h
2
6
f
′′′
(ξ
1
)
=
1
h
_
−
1
2
f(x
0
) +
1
2
f(x
2
)
_
−
h
2
6
f
′′′
(ξ
1
),
and, similarly,
f
′
(x
2
) =
1
h
_
1
2
f(x
0
) −2f(x
1
) +
3
2
f(x
2
)
_
+
h
2
3
f
′′′
(ξ
2
).
These threepoint formulae are usually written at x
0
:
f
′
(x
0
) =
1
2h
[−3f(x
0
) + 4f(x
0
+h) −f(x
0
+ 2h)] +
h
2
3
f
′′′
(ξ
0
), (10.2)
f
′
(x
0
) =
1
2h
[f(x
0
+h) − f(x
0
−h)] −
h
2
6
f
′′′
(ξ
1
). (10.3)
The third formula is obtained from (10.2) by replacing h with −h. It is to be
noted that the centred formula (10.3) is more precise than (10.2) since its error
coeﬃcient is half the error coeﬃcient of the other formula.
10.1.3. Threepoint centered diﬀerence formula for f
′′
(x). We use
truncated Taylor’s expansions for f(x +h) and f(x −h):
f(x
0
+h) = f(x
0
) +f
′
(x
0
)h +
1
2
f
′′
(x
0
)h
2
+
1
6
f
′′′
(x
0
)h
3
+
1
24
f
(4)
(ξ
0
)h
4
,
f(x
0
−h) = f(x
0
) −f
′
(x
0
)h +
1
2
f
′′
(x
0
)h
2
−
1
6
f
′′′
(x
0
)h
3
+
1
24
f
(4)
(ξ
1
)h
4
.
Adding these expansions, we have
f(x
0
+h) +f(x
0
− h) = 2f(x
0
) +f
′′
(x
0
)h
2
+
1
24
_
f
(4)
(ξ
0
) +f
(4)
(ξ
1
)
_
h
4
.
Solving for f
′′
(x
0
), we have
f
′′
(x
0
) =
1
h
2
[f(x
0
−h) −2f(x
0
) +f(x
0
+h)] −
1
24
_
f
(4)
(ξ
0
) +f
(4)
(ξ
1
)
_
h
2
.
By the Mean Value Theorem 8.5 for sums, there is a value ξ, x
0
−h < ξ < x
0
+h,
such that
1
2
_
f
(4)
(ξ
0
) +f
(4)
(ξ
1
)
_
= f
(4)
(ξ).
We thus obtain the threepoint secondorder centered diﬀerence formula
f
′′
(x
0
) =
1
h
2
[f(x
0
−h) −2f(x
0
) +f(x
0
+h)] −
h
2
12
f
(4)
(ξ). (10.4)
10.2. THE EFFECT OF ROUNDOFF AND TRUNCATION ERRORS 189
z
0
h
h
*
1/
1/
Figure 10.1. Truncation and roundoﬀ error curve as a function
of 1/h.
10.2. The Eﬀect of Roundoﬀ and Truncation Errors
The presence of the stepsize h in the denominator of numerical diﬀerentiation
formulae may produce large errors due to roundoﬀ errors. We consider the case of
the twopoint centred formula (10.3) for f
′
(x). Other cases are treated similarly.
Suppose that the roundoﬀ error in the evaluated value
¯
f(x
j
) for f(x
j
) is
e(x
j
). Thus,
f(x
0
+h) =
¯
f(x
0
+h) +e(x
0
+h), f(x
0
−h) =
¯
f(x
0
−h) + e(x
0
−h).
Subtituting these values in (10.3), we have the total error, which is the sum of
the roundoﬀ and the truncation errors,
f
′
(x
0
) −
¯
f(x
0
+h) −
¯
f(x
0
−h)
2h
=
e(x
0
+h) −e(x
0
−h)
2h
−
h
2
6
f
(3)
(ξ).
Taking the absolute value of the righthand side and applying the triangle in
equality, we have
¸
¸
¸
¸
e(x
0
+h) −e(x
0
−h)
2h
−
h
2
6
f
(3)
(ξ)
¸
¸
¸
¸
≤
1
2h
([e(x
0
+h)[ +[e(x
0
−h)[)+
h
2
6
[f
(3)
(ξ)[.
If
[e(x
0
±h)[ ≤ ε, [f
(3)
(x)[ ≤ M,
then
¸
¸
¸
¸
¸
f
′
(x
0
) −
¯
f(x
0
+h) −
¯
f(x
0
−h)
2h
¸
¸
¸
¸
¸
≤
ε
h
+
h
2
6
M.
We remark that the expression
z(h) =
ε
h
+
h
2
6
M
ﬁrst decreases and afterwards increases as 1/h increases, as shown in Fig. 10.1.
The term Mh
2
/6 is due to the trunctation error and the term ε/h is due to
roundoﬀ errors.
Example 10.1. (a) Given the function f(x) and its ﬁrst derivative f
′
(x):
f(x) = cos x, f
′
(x) = −sin x,
190 10. NUMERICAL DIFFERENTIATION AND INTEGRATION
approxminate f
′
(0.7) with h = 0.1 by the ﬁvepoint formula, without the trunca
tion error term,
f
′
(x) =
1
12h
_
−f(x + 2h) + 8f(x +h) −8f(x −h) +f(x − 2h)
¸
+
h
4
30
f
(5)
(ξ),
where ξ, in the truncaction error, satisﬁes the inequalities x −2h ≤ ξ ≤ x + 2h.
(b) Given that the roundoﬀ error in each evaluation of f(x) is bounded by ǫ =
5 10
−7
, ﬁnd a bound for the total error in f
′
(0.7) by adding bounds for the
roundoﬀ and the truncation errors).
(c) Finally, ﬁnd the value of h that minimizes the total error.
Solution. (a) A simple computation with the given formula, without the
truncation error, gives the approximation
f
′
(0.7) ≈ −0.644 215 542.
(b) Since
f
(5)
(x) = −sinx
is negative and decreasing on the interval 0.5 ≤ x ≤ 0.9, then
M = max
0.5≤x≤0.9
[ −sin x[ = sin 0.9 = 0.7833.
Hence, a bound for the total error is
Total error ≤
1
12 0.1
(1 + 8 + 8 + 1) 5 10
−7
+
(0.1)
4
30
0.7833
= 7.5000 10
−6
+ 2.6111 10
−6
= 1.0111 10
−5
.
(c) The minimum of the total error, as a function of h,
90 10
−7
12h
+
0.7833
30
h
4
,
will be attained at a zero of its derivative with respect to h, that is,
d
dh
_
90 10
−7
12h
+
0.7833
30
h
4
_
= 0.
Performing the derivative and multiplying both sides by h
2
, we obtain a quintic
equation for h:
−7.5 10
−7
+
4 0.7833
30
h
5
= 0.
Hence,
h =
_
7.5 10
−7
30
4 0.7833
_
1/5
= 0.0936
minimizes the total error.
10.3. RICHARDSON’S EXTRAPOLATION 191
10.3. Richardson’s Extrapolation
Suppose it is known that a numerical formula, N(h), approximates an exact
value M with an error in the form of a series in h
j
,
M = N(h) +K
1
h +K
2
h
2
+K
3
h
3
+. . . ,
where the constants K
j
are independant of h. Then computing N(h/2), we have
M = N
_
h
2
_
+
1
2
K
1
h +
1
4
K
2
h
2
+
1
8
K
3
h
3
+. . . .
Subtracting the ﬁrst expression from twice the second, we eliminate the error in
h:
M = N
_
h
2
_
+
_
N
_
h
2
_
−N(h)
_
+
_
h
2
2
−h
2
_
K
2
+
_
h
3
4
−h
3
_
K
3
+. . . .
If we put
N
1
(h) = N(h),
N
2
(h) = N
1
_
h
2
_
+
_
N
1
_
h
2
_
−N
1
(h)
_
,
the last expression for M becomes
M = N
2
(h) −
1
2
K
2
h
2
−
3
4
K
3
h
3
−. . . .
Now with h/4, we have
M = N
2
_
h
2
_
−
1
8
K
2
h
2
−
3
32
K
3
h
3
+. . . .
Subtracting the second last expression for M from 4 times the last one and di
viding the result by 3, we elininate the term in h
2
:
M =
_
N
2
_
h
2
_
+
N
2
(h/2) −N
2
(h)
3
_
+
1
8
K
3
h
3
+. . . .
Now, putting
N
3
(h) = N
2
_
h
2
_
+
N
2
(h/2) −N
2
(h)
3
,
we have
M = N
3
(h) +
1
8
K
3
h
3
+. . . .
The presence of the number 2
j−1
− 1 in the denominator of the second term of
N
j
(h) ensures convergence. It is clear how to continue this process which is called
Richardson’s extrapolation.
An important case of Richardson’s extrapolation is when N(h) is the centred
diﬀerence formula (10.3) for f
′
(x), that is,
f
′
(x
0
) =
1
2h
_
f(x
0
+h) −f(x
0
−h)
¸
−
h
2
6
f
′′′
(x
0
) −
h
4
120
f
(5)
(x
0
) −. . . .
Since, in this case, the error term contains only even powers of h, the convergence
of Richardson’s extrapolation is very fast. Putting
N
1
(h) = N(h) =
1
2h
_
f(x
0
+h) −f(x
0
−h)
¸
,
192 10. NUMERICAL DIFFERENTIATION AND INTEGRATION
Table 10.1. Richardson’s extrapolation to the derivative of xe
x
.
N
1
(0.2) = 22.414 160
N
1
(0.1) = 22.228 786 N
2
(0.2) = 22.166 995
N
1
(0, 05) = 22.182 564 N
2
(0.1) = 22.167 157 N
3
(0.2) = 22.167 168
the above formula for f
′
(x
0
) becomes
f
′
(x
0
) = N
1
(h) −
h
2
6
f
′′′
(x
0
) −
h
4
120
f
(5)
(x
0
) −. . . .
Replacing h with h/2 in this formula gives the approximation
f
′
(x
0
) = N
1
_
h
2
_
−
h
2
24
f
′′′
(x
0
) −
h
4
1920
f
(5)
(x
0
) −. . . .
Subtracting the second last formula for f
′
(x
0
) from 4 times the last one and
dividing by 3, we have
f
′
(x
0
) = N
2
(h) −
h
4
480
f
(5)
(x
0
) +. . . ,
where
N
2
(h) = N
1
_
h
2
_
+
N
1
(h/2) −N
1
(h)
3
.
The presence of the number 4
j−1
− 1 in the denominator of the second term of
N
j
(h) provides fast convergence.
Example 10.2. Let
f(x) = xe
x
.
Apply Richardson’s extrapolation to the centred diﬀerence formula to compute
f
′
(x) at x
0
= 2 with h = 0.2.
Solution. We have
N
1
(0.2) = N(0.2) =
1
0.4
[f(2.2) −f(1.8)] = 22.414 160,
N
1
(0.1) = N(0.1) =
1
0.2
[f(2.1) −f(1.9)] = 22.228 786,
N
1
(0.05) = N(0.05) =
1
0.1
[f(2.05) −f(1.95)] = 22.182 564.
Next,
N
2
(0.2) = N
1
(0.1) +
N
1
(0.1) −N
1
(0.2)
3
= 22.166 995,
N
2
(0.1) = N
1
(0.05) +
N
1
(0.05) −N
1
(0.1)
3
= 22.167 157.
Finally,
N
3
(0.2) = N
2
(0.1) +
N
2
(0.1) −N
2
(0.2)
15
= 22.167 168,
which is correct to all 6 decimals. The results are listed in Table 10.1. One
sees the fast convergence of Richarson’s extrapolation for the centred diﬀerence
formula.
10.4. BASIC NUMERICAL INTEGRATION RULES 193
10.4. Basic Numerical Integration Rules
To approximate the value of the deﬁnite integral
_
b
a
f(x) dx,
where the function f(x) is smooth on [a, b] and a < b, we subdivide the interval
[a, b] into n subintervals of equal length h = (b − a)/n. The function f(x) is
approximated on each of these subintervals by an interpolating polynomial and
the polynomials are integrated.
For the midpoint rule, f(x) is interpolated on each subinterval [x
i−1
, x
1
] by
f([x
i−1
+ x
1
]/2), and the integral of f(x) over a subinterval is estimated by the
area of a rectangle (see Fig. 10.2).
For the trapezoidal rule, f(x) is interpolated on each subinterval [x
i−1
, x
1
]
by a polynomial of degree one, and the integral of f(x) over a subinterval is
estimated by the area of a trapezoid (see Fig. 10.3).
For Simpson’s rule, f(x) is interpolated on each pair of subintervals, [x
2i
, x
2i+1
]
and [x
2i+1
, x
2i+2
], by a polynomial of degree two (parabola), and the integral of
f(x) over such pair of subintervals is estimated by the area under the parabola
(see Fig. 10.4).
10.4.1. Midpoint rule. The midpoint rule,
_
x1
x0
f(x) dx = hf(x
∗
1
) +
1
24
f
′′
(ξ)h
3
, x
0
< ξ < x
1
, (10.5)
approximates the integral of f(x) on the interval x
0
≤ x ≤ x
1
by the area of a
rectangle with height f(x
∗
1
) and base h = x
1
− x
0
, where x
∗
1
is the midpoint of
the interval [x
0
, x
1
],
x
∗
1
=
x
0
+x
1
2
,
(see Fig. 10.2).
To derive formula (10.5), we expand f(x) in a truncated Taylor series with
center at x = x
∗
1
,
f(x) = f(x
∗
1
) +f
′
(x
∗
1
)(x −x
∗
1
) +
1
2
f
′′
(ξ)(x −x
∗
1
)
2
, x
0
< ξ < x
1
.
Integrating this expression from x
0
to x
1
, we have
_
x1
x0
f(x) dx = hf(x
∗
1
) +
_
x1
x0
f
′
(x
∗
1
)(x −x
∗
1
) dx +
1
2
_
x1
x0
f
′′
(ξ(x))(x −x
∗
1
)
2
dx
= hf(x
∗
1
) +
1
2
f
′′
(ξ)
_
x1
x0
(x −x
∗
1
)
2
dx.
where the integral over the linear term (x−x
∗
1
) is zero because this term is an odd
function with respect to the midpoint x = x
∗
1
and the Mean Value Theorem 8.4
for integrals has been used in the integral of the quadratic term (x − x
∗
0
)
2
which
does not change sign over the interval [x
0
, x
1
]. The result follows from the value
of the integral
1
2
_
x1
x0
(x −x
∗
1
)
2
dx =
1
6
_
(x −x
∗
1
)
3
¸
¸
x1
x0
=
1
24
h
3
.
194 10. NUMERICAL DIFFERENTIATION AND INTEGRATION
10.4.2. Trapezoidal rule. The trapezoidal rule,
_
x1
x0
f(x) dx =
h
2
[f(x
0
) +f(x
1
)] −
1
12
f
′′
(ξ)h
3
, x
0
< ξ < x
1
, (10.6)
approximates the integral of f(x) on the interval x
0
≤ x ≤ x
1
by the area of a
trapezoid with heights f(x
0
) and f(x
1
) and base h = x
1
−x
0
(see Fig. 10.3).
To derive formula (10.6), we interpolate f(x) at x = x
0
and x = x
1
by the
linear Lagrange polynomial
p
1
(x) = f(x
0
)
x −x
1
x
0
−x
1
+f(x
1
)
x −x
0
x
1
−x
0
.
Thus,
f(x) = p
1
(x) +
f
′′
(ξ)
2
(x −x
0
)(x −x
1
), x
0
< ξ < x
1
.
Since
_
x1
x0
p
1
(x) dx =
h
2
_
f(x
0
) +f(x
1
)
¸
,
we have
_
x1
x0
f(x) dx −
h
2
[f(x
0
) +f(x
1
)]
=
_
x1
x0
[f(x) −p
1
(x)] dx
=
_
x1
x0
f
′′
(ξ(x))
2
(x −x
0
)(x −x
1
) dx
by the Mean Value Theorem 8.4 for integrals
since (x −x
0
)(x −x
1
) ≤ 0 over [x
0
, x
1
]
=
f
′′
(ξ)
2
_
x1
x0
(x −x
0
)(x −x
1
) dx
with x −x
0
= s, dx = ds, x −x
1
= (x −x
0
) −(x
1
−x
0
) = s −h
=
f
′′
(ξ)
2
_
h
0
s(s −h) ds
=
f
′′
(ξ)
2
_
s
3
3
−
h
2
s
2
_
h
0
= −
f
′′
(ξ)
12
h
3
,
.
10.4.3. Simpson’s rule. Simpson’s rule
_
x2
x0
f(x) dx =
h
3
_
f(x
0
) +4f(x
1
) +f(x
2
)
¸
−
h
5
90
f
(4)
(ξ), x
0
< ξ < x
2
, (10.7)
approximates the integral of f(x) on the interval x
0
≤ x ≤ x
2
by the area under
a parabola which interpolates f(x) at x = x
0
, x
1
and x
2
(see Fig. 10.4).
To derive formula (10.7), we expand f(x) in a truncated Taylor series with
center at x = x
1
,
f(x) = f(x
1
)+f
′
(x
1
)(x−x
1
)+
f
′′
(x
1
)
2
(x−x
1
)
2
+
f
′′′
(x
1
)
6
(x−x
1
)
3
+
f
(4)
(ξ(x))
24
(x−x
1
)
4
.
10.5. THE COMPOSITE MIDPOINT RULE 195
Integrating this expression from x
0
to x
2
and noticing that the odd terms (x−x
1
)
and (x − x
1
)
3
are odd functions with respect to the point x = x
1
so that their
integrals vanish, we have
_
x2
x0
f(x) dx =
_
f(x)x +
f
′′
(x
1
)
6
(x − x
1
)
3
+
f
(4)
(ξ
1
)
120
(x −x
1
)
5
¸
¸
¸
¸
x2
x0
= 2hf(x
1
) +
h
3
3
f
′′
(x
1
) +
f
(4)
(ξ
1
)
60
h
5
,
where the Mean Value Theorem 8.4 for integrals was used in the integral of the
error term because the factor (x − x
1
)
4
does not change sign over the interval
[x
0
, x
2
].
Substituting the threepoint centered diﬀerence formula (10.4) for f
′′
(x
1
) in
terms of f(x
0
), f(x
1
) and f(x
2
):
f
′′
(x
1
) =
1
h
2
[f(x
0
) −2f(x
1
) +f(x
2
)] −
1
12
f
(4)
(ξ
2
)h
2
,
we obtain
_
x2
x0
f(x) dx =
h
3
_
f(x
0
) + 4f(x
1
) +f(x
2
)
¸
−
h
5
12
_
1
3
f
(4)
(ξ
2
) −
1
5
f
(4)
(ξ
2
)
_
.
In this case, we cannot apply the Mean Value Theorem 8.5 for sums to express the
error term in the form of f
(4)
(ξ) evaluated at one point since the weights 1/3 and
−1/5 have diﬀerent signs. However, since the formula is exact for polynomials of
degree less than or equal to 4, to obtain the factor 1/90 it suﬃces to apply the
formula to the monomial f(x) = x
4
and, for simplicity, integrate from −h to h:
_
h
−h
x
4
dx =
h
3
_
(−h)
4
+ 4(0)
4
+h
4
¸
+ kf
(4)
(ξ)
=
2
3
h
5
+ 4!k =
2
5
h
5
,
where the last term is the exact value of the integral. It follows that
k =
1
4!
_
2
5
−
2
3
_
h
5
= −
1
90
h
5
,
which yields (10.7).
10.5. The Composite Midpoint Rule
We subdivide the interval [a, b] into n subintervals of equal length h = (b −
a)/n with endpoints
x
0
= a, x
1
= a +h, . . . , x
i
= a +ih, . . . , x
n
= b.
On the subinterval [x
i−1
, x
i
], the integral of f(x) is approximated by the signed
area of the rectangle with base [x
i−1
, x
i
] and height f(x
∗
i
), where
x
∗
i
=
1
2
(x
i−1
+x
i
)
is the midpoint of the segment [x
i−1
, x
i
], as shown in Fig. 10.2 Thus, on the
interval [x
i−1
, x
1
], by the basic midpoint rule (10.5) we have
_
xi
xi−1
f(x) dx = hf(x
∗
i
) +
1
24
f
′′
(ξ
i
)h
3
, x
i−1
< ξ
i
< x
i
.
196 10. NUMERICAL DIFFERENTIATION AND INTEGRATION
y
0 x
b a
y = f (x)
x
i1
x
i
*
Rectangle
x
i
Figure 10.2. The ith panel of the midpoint rule.
Summing over all the subintervals, we have
_
b
a
f(x) dx = h
n
i=1
f(x
∗
i
) +
h
3
24
n
i=1
f
′′
(ξ
i
).
Multiplying and dividing the error term by n, applying the Mean Value Theo
rem 8.5 for sums to this term and using the fact that nh = b −a, we have
nh
3
24
n
i=1
1
n
f
′′
(ξ
i
) =
(b −a)h
2
24
f
′′
(ξ), a < ξ < b.
Thus, we obtain the composite midpoint rule:
_
b
a
f(x) dx = h
_
f(x
∗
1
) +f(x
∗
2
) + +f(x
∗
n
)
¸
+
(b −a)h
2
24
f
′′
(ξ), a < ξ < b. (10.8)
We see that the composite midpoint rule is a method of order O(h
2
), which is
exact for polynomials of degree smaller than or equal to 1.
Example 10.3. Use the composite midpoint rule to approximate the integral
I =
_
1
0
e
x
2
dx
with step size h such that the absolute truncation error is bounded by 10
−4
.
Solution. Since
f(x) = e
x
2
and f
′′
(x) = (2 + 4 x
2
) e
x
2
,
then
0 ≤ f
′′
(x) ≤ 6 e for x ∈ [0, 1].
Therefore, a bound for the absolute truncation error is
[ǫ
M
[ ≤
1
24
6 e(1 −0)h
2
=
1
4
eh
2
< 10
−4
.
Thus
h < 0.0121
1
h
= 82.4361.
10.6. THE COMPOSITE TRAPEZOIDAL RULE 197
y
0 x
b a
y = f (x)
x
i1
x
i
Trapezoid
Figure 10.3. The ith panel of the trapezoidal rule.
We take n = 83 ≥ 1/h = 82.4361 and h = 1/83. The approximate value of I is
I ≈
1
83
_
e
(0.5/83)
2
+ e
(1.5/83)
2
+ + e
(13590.5/83)
2
+e
(82.5/83)
2
_
≈ 1.46262
The following Matlab commands produce the midpoint integration.
x = 0.5:82.5; y = exp((x/83).^2);
z = 1/83*sum(y)
z = 1.4626
10.6. The Composite Trapezoidal Rule
We divide the interval [a, b] into n subintervals of equal length h = (b −a)/n,
with endpoints
x
0
= a, x
1
= a +h, . . . , x
i
= a +ih, . . . , x
n
= b.
On each subinterval [x
i−1
, x
i
], the integral of f(x) is approximated by the signed
area of the trapezoid with vertices
(x
i−1
, 0), (x
i
, 0), (x
i
, f(x
i
)), (x
i−1
, f(x
i−1
)),
as shown in Fig. 10.3. Thus, by the basic trapezoidal rule (10.6),
_
x1
xi−1
f(x) dx =
h
2
[f(x
i−1
) +f(x
i
)] −
h
3
12
f
′′
(ξ
i
).
Summing over all the subintervals, we have
_
b
a
f(x) dx =
h
2
n
i=1
_
f(x
i−1
) +f(x
i
)
¸
−
h
3
12
n
i=1
f
′′
(ξ
i
).
Multiplying and dividing the error term by n, applying the Mean Value Theo
rem 8.5 for sums to this term and using the fact that nh = b −a, we have
−
nh
3
12
n
i=1
1
n
f
′′
(ξ
i
) = −
(b −a)h
2
12
f
′′
(ξ), a < ξ < b.
198 10. NUMERICAL DIFFERENTIATION AND INTEGRATION
Thus, we obtain the composite trapezoidal rule:
_
b
a
f(x) dx =
h
2
_
f(x
0
) + 2f(x
1
) + 2f(x
2
) + + 2f(x
n−2
)
+ 2f(x
n−1
) +f(x
n
)
¸
−
(b −a)h
2
12
f
′′
(ξ), a < ξ < b. (10.9)
We see that the composite trapezoidal rule is a method of order O(h
2
), which is
exact for polynomials of degree smaller than or equal to 1. Its absolute truncation
error is twice the absolute truncation error of the midpoint rule.
Example 10.4. Use the composite trapezoidal rule to approximate the inte
gral
I =
_
1
0
e
x
2
dx
with step size h such that the absolute truncation error is bounded by 10
−4
.
Compare with Examples 10.3 and 10.6.
Solution. Since
f(x) = e
x
2
and f
′′
(x) = (2 + 4 x
2
) e
x
2
,
then
0 ≤ f
′′
(x) ≤ 6 e for x ∈ [0, 1].
Therefore,
[ǫ
T
[ ≤
1
12
6 e(1 −0)h
2
=
1
2
eh
2
< 10
−4
, that is, h < 0.008 577 638.
We take n = 117 ≥ 1/h = 116.6 (compared to 83 for the composite midpoint
rule). The approximate value of I is
I ≈
1
117 2
_
e
(0/117)
2
+ 2 e
(1/117)
2
+ 2 e
(2/117)
2
+
+ 2 e
(115/117)
2
+ 2 e
(116/117)
2
+ e
(117/117)
2
_
= 1.46268.
The following Matlab commands produce the trapesoidal integration of nu
merical values y
k
at nodes k/117, k = 0, 1, . . . , 117, with stepsize h = 1/117.
x = 0:117; y = exp((x/117).^2);
z = trapz(x,y)/117
z = 1.4627
Example 10.5. How many subintervals are necessary for the composite trape
zoidal rule to approximate the integral
I =
_
2
1
_
x
2
−
1
12
(x −1.5)
4
_
dx
with step size h such that the absolute truncation error is bounded by 10
−3
.
10.7. THE COMPOSITE SIMPSON’S RULE 199
y
0 x
b a
y = f (x)
x
2i+2
x
2i
x
2i+1
Figure 10.4. A double panel of Simpson’s rule.
Solution. Denote the integrand by
f(x) = x
2
−
1
12
(x −1.5)
4
.
Then
f
′′
(x) = 2 −(x −1.5)
2
.
It is clear that
M = max
1≤x≤2
f
′′
(x) = f(1.5) = 2.
To bound the absolute truncation error by 10
−3
, we need
¸
¸
¸
¸
(b −a)h
2
12
f
′′
(ξ)
¸
¸
¸
¸
≤
h
2
12
M
=
h
2
6
≤ 10
−3
.
This gives
h ≤
_
6 10
−3
= 0.0775
and
1
h
= 12.9099 ≤ n = 13.
Thus it suﬃces to take
h =
1
13
, n = 13.
10.7. The Composite Simpson’s Rule
We subdivide the interval [a, b] into an even number, n = 2m, of subintervals
of equal length, h = (b −a)/(2m), with endpoints
x
0
= a, x
1
= a +h, . . . , x
i
= a +i h, . . . , x
2m
= b.
On the subinterval [x
2i
, x
2i+2
], the function f(x) is interpolated by the quadratic
polynomial p
2
(x) which passes through the points
_
x
2i
, f(x
2i
)
_
,
_
x
2i+1
, f(x
2i+1
)
_
,
_
x
2i+2
, f(x
2i+2
)
_
,
as shown in Fig. 10.4.
Thus, by the basic Simpson’s rule (10.7),
_
x2i+2
x2i
f(x) dx =
h
3
_
f(x
2i
)+4f(x
2i+1
)+f(x
2i+2
)
¸
−
h
5
90
f
(4)
(ξ
i
), x
2i
< ξ < x
2i+2
.
200 10. NUMERICAL DIFFERENTIATION AND INTEGRATION
Summing over all the subintervals, we have
_
b
a
f(x) dx =
h
3
m
i=1
_
f(x
2i
) + 4f(x
2i+1
) +f(x
2i+2
)
¸
−
h
5
90
m
i=1
f
(4)
(ξ
i
).
Multiplying and dividing the error term by m, applying the Mean Value Theo
rem 8.5 for sums to this term and using the fact that 2mh = nh = b − a, we
have
−
2mh
5
2 90
m
i=1
1
m
f
(4)
(ξ
i
) = −
(b −a)h
4
180
f
(4)
(ξ), a < ξ < b.
Thus, we obtain the composite Simpson’s rule:
_
b
a
f(x) dx =
h
3
_
f(x
0
) + 4f(x
1
) + 2f(x
2
) + 4f(x
3
) +
+ 2f(x
2m−2
) + 4f(x
2m−1
) +f(x
2m
)
¸
−
(b −a)h
4
180
f
(4)
(ξ), a < ξ < b.
(10.10)
We see that the composite Simpson’s rule is a method of order O(h
4
), which
is exact for polynomials of degree smaller than or equal to 3.
Example 10.6. Use the composite Simpson’s rule to approximate the integral
I =
_
1
0
e
x
2
dx
with stepsize h such that the absolute truncation error is bounded by 10
−4
. Com
pare with Examples 10.3 and 10.4.
Solution. We have
f(x) = e
x
2
and f
(4)
(x) = 4 e
x
2 _
3 + 12x
2
+ 4x
4
_
.
Thus
0 ≤ f
(4)
(x) ≤ 76 e on [0, 1].
The absolute truncation error is thus less than or equal to
76
180
e(1 −0)h
4
. Hence,
h must satisfy the inequality
76
180
eh
4
< 10
−4
, that is, h < 0.096 614 232.
To satisfy the inequality
2m ≥
1
h
= 10.4
we take
n = 2m = 12 and h =
1
12
.
The approximation is
I ≈
1
12 3
_
e
(0/12)
2
+ 4 e
(1/12)
2
+ 2 e
(2/12)
2
+ + 2 e
(10/12)
2
+ 4 e
(11/12)
2
+e
(12/12)
2
_
= 1.46267.
We obtain a value which is similar to those found in Examples 10.3 and 10.4.
However, the number of arithmetic operations is much less when using Simpson’s
rule (hence cost and truncation errors are reduced). In general, Simpson’s rule is
preferred to the midpoint and trapezoidal rules.
10.8. ROMBERG INTEGRATION FOR THE TRAPEZOIDAL RULE 201
Example 10.7. Use the composite Simpson’s rule to approximate the integral
I =
_
2
0
_
1 + cos
2
xdx
within an accuracy of 0.0001.
Solution. We must determine the step size h such that the absolute trun
cation error, [ǫ
S
[, will be bounded by 0.0001. For
f(x) =
_
1 + cos
2
x,
we have
f
(4)
(x) =
−3 cos
4
(x)
(1 + cos
2
(x))
3/2
+
4 cos
2
(x)
_
1 + cos
2
(x)
−
18 cos
4
(x) sin
2
(x)
(1 + cos
2
(x))
5/2
+
22 cos
2
(x) sin
2
(x)
(1 + cos
2
(x))
3/2
−
4 sin
2
(x)
_
1 + cos
2
(x)
−
15 cos
4
(x) sin
4
(x)
(1 + cos
2
(x))
7/2
+
18 cos
2
(x) sin
4
(x)
(1 + cos
2
(x))
5/2
−
3 sin
4
(x)
(1 + cos
2
(x))
3/2
.
Since every denominator is greater than one, we have
[f
(4)
(x)[ ≤ 3 + 4 + 18 + 22 + 4 + 15 + 18 + 3 = 87.
Therefore, we need
[ǫ
S
[ <
87
180
(2 −0)h
4
.
Hence,
h < 0.100 851 140,
1
h
> 9.915 604 269.
To have 2m ≥ 2/h = 2 9.9 we take n = 2m = 20 and h = 1/10. The
approximation is
I ≈
1
20 3
_
_
1 + cos
2
(0) + 4
_
1 + cos
2
(0.1) + 2
_
1 + cos
2
(0.2) +
+ 2
_
1 + cos
2
(1.8) + 4
_
1 + cos
2
(1.9) +
_
1 + cos
2
(2)
_
= 2.35169.
10.8. Romberg Integration for the Trapezoidal Rule
Romberg integration uses Richardson’s extrapolation to improve the trape
zoidal rule approximation, R
k,1
, with step size h
k
, to an integral
I =
_
b
a
f(x) dx.
It can be shown that
I = R
k,1
+K
1
h
2
k
+K
2
h
4
k
+K
3
h
6
k
+. . . ,
where the constants K
j
are independant of h
k
. With step sizes
h
1
= h, h
2
=
h
2
, h
3
=
h
2
2
, . . . , h
k
=
h
2
k−1
, . . . ,
202 10. NUMERICAL DIFFERENTIATION AND INTEGRATION
one can cancel errors of order h
2
, h
4
, etc. as follows. Suppose R
k,1
and R
k+1,1
have been computed, then we have
I = R
k,1
+K
1
h
2
k
+K
2
h
4
k
+K
3
h
6
k
+. . .
and
I = R
k+1,1
+K
1
h
2
k
4
+K
2
h
2
k
16
+K
3
h
2
k
64
+. . . .
Subtracting the ﬁrst expression for I from 4 times the second expression and
dividing by 3, we obtain
I =
_
R
k+1,1
+
R
k+1,1
−R
k,1
3
_
+
K
2
3
_
1
4
−1
_
h
4
k
+
K
3
3
_
1
16
−1
_
h
4
k
+. . . .
Put
R
k,2
= R
k,1
+
R
k,1
−R
k−1,1
3
and, in general,
R
k,j
= R
k,j−1
+
R
k,j−1
−R
k−1,j−1
4
j−1
−1
.
Then R
k,j
is a better approximation to I than R
k,j−1
and R
k−1,j−1
. The relations
between the R
k,j
are shown in Table 10.2.
Table 10.2. Romberg integration table with n levels
R
1,1
ց
R
2,1
→ R
2,2
ց ց
R
3,1
→ R
3,2
→ R
3,3
ց ց ց
R
4,1
→ R
4,2
→ R
4,3
→ R
4,4
.
.
.
.
.
.
.
.
.
.
.
.
ց ց ց ց
R
n,1
→ R
n,2
→ R
n,3
→ R
n,4
→ R
n,n
Example 10.8. Use 6 levels of Romberg integration, with h
1
= h = π/4, to
approximate the integral
I =
_
π/4
0
tan xdx.
Solution. The following results are obtained by a simple Matlab program.
Romberg integration table:
0.39269908
0.35901083 0.34778141
0.34975833 0.34667417 0.34660035
0.34737499 0.34658054 0.34657430 0.34657388
0.34677428 0.34657404 0.34657360 0.34657359 0.34657359
0.34662378 0.34657362 0.34657359 0.34657359 0.34657359 0.34657359
10.9. ADAPTIVE QUADRATURE METHODS 203
10.9. Adaptive Quadrature Methods
Uniformly spaced composite rules that are exact for degree d polynomials are
eﬃcient if the (d+1)st derivative f
(d+1)
is uniformly behaved across the interval of
integration [a, b]. However, if the magnitude of this derivative varies widely across
this interval, the error control process may result in an unnecessary number of
function evaluations. This is because the number n of nodes is determined by an
intervalwide derivative bound M
d+1
. In regions where f
(d+1)
is small compared
to this value, the subintervals are (possibly) much shorter than necessary. Adap
tive quadrature methods address this problem by discovering where the integrand
is ill behaved and shortening the subintervals accordingly.
We take Simpson’s rule as a typical example:
I =:
_
b
a
f(x) dx = S(a, b) −
h
5
90
f
(4)
(ξ), 0 < ξ < b,
where
S(a, b) =
h
3
[f(a) + 4f(a +h) +f(b)], h =
b −a
2
.
The aim of adaptive quadrature is to take h large over regions where [f
(4)
(x)[ is
small and take h small over regions where [f
(4)
(x)[ is large to have a uniformly
small error. A simple way to estimate the error is to use h and h/2 as follows:
I = S(a, b) −
h
5
90
f
(4)
(ξ
1
), (10.11)
I = S
_
a,
a +b
2
_
+S
_
a +b
2
, b
_
−
2
32
h
5
90
f
(4)
(ξ
2
). (10.12)
Assuming that
f
(4)
(ξ
2
) ≈ f
(4)
(ξ
1
)
and subtracting the second expression for I from the ﬁrst we have an expression
for the error term:
h
5
90
f
(4)
(ξ
1
) ≈
16
15
_
S(a, b) −S
_
a,
a +b
2
_
−S
_
a +b
2
, b
__
.
Putting this expression in (10.12), we obtain an estimate for the absolute error:
¸
¸
¸
¸
I −S
_
a,
a + b
2
_
−S
_
a +b
2
, b
_¸
¸
¸
¸
≈
1
15
¸
¸
¸
¸
S(a, b) −S
_
a,
a +b
2
_
−S
_
a +b
2
, b
_¸
¸
¸
¸
.
If the righthand side of this estimate is smaller than a given tolerance, then
S
_
a,
a +b
2
_
+S
_
a +b
2
, b
_
is taken as a good approximation to the value of I.
The adaptive quadrature for Simpson’s rule is often better than the composite
Simpson’s rule. For example, in integrating the function
f(x) =
100
x
2
sin
_
10
x
_
, 1 ≤ x ≤ 3,
shown in Fig. 10.5, with toleralance 10
−4
, the adaptive quadrature uses 23 subin
tervals and requires 93 evaluations of f. On the other hand, the composite Simp
son’s rule uses a constant value of h = 1/88 and requires 177 evaluations of f. It
is seen from the ﬁgure that f varies quickly over the interval [1, 1.5]. The adaptive
204 10. NUMERICAL DIFFERENTIATION AND INTEGRATION
1 1.5 2 2.5 3
60
40
20
0
20
40
60
80
x
y
(100/x
2
)sin(10/x)
Figure 10.5. A fast varying function for adaptive quadrature.
quadrature needs 11 subintervals on the short interval [1, 1.5] and only 12 on the
longer interval [1.5, 3].
The Matlab quadrature routines quad, quadl and dblquad are adaptive
routines.
Matlab’s adaptive Simpson’s rule quad and adaptive Newton–Cotes 8panel
rule quad8 evaluate the integral
I =
_
π/2
0
sinxdx
as follows.
>> v1 = quad(’sin’,0,pi/2)
v1 = 1.00000829552397
>> v2 = quad8(’sin’,0,pi/2)
v2 = 1.00000000000000
respectively, within a relative error of 10
−3
.
10.10. Gaussian Quadratures
The Gaussian quadrature formulae are the most accurate integration for
mulae for a given number of nodes. The npoint Gaussian quadrature formula
approximate the integral of f(x) over the standardized interval −1 ≤ x ≤ 1 by
the formula
_
1
−1
f(x) dx ≈
n
i=1
w
i
f(t
i
) (10.13)
where the nodes x
i
are the zeros of the Legendre polynomial P
n
(x) of degree n.
The twopoint Gaussian quadrature formula is
_
1
−1
f(x) dx = f
_
−
1
√
3
_
+f
_
1
√
3
_
.
The threepoint Gaussian quadrature formula is
_
1
−1
f(x) dx =
5
9
f
_
−
_
3
5
_
+
8
9
f(0) +
5
9
f
_
_
3
5
_
.
The nodes x
i
, weights w
i
and precision 2n −1 of n points Gaussian quadra
tures, are listed in Table 10.3 for n = 1, 2, . . . , 5.
10.10. GAUSSIAN QUADRATURES 205
Table 10.3. Nodes x
i
, weights w
i
and precision 2n − 1 of n
points Gaussian quadratures.
n x
i
w
i
Precision 2n −1
2 −1/
√
3 1 3
1/
√
3 1
3 −
_
3/5 5/9 5
0 8/9
_
3/5 5/9
4 −0.861 136 311 6 0.347 854 845 1 7
−0.339 981 043 6 0.652 145 154 9
0.339 981 043 6 0.652 145 154 9
0.861 136 311 6 0.347 854 845 1
5 −0.906 179 845 9 0.236 926 885 1 9
−0.538 469 310 1 0.478 628 670 5
0 0,568 888 888 9
0.538 469 310 1 0.478 628 670 5
0.906 179 845 9 0.236 926 885 1
The error in the npoint formula is
E
n
(f) =
2
(2n + 1)!
_
2
n
(n!)
2
(2n)!
_
2
f
(2n)
(ξ), −1 < ξ < 1.
This formula is therefore exact for polynomials of degree 2n −1 or less.
Gaussian quadratures are derived in Section 5.6 by means of the orthogonality
relations of the Legendre polynomials. These quadratures can also be obtained
by means of the integrals of the Lagrange basis on −1 ≤ x ≤ 1 for the nodes x
i
taken as the zeros of the Legendre polynomials:
w
i
=
_
1
−1
n
j=1,j=i
x −x
j
x
i
−x
j
dx.
Examples can be found in Section 5.6 and exercises in Exercises for Chapter 5.
In the applications, the interval [a, b] of integration is split into smaller inter
vals and a Gaussian quadrature is used on each subinterval with an appropriate
change of variable as in Example 5.11.
CHAPTER 11
Matrix Computations
With the advent of digitized systems in many areas of science and engineering,
matrix computation is occupying a central place in modern computer software.
In this chapter, we study the solutions of linear systems,
Ax = b, A ∈ R
m×n
,
and eigenvalue problems,
Ax = λx, A ∈ R
n×n
, x ,= 0,
as implemented in softwares, where accuracy, stability and algorithmic complexity
are of the utmost importance.
11.1. LU Solution of Ax = b
The solution of a linear system
Ax = b, A ∈ R
n×n
,
with partial pivoting, to be explained below, is obtained by the LU decomposition
of A,
A = LU,
where L is a rowpermutation of a lower triangular matrix M with m
ii
= 1 and
[m
ij
[ ≤ 1, for i > j, and U is an upper triangular matrix. Thus the system
becomes
LUx = b.
The solution is obtained in two steps. First,
Ly = b
is solved for y by forward substitution and, second,
Ux = y
is solved for x by backward substitution. The following example illustrates the
above steps.
Example 11.1. Solve the system Ax = b,
_
_
3 9 6
18 48 39
9 −27 42
_
_
_
_
x
1
x
2
x
3
_
_
=
_
_
23
136
45
_
_
by the LU decomposition with partial pivoting.
207
208 11. MATRIX COMPUTATIONS
Solution. Since a
21
= 18 is the largest pivot in absolute value in the ﬁrst
column of A,
[18[ > [3[, [18[ > [9[,
we interchange the second and ﬁrst rows of A,
P
1
A =
_
_
18 48 39
3 9 6
9 −27 42
_
_
, where P
1
=
_
_
0 1 0
1 0 0
0 0 1
_
_
.
We now apply a Gaussian transformation, M
1
, on P
1
A to put zeros under 18 in
the ﬁrst column,
_
_
1 0 0
−1/6 1 0
−1/2 0 1
_
_
_
_
18 48 39
3 9 6
9 −27 42
_
_
=
_
_
18 48 39
0 1 −1/2
0 −51 45/2
_
_
,
with multipliers −1/6 and −1/2. Thus
M
1
P
1
A = A
1
.
Considering the 2 2 submatrix
_
1 −1/2
−51 45/2
_
,
we see that −51 is the pivot in the ﬁrst column since
[ −51[ > [1[.
Hence we interchange the third and second row,
P
2
A
1
=
_
_
18 48 39
0 −51 45/2
0 1 −1/2
_
_
, where P
2
=
_
_
1 0 0
0 0 1
0 1 0
_
_
.
To zero the (3, 2) element we apply a Gaussian transformation, M
2
, on P
2
A
1
,
_
_
1 0 0
0 1 0
0 1/51 1
_
_
_
_
18 48 39
0 −51 45/2
0 1 −1/2
_
_
=
_
_
18 48 39
0 −51 22.5
0 0 −0.0588
_
_
,
where 1/51 is the multiplier. Thus
M
2
P
2
A
1
= U.
Therefore
M
2
P
2
M
1
P
1
A = U,
and
A = P
−1
1
M
−1
1
P
−1
2
M
−1
2
U = LU.
The inverse of a Gaussian transformation is easily written:
M
1
=
_
_
1 0 0
−a 1 0
−b 0 1
_
_
=⇒ M
−1
1
=
_
_
1 0 0
a 1 0
b 0 1
_
_
,
M
2
=
_
_
1 0 0
0 1 0
0 −c 1
_
_
=⇒ M
−1
2
=
_
_
1 0 0
0 1 0
0 c 1
_
_
,
11.1. LU SOLUTION OF Ax = b 209
once the multipliers −a, −b, −c are known. Moreover the product M
−1
1
M
−1
2
can
be easily written:
M
−1
1
M
−1
2
=
_
_
1 0 0
a 1 0
b 0 1
_
_
_
_
1 0 0
0 1 0
0 c 1
_
_
=
_
_
1 0 0
a 1 0
b c 1
_
_
.
It is easily seen that a permutation P, which consists of the identity matrix I
with permuted rows, is an orthogonal matrix. Hence,
P
−1
= P
T
.
Therefore, if
L = P
T
1
M
−1
1
P
T
2
M
−1
2
,
then, solely by a rearrangement of the elements of M
−1
1
and M
−1
2
without any
arithemetic operations, we obtain
L =
_
_
0 1 0
1 0 0
0 0 1
_
_
_
_
1 0 0
1/6 1 0
1/2 0 1
_
_
_
_
1 0 0
0 0 1
0 1 0
_
_
_
_
1 0 0
0 1 0
0 −1/51 1
_
_
=
_
_
1/6 1 0
1 0 0
1/2 0 1
_
_
_
_
1 0 0
0 −1/51 1
0 1 0
_
_
=
_
_
1/6 −1/51 1
1 0 0
1/2 1 0
_
_
which is the rowpermutation of a lower triangular matrix, that is, it becomes
lower triangular if the second and ﬁrst rows are interchanged, and then the new
second row is interchanged with the third row, namely, P
2
P
1
L is lower triangular.
The system
Ly = b
is solved by forward substitution:
_
_
1/6 −1/51 1
1 0 0
1/2 1 0
_
_
_
_
y
1
y
2
y
3
_
_
=
_
_
23
136
45
_
_
,
y
1
= 136,
y
2
= 45 −136/2 = −23,
y
3
= 23 −136/6 −23/51 = −0.1176.
Finally, the system
Ux = y
is solved by backward substitution:
_
_
18 48 39
0 −51 22.5
0 0 −0.0588
_
_
_
_
x
1
x
2
x
3
_
_
=
_
_
136
−23
−0.1176
_
_
,
x
3
= 0.1176/0.0588 = 2,
x
2
= (−23 −22.5 2)/(−51) = 1.3333,
x
1
= (136 −48 1.3333 −39 2)/18 = −0.3333.
The following Matlab session does exactly that.
210 11. MATRIX COMPUTATIONS
>> A = [3 9 6; 18 48 39; 9 27 42]
A =
3 9 6
18 48 39
9 27 42
>> [L,U] = lu(A)
L =
0.1667 0.0196 1.0000
1.0000 0 0
0.5000 1.0000 0
U =
18.0000 48.0000 39.0000
0 51.0000 22.5000
0 0 0.0588
>> b = [23; 136; 45]
b =
23
136
45
>> y = L\b % forward substitution
y =
136.0000
23.0000
0.1176
>> x = U\y % backward substitution
x =
0.3333
1.3333
2.0000
>> z = A\b % Matlab leftinverse to solve Az = b by the LU decomposition
z =
0.3333
1.3333
2.0000
The didactic Matlab command
[L,U,P] = lu(A)
11.1. LU SOLUTION OF Ax = b 211
ﬁnds the permutation matrix P which does all the pivoting at once on the system
Ax = b
and produces the equivalent permuted system
PAx = Pb
which requires no further pivoting. Then it computes the LU decomposition of
PA,
PA = LU,
where the matrix L is unit lower triangular with l
ij
≤ 1, for i > j, and the matrix
U is upper triangular.
We repeat the previous Matlab session making use of the matrix P.
A = [3 9 6; 18 48 39; 9 27 42]
A = 3 9 6
18 48 39
9 27 42
b = [23; 136; 45]
b = 23
136
45
[L,U,P] = lu(A)
L = 1.0000 0 0
0.5000 1.0000 0
0.1667 0.0196 1.0000
U = 18.0000 48.0000 39.0000
0 51.0000 22.5000
0 0 0.0588
P = 0 1 0
0 0 1
1 0 0
y = L\P*b
y = 136.0000
23.0000
0.1176
x = U\y
x = 0.3333
1.3333
2.0000
Theorem 11.1. The LU decomposition of a matrix A exists if and only if all
its principal minors are nonzero.
The principal minors of A are the determinants of the top left submatrices of
A. Partial pivoting attempts to make the principal minors of PA nonzero.
212 11. MATRIX COMPUTATIONS
Example 11.2. Given
A =
_
_
3 2 0
12 13 6
−3 8 9
_
_
, b =
_
_
14
40
−28
_
_
,
ﬁnd the LU decomposition of A without pivoting and solve
Ax = b.
Solution. For M
1
A = A
1
, we have
_
_
1 0 0
−4 1 0
1 0 1
_
_
_
_
3 2 0
12 13 6
−3 8 9
_
_
=
_
_
3 2 0
0 5 6
0 10 9
_
_
.
For M
2
A
1
= U, we have
_
_
1 0 0
0 1 0
0 −2 1
_
_
_
_
3 2 0
0 5 6
0 10 9
_
_
=
_
_
3 2 0
0 5 6
0 0 −3
_
_
= U,
that is
M
2
M
1
A = U, A = M
−1
1
M
−1
2
U = LU.
Thus
L = M
−1
1
M
−1
2
=
_
_
1 0 0
4 1 0
−1 0 1
_
_
_
_
1 0 0
0 1 0
0 2 1
_
_
=
_
_
1 0 0
4 1 0
−1 2 1
_
_
.
Forward substitution is used to obtain y from Ly = b,
_
_
1 0 0
4 1 0
−1 2 1
_
_
_
_
y
1
y
2
y
3
_
_
=
_
_
14
40
−28
_
_
;
thus
y
1
= 14,
y
2
= 40 −56 = −16,
y
3
= −28 + 14 + 32 = 18.
Finally, backward substitution is used to obtain x from Ux = y,
_
_
3 2 0
0 5 6
0 0 −3
_
_
_
_
x
1
x
2
x
3
_
_
=
_
_
14
−16
18
_
_
;
thus
x
3
= −6,
x
2
= (−16 + 36)/5 = 4,
x
1
= (14 −8)/3 = 2.
11.1. LU SOLUTION OF Ax = b 213
We note that, without pivoting, [l
ij
[, i > j, may be larger than 1.
The LU decomposition without partial pivoting is an unstable procedure
which may lead to large errors in the solution. In practice, partial pivoting is
usually stable. However, in some cases, one needs to resort to complete pivoting
on rows and columns to ensure stability, or to use the stable QR decomposition.
Sometimes it is useful to scale the rows or columns of the matrix of a linear
system before solving it. This may alter the choice of the pivots. In practice, one
has to consider the meaning and physical dimensions of the unknown variables
to decide upon the type of scaling or balancing of the matrix. Softwares provide
some of these options. Scaling in the l
∞
norm is used in the following example.
Example 11.3. Scale each equation in the l
∞
norm, so that the largest coef
ﬁcient of each row on the lefthand side is equal to 1 in absolute value, and solve
the following system:
30.00x
1
+ 591400x
2
= 591700
5.29x
1
− 6.130x
2
= 46.70
by the LU decomposition with pivoting with fourdigit arithmetic.
Solution. Dividing the ﬁrst equation by
s
1
= max¦[30.00[, [591400[¦ = 591400
and the second equation by
s
2
= max¦[5.291[, [6.130[¦ = 6.130,
we ﬁnd that
[a
11
[
s
1
=
30.00
591400
= 0.5073 10
−4
,
[a
21
[
s
2
=
5.291
6.130
= 0.8631.
Hence the scaled pivot is in the second equation. Note that the scaling is done only
for comprison purposes and the division to determine the scaled pivots produces
no roundoﬀ error in solving the system. Thus the LU decomposition applied to
the interchanged system
5.29x
1
− 6.130x
2
= 46.70
30.00x
1
+ 591400x
2
= 591700
produces the correct results:
x
1
= 10.00, x
2
= 1.000.
On the other hand, the LU decomposition with fourdigit arithmetic applied to
the noninterchanged system produces the erroneous results x
1
≈ −10.00 and
x
2
≈ 1.001.
The following Matlab function Mﬁles are found in
ftp://ftp.cs.cornell.edu/pub/cv. The forward substitution algorithm solves
a lower triangular system:
function x = LTriSol(L,b)
%
% Pre:
% L nbyn nonsingular lower triangular matrix
% b nby1
%
214 11. MATRIX COMPUTATIONS
% Post:
% x Lx = b
n = length(b);
x = zeros(n,1);
for j=1:n1
x(j) = b(j)/L(j,j);
b(j+1:n) = b(j+1:n)  L(j+1:n,j)*x(j);
end
x(n) = b(n)/L(n,n);
The backward substitution algorithm solves a upper triangular system:
function x = UTriSol(U,b)
%
% Pre:
% U nbyn nonsingular upper triangular matrix
% b nby1
%
% Post:
% x Lx = b
n = length(b);
x = zeros(n,1);
for j=n:1:2
x(j) = b(j)/U(j,j);
b(1:j1) = b(1:j1)  x(j)*U(1:j1,j);
end
x(1) = b(1)/U(1,1);
The LU decomposition without pivoting is performed by the following function.
function [L,U] = GE(A);
%
% Pre:
% A nbyn
%
% Post:
% L nbyn unit lower triangular with L(i,j)<=1.
% U nbyn upper triangular.
% A = LU
[n,n] = size(A);
for k=1:n1
A(k+1:n,k) = A(k+1:n,k)/A(k,k);
A(k+1:n,k+1:n) = A(k+1:n,k+1:n)  A(k+1:n,k)*A(k,k+1:n);
end
L = eye(n,n) + tril(A,1);
U = triu(A);
The LU decomposition with pivoting is performed by the following function.
function [L,U,piv] = GEpiv(A);
11.2. CHOLESKY DECOMPOSITION 215
%
% Pre:
% A nbyn
%
% Post:
% L nbyn unit lower triangular with L(i,j)<=1.
% U nbyn upper triangular
% piv integer nvector that is a permutation of 1:n.
%
% A(piv,:) = LU
[n,n] = size(A);
piv = 1:n;
for k=1:n1
[maxv,r] = max(abs(A(k:n,k)));
q = r+k1;
piv([k q]) = piv([q k]);
A([k q],:) = A([q k],:);
if A(k,k) ~= 0
A(k+1:n,k) = A(k+1:n,k)/A(k,k);
A(k+1:n,k+1:n) = A(k+1:n,k+1:n)  A(k+1:n,k)*A(k,k+1:n);
end
end
L = eye(n,n) + tril(A,1);
U = triu(A);
11.2. Cholesky Decomposition
The important class of positive deﬁnite symmetric matrices admits the Cholesky
decomposition
A = GG
T
where G is lower triangular.
Definition 11.1. A symmetric matrix A ∈ R
n×n
is said to be positive deﬁ
nite if
x
T
Ax > 0, for all x ,= 0, x ∈ R
n
.
In that case we write A > 0.
A symmetric matrix, A, is positive deﬁnite if and only if all its eigenvalues λ,
Ax = λx, x ,= 0,
are positive, λ > 0.
A symmetric matrix A is positive deﬁnite if and only if all its principal minors
are positive. For example,
A =
_
_
a
11
a
12
a
13
a
21
a
22
a
23
a
31
a
32
a
33
_
_
> 0
if and only if
det a
11
= a
11
> 0, det
_
a
11
a
12
a
21
a
22
_
> 0, det A > 0.
216 11. MATRIX COMPUTATIONS
If A > 0, then a
ii
> 0, i = 1, 2, . . . , n.
An n n matrix A is diagonally dominant if
[a
ii
[ > [a
i1
[ +[a
i2
[ + +[a
i,i−1
[ +[a
i,i+1
[ + +[a
in
[, i = 1, 2, . . . , n.
A diagonally dominant symmetric matrix with positive diagonal entries is
positive deﬁnite.
Theorem 11.2. If A is positive deﬁnite, the Cholesky decomposition
A = GG
T
does not require any pivoting, and hence Ax = b can be solved by the Cholesky
decomposition without pivoting, by forward and backward substitutions:
Gy = b, G
T
x = y.
Example 11.4. Let
A =
_
_
4 6 8
6 34 52
8 52 129
_
_
, b =
_
_
0
−160
−452
_
_
.
Find the Cholesky decomposition of A and use it to compute the determinant of
A and to solve the system
Ax = b.
Solution. The Cholesky decomposition is obtained (without pivoting) by
solving the following system for g
ij
:
_
_
g
11
0 0
g
21
g
22
0
g
31
g
32
g
33
_
_
_
_
g
11
g
21
g
31
0 g
22
g
32
0 0 g
33
_
_
=
_
_
4 6 8
6 34 52
8 52 129
_
_
.
g
2
11
= 4 =⇒ g
11
= 2 > 0,
g
11
g
21
= 6 =⇒ g
21
= 3,
g
11
g
31
= 8 =⇒ g
31
= 4,
g
2
21
+g
2
22
= 34 =⇒ g
22
= 5 > 0,
g
21
g
31
+g
22
g
32
= 52 =⇒ g
32
= 8,
g
2
31
+g
2
32
+g
2
33
= 129 =⇒ g
33
= 7 > 0.
Hence
G =
_
_
2 0 0
3 5 0
4 8 7
_
_
,
and
det A = det Gdet G
T
= (det G)
2
= (2 5 7)
2
> 0.
Solving Gy = b by forward substitution,
_
_
2 0 0
3 5 0
4 8 7
_
_
_
_
y
1
y
2
y
3
_
_
=
_
_
0
−160
−452
_
_
,
11.2. CHOLESKY DECOMPOSITION 217
we have
y
1
= 0,
y
2
= −32,
y
3
= (−452 + 256)/7 = −28.
Solving G
T
x = y by backward substitution,
_
_
2 3 4
0 5 8
0 0 7
_
_
_
_
x
1
x
2
x
3
_
_
=
_
_
0
−32
−28
_
_
,
we have
x
3
= −4,
x
2
= (−32 + 32)/5 = 0,
x
1
= (0 −3 0 + 16)/2 = 8.
The numeric Matlab command chol ﬁnd the Cholesky decomposition R
T
R
of the symmetric matrix A as follows.
>> A = [4 6 8;6 34 52;8 52 129];
>> R = chol(A)
R =
2 3 4
0 5 8
0 0 7
The following Matlab function Mﬁles are found in
ftp://ftp.cs.cornell.edu/pub/cv. They are introduced here to illustrate the
diﬀerent levels of matrixvector multiplications.
The simplest “scalar” Cholesky decomposition is obtained by the following
function.
function G = CholScalar(A);
%
% Pre: A is a symmetric and positive definite matrix.
% Post: G is lower triangular and A = G*G’.
[n,n] = size(A);
G = zeros(n,n);
for i=1:n
% Compute G(i,1:i)
for j=1:i
s = A(j,i);
for k=1:j1
s = s  G(j,k)*G(i,k);
end
if j<i
G(i,j) = s/G(j,j);
else
G(i,i) = sqrt(s);
end
218 11. MATRIX COMPUTATIONS
end
end
The dot product of two vectors returns a scalar, c = x
T
y. Noticing that the
kloop in CholScalar oversees an inner product between subrows of G, we obtain
the following level1 dot product implementation.
function G = CholDot(A);
%
% Pre: A is a symmetric and positive definite matrix.
% Post: G is lower triangular and A = G*G’.
[n,n] = size(A);
G = zeros(n,n);
for i=1:n
% Compute G(i,1:i)
for j=1:i
if j==1
s = A(j,i);
else
s = A(j,i)  G(j,1:j1)*G(i,1:j1)’;
end
if j<i
G(i,j) = s/G(j,j);
else
G(i,i) = sqrt(s);
end
end
end
An update of the form
vector ← vector + vector scalar
is called a saxpy operation, which stands for “scalar a times x plus y”, that is
y = ax + y. A columnorientation version that features the saxpy operation is
the following implementation.
function G = CholSax(A);
%
% Pre: A is a symmetric and positive definite matrix.
% Post: G is lower triangular and A = G*G’.
[n,n] = size(A);
G = zeros(n,n);
s = zeros(n,1);
for j=1:n
s(j:n) = A(j:n,j);
for k=1:j1
s(j:n) = s(j:n)  G(j:n,k)*G(j,k);
end
G(j:n,j) = s(j:n)/sqrt(s(j));
end
11.3. MATRIX NORMS 219
An update of the form
vector ← vector + matrix vector
is called a gaxpy operation, which stands for “general A times x plus y” (general
saxpy), that is y = Ax + y. A version that features level2 gaxpy operation is
the following implementation.
function G = CholGax(A);
%
% Pre: A is a symmetric and positive definite matrix.
% Post: G is lower triangular and A = G*G’.
[n,n] = size(A);
G = zeros(n,n);
s = zeros(n,1);
for j=1:n
if j==1
s(j:n) = A(j:n,j);
else
s(j:n) = A(j:n,j)  G(j:n,1:j1)*G(j,1:j1)’;
end
G(j:n,j) = s(j:n)/sqrt(s(j));
end
There is also a recursive implementation which computes the Cholesky factor row
by row, just like ChoScalar
function G = CholRecur(A);
%
% Pre: A is a symmetric and positive definite matrix.
% Post: G is lower triangular and A = G*G’.
[n,n] = size(A);
if n==1
G = sqrt(A);
else
G(1:n1,1:n1) = CholRecur(A(1:n1,1:n1));
G(n,1:n1) = LTriSol(G(1:n1,1:n1),A(1:n1,n))’;
G(n,n) = sqrt(A(n,n)  G(n,1:n1)*G(n,1:n1)’);
end
There is even a high performance level3 implementation of the Cholesky decom
position CholBlock
11.3. Matrix Norms
In matrix computations, norms are used to quantify results, like error esti
mates and to study the convergence of iterative schemes.
220 11. MATRIX COMPUTATIONS
Given a matrix A ∈ R
n×n
or C
n×n
, and a vector norm x for x ∈ R
n
or
C
n
, a subordinate matrix norm, A, is deﬁned by the supremum
A = sup
x=0
Ax
x
= sup
x=1
Ax.
There are three important vector norms in scientiﬁc computation, the l
1
norm of
x,
x
1
=
n
i=1
[x
i
[ = [x
1
[ +[x
2
[ + +[x
n
[,
the Euclidean norm, or l
2
norm, of x,
x
2
=
_
n
i=1
[x
i
[
2
_
1/2
=
_
[x
1
[
2
+[x
2
[
2
+ +[x
n
[
2
¸
1/2
,
and the supremum norm, or l
∞
norm, of x,
x
∞
= sup
i=1,2,...,n
[x
i
[ = sup¦[x
1
[, [x
2
[, . . . , [x
n
[¦.
It can be shown that the corresponding matrix norms are given by the following
formulae.
The l
1
norm, or column “sum” norm, of A is
A
1
= max
j=1,2,...,n
n
i=1
[a
ij
[ (largest column in the l
1
vector norm),
the l
∞
norm, or a row “sum” norm, of A is
A
∞
= max
i=1,2,...,n
n
j=1
[a
ij
[ (largest row in the l
1
vector norm),
and the l
2
norm of A is
A
2
= max
i=1,2,...,n
¦σ
i
¦ (largest singular value of A),
where the σ
2
i
≥ 0 are the eigenvalues of A
T
A. The singular values of a matrix are
considered in Subsection 11.9.
An important nonsubordinate matrix norm is the Frobenius norm, or Eu
clidean matrix norm,
A
F
=
_
_
n
j=1
n
i=1
[a
ij
[
2
_
_
1/2
.
Definition 11.2 (Condition number). The condition number of a matrix
A ∈ R
n×n
is the number
κ(A) = A A
−1
. (11.1)
Note that κ(A) ≥ 1 if I = 1.
The condition number of A appears in an upper bound for the relative error
in the solution to the system
Ax = b.
In fact, let ´ x be the exact solution to the perturbed system
(A + ∆A)´ x = b +δb,
11.4. ITERATIVE METHODS 221
where all experimental and numerical roundoﬀ errors are lumped into ∆A and
δb. Then we have the bound
´ x −x
x
≤ κ(A)
_
∆A
A
+
δb
b
_
. (11.2)
We say that a system Ax = b is well conditioned if κ(A) is small; otherwise it is
ill conditioned.
Example 11.5. Study the ill condition of the following system
_
1.0001 1
1 1.0001
_ _
x
1
x
2
_
=
_
2.0001
2.0001
_
with exact and some approximate solutions
x =
_
1
1
_
, ´ x =
_
2.0000
0.0001
_
,
respectively.
Solution. The approximate solution has a very small residual (to 4 deci
mals), r = b −A´ x,
r =
_
2.0001
2.0001
_
−
_
1.0001 1
1 1.0001
_ _
2.0000
0.0001
_
=
_
2.0001
2.0001
_
−
_
2.0003
2.0001
_
=
_
−0.0002
0.0000
_
.
However, the relative error in ´ x is
´ x −x
1
x
1
=
(1.0000 + 0.9999)
1 + 1
≈ 1,
that is 100%. This is explained by the fact that the system is very ill conditioned.
In fact,
A
−1
=
1
0.0002
_
1.0001 −1.0000
−1.0000 1.0001
_
=
_
5000.5 −5000.0
−5000.0 5000.5
_
,
and
κ
1
(A) = (1.0001 + 1.0000)(5000.5 + 5000.0) = 20 002.
The l
1
norm of the matrix A of the previous example and the l
1
condition
number of A are obtained by the following numeric Matlab commands:
>> A = [1.0001 1;1 1.0001];
>> N1 = norm(A,1)
N1 = 2.0001
>> K1 = cond(A,1)
K1 = 2.0001e+04
11.4. Iterative Methods
One can solve linear systems by iterative methods, especially when dealing
with very large systems. One such method is Gauss–Seidel’s method which uses
the latest values for the variables as soon as they are obtained. This method is
best explained by means of an example.
222 11. MATRIX COMPUTATIONS
Example 11.6. Apply two iterations of Gauss–Seidel’s iterative scheme to
the system
4x
1
+ 2x
2
+ x
3
= 14,
x
1
+ 5x
2
− x
3
= 10,
x
1
+ x
2
+ 8x
3
= 20,
with
x
(0)
1
= 1,
x
(0)
2
= 1,
x
(0)
3
= 1.
Solution. Since the system is diagonally dominant, Gauss–Seidel’s iterative
scheme will converge. This scheme is
x
(n+1)
1
=
1
4
(14 − 2x
(n)
2
− x
(n)
3
),
x
(n+1)
2
=
1
5
(10 − x
(n+1)
1
+ x
(n)
3
),
x
(n+1)
3
=
1
8
(20 − x
(n+1)
1
− x
(n+1)
2
),
x
(0)
1
= 1,
x
(0)
2
= 1,
x
(0)
3
= 1.
For n = 0, we have
x
(1)
1
=
1
4
(14 −2 −1) =
11
4
= 2.75
x
(1)
2
=
1
5
(10 −2.75 + 1) = 1.65
x
(1)
3
=
1
8
(20 −2.75 −1.65) = 1.95.
For n = 1:
x
(2)
1
=
1
4
(14 −2 1.65 −1.95) = 2.1875
x
(2)
2
=
1
5
(10 −2.1875 + 1.95) = 1.9525
x
(2)
3
=
1
8
(20 −2.1875 −1.9525) = 1.9825
Gauss–Seidel’s iteration to solve the system Ax = b is given by the following
iterative scheme:
x
(m+1)
= D
−1
_
b −Lx
(m+1)
−Ux
(m)
_
, with properly chosen x
(0)
,
where the matrix A has been split as the sum of three matrices,
A = D +L +U,
with D diagonal, L strictly lower triangular, and U strictly upper triangular.
This algorithm is programmed in Matlab to do k = 5 iterations for the fol
lowing system:
A = [7 1 1;1 11 1;1 1 9]; b = [3 0 17]’;
D = diag(A); L = tril(A,1); U = triu(A,1);
m = size(b,1); % number of rows of b
x = ones(m,1); % starting value
y = zeros(m,1); % temporary storage
k = 5; % number of iterations
for j = 1:k
uy = U*x(:,j);
for i = 1:m
y(i) = (1/D(i))*(b(i)L(i,:)*yuy(i));
end
x = [x,y];
11.5. OVERDETERMINED SYSTEMS 223
end
x
x =
1.0000 0.4286 0.1861 0.1380 0.1357 0.1356
1.0000 0.1299 0.1492 0.1588 0.1596 0.1596
1.0000 1.8268 1.8848 1.8912 1.8915 1.8916
It is important to rearrange the coeﬃcient matrix of a given linear system
in as much a diagonally dominant matrix as possible since this may assure or
improve the convergence of the Gauss–Seidel iteration.
Example 11.7. Rearrange the system
2x
1
+ 10x
2
− x
3
= −32
−x
1
+ 2x
2
− 15x
3
= 17
10x
1
− x
2
+ 2x
3
= 35
such that Gauss–Seidel’s scheme converges.
Solution. By placing the last equation ﬁrst, the system will be diagonally
dominant,
10x
1
− x
2
+ 2x
3
= 35
2x
1
+ 10x
2
− x
3
= −32
−x
1
+ 2x
2
− 15x
3
= 17
The Jacobi iteration solves the system Ax = b by the following simultaneous
iterative scheme:
x
(m+1)
= D
−1
_
b −Lx
(m)
−Ux
(m)
_
, with properly chosen x
(0)
,
where the matrices D, L and U are as deﬁned above.
Applied to Example 11.6, Jacobi’s method is
x
(n+1)
1
=
1
4
(14 − 2x
(n)
2
− x
(n)
3
),
x
(n+1)
2
=
1
5
(10 − x
(n)
1
+ x
(n)
3
),
x
(n+1)
3
=
1
8
(20 − x
(n)
1
− x
(n)
2
),
x
(0)
1
= 1,
x
(0)
2
= 1,
x
(0)
3
= 1.
We state the following three theorems, without proof, on the convergence of
iterative schemes.
Theorem 11.3. If the matrix A is diagonally dominant, then the Jacobi and
GaussSeidel iterations converge.
Theorem 11.4. Suppose the matrix A ∈ R
n×n
is such that a
ii
> 0 and
a
ij
≤ 0 for i ,= j, i, j = 1, 2, . . . , n. If the Jacobi iterative scheme converges,
then the GaussSeidel iteration converges faster. If the Jacobi iterative scheme
diverges, then the GaussSeidel iteration diverges faster.
Theorem 11.5. If A ∈ R
n×n
is symmetric and positive deﬁnite, then the
GaussSeidel iteration converges for any x
(0)
.
11.5. Overdetermined Systems
A linear system is said to be overdetermined if it has more equations than
unknowns. In curve ﬁtting we are given N points,
(x
1
, y
1
), (x
2
, y
2
), . . . , (x
N
, y
N
),
224 11. MATRIX COMPUTATIONS
and want to determine a function f(x) such that
f(x
i
) ≈ y
i
, i = 1, 2, . . . , N.
For properly chosen functions, ϕ
0
(x), ϕ
1
(x), . . . , ϕ
n
(x), we put
f(x) = a
0
ϕ
0
(x) +a
1
ϕ
1
(x) + +a
n
ϕ
n
(x),
and minimize the quadratic form
Q(a
0
, a
1
, . . . , a
n
) =
N
i=1
(f(x
i
) −y
i
)
2
.
Typically, N ≫n+1. If the functions ϕ
j
(x) are “linearly independent”, the qua
dratic form is nondegenerate and the minimum is attained for values of a
0
, a
1
, . . . , a
n
,
such that
∂Q
∂a
j
= 0, j = 0, 1, 2, . . . , n.
Writing the quadratic form Q explicitly,
Q =
N
i=1
(a
0
ϕ
0
(x
i
) + +a
n
ϕ
n
(x
i
) −y
i
)
2
,
and equating the partial derivatives of Q with respect to a
j
to zero, we have
∂Q
∂a
j
= 2
N
i=1
(a
0
ϕ
0
(x
i
) + +a
n
ϕ
n
(x
i
) −y
i
)ϕ
j
(x
i
) = 0.
This is an (n + 1) (n + 1) symmetric linear algebraic system
_
¸
_
ϕ
0
(x
i
)ϕ
0
(x
i
)
ϕ
1
(x
i
)ϕ
0
(x
i
)
ϕ
n
(x
i
)ϕ
0
(x
i
)
.
.
.
.
.
.
ϕ
0
(x
i
)ϕ
n
(x
i
)
ϕ
1
(x
i
)ϕ
n
(x
i
)
ϕ
n
(x
i
)ϕ
n
(x
i
)
_
¸
_
_
¸
_
a
0
.
.
.
a
n
_
¸
_
=
_
¸
_
ϕ
0
(x
i
)y
i
.
.
.
ϕ
n
(x
i
)y
i
_
¸
_, (11.3)
where all sums are over i from 1 to N. Setting the N (n + 1) matrix A, and
the N vector y as
A =
_
¸
_
ϕ
0
(x
1
) ϕ
1
(x
1
) ϕ
n
(x
1
)
.
.
.
.
.
.
ϕ
0
(x
N
) ϕ
1
(x
N
) ϕ
n
(x
N
)
_
¸
_, y =
_
¸
_
y
1
.
.
.
y
N
_
¸
_,
we see that the previous square system can be written in the form
A
T
A
_
¸
_
a
0
.
.
.
a
n
_
¸
_ = A
T
y.
These equations are called the normal equations.
In the case of linear regression, we have
ϕ
0
(x) = 1, ϕ
1
(x) = x,
11.5. OVERDETERMINED SYSTEMS 225
and the normal equations are
_
N
N
i=1
x
i
N
i=1
x
i
N
i=1
x
2
i
_
_
a
0
a
1
_
=
_
N
i=1
y
i
N
i=1
x
i
y
i
_
.
This is the leastsquares ﬁt by a straight line.
In the case of quadratic regression, we have
ϕ
0
(x) = 1, ϕ
1
(x) = x, ϕ
2
(x) = x
2
,
and the normal equations are
_
¸
_
N
N
i=1
x
i
N
i=1
x
2
i
N
i=1
x
i
N
i=1
x
2
i
N
i=1
x
3
i
N
i=1
x
2
i
N
i=1
x
3
i
N
i=1
x
4
i
_
¸
_
_
_
a
0
a
1
a
2
_
_
=
_
¸
_
N
i=1
y
i
N
i=1
x
i
y
i
N
i=1
x
2
i
y
i
_
¸
_.
This is the leastsquares ﬁt by a parabola.
Example 11.8. Using the method of least squares, ﬁt a parabola
f(x) = a
0
+a
1
x +a
2
x
2
to the following data
i 1 2 3 4 5
x
i
0 1 2 4 6
y
i
3 1 0 1 4
Solution. (a) The analytic solution.— The normal equations are
_
_
1 1 1 1 1
0 1 2 4 6
0 1 4 16 36
_
_
_
¸
¸
¸
¸
_
1 0 0
1 1 1
1 2 4
1 4 16
1 6 36
_
¸
¸
¸
¸
_
_
_
a
0
a
1
a
2
_
_
=
_
_
1 1 1 1 1
0 1 2 4 6
0 1 4 16 36
_
_
_
¸
¸
¸
¸
_
3
1
0
1
4
_
¸
¸
¸
¸
_
,
that is
_
_
5 13 57
13 57 289
57 289 1569
_
_
_
_
a
0
a
1
a
2
_
_
=
_
_
9
29
161
_
_
,
or
Na = b.
Using the Cholesky decomposition N = GG
T
, we have
G =
_
_
2.2361 0 0
5.8138 4.8166 0
25.4921 29.2320 8.0430
_
_
.
226 11. MATRIX COMPUTATIONS
The solution a is obtained by forward and backward substitutions with Gw = b
and G
T
a = w,
a
0
= 2.8252
a
1
= −2.0490
a
2
= 0.3774.
(b) The Matlab numeric solution.—
x = [0 1 2 4 6]’;
A = [x.^0 x x.^2];
y = [3 1 0 1 4]’;
a = (A’*A\(A’*y))’
a = 2.8252 2.0490 0.3774
The result is plotted in Fig. 11.1
0 2 4 6
0
1
2
3
4
5
x
y
Figure 11.1. Quadratic leastsquares approximation in Example 11.8.
11.6. Matrix Eigenvalues and Eigenvectors
An eigenvalue, or characteristic value, of a matrix A ∈ R
n×n
, or C
n×n
, is a
real or complex number such that the vector equation
Ax = λx, x ∈ R
n
or C
n
, (11.4)
has a nontrivial solution, x ,= 0, called an eigenvector. We rewrite (11.4) in the
form
(A −λI)x = 0, (11.5)
where I is the n n identity matrix. This equation has a nonzero solution x if
and only if the characteristic determinant is zero,
det(A −λI) = 0, (11.6)
that is, λ is a zero of the characteristic polynomial of A.
11.6. MATRIX EIGENVALUES AND EIGENVECTORS 227
11.6.1. Gershgorin’s disks. The inclusion theorem of Gershgorin states
that each eigenvalue of A lies in a Gershgorin disk.
Theorem 11.6 (Gershgorin Theorem). Let λ be an eigenvalue of an arbitrary
n n matrix A = (a
ij
). Then for some i, 1 ≤ i ≤ n, we have
[a
ii
−λ[ ≤ [a
i1
[ +[a
i2
[ + +[a
i,i−1
[ +[a
i,i+1
[ + +[a
in
[. (11.7)
Proof. Let x be an eigenvector corresponding to the eigenvalue λ, that is,
(A −λI)x = 0. (11.8)
Let x
i
be a component of x that is largest in absolute value. Then we have
[x
j
/x
i
[ ≤ 1 for j = 1, 2, . . . , n. The vector equation (11.8) is a system of n
equations and the ith equation is
a
i1
x
1
+ +a
i,i−1
x
i−1
+ (a
ii
−λ)x
i
+a
i,i+1
x
i+1
+ +a
in
x
n
= 0.
Division by x
i
and reshuﬄing terms give
a
ii
−λ = −a
i1
x
1
x
i
− −a
i,i−1
x
i−1
x
i
−a
i,i+1
x
i+1
x
i
− −a
in
x
n
x
i
.
Taking absolute values on both sides of this equation, applying the triangle in
equality [a+b[ ≤ [a[+[b[ (where a and b are any complex numbers), and observing
that because of the choice of i,
¸
¸
¸
¸
x
1
x
i
¸
¸
¸
¸
≤ 1, . . . ,
¸
¸
¸
¸
x
n
x
j
¸
¸
¸
¸
≤ 1,
we obtain (11.7).
Example 11.9. Using Gershgorin Theorem, determine and sketch the Gersh
gorin disks D
k
that contain the eigenvalues of the matrix
A =
_
_
−3 0.5i −i
1 −i 1 +i 0
0.1i 1 −i
_
_
.
Solution. The centres, c
i
, and radii, r
i
, of the disks are
c
1
= −3, r
1
= [0.5i[ +[ −i[ = 1.5
c
2
= 1 +i, r
2
= [1 −i[ +[0[ =
√
2
c
3
= −i, r
3
= [0.1i[ + 1 = 1.1
as shown in Fig. 11.2.
The eigenvalues of the matrix A of Example 11.9, found by some software
(see Example 11.10) are
−3.2375 −0.1548i, 1.0347 + 1.1630i, 0.2027 −1.0082i.
228 11. MATRIX COMPUTATIONS
y
x
1
2
1
1
1
2
2 3 4 5 0
c
3
c
1
c
2
1+i D
1
D
3
D
2
Figure 11.2. Gershgorin disks for Example 11.9.
11.6.2. The power method. The power method can be used to determine
the eigenvalue of largest modulus of a matrix A and the corresponding eigenvector.
The method is derived as follows.
For simplicity we assume that A admits n linearly independent eigenvectors
z
1
, z
2
, . . . , z
n
corresponding to the eigenvalues λ
1
, λ
2
, . . . , λ
n
, ordered such that
[λ
1
[ > [λ
2
[ ≥ [λ
3
[ ≥ ≥ [λ
n
[.
Then any vector x can be represented in the form
x = a
1
z
1
+a
2
z
2
+ +a
n
z
n
.
Applying A
k
to x, we have
A
k
x = a
1
λ
k
1
z
1
+a
2
λ
k
2
z
2
+ +a
n
λ
k
n
z
n
= λ
k
1
_
a
1
z
1
+ a
2
_
λ
2
λ
1
_
k
z
2
+ +a
n
_
λ
n
λ
1
_
k
z
n
_
→λ
k
1
a
1
z
1
= y as k →∞.
Thus Ay = λ
1
y. In practice, successive vectors are scaled to avoid overﬂows.
Ax
(0)
= x
(1)
, u
(1)
=
x
(1)
x
(1)

∞
,
Au
(1)
= x
(2)
, u
(2)
=
x
(2)
x
(2)

∞
,
.
.
.
Au
(n)
= x
(n+1)
≈ λ
1
u
(n)
.
Example 11.10. Using the power method, ﬁnd the largest eigenvalue and
the corresponding eigenvector of the matrix
_
3 2
2 5
_
.
11.6. MATRIX EIGENVALUES AND EIGENVECTORS 229
Solution. Letting x
(0)
=
_
1
1
_
, we have
_
3 2
2 5
_ _
1
1
_
=
_
5
7
_
= x
(1)
, u
(1)
=
_
5/7
1
_
,
_
3 2
2 5
_ _
5/7
1
_
=
_
4.14
6.43
_
= x
(2)
, u
(2)
=
_
0.644
1
_
,
_
3 2
2 5
_ _
0.644
1
_
=
_
3.933
6.288
_
= x
(3)
, u
(3)
=
_
0.6254
1
_
.
Hence
λ
1
≈ 6.288, x
1
≈
_
0.6254
1
_
.
Numeric Matlab has the command eig to ﬁnd the eigenvalues and eigenvec
tors of a numeric matrix. For example
>> A = [3 2;2 5];
>> [X,D] = eig(A)
X =
0.8507 0.5257
0.5257 0.8507
D =
1.7639 0
0 6.2361
where the columns of the matrix X are the eigenvectors of A and the diagonal el
ements of the diagonal matrix D are the eigenvalues of A. The numeric command
eig uses the QR algorithm with shifts to be described in Section 11.8.
11.6.3. The inverse power method. A more versatile method to deter
mine any eigenvalue of a matrix A ∈ R
n×n
, or C
n×n
, is the inverse power method.
It is derived as follows, under the simplifying assumption that A has n linearly
independent eigenvectors z
1
, . . . , z
n
, and λ is near λ
1
.
We have
(A −λI)x
(1)
= x
(0)
= a
1
z
1
+ +a
n
z
n
,
x
(1)
= a
1
1
λ
1
−λ
z
1
+a
2
1
λ
2
−λ
z
2
+ +a
n
1
λ
n
−λ
z
n
.
Similarly, by recurrence,
x
(k)
= a
1
1
(λ
1
−λ)
k
_
z
1
+a
2
_
λ
1
− λ
λ
2
− λ
_
k
z
2
+ +a
n
_
λ
1
−λ
λ
n
−λ
_
k
z
n
_
→a
1
1
(λ
1
−λ)
k
z
1
, as k →∞,
since
¸
¸
¸
¸
λ
1
−λ
λ
j
−λ
¸
¸
¸
¸
< 1, j ,= 1.
Thus, the sequence x
(k)
converges in the direction of z
1
. In practice the vectors
x
(k)
are normalized and the system
(A −λI)x
(k+1)
= x
(k)
is solved by the LU decomposition. The algorithm is as follows.
230 11. MATRIX COMPUTATIONS
Choose x
(0)
For k = 1, 2, 3, . . . , do
Solve
(A −λI)y
(k)
= x
(k−1)
by the LU decomposition with partial pivoting.
x
(k)
= y
(k)
/y
(k)

∞
Stop if (A−λI)x
(k)

∞
< cǫA
∞
, where c is a constant of order unity and
ǫ is the machine epsilon.
11.7. The QR Decomposition
A very powerful method to solve illconditioned and overdetermined system
Ax = b, A ∈ R
m×n
, m ≥ n,
is the QR decomposition,
A = QR,
where Q is orthogonal, or unitary, and R is upper triangular. In this case,
Ax −b
2
= QRx −b
2
= Rx −Q
T
b
2
.
If A has full rank, that is, rank of A is equal to n, we can write
R =
_
R
1
0
_
, Q
T
b =
_
c
d
_
,
where R
1
∈ R
n×n
, 0 ∈ R
(m−n)×n
, c ∈ R
n
, d ∈ R
m−n
, and R
1
is upper triangular
and non singular.
Then the leastsquares solution is
x = R
−1
1
c
obtained by solving
R
1
x = c
by backward substitution and the residual is
ρ = min
x∈R
n
Ax −b
2
= d
2
.
In the QR decomposition, the matrix A is transformed into an uppertriangular
matrix by the successive application of n−1 Householder reﬂections, the kth one
zeroing the elements below the diagonal element in the kth column. For exam
ple, to zero the elements x
2
, x
3
, . . . , x
n
in the vector x ∈ R
n
, one applies the
Householder reﬂection
P = I −2
vv
T
v
T
v
,
with
v = x + sign (x
1
)x
2
e
1
, where e
1
=
_
¸
¸
¸
_
1
0
.
.
.
0
_
¸
¸
¸
_
.
In this case,
P
_
¸
¸
¸
_
x
1
x
2
.
.
.
x
n
_
¸
¸
¸
_
=
_
¸
¸
¸
_
−x
2
0
.
.
.
0
_
¸
¸
¸
_
.
11.8. THE QR ALGORITHM 231
The matrix P is symmetric and orthogonal and it is equal to its own inverse, that
is, it satisﬁes the relations
P
T
= P = P
−1
.
To minimize the number of ﬂoating point operations and memory allocation, the
scalar
s = 2/v
T
v
is ﬁrst computed and then
Px = x −s(v
T
x)v
is computed taking the special structure of the matrix P into account. To keep
P in memory, only the number s and the vector v need be stored.
Softwares systematically use the QR decomposition to solve overdetermined
systems. So does the Matlab leftdivision command \ with an overdetermined or
singular system.
The numeric Matlab command qr produces the QR decomposition of a ma
trix:
>> A = [1 2 3; 4 5 6; 7 8 9];
>> [Q,R] = qr(A)
Q =
0.1231 0.9045 0.4082
0.4924 0.3015 0.8165
0.8616 0.3015 0.4082
R =
8.1240 9.6011 11.0782
0 0.9045 1.8091
0 0 0.0000
It is seen that the matrix A is singular since the diagonal element r
33
= 0.
11.8. The QR algorithm
The QR algorithm uses a sequence of QR decompositions
A = Q
1
R
1
A
1
= R
1
Q
1
= Q
2
R
2
A
2
= R
2
Q
2
= Q
3
R
3
.
.
.
to yield the eigenvalues of A, since A
n
converges to an upper or quasiupper tri
angular matrix with the real eigenvalues on the diagonal and complex eigenvalues
in 2 2 diagonal blocks, respectively. Combined with simple shifts, double shifts,
and other shifts, convergence is very fast.
For large matrices, of order n ≥ 100, one seldom wants all the eigenvalues.
To ﬁnd selective eigenvalues, one may use Lanczos’ method.
The Jacobi method to ﬁnd the eigenvalues of a symmetric matrix is being
revived since it is parallelizable for parallel computers.
232 11. MATRIX COMPUTATIONS
11.9. The Singular Value Decomposition
The singular value decomposition is a very powerful tool in matrix compu
tation. It is more expensive in time than the previous methods. Any matrix
A ∈ R
m×n
, say, with m ≥ n, can be factored in the form
A = UΣV
T
,
where U ∈ R
m×m
and V ∈ R
n×n
are orthogonal matrices and Σ ∈ R
m×n
is a
diagonal matrix, whose diagonal elements σ
i
ordered in decreasing order
σ
1
≥ σ
2
≥ σ
n
≥ 0,
are the singular values of A. If A ∈ R
n×n
is a square matrix, it is seen that
A
2
= σ
1
, A
−1

2
= 1/σ
n
.
The same decomposition holds for complex matrices A ∈ C
m×n
. In this case U
and V are unitary and the transpose V
T
is replaced by the Hermitian transpose
V
H
=
¯
V
T
.
The rank of a matrix A is the number of nonzero singular values of A.
The numeric Matlab command svd produces the singular values of a matrix:
A = [1 2 3; 4 5 6; 7 8 9];
[U,S,V] = svd(A)
U =
0.2148 0.8872 0.4082
0.5206 0.2496 0.8165
0.8263 0.3879 0.4082
S =
16.8481 0 0
0 1.0684 0
0 0 0.0000
V =
0.4797 0.7767 0.4082
0.5724 0.0757 0.8165
0.6651 0.6253 0.4082
The diagonal elements of the matrix S are the singular values of A. The l
2
norm
of A is A
2
= σ
1
= 16.8481. Since σ
3
= 0, the matrix A is singular.
If A is symmetric, A
T
= A, Hermitian symmetric A
H
= A or, more generally,
normal , AA
H
= A
H
A, then the moduli of the eigenvalues of A are the singular
values of A.
Theorem 11.7 (Schur Decomposition). Any square matrix A admits the
Schur decomposition
A = UTU
H
,
where the diagonal elements of the upper triangular matrix T are the eigenvalues
of A and the matrix U is unitary.
For normal matrices, the matrix T of the Schur decomposition is diagonal.
11.9. THE SINGULAR VALUE DECOMPOSITION 233
Theorem 11.8. A matrix A is normal if and only if it admits the Schur
decomposition
A = UDU
H
,
where the diagonal matrix D contains the eigenvalues of A and the columns of
the unitary matrix U are the eigenvectors of A.
CHAPTER 12
Numerical Solution of Diﬀerential Equations
12.1. Initial Value Problems
Consider the ﬁrstorder initial value problem:
y
′
= f(x, y), y(x
0
) = y
0
. (12.1)
To ﬁnd an approximation to the solution y(x) of (12.1) on the interval a ≤ x ≤ b,
we choose N + 1 distinct points, x
0
, x
1
, . . . , x
N
, such that a = x
0
< x
1
< x
2
<
. . . < x
N
= b, and construct approximations y
n
to y(x
n
), n = 0, 1, . . . , N.
It is important to know whether or not a small perturbation of (12.1) shall
lead to a large variation in the solution. If this is the case, it is extremely unlikely
that we will be able to ﬁnd a good approximation to (12.1). Truncation errors,
which occur when computing f(x, y) and evaluating the initial condition, can be
identiﬁed with perturbations of (12.1). The following theorem gives suﬃcient
conditions for an initial value problem to be well posed.
Definition 12.1. Problem (12.1) is said to be well posed in the sense of
Hadamard if it has one, and only one, solution and any small perturbation of the
problem leads to a correspondingly small change in the solution.
Theorem 12.1. Let
D = ¦(x, y) : a ≤ x ≤ b and −∞< y < ∞¦.
If f(x, y) is continuous on D and satisﬁes the Lipschitz condition
[f(x, y
1
) −f(x, y
2
)[ ≤ L[y
1
−y
2
[ (12.2)
for all (x, y
1
) and (x, y
2
) in D, where L is the Lipschitz constant, then the initial
value problem (12.1) is wellposed.
In the sequel, we shall assume that the conditions of Theorem 12.1 hold and
(12.1) is well posed. Moreover, we shall suppose that f(x, y) has mixed partial
derivatives of arbitrary order.
In considering numerical methods for the solution of (12.1) we shall use the
following notation:
• h > 0 denotes the integration step size
• x
n
= x
0
+nh is the nth node
• y(x
n
) is the exact solution at x
n
• y
n
is the numerical solution at x
n
• f
n
= f(x
n
, y
n
) is the numerical value of f(x, y) at (x
n
, y
n
)
A function, g(x), is said to be of order p as x →x
0
, written g ∈ O([x −x
0
[
p
)
if
[g(x)[ < M[x −x
0
[
p
, M a constant,
for all x near x
0
.
235
236 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
12.2. Euler’s and Improved Euler’s Method
We begin with the simplest explicit methods.
12.2.1. Euler’s method. To ﬁnd an approximation to the solution y(x) of
(12.1) on the interval a ≤ x ≤ b, we choose N + 1 distinct points, x
0
, x
1
, . . . , x
N
,
such that a = x
0
< x
1
< x
2
< . . . < x
N
= b and set h = (x
N
− x
0
)/N. From
Taylor’s Theorem we get
y(x
n+1
) = y(x
n
) +y
′
(x
n
) (x
n+1
−x
n
) +
y
′′
(ξ
n
)
2
(x
n+1
−x
n
)
2
with ξ
n
between x
n
and x
n+1
, n = 0, 1, . . . , N. Since y
′
(x
n
) = f(x
n
, y(x
n
)) and
x
n+1
−x
n
= h, it follows that
y(x
n+1
) = y(x
n
) +f
_
x
n
, y(x
n
)
_
h +
y
′′
(ξ
n
)
2
h
2
.
We obtain Euler’s method,
y
n+1
= y
n
+hf(x
n
, y
n
), (12.3)
by deleting the term of order O(h
2
),
y
′′
(ξ
n
)
2
h
2
,
called the local truncation error.
The algorithm for Euler’s method is as follows.
(1) Choose h such that N = (x
N
−x
0
)/h is an integer.
(2) Given y
0
, for n = 0, 1, . . . , N, iterate the scheme
y
n+1
= y
n
+hf(x
0
+nh, y
n
). (12.4)
Then, y
n
is as an approximation to y(x
n
).
Example 12.1. Use Euler’s method with h = 0.1 to approximate the solution
to the initial value problem
y
′
(x) = 0.2xy, y(1) = 1, (12.5)
on the interval 1 ≤ x ≤ 1.5.
Solution. We have
x
0
= 1, x
N
= 1.5, y
0
= 1, f(x, y) = 0.2xy.
Hence
x
n
= x
0
+hn = 1 + 0.1n, N =
1.5 −1
0.1
= 5,
and
y
n+1
= y
n
+ 0.1 0.2(1 + 0.1n)y
n
, with y
0
= 1,
for n = 0, 1, . . . , 4. The numerical results are listed in Table 12.1. Note that the
diﬀerential equation in (12.5) is separable. The (unique) solution of (12.5) is
y(x) = e
(0.1x
2
−0.1)
.
This formula has been used to compute the exact values y(x
n
) in the table.
The next example illustrates the limitations of Euler’s method. In the next
subsections, we shall see more accurate methods than Euler’s method.
12.2. EULER’S AND IMPROVED EULER’S METHOD 237
Table 12.1. Numerical results of Example 12.1.
n x
n
y
n
y(x
n
) Absolute Relative
error error
0 1.00 1.0000 1.0000 0.0000 0.00
1 1.10 1.0200 1.0212 0.0012 0.12
2 1.20 1.0424 1.0450 0.0025 0.24
3 1.30 1.0675 1.0714 0.0040 0.37
4 1.40 1.0952 1.1008 0.0055 0.50
5 1.50 1.1259 1.1331 0.0073 0.64
Table 12.2. Numerical results of Example 12.2.
n x
n
y
n
y(x
n
) Absolute Relative
error error
0 1.00 1.0000 1.0000 0.0000 0.00
1 1.10 1.2000 1.2337 0.0337 2.73
2 1.20 1.4640 1.5527 0.0887 5.71
3 1.30 1.8154 1.9937 0.1784 8.95
4 1.40 2.2874 2.6117 0.3244 12.42
5 1.50 2.9278 3.4904 0.5625 16.12
Example 12.2. Use Euler’s method with h = 0.1 to approximate the solution
to the initial value problem
y
′
(x) = 2xy, y(1) = 1, (12.6)
on the interval 1 ≤ x ≤ 1.5.
Solution. As in the previous example, we have
x
0
= 1, x
N
= 1.5, y
0
= 1, x
n
= x
0
+hn = 1 + 0.1n, N =
1.5 −1
0.1
= 5.
With f(x, y) = 2xy, Euler’s method is
y
n+1
= y
n
+ 0.1 2(1 + 0.1n)y
n
, y
0
= 1,
for n = 0, 1, 2, 3, 4. The numerical results are listed in Table 12.2. The relative
errors show that our approximations are not very good.
Definition 12.2. The local truncation error of a method of the form
y
n+1
= y
n
+hφ(x
n
, y
n
), (12.7)
is deﬁned by the expression
τ
n+1
=
1
h
_
y(x
n+1
) −y(x
n
)
¸
−φ(x
n
, y(x
n
)) for n = 0, 1, 2, . . . , N −1.
The method (12.7) is of order k if [τ
j
[ ≤ M h
k
for some constant M and for all
j.
An equivalent deﬁnition is found in Section 12.4
Example 12.3. The local truncation error of Euler’s method is
τ
n+1
=
1
h
_
y(x
n+1
) −y(x
n
)
¸
−f
_
x
n
, y(x
n
)
_
=
h
2
y
′′
(ξ
n
)
238 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
z
0
h
h
*
z = Mh / 2 + δ / h
1/
1/
Figure 12.1. Truncation and roundoﬀ error curve as a function
of 1/h.
for some ξ
n
between x
n
and x
n+1
. If
M = max
x0≤x≤xN
[y
′′
(x)[,
then [τ
n
[ ≤
h
2
M for all n. Hence, Euler’s method is of order one.
Remark 12.1. It is generally incorrect to say that by taking h suﬃciently
small one can obtain any desired level of precision, that is, get y
n
as close to
y(x
n
) as one wants. As the step size h decreases, at ﬁrst the truncation error
of the method decreases, but as the number of steps increases, the number of
arithmetic operations increases, and, hence, the roundoﬀ errors increase as shown
in Fig. 12.1.
For instance, let y
n
be the computed value for y(x
n
) in (12.4). Set
e
n
= y(x
n
) −y
n
, for n = 0, 1, . . . , N.
If
[e
0
[ < δ
0
and the precision in the computations is bounded by δ, then it can be shown that
[e
n
[ ≤
1
L
_
Mh
2
+
δ
h
_
_
e
L(xn−x0)
−1
_
+δ
0
e
L(xn−x0)
,
where L is the Lipschitz constant deﬁned in Theorem 12.1,
M = max
x0≤x≤xN
[y
′′
(x)[,
and h = (x
N
−x
0
)/N.
We remark that the expression
z(h) =
Mh
2
+
δ
h
ﬁrst decreases and afterwards increases as 1/h increases, as shown in Fig. 12.1.
The term Mh/2 is due to the trunctation error and the term δ/h is due to the
roundoﬀ errors.
12.3. LOWORDER EXPLICIT RUNGE–KUTTA METHODS 239
Table 12.3. Numerical results of Example 12.4.
n x
n
y
P
n
y
C
n
y(x
n
) Absolute Relative
error error
0 1.00 1.0000 1.0000 0.0000 0.00
1 1.10 1.200 1.2320 1.2337 0.0017 0.14
2 1.20 1.5479 1.5527 0.0048 0.31
3 1.30 1.9832 1.9937 0.0106 0.53
4 1.40 2.5908 2.6117 0.0209 0.80
5 1.50 3.4509 3.4904 0.0344 1.13
12.2.2. Improved Euler’s method. The improved Euler’s method takes
the average of the slopes at the left and right ends of each step. It is, here,
formulated in terms of a predictor and a corrector:
y
P
n+1
= y
C
n
+hf(x
n
, y
C
n
),
y
C
n+1
= y
C
n
+
1
2
h
_
f(x
n
, y
C
n
) +f(x
n+1
, y
P
n+1
)
¸
.
This method is of order 2.
Example 12.4. Use the improved Euler method with h = 0.1 to approximate
the solution to the initial value problem of Example 12.2.
y
′
(x) = 2xy, y(1) = 1,
1 ≤ x ≤ 1.5.
Solution. We have
x
n
= x
0
+hn = 1 + 0.1n, n = 0, 1, . . . , 5.
The approximation y
n
to y(x
n
) is given by the predictorcorrector scheme
y
C
0
= 1,
y
P
n+1
= y
C
n
+ 0.2 x
n
y
n
,
y
C
n+1
= y
C
n
+ 0.1
_
x
n
y
C
n
+x
n+1
y
P
n+1
_
for n = 0, 1, . . . , 4. The numerical results are listed in Table 12.3. These results
are much better than those listed in Table 12.2 for Euler’s method.
We need to develop methods of order greater than one, which, in general, are
more precise than Euler’s method.
12.3. LowOrder Explicit Runge–Kutta Methods
Runge–Kutta methods are onestep multistage methods.
12.3.1. Secondorder Runge–Kutta method. Twostage explicit Runge–
Kutta methods are given by the formula (left) and, conveniently, in the form of
a Butcher tableau (right):
k
1
= hf(x
n
, y
n
)
k
2
= hf (x
n
+c
2
h, y
n
+a
21
k
1
)
y
n+1
= y
n
+b
1
k
1
+b
2
k
2
c A
k
1
0 0
k
2
c
2
a
21
0
y
n+1
b
T
b
1
b
2
240 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
In a Butcher tableau, the components of the vector c are the increments of x
n
and
the entries of the matrix A are the multipliers of the approximate slopes which,
after multiplication by the step size h, increments y
n
. The components of the
vector b are the weights in the combination of the intermediary values k
j
. The
leftmost column of the tableau is added here for the reader’s convenience.
To attain second order, c, A and b have to be chosen judiciously. We proceed
to derive twostage secondorder RungeKutta methods.
By Taylor’s Theorem, we have
y(x
n+1
) = y(x
n
) +y
′
(x
n
)(x
n+1
−x
n
) +
1
2
y
′′
(x
n
)(x
n+1
−x
n
)
2
+
1
6
y
′′′
(ξ
n
)(x
n+1
−x
n
)
3
(12.8)
for some ξ
n
between x
n
and x
n+1
and n = 0, 1, . . . , N −1. From the diﬀerential
equation
y
′
(x) = f
_
x, y(x)
_
,
and its ﬁrst total derivative with respect to x, we obtain expressions for y
′
(x
n
)
and y
′′
(x
n
),
y
′
(x
n
) = f
_
x
n
, y(x
n
)
_
,
y
′′
(x
n
) =
d
dx
f
_
x, y(x)
_¸
¸
x=xn
= f
x
_
x
n
, y(x
n
)
_
+f
y
_
x
n
, y(x
n
)
_
f
_
x
n
, y(x
n
)
_
.
Therefore, putting h = x
n+1
− x
n
and substituting these expressions in (12.8),
we have
y(x
n+1
) = y(x
n
) +f
_
x
n
, y(x
n
)
_
h
+
1
2
_
f
x
_
x
n
, y(x
n
)
_
+f
y
_
x
n
, y(x
n
)
_
f
_
x
n
, y(x
n
)
_¸
h
2
+
1
6
y
′′′
(ξ
n
)h
3
(12.9)
for n = 0, 1, . . . , N −1.
Our goal is to replace the expression
f
_
x
n
, y(x
n
)
_
h +
1
2
_
f
x
_
x
n
, y(x
n
)
_
+f
y
_
x
n
, y(x
n
)
_
f
_
x
n
, y(x
n
)
_¸
h +O(h
2
)
by an expression of the form
af
_
x
n
, y(x
n
)
_
h +bf
_
x
n
+αh, y(x
n
) +βhf(x
n
, y(x
n
)
_
h +O(h
2
). (12.10)
The constants a, b, α and β are to be determined. This last expression is simpler
to evaluate than the previous one since it does not involve partial derivatives.
Using Taylor’s Theorem for functions of two variables, we get
f
_
x
n
+αh, y(x
n
) +βhf(x
n
, y(x
n
))
_
= f
_
x
n
, y(x
n
)
_
+αhf
x
_
x
n
, y(x
n
)
_
+βhf
_
x
n
, y(x
n
)
_
f
y
_
x
n
, y(x
n
)
_
+O(h
2
).
In order for the expressions (12.8) and (12.9) to be equal to order h
3
, we must
have
a +b = 1, αb = 1/2, βb = 1/2.
12.3. LOWORDER EXPLICIT RUNGE–KUTTA METHODS 241
Thus, we have three equations in four unknowns. This gives rise to a one
parameter family of solutions. Identifying the parameters:
c
1
= α, a
21
= β, b
1
= a, b
2
= b,
we obtain secondorder Runge–Kutta methods.
Here are some twostage secondorder Runge–Kutta methods.
The improved Euler’s method can be written in the form of a twostage
explicit Runge–Kutta method (left) with its Butcher tableau (right):
k
1
= hf(x
n
, y
n
)
k
2
= hf (x
n
+h, y
n
+k
1
)
y
n+1
= y
n
+
1
2
(k
1
+k
2
)
c A
k
1
0 0
k
2
1 1 0
y
n+1
b
T
1/2 1/2
This is Heun’s method of order 2.
Other twostage secondorder methods are the midpoint method:
k
1
= hf(x
n
, y
n
)
k
2
= hf
_
x
n
+
1
2
h, y
n
+
1
2
k
1
_
y
n+1
= y
n
+k
2
c A
k
1
0 0
k
2
1/2 1/2 0
y
n+1
b
T
0 1
and Heun’s method:
k
1
= hf(x
n
, y
n
)
k
2
= hf
_
x
n
+
2
3
h, y
n
+
2
3
k
1
_
y
n+1
= y
n
+
1
4
k
1
+
3
4
k
2
c A
k
1
0 0
k
2
2/3 2/3 0
y
n+1
b
T
1/4 3/4
12.3.2. Thirdorder Runge–Kutta method. We list two common three
stage thirdorder Runge–Katta methods in their Butcher tableau, namely Heun’s
thirdorder formula and Kutta’s thirdorder rule.
c A
k
1
0 0
k
2
1/3 1/3 0
k
3
2/3 0 2/3 0
y
n+1
b
T
1/4 0 3/4
Butcher tableau of Heun’s thirdorder formula.
c A
k
1
0 0
k
2
1/2 1/2 0
k
3
1 −1 2 0
y
n+1
b
T
1/6 2/3 1/6
Butcher tableau of Kutta’s thirdorder rule.
242 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
12.3.3. Fourthorder Runge–Kutta method. The fourthorder (classic)
Runge–Kutta method (also known as the classic Runge–Kutta method) is the very
popular among the explicit onestep methods.
By Taylor’s Theorem, we have
y(x
n+1
) = y(x
n
)+y
′
(x
n
)(x
n+1
−x
n
)+
y
′′
(x
n
)
2!
(x
n+1
−x
n
)
2
+
y
(3)
(x
n
)
3!
(x
n+1
−x
n
)
3
+
y
(4)
(x
n
)
4!
(x
n+1
−x
n
)
4
+
y
(5)
(ξ
n
)
5!
(x
n+1
−x
n
)
5
for some ξ
n
between x
n
and x
n+1
and n = 0, 1, . . . , N − 1. To obtain the
fourthorder Runge–Kutta method, we can proceed as we did for the second
order Runge–Kutta methods. That is, we seek values of a, b, c, d, α
j
and β
j
such
that
y
′
(x
n
)(x
n+1
−x
n
) +
y
′′
(x
n
)
2!
(x
n+1
−x
n
)
2
+
y
(3)
(x
n
)
3!
(x
n+1
−x
n
)
3
+
y
(4)
(x
n
)
4!
(x
n+1
−x
n
)
4
+O(h
5
)
is equal to
ak
1
+bk
2
+ck
3
+dk
4
+O(h
5
),
where
k
1
= hf(x
n
, y
n
),
k
2
= hf(x
n
+α
1
h, y
n
+β
1
k
1
),
k
3
= hf(x
n
+α
2
h, y
n
+β
2
k
2
),
k
4
= hf(x
n
+α
3
h, y
n
+β
3
k
3
).
This follows from the relations
x
n+1
−x
n
= h,
y
′
(x
n
) = f(x
n
, y(x
n
)),
y
′′
(x
n
) =
d
d x
f(x, y(x))[
t=xn
= f
x
(x
n
, y(x
n
)) +f
y
(x
n
, y(x
n
)) f(x
n
, y(x
n
)), . . . ,
and Taylor’s Theorem for functions of two variables. The lengthy computation is
omitted.
The (classic) fourstage Runge–Kutta method of order 4 given by its formula
(left) and, conveniently, in the form of a Butcher tableau (right).
k
1
= hf(x
n
, y
n
)
k
2
= hf
_
x
n
+
1
2
h, y
n
+
1
2
k
1
_
k
3
= hf
_
x
n
+
1
2
h, y
n
+
1
2
k
2
_
k
4
= hf (x
n
+h, y
n
+k
3
)
y
n+1
= y
n
+
1
6
(k
1
+ 2k
2
+ 2k
3
+ k
4
)
c A
k
1
0 0
k
2
1/2 1/2 0
k
3
1/2 0 1/2 0
k
4
1 0 0 1 0
y
n+1
b
T
1/6 2/6 2/6 1/6
12.3. LOWORDER EXPLICIT RUNGE–KUTTA METHODS 243
Table 12.4. Numerical results for Example 12.5.
x
n
y
n
y(x
n
) Absolute Relative
error error
1.00 1.0000 1.0000 0.0000 0.0
1.10 1.2337 1.2337 0.0000 0.0
1.20 1.5527 1.5527 0.0000 0.0
1.30 1.9937 1.9937 0.0000 0.0
1.40 2.6116 2.6117 0.0001 0.0
1.50 3.4902 3.4904 0.0002 0.0
The next example shows that the fourthorder Runge–Kutta method yields
better results for (12.6) than the previous methods.
Example 12.5. Use the fourthorder Runge–Kutta method with h = 0.1 to
approximate the solution to the initial value problem of Example 12.2,
y
′
(x) = 2xy, y(1) = 1,
on the interval 1 ≤ x ≤ 1.5.
Solution. We have f(x, y) = 2xy and
x
n
= 1.0 + 0.1n, for n = 0, 1, . . . , 5.
With the starting value y
0
= 1.0, the approximation y
n
to y(x
n
) is given by the
scheme
y
n+1
= y
n
+
1
6
(k
1
+ 2 k
2
+ 2 k
3
+k
4
)
where
k
1
= 0.1 2(1.0 + 0.1n)y
n
,
k
2
= 0.1 2(1.05 + 0.1n)(y
n
+k
1
/2),
k
3
= 0.1 2(1.05 + 0.1n)(y
n
+k
2
/2),
k
4
= 0.1 2(1.0 + 0.1(n + 1))(y
n
+k
3
),
and n = 0, 1, 2, 3, 4. The numerical results are listed in Table 12.4. These results
are much better than all those previously obtained.
Example 12.6. Consider the initial value problem
y
′
= (y −x −1)
2
+ 2, y(0) = 1.
Compute y
4
by means of Runge–Kutta’s method of order 4 with step size h = 0.1.
Solution. The solution is given in tabular form.
Exact value Global error
n x
n
y
n
y(x
n
) y(x
n
) −y
n
0 0.0 1.000 000 000 1.000 000 000 0.000 000 000
1 0.1 1.200 334 589 1.200 334 672 0.000 000 083
2 0.2 1.402 709 878 1.402 710 036 0.000 000 157
3 0.3 1.609 336 039 1.609 336 250 0.000 000 181
4 0.4 1.822 792 993 1.822 793 219 0.000 000 226
244 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
Example 12.7. Use the Runge–Kutta method of order 4 with h = 0.01 to
obtain a sixdecimal approximation for the initial value problem
y
′
= x + arctany, y(0) = 0,
on 0 ≤ x ≤ 1. Print every tenth value and plot the numerical solution.
Solution. The Matlab numeric solution.— The Mﬁle exp5_7 for Ex
ample 12.7 is
function yprime = exp5_7(x,y); % Example 5.7.
yprime = x+atan(y);
The Runge–Kutta method of order 4 is applied to the given diﬀerential equa
tion:
clear
h = 0.01; x0= 0; xf= 1; y0 = 0;
n = ceil((xfx0)/h); % number of steps
%
count = 2; print_time = 10; % when to write to output
x = x0; y = y0; % initialize x and y
output = [0 x0 y0];
for i=1:n
k1 = h*exp5_7(x,y);
k2 = h*exp5_7(x+h/2,y+k1/2);
k3 = h*exp5_7(x+h/2,y+k2/2);
k4 = h*exp5_7(x+h,y+k3);
z = y + (1/6)*(k1+2*k2+2*k3+k4);
x = x + h;
if count > print_time
output = [output; i x z];
count = count  print_time;
end
y = z;
count = count + 1;
end
output
save output %for printing the graph
The command output prints the values of n, x, and y.
n x y
0 0 0
10.0000 0.1000 0.0052
20.0000 0.2000 0.0214
30.0000 0.3000 0.0499
40.0000 0.4000 0.0918
50.0000 0.5000 0.1486
60.0000 0.6000 0.2218
70.0000 0.7000 0.3128
80.0000 0.8000 0.4228
90.0000 0.9000 0.5531
12.3. LOWORDER EXPLICIT RUNGE–KUTTA METHODS 245
0 0.5 1 1.5
0
0.2
0.4
0.6
0.8
Plot of solution y
n
for Example 5.7
x
n
y
n
Figure 12.2. Graph of numerical solution of Example 12.7.
100.0000 1.0000 0.7040
The following commands print the output.
load output;
subplot(2,2,1); plot(output(:,2),output(:,3));
title(’Plot of solution y_n for Example 5.7’);
xlabel(’x_n’); ylabel(’y_n’);
In the next example, the Runge–Kutta method of order 4 is used to solve the
van der Pol system of two equations. This system is also solved by means of the
Matlab ode23 code and the graphs of the two solutions are compared.
Example 12.8. Use the Runge–Kutta method of order 4 with ﬁxed step size
h = 0.1 to solve the secondorder van der Pol equation
y
′′
+
_
y
2
−1
_
y
′
+y = 0, y(0) = 0, y
′
(0) = 0.25, (12.11)
on 0 ≤ x ≤ 20, print every tenth value, and plot the numerical solution. Also,
use the ode23 code to solve (12.11) and plot the solution.
Solution. We ﬁrst rewrite problem (12.11) as a system of two ﬁrstorder
diﬀerential equations by putting y
1
= y and y
2
= y
′
1
,
y
′
1
= y
2
,
y
′
2
= y
2
_
1 −y
2
1
_
−y
1
,
with initial conditions y
1
(0) = 0 and y
2
(0) = 0.25.
Our Matlab program will call the Matlab function Mﬁle exp1vdp.m:
function yprime = exp1vdp(t,y); % Example 5.8.
yprime = [y(2); y(2).*(1y(1).^2)y(1)]; % van der Pol system
The following program applies the Runge–Kutta method of order 4 to the
diﬀerential equation deﬁned in the Mﬁle exp1vdp.m:
246 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
clear
h = 0.1; t0= 0; tf= 21; % step size, initial and final times
y0 = [0 0.25]’; % initial conditions
n = ceil((xft0)/h); % number of steps
count = 2; print_control = 10; % when to write to output
t = t0; y = y0; % initialize t and y
output = [t0 y0’]; % first row of matrix of printed values
w = [t0, y0’]; % first row of matrix of plotted values
for i=1:n
k1 = h*exp1vdp(x,y); k2 = h*exp1vdp(x+h/2,y+k1/2);
k3 = h*exp1vdp(x+h/2,y+k2/2); k4 = h*exp1vdp(x+h,y+k3);
z = y + (1/6)*(k1+2*k2+2*k3+k4);
t = t + h;
if count > print_control
output = [output; t z’]; % augmenting matrix of printed values
count = count  print_control;
end
y = z;
w = [w; t z’]; % augmenting matrix of plotted values
count = count + 1;
end
[output(1:11,:) output(12:22,:)] % print numerical values of solution
save w % save matrix to plot the solution
The command output prints the values of t, y
1
, and y
2
.
t y(1) y(2) t y(1) y(2)
0 0 0.2500 11.0000 1.9923 0.2797
1.0000 0.3586 0.4297 12.0000 1.6042 0.7195
2.0000 0.6876 0.1163 13.0000 0.5411 1.6023
3.0000 0.4313 0.6844 14.0000 1.6998 1.6113
4.0000 0.7899 1.6222 15.0000 1.8173 0.5621
5.0000 1.6075 0.1456 16.0000 0.9940 1.1654
6.0000 0.9759 1.0662 17.0000 0.9519 2.6628
7.0000 0.8487 2.5830 18.0000 1.9688 0.3238
8.0000 1.9531 0.2733 19.0000 1.3332 0.9004
9.0000 1.3357 0.8931 20.0000 0.1068 2.2766
10.0000 0.0939 2.2615 21.0000 1.9949 0.2625
The following commands graph the solution.
load w % load values to produce the graph
subplot(2,2,1); plot(w(:,1),w(:,2)); % plot RK4 solution
title(’RK4 solution y_n for Example 5.8’); xlabel(’t_n’); ylabel(’y_n’);
We now use the ode23 code. The command
load w % load values to produce the graph
v = [0 21 3 3 ]; % set t and y axes
12.4. CONVERGENCE OF NUMERICAL METHODS 247
0 5 10 15 20
3
2
1
0
1
2
3
RK4 solution y
n
for Example 5.8
t
n
y
n
0 5 10 15 20
3
2
1
0
1
2
3
ode23 solution y
n
for Example 5.8
t
n
y
n
Figure 12.3. Graph of numerical solution of Example 12.8.
subplot(2,2,1);
plot(w(:,1),w(:,2)); % plot RK4 solution
axis(v);
title(’RK4 solution y_n for Example 5.8’); xlabel(’t_n’); ylabel(’y_n’);
subplot(2,2,2);
[t,y] = ode23(’exp1vdp’,[0 21], y0);
plot(x,y(:,1)); % plot ode23 solution
axis(v);
title(’ode23 solution y_n for Example 5.8’); xlabel(’t_n’); ylabel(’y_n’);
The code ode23 produces three vectors, namely t of (144 unequallyspaced) nodes
and corresponding solution values y(1) and y(2), respectively. The left and right
parts of Fig. 10.3 show the plots of the solutions obtained by RK4 and ode23,
respectively. It is seen that the two graphs are identical.
12.4. Convergence of Numerical Methods
In this and the next sections, we introduce the concepts of convergence, con
sistency and stability of numerical ode solvers.
The numerical methods considered in this chapter can be written in the gen
eral form
k
n=0
α
j
y
n+j
= hϕ
f
(y
n+k
, y
n+k−1
, . . . , y
n
, x
n
; h). (12.12)
where the subscript f to ϕ indicates the dependance of ϕ on the function f(x, y)
of (12.1). We impose the condition that
ϕ
f≡0
(y
n+k
, y
n+k−1
, . . . , y
n
, x
n
; h) ≡ 0,
and note that the Lipschitz continuity of ϕ with respect to y
n+j
, n = 0, 1, . . . , k,
follows from the Lipschitz continuity (12.2) of f.
Definition 12.3. Method (12.12) with appropriate starting values is said to
be convergent if, for all initial value problems (12.1), we have
y
n
−y(x
n
) →0 as h ↓ 0,
248 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
where nh = x for all x ∈ [a, b].
The local truncation error of (12.12) is the residual
R
n+k
:=
k
n=0
α
j
y(x
n+j
) −hϕ
f
(y(x
n+k
), y(x
n+k−1
), . . . , y(x
n
), x
n
; h). (12.13)
Definition 12.4. Method (12.12) with appropriate starting values is said to
be consistent if, for all initial value problems (12.1), we have
1
h
R
n+k
→0 as h ↓ 0,
where nh = x for all x ∈ [a, b].
Definition 12.5. Method (12.12) is zerostable if the roots of the charac
teristic polynomial
k
n=0
α
j
r
n+j
lie inside or on the boundary of the unit disk, and those on the unit circle are
simple.
We ﬁnally can state the following fundamental theorem.
Theorem 12.2. A method is convergent as h ↓ 0 if and only if it is zero
stable and consistent.
All numerical methods considered in this chapter are convergent.
12.5. Absolutely Stable Numerical Methods
We now turn attention to the application of a consistent and zerostable
numerical solver with small but nonvanishing step size.
For n = 0, 1, 2, . . ., let y
n
be the numerical solution of (12.1) at x = x
n
, and
y
[n]
(x
n+1
) be the exact solution of the local problem:
y
′
= f(x, y), y(x
n
) = y
n
. (12.14)
A numerical method is said to have local error,
ε
n+1
= y
n+1
−y
[n]
(x
n+1
). (12.15)
If we assume that y(x) ∈ C
p+1
[x
0
, x
N
] and
ε
n+1
≈ C
p+1
h
p+1
n+1
y
(p+1)
(x
n
) +O(h
p+2
n+1
), (12.16)
then we say that the local error is of order p+1 and C
p+1
is the error constant of
the method. For consistent and zerostable methods, the global error is of order
p whenever the local error is of order p +1. In such case, we say that the method
is of order p. We remark that a method of order p ≥ 1 is consistent according to
Deﬁnition 12.4.
Let us now apply the solver (12.12), with its small nonvanishing parameter
h, to the linear test equation
y
′
= λy, ℜλ < 0. (12.17)
The region of absolute stability, R, is that region in the complex
´
hplane,
where
´
h = hλ, for which the numerical solution y
n
of (12.17) goes to zero, as n
goes to inﬁnity.
12.6. STABILITY OF RUNGE–KUTTA METHODS 249
The region of absolute stability of the explicit Euler method is the disk of
radius 1 and center (−1, 0), see curve k = 1 in Fig. 12.7. The region of stability
of the implicit backward Euler method is the outside of the disk of radius 1 and
center (1, 0), hence it contains the left halfplane, see curve k = 1 in Fig. 12.10.
The region of absolute stability, R, of an explicit method is very roughly a
disk or cardioid in the left halfplane (the cardioid overlaps with the right half
plane with a cusp at the origin). The boundary of R cuts the real axis at α,
where −∞ < α < 0, and at the origin. The interval [α, 0] is called the interval
of absolute stability. For methods with real coeﬃcients, R is symmetric with
respect to the real axis. All methods considered in this work have real coeﬃcients;
hence Figs. 12.7, 12.8 and 12.10, below, show only the upper half of R.
The region of stability, R, of implicit methods extends to inﬁnity in the left
halfplane, that is α = −∞. The angle subtended at the origin by R in the left
halfplane is usually smaller for higher order methods, see Fig. 12.10.
If the region R does not include the whole negative real axis, that is, −∞<
α < 0, then the inclusion
hλ ∈ R
restricts the step size:
α ≤ hRe λ =⇒ 0 < h ≤
α
Re λ
.
In practice, we want to use a step size h small enough to ensure accuracy of the
numerical solution as implied by (12.15)–(12.16), but not too small.
12.6. Stability of Runge–Kutta methods
There are stable sstage explicit RungeKutta methods of order p = s for
s = 1, 2, 3, 4. The minimal number of stages of a stable explicit RungeKutta
method of order 5 is 6.
Applying a RungeKutta method to the test equation,
y
′
= λy, ℜλ < 0,
with solution y(x) → 0 as t → ∞, one obtains a onestep diﬀerence equation of
the form
y
n+1
= Q(
´
h)y
n
,
´
h = hλ,
where Q(
´
h) is the stability function of the method. We see that y
n
→ 0 as
n →∞ if and only if
[Q(
´
h)[ < 1, (12.18)
and the method is absolutely stable for those values of
´
h in the complex plane
for which (12.18) hold; those values form the region of absolute stability of
the method. It can be shown that the stability function of explicit sstage Runge
Kutta methods of order p = s, s = 1, 2, 3, 4, is
R(
´
h) =
y
n+1
y
n
= 1 +
´
h +
1
2!
´
h
2
+ +
1
s!
´
h
s
.
The regions of absolute stability, R, of sstage explicit Runge–Kutta methods of
order k = s, for s = 1, 2, 3, 4, are the interior of the closed regions whose upper
halves are shown in Fig. 12.4. The leftmost point α of R is −2, −2, 2.51 and
−2.78 for the methods of order s = 1, 2, 3 and 4, respectively
250 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
3 2 1
1i
3i
k = 3
k = 4
k = 2
k = 1
Figure 12.4. Region of absolute stability of sstage explicit
Runge–Kutta methods of order k = s.
Fixed stepsize Runge–Kutta methods of order 1 to 5 are implemented in the
following Matlab function Mﬁles which are found in
ftp://ftp.cs.cornell.edu/pub/cv.
function [tvals,yvals] = FixedRK(fname,t0,y0,h,k,n)
%
% Produces approximate solution to the initial value problem
%
% y’(t) = f(t,y(t)) y(t0) = y0
%
% using a strategy that is based upon a kth order
% RungeKutta method. Stepsize is fixed.
%
% Pre: fname = string that names the function f.
% t0 = initial time.
% y0 = initial condition vector.
% h = stepsize.
% k = order of method. (1<=k<=5).
% n = number of steps to be taken,
%
% Post: tvals(j) = t0 + (j1)h, j=1:n+1
% yvals(:j) = approximate solution at t = tvals(j), j=1:n+1
%
tc = t0;
yc = y0;
tvals = tc;
yvals = yc;
fc = feval(fname,tc,yc);
for j=1:n
[tc,yc,fc] = RKstep(fname,tc,yc,fc,h,k);
yvals = [yvals yc ];
tvals = [tvals tc];
end
function [tnew,ynew,fnew] = RKstep(fname,tc,yc,fc,h,k)
12.6. STABILITY OF RUNGE–KUTTA METHODS 251
%
% Pre: fname is a string that names a function of the form f(t,y)
% where t is a scalar and y is a column dvector.
%
% yc is an approximate solution to y’(t) = f(t,y(t)) at t=tc.
%
% fc = f(tc,yc).
%
% h is the time step.
%
% k is the order of the RungeKutta method used, 1<=k<=5.
%
% Post: tnew=tc+h, ynew is an approximate solution at t=tnew, and
% fnew = f(tnew,ynew).
if k==1
k1 = h*fc;
ynew = yc + k1;
elseif k==2
k1 = h*fc;
k2 = h*feval(fname,tc+h,yc+k1);
ynew = yc + (k1 + k2)/2;
elseif k==3
k1 = h*fc;
k2 = h*feval(fname,tc+(h/2),yc+(k1/2));
k3 = h*feval(fname,tc+h,yck1+2*k2);
ynew = yc + (k1 + 4*k2 + k3)/6;
elseif k==4
k1 = h*fc;
k2 = h*feval(fname,tc+(h/2),yc+(k1/2));
k3 = h*feval(fname,tc+(h/2),yc+(k2/2));
k4 = h*feval(fname,tc+h,yc+k3);
ynew = yc + (k1 + 2*k2 + 2*k3 + k4)/6;
elseif k==5
k1 = h*fc;
k2 = h*feval(fname,tc+(h/4),yc+(k1/4));
k3 = h*feval(fname,tc+(3*h/8),yc+(3/32)*k1
+(9/32)*k2);
k4 = h*feval(fname,tc+(12/13)*h,yc+(1932/2197)*k1
(7200/2197)*k2+(7296/2197)*k3);
k5 = h*feval(fname,tc+h,yc+(439/216)*k1
 8*k2 + (3680/513)*k3 (845/4104)*k4);
k6 = h*feval(fname,tc+(1/2)*h,yc(8/27)*k1
+ 2*k2 (3544/2565)*k3 + (1859/4104)*k4  (11/40)*k5);
252 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
ynew = yc + (16/135)*k1 + (6656/12825)*k3 +
(28561/56430)*k4  (9/50)*k5 + (2/55)*k6;
end
tnew = tc+h;
fnew = feval(fname,tnew,ynew);
12.7. Embedded Pairs of Runge–Kutta methods
Thus far, we have only considered a constant step size h. In practice, it is
advantageous to let h vary so that h is taken larger when y(x) does not vary
rapidly and smaller when y(x) changes rapidly. We turn to this problem.
Embedded pairs of Runge–Kutta methods of orders p and p +1 have builtin
local error and stepsize controls by monitoring the diﬀerence between the higher
and lower order solutions, y
n+1
− ´ y
n+1
. Some pairs include an interpolant which
is used to interpolate the numerical solution between the nodes of the numerical
solution and also, in some case, to control the stepsize.
12.7.1. Matlab’s fourstage RK pair ode23. The code ode23 consists
in a fourstage pair of embedded explicit Runge–Kutta methods of orders 2 and 3
with error control. It advances from y
n
to y
n+1
with the thirdorder method (so
called local extrapolation) and controls the local error by taking the diﬀerence
between the thirdorder and the secondorder numerical solutions. The four stages
are:
k
1
= hf(x
n
, y
n
),
k
2
= hf(x
n
+ (1/2)h, y
n
+ (1/2)k
1
),
k
3
= hf(x
n
+ (3/4)h, y
n
+ (3/4)k
2
),
k
4
= hf(x
n
+h, y
n
+ (2/9)k
1
+ (1/3)k
2
+ (4/9)k
3
),
The ﬁrst three stages produce the solution at the next time step:
y
n+1
= y
n
+
2
9
k
1
+
1
3
k
2
+
4
9
k
3
,
and all four stages give the local error estimate:
E = −
5
72
k
1
+
1
12
k
2
+
1
9
k
3
−
1
8
k
4
.
However, this is really a threestage method since the ﬁrst step at x
n+1
is the
same as the last step at x
n
, that is k
[n+1]
1
= k
[n]
4
. Such methods are called FSAL
methods.
The natural interpolant used in ode23 is the twopoint Hermite polyno
mial of degree 3 which interpolates y
n
and f(x
n
, y
n
) at x = x
n
, and y
n+1
and
f(x
n+1
, x
n+1
) at t = x
n+1
.
Example 12.9. Use Matlab’s fourstage FSAL ode23 method with h = 0.1
to approximate y(0.1) and y(0.2) to 5 decimal places and estimate the local error
for the initial value problem
y
′
= xy + 1, y(0) = 1.
Solution. The righthand side of the diﬀerential equation is
f(x, y) = xy + 1.
12.7. EMBEDDED PAIRS OF RUNGE–KUTTA METHODS 253
With n = 0:
k
1
= 0.1 1 = 0.1
k
2
= 0.1 (0.05 1.05 + 1) = 0.105 25
k
3
= 0.1 (0.75 1.078 937 5 + 1) = 0.108 092 031 25
k
4
= 0.1 (0.1 1.105 346 458 333 33 + 1) = 0.111 053 464 583 33
y
1
= 1.105 346 458 333 33
The estimate of the local error is
Local error estimate = −4.506 848 958 333 448e −05
With n = 1:
k
1
= 0.111 053 464 583 33
k
2
= 0.117 413 097 859 37
k
3
= 0.120 884 609 930 24
k
4
= 0.124 457 783 972 15
y
2
= 1.222 889 198 607 30
The estimate of the local error is
Local error estimate = −5.322 100 094 209 102e −05
To use the numeric Matlab command ode23 to solve and plot the given initial
value problem on [0, 1], one writes the function Mﬁle exp5_9.m:
function yprime = exp5_9(x,y)
yprime = x.*y+1;
and use the commands
clear
xspan = [0 1]; y0 = 1; % xspan and initial value
[x,y] = ode23(’exp5_9’,xspan,y0);
subplot(2,2,1); plot(x,y); xlabel(’x’); ylabel(’y’);
title(’Solution to equation of Example 5.9’);
print deps2 Figexp5_9 % print figure to file Fig.exp5.9
The Matlab solver ode23 is an implementation of the explicit Runge–Kutta
(2,3) pair of Bogacki and Shampine called BS23. It uses a “free” interpolant of
order 3. Local extrapolation is done, that is, the higherorder solution, namely of
order 3, is used to avance the solution.
254 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
0 0.2 0.4 0.6 0.8 1
1
1.5
2
2.5
3
3.5
x
y
Solution to equation of Example 5.9
Figure 12.5. Graph of numerical solutions of Example 12.9.
12.7.2. Sevenstage Dormand–Prince pair DP(5,4)7M with inter
polant. The sevenstage Dormand–Prince pair DP(5,4)7M [3] with local error
estimate and interpolant is presented in a Butcher tableau. The number 5 in the
designation DP(5,4)7M means that the solution is advanced with the solution
y
n+1
of order ﬁve (a procedure called local extrapolation). The number 4 means
that the solution ´ y
n+1
of order four is used to obtain the local error estimate by
means of the diﬀerence y
n+1
− ´ y
n+1
. In fact, ´ y
n+1
is not computed; rather the
coeﬃcients in the line b
T
−
´
b
T
are used to obtain the local error estimate. The
number 7 means that the method has seven stages. The letter M means that the
constant C
6
in the toporder error term has been minimized, while maintaining
stability. Six stages are necessary for the method of order 5. The seventh stage is
necessary to have an interpolant. The last line of the tableau is used to produce
an interpolant.
c A
k
1
0 0
k
2
1
5
1
5
0
k
3
3
10
3
40
9
40
0
k
4
4
5
44
45
−
56
15
32
9
0
k
5
8
9
19372
6561
−
25360
2187
64448
6561
−
212
729
0
k
6
1
9017
3168
−
355
33
46732
5247
49
176
−
5103
18656
0
k
7
1
35
384
0
500
1113
125
192
−
2187
6784
11
84
´ y
n+1
´
b
T 5179
57600
0
7571
16695
393
640
−
92097
339200
187
2100
1
40
y
n+1
b
T 35
384
0
500
1113
125
192
−
2187
6784
11
84
0
b
T
−
´
b
T 71
57 600
0 −
71
16 695
71
1 920
−
17 253
339 200
22
525
−
1
40
y
n+0.5
5783653
57600000
0
466123
1192500
−
41347
1920000
16122321
339200000
−
7117
20000
183
10000
(12.19)
Sevenstage Dormand–Prince pair DP(5,4)7M of order 5 and 4.
12.7. EMBEDDED PAIRS OF RUNGE–KUTTA METHODS 255
4i
4 2 0
2i
Figure 12.6. Region of absolute stability of the Dormand
Prince pair DP(5,4)7M.
This sevenstage method reduces, in practice, to a sixstage method since k
[n+1]
1
=
k
[n]
7
; in fact the row vector b
T
is the same as the 7th line corresponding to k
7
.
Such methods are called FSAL (First Same As Last) since the ﬁrst line is the
same as the last one.
The interval of absolute stability of the pair DP(5,4)7M is approximately
(−3.3, 0) (see Fig. 12.6).
One notices that the matrix A in the Butcher tableau of an explicit Rung–
Kutta method is strictly lower triangular. Semiexplicit methods have a lower
triangular matrix. Otherwise, the method is implicit. Solving semiexplicit meth
ods for the vector solution y
n+1
of a system is much cheaper than solving implicit
methods.
Runge–Kutta methods constitute a clever and sensible idea [2]. The unique
solution of a wellposed initial value problem is a single curve in R
n+1
, but due
to truncation and roundoﬀ error, any numerical solution is, in fact, going to
wander oﬀ that integral curve, and the numerical solution is inevitably going to
be aﬀected by the behavior of neighboring curves. Thus, it is the behavior of the
family of integral curves, and not just that of the unique solution curve, that is of
importance. Runge–Kutta methods deliberately try to gather information about
this family of curves, as it is most easily seen in the case of explicit Runge–Kutta
methods.
The Matlab solver ode45 is an implementation of the explicit Runge–Kutta
(5,4) pair of Dormand and Prince called variously RK5(4)7FM, DOPRI5, DP(4,5)
and DP54. It uses a “free” interpolant of order 4 communicated privately by
Dormand and Prince. Local extrapolation is done.
Details on Matlab solvers ode23, ode45 and other solvers can be found in
The MATLAB ODE Suite, L. F. Shampine and M. W. Reichelt, SIAM Journal
on Scientiﬁc Computing, 18(1), 1997.
12.7.3. Sixstage Runge–Kutta–Fehlberg pair RKF(4,5). The sixstage
Runge–Kutta–Fehlberg pair RKF(4,5) with local error estimate uses a method of
order 4 to advance the numerical value from y
n
to y
n+1
, and a method of order
5 to obtain the auxiliary value ´ y
n+1
which serves in computing the local error
256 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
by means of the diﬀerence y
n+1
− ´ y
n+1
. We present this method in a Butcher
tableau. The estimated local error is obtained from the last line. The method of
order 4 minimizes the local error.
k
1
0 0
k
2
1
4
1
4
0
k
3
3
8
3
32
9
32
0
k
4
12
13
1932
2197
−
7200
2197
7296
2197
0
k
5
1
439
216
−8
3680
513
−
845
4104
0
k
6
1
2
−
8
27
2 −
3544
2565
1859
4104
−
11
40
0
2197
4104
−
1
5
0
´ y
n+1
´
b
T 16
135
0
6656
12825
28561
56430
−
9
50
2
55
´
b
T
−b
T 1
360
0 −
128
4275
−
2197
75240
1
50
2
55
(12.20)
Sixstage Runge–Kutta–Fehlberg pair RKF(4,5) of order 4 and 5.
The interval of absolute stability of the pair RKF(4,5) is approximately
(−3.78, 0).
The pair RKF45 of order four and ﬁve minimizes the error constant C
5
of the
lower order method which is used to advance the solution from y
n
to y
n+1
, that
is, without using local extrapolation. The algorithm follows.
Algorithm 12.1. Let y
0
be the initial condition. Suppose that the approx
imation y
n
to y(x
n
) has been computed and satisﬁes [y(x
n
) − y
n
[ < ǫ where ǫ is
the desired precision. Let h > 0.
(1) Compute two approximations for y
n+1
: one using the fourthorder method
y
n+1
= y
n
+
_
25
216
k
1
+
1408
2565
k
3
+
2197
4104
k
4
−
1
5
k
5
_
, (12.21)
and the second using the ﬁfthorder method,
´ y
j+1
= y
n
+
_
16
135
k
1
+
6656
12825
k
3
+
28561
56430
k
4
−
9
50
k
5
+
2
55
k
6
_
, (12.22)
where
k
1
= hf(x
n
, y
n
),
k
2
= hf(x
n
+h/4, y
n
+k
1
/4),
k
3
= hf(x
n
+ 3h/8, y
n
+ 3k
1
/32 + 9k
2
/32),
k
4
= hf(x
n
+ 12h/13, y
n
+ 1932k
1
/2197 −7200k
2
/2197 + 7296k
3
/2197),
k
5
= hf(x
n
+h, y
n
+ 439k
1
/216 −8k
2
+ 3680k
3
/513 + 845k
4
/4104),
k
6
= hf(x
n
+h/2, y
n
−8k
1
/27 + 2k
2
+ 3544k
3
/2565 + 1859k
4
/4104 −11k
5
/40).
(2) If [´ y
j+1
− y
n+1
[ < ǫh, accept y
n+1
as the approximation to y(x
n+1
).
Replace h by qh where
q =
_
ǫh/(2[´ y
j+1
−y
n+1
[)
¸
1/4
and go back to step (1) to compute an approximation for y
j+2
.
12.8. MULTISTEP PREDICTORCORRECTOR METHODS 257
(3) If [´ y
j+1
−y
n+1
[ ≥ ǫh, replace h by qh where
q =
_
ǫh/(2[´ y
j+1
−y
n+1
[)
¸
1/4
and go back to step (1) to compute the next approximation for y
n+1
.
One can show that the local truncation error for (12.21) is approximately
[´ y
j+1
−y
n+1
[/h.
At step (2), one requires that this error be smaller than ǫh in order to get [y(x
n
)−
y
n
[ < ǫ for all j (and in particular [y(x
N
) − y
f
[ < ǫ). The formula to compute q
in (2) and (3) (and hence a new value for h) is derived from the relation between
the local truncation errors of (12.21) and (12.22).
RKF(4,5) overestimate the error in the orderfour solution because its local
error constant is minimized. The next method, RKV, corrects this fault.
12.7.4. Eightstage Runge–Kutta–Verner pair RKV(5,6). The eight
stage Runge–Kutta–Verner pair RKV(5,6) of order 5 and 6 is presented in a
Butcher tableau. Note that 8 stages are necessary to get order 6. The method
attempts to keep the global error proportional to a userspeciﬁed tolerance. It is
eﬃcient for nonstiﬀ systems where the derivative evaluations are not expensive
and where the solution is not required at a large number of ﬁnely spaced points
(as might be required for graphical output).
c A
k
1
0 0
k
2
1
6
1
6
0
k
3
4
15
4
75
16
75
0
k
4
2
3
5
6
−
8
3
5
2
0
k
5
5
6
−
165
64
55
6
−
425
64
85
96
0
k
6
1
12
5
−8
4015
612
−
11
36
88
255
0
k
7
1
15
−
8263
15000
124
75
−
643
680
−
81
250
2484
10625
0
k
8
1
3501
1720
−
300
43
297275
52632
−
319
2322
24068
84065
0
3850
26703
y
n+1
b
T 13
160
0
2375
5984
5
16
12
85
3
44
´ y
n+1
´
b
T 3
40
0
875
2244
23
72
264
1955
0
125
11592
43
616
(12.23)
Eightstage Runge–Kutta–Verner pair RKV(5,6) of order 5 and 6.
12.8. Multistep PredictorCorrector Methods
12.8.1. General multistep methods. Consider the initial value problem
y
′
= f(x, y), y(a) = η, (12.24)
where f(x, y) is continuous with respect to x and Lipschitz continuous with re
spect to y on the strip [a, b] (−∞, ∞). Then, by Theorem 12.1, the exact
solution, y(x), exists and is unique on [a, b].
We look for an approximate numerical solution ¦y
n
¦ at the nodes x
n
= a + nh
258 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
where h is the step size and n = (b −a)/h.
For this purpose, we consider the kstep linear method:
k
j=0
α
j
y
n+j
= h
k
j=0
β
j
f
n+j
, (12.25)
where y
n
≈ y(x
n
) and f
n
:= f(x
n
, y
n
). We normalize the method by the condition
α
k
= 1 and insist that the number of steps be exactly k by imposing the condition
(α
0
, β
0
) ,= (0, 0).
We choose k starting values y
0
, y
1
, . . . , y
k−1
, say, by means of a Runge–Kutta
method of the same order.
The method is explicit if β
k
= 0; in this case, we obtain y
n+1
directly. The
method is implicit if β
k
,= 0; in this case, we have to solve for y
n+k
by the
recurrence formula:
y
[s+1]
n+k
= hβ
k
f
_
x
n+k
, y
[s]
n+k
_
+g, y
[0]
n+k
arbitrary, s = 0, 1, . . . , (12.26)
where the function
g = g(x
n
, . . . , x
n+k−1
, y
0
, . . . , y
n+k−1
)
contains only known values. The recurrence formula (12.26) converges as s →∞,
if 0 ≤ M < 1 where M is the Lipschitz constant of the righthand side of (12.26)
with respect to y
n+k
. If L is the Lipschitz constant of f(x, y) with respect to y,
then
M := Lh[β
k
[ < 1 (12.27)
and the inequality
h <
1
L[β
k
[
implies convergence.
Applying (12.25) to the test equation,
y
′
= λy, ℜλ < 0,
with solution y(x) → 0 as t → ∞, one ﬁnds that the numerical solution y
n
→ 0
as n →∞ if the zeros, r
s
(
´
h), of the stability polynomial
π(r,
´
h) :=
k
n=0
(α
j
−
´
hβ
j
)r
j
satisfy [r
s
(
´
h)[ ≤ 1, s = 1, 2, . . . , k, s = 1, 2, . . . , k, and [r
s
(
´
h)[ < 1 if r
s
(
´
h) is a
multiple zero. In that case, we say that the linear multistep method (12.25) is
absolutely stable for given
´
h. The region of absolute stability, R, in the
complex plane is the set of values of
´
h for with the method is absolutely stable.
12.8.2. AdamsBashforthMoulton linear multistep methods. Pop
ular linear kstep methods are (explicit) Adams–Bashforth (AB) and (implicit)
Adams–Moulton (AM) methods,
y
n+1
−y
n
= h
k−1
j=0
β
∗
j
f
n+j−k+1
, y
n+1
−y
n
= h
k
j=0
β
j
f
n+j−k+1
,
12.8. MULTISTEP PREDICTORCORRECTOR METHODS 259
respectively. Tables 12.5 and 12.6 list the AB and AM methods of stepnumber 1
to 6, respectively. In the tables, the coeﬃcients of the methods are to be divided
by d, k is the stepnumber, p is the order, and C
∗
p+1
and C
p+1
are the corresponding
error constants of the methods.
Table 12.5. Coeﬃcients of Adams–Bashforth methods of step
number 1–6.
β
∗
5
β
∗
4
β
∗
3
β
∗
2
β
∗
1
β
∗
0
d k p C
∗
p+1
1 1 1 1 1/2
3 −1 2 2 2 5/12
23 −16 5 12 3 3 3/8
55 −59 37 −9 24 4 4 251/720
1901 −2774 1616 −1274 251 720 5 5 95/288
4277 −7923 9982 −7298 2877 −475 1440 6 6 19 087/60480
Table 12.6. Coeﬃcients of Adams–Moulton methods of step
number 1–6.
β
5
β
4
β
3
β
2
β
1
β
0
d k p C
p+1
1 1 2 1 2 −1/12
5 8 −1 12 2 3 −1/24
9 19 −5 1 24 3 4 −19/720
251 646 −264 106 −19 720 4 5 −3/160
475 1427 −798 482 −173 27 1440 5 6 −863/60 480
The regions of absolute stability of kstep Adams–Bashforth and Adams–
Moulton methods of order k = 1, 2, 3, 4, are the interior of the closed regions whose
upper halves are shown in the left and right parts, respectively, of Fig. 12.7. The
region of absolute stability of the Adams–Bashforth method of order 3 extends in
a small triangular region in the right halfplane. The region of absolute stability
of the Adams–Moulton method of order 1 is the whole left halfplane.
In practice, an AB method is used as a predictor to predict the nextstep
value y
∗
n+1
, which is then inserted in the righthand side of an AM method used
as a corrector to obtain the corrected value y
n+1
. Such combination is called an
ABM predictorcorrector which, when of the same order, comes with the Milne
estimate for the principal local truncation error
ǫ
n+1
≈
C
p+1
C
∗
p+1
−C
p+1
(y
n+1
− y
∗
n+1
).
The procedure called local approximation improves the higherorder solution y
n+1
by the addition of the error estimator, namely,
y
n+1
+
C
p+1
C
∗
p+1
−C
p+1
(y
n+1
−y
∗
n+1
).
260 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
2 1
1i
3i
k = 1
k = 2
k = 3
k = 4
4 2
1i
3i
k = 1
k = 2
k = 3
k = 4
2i
6
k = 1
Figure 12.7. Left: Regions of absolute stability of kstep
Adams–Bashforth methods. Right: Regions of absolute stability
of kstep Adams–Moulton methods.
2 1
1i
2i
k = 1
k = 2
k = 3
k = 4
2 1
1i
2i
k = 1
k = 2
k = 3
k = 4
Figure 12.8. Regions of absolute stability of korder Adams–
Bashforth–Moulton methods,left in PECE mode, and right in
PECLE mode.
The regions of absolute stability of kthorder Adams–Bashforth–Moulton
pairs, for k = 1, 2, 3, 4, in PredictorEvaluationCorrectorEvaluation mode, de
noted by PECE, are the interior of the closed regions whose upper halves are
shown in the left part of Fig. 12.8. The regions of absolute stability of kthorder
Adams–Bashforth–Moulton pairs, for k = 1, 2, 3, 4, in the PECLE mode where L
stands for local extrapolation, are the interior of the closed regions whose upper
halves are shown in the right part of Fig. 12.8.
12.8.3. Adams–Bashforth–Moulton methods of orders 3 and 4. As a
ﬁrst example of multistep methods, we consider the threestep Adams–Bashforth–
Moulton method of order 3, given by the formula pair:
y
P
n+1
= y
C
n
+
h
12
_
23f
C
n
− 16f
C
n−1
+ 5f
C
n−2
_
, f
C
k
= f
_
x
k
, y
C
k
_
, (12.28)
y
C
n+1
= y
C
n
+
h
12
_
5f
P
n+1
+ 8f
C
n
−f
C
n−1
_
, f
P
k
= f
_
x
k
, y
P
k
_
, (12.29)
with local error estimate
Err. ≈ −
1
10
_
y
C
n+1
−y
P
n+1
¸
. (12.30)
12.8. MULTISTEP PREDICTORCORRECTOR METHODS 261
Example 12.10. Solve to six decimal places the initial value problem
y
′
= x + siny, y(0) = 0,
by means of the Adams–Bashforth–Moulton method of order 3 over the interval
[0, 2] with h = 0.2. The starting values have been obtained by a high precision
method. Use formula (12.30) to estimate the local error at each step.
Solution. The solution is given in a table.
Starting Predicted Corrected 10
5
Local Error in y
C
n
n x
n
y
C
n
y
P
n
y
C
n
≈ −(y
C
n
−y
P
n
) 10
4
0 0.0 0.000 000 0
1 0.2 0.021 404 7
2 0.4 0.091 819 5
3 0.6 0.221 260 0.221 977 −7
4 0.8 0.423 703 0.424 064 −4
5 1.0 0.710 725 0.709 623 11
6 1.2 1.088 004 1.083 447 46
7 1.4 1.542 694 1.533 698 90
8 1.6 2.035 443 2.026 712 87
9 1.8 2.518 039 2.518 431 −4
10 2.0 2.965 994 2.975 839 −98
As a second and better known example of multistep methods, we consider
the fourstep Adams–Bashforth–Moulton method of order 4.
The Adams–Bashforth predictor and the Adams–Moulton corrector of order
4 are
y
P
n+1
= y
C
n
+
h
24
_
55f
C
n
− 59f
C
n−1
+ 37f
C
n−2
−9f
C
n−3
_
(12.31)
and
y
C
n+1
= y
C
n
+
h
24
_
9f
P
n+1
+ 19f
C
n
−5f
C
n−1
+f
C
n−2
_
, (12.32)
where
f
C
n
= f(x
n
, y
C
n
) and f
P
n
= f(x
n
, y
P
n
).
Starting values are obtained with a Runge–Kutta method or otherwise.
The local error is controlled by means of the estimate
C
5
h
5
y
(5)
(x
n+1
) ≈ −
19
270
_
y
C
n+1
−y
P
n+1
¸
. (12.33)
A certain number of past values of y
n
and f
n
are kept in memory in order to
extend the step size if the local error is small with respect to the given tolerance.
If the local error is too large with respect to the given tolerance, the step size can
be halved by means of the following formulae:
y
n−1/2
=
1
128
(35y
n
+ 140y
n−1
−70y
n−2
+ 28y
n−3
−y
n−4
) , (12.34)
y
n−3/2
=
1
162
(−y
n
+ 24y
n−1
+ 54y
n−2
−16y
n−3
+ 3y
n−4
) . (12.35)
262 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
In PECE mode, the Adams–Bashforth–Moulton pair of order 4 has interval
of absolute stability equal to (−1.25, 0), that is, the method does not amplify past
errors if the step size h is suﬃciently small so that
−1.25 < h
∂f
∂y
< 0, where
∂f
∂y
< 0.
Example 12.11. Consider the initial value problem
y
′
= x +y, y(0) = 0.
Compute the solution at x = 2 by the Adams–Bashforth–Moulton method of
order 4 with h = 0.2. Use Runge–Kutta method of order 4 to obtain the starting
values. Use ﬁve decimal places and use the exact solution to compute the global
error.
Solution. The global error is computed by means of the exact solution
y(x) = e
x
− x −1.
We present the solution in the form of a table for starting values, predicted values,
corrected values, exact values and global errors in the corrected solution.
Starting Predicted Corrected Exact Error: 10
6
n x
n
y
C
n
y
P
n
y
C
n
y(x
n
) (y(x
n
) −y
C
n
)
0 0.0 0.000 000 0.000 000 0
1 0.2 0.021 400 0.021 403 3
2 0.4 0.091 818 0.091 825 7
3 0.6 0.222 107 0.222 119 12
4 0.8 0.425 361 0.425 529 0.425 541 12
5 1.0 0.718 066 0.718 270 0.718 282 12
6 1.2 1.119 855 1.120 106 1.120 117 11
7 1.4 1.654 885 1.655 191 1.655 200 9
8 1.6 2.352 653 2.353 026 2.353 032 6
9 1.8 3.249 190 3.249 646 3.249 647 1
10 2.0 4.388 505 4.389 062 4.389 056 −6
We see that the method is stable since the error does not grow.
Example 12.12. Solve to six decimal places the initial value problem
y
′
= arctanx + arctany, y(0) = 0,
by means of the Adams–Bashforth–Moulton method of order 3 over the interval
[0, 2] with h = 0.2. Obtain the starting values by Runge–Kutta 4. Use formula
(12.30) to estimate the local error at each step.
Solution. The Matlab numeric solution.— The Mﬁle exp5_12 for Ex
ample 12.12 is
function yprime = exp5_12(x,y); % Example 5.12.
yprime = atan(x)+atan(y);
The initial conditions and the Runge–Kutta method of order 4 is used to
obtain the four starting values
12.8. MULTISTEP PREDICTORCORRECTOR METHODS 263
clear
h = 0.2; x0= 0; xf= 2; y0 = 0;
n = ceil((xfx0)/h); % number of steps
%
count = 2; print_time = 1; % when to write to output
x = x0; y = y0; % initialize x and y
output = [0 x0 y0 0];
%RK4
for i=1:3
k1 = h*exp5_12(x,y);
k2 = h*exp5_12(x+h/2,y+k1/2);
k3 = h*exp5_12(x+h/2,y+k2/2);
k4 = h*exp5_12(x+h,y+k3);
z = y + (1/6)*(k1+2*k2+2*k3+k4);
x = x + h;
if count > print_time
output = [output; i x z 0];
count = count  print_time;
end
y = z;
count = count + 1;
end
% ABM4
for i=4:n
zp = y + (h/24)*(55*exp5_12(output(i,2),output(i,3))...
59*exp5_12(output(i1,2),output(i1,3))+...
37*exp5_12(output(i2,2),output(i2,3))...
9*exp5_12(output(i3,2),output(i3,3)) );
z = y + (h/24)*( 9*exp5_12(x+h,zp)+...
19*exp5_12(output(i,2),output(i,3))...
5*exp5_12(output(i1,2),output(i1,3))+...
exp5_12(output(i2,2),output(i2,3)) );
x = x + h;
if count > print_time
errest = (19/270)*(zzp);
output = [output; i x z errest];
count = count  print_time;
end
y = z;
count = count + 1;
end
output
save output %for printing the graph
The command output prints the values of n, x, and y.
n x y Error estimate
264 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
0 0.5 1 1.5 2
0
0.5
1
1.5
2
2.5
3
Plot of solution y
n
for Example 5.12
x
n
y
n
Figure 12.9. Graph of the numerical solution of Example 12.12.
0 0 0 0
1 0.2 0.02126422549044 0
2 0.4 0.08962325332457 0
3 0.6 0.21103407185113 0
4 0.8 0.39029787517821 0.00001007608281
5 1.0 0.62988482479868 0.00005216829834
6 1.2 0.92767891924367 0.00004381671342
7 1.4 1.27663327419538 0.00003607372725
8 1.6 1.66738483675693 0.00008228934754
9 1.8 2.09110753309673 0.00005318684309
10 2.0 2.54068815072267 0.00001234568256
The following commands print the output.
load output;
subplot(2,2,1); plot(output(:,2),output(:,3));
title(’Plot of solution y_n for Example 5.12’);
xlabel(’x_n’); ylabel(’y_n’);
Fixed stepsize Adams–Bashforth–Moulton methods of order 1 to 5 are imple
mented in the following Matlab function Mﬁles which are found in
ftp://ftp.cs.cornell.edu/pub/cv.
function [tvals,yvals] = FixedPC(fname,t0,y0,h,k,n)
%
% Produces an approximate solution to the initial value problem
%
% y’(t) = f(t,y(t)) y(t0) = y0
%
% using a strategy that is based upon a kth order
% Adams PC method. Stepsize is fixed.
%
12.8. MULTISTEP PREDICTORCORRECTOR METHODS 265
% Pre: fname = string that names the function f.
% t0 = initial time.
% y0 = initial condition vector.
% h = stepsize.
% k = order of method. (1<=k<=5).
% n = number of steps to be taken,
%
% Post: tvals(j) = t0 + (j1)h, j=1:n+1
% yvals(:j) = approximate solution at t = tvals(j), j=1:n+1
%
[tvals,yvals,fvals] = StartAB(fname,t0,y0,h,k);
tc = tvals(k);
yc = yvals(:,k);
fc = fvals(:,k);
for j=k:n
% Take a step and then update.
[tc,yPred,fPred,yc,fc] = PCstep(fname,tc,yc,fvals,h,k);
tvals = [tvals tc];
yvals = [yvals yc];
fvals = [fc fvals(:,1:k1)];
end
The starting values are obtained by the following Mﬁle by means of a Runge–
Kutta method.
function [tvals,yvals,fvals] = StartAB(fname,t0,y0,h,k)
%
% Uses kth order RungeKutta to generate approximate
% solutions to
% y’(t) = f(t,y(t)) y(t0) = y0
%
% at t = t0, t0+h, ... , t0 + (k1)h.
%
% Pre:
% fname is a string that names the function f.
% t0 is the initial time.
% y0 is the initial value.
% h is the step size.
% k is the order of the RK method used.
%
% Post:
% tvals = [ t0, t0+h, ... , t0 + (k1)h].
% For j =1:k, yvals(:,j) = y(tvals(j)) (approximately).
% For j =1:k, fvals(:,j) = f(tvals(j),yvals(j)) .
%
tc = t0;
yc = y0;
fc = feval(fname,tc,yc);
266 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
tvals = tc;
yvals = yc;
fvals = fc;
for j=1:k1
[tc,yc,fc] = RKstep(fname,tc,yc,fc,h,k);
tvals = [tvals tc];
yvals = [yvals yc];
fvals = [fc fvals];
end
The function Mﬁle Rkstep is found in Subsection 12.6 The AdamsBashforth
predictor step is taken by the following Mﬁle.
function [tnew,ynew,fnew] = ABstep(fname,tc,yc,fvals,h,k)
%
% Pre: fname is a string that names a function of the form f(t,y)
% where t is a scalar and y is a column dvector.
%
% yc is an approximate solution to y’(t) = f(t,y(t)) at t=tc.
%
% fvals is an dbyk matrix where fvals(:,i) is an approximation
% to f(t,y) at t = tc +(1i)h, i=1:k
%
% h is the time step.
%
% k is the order of the AB method used, 1<=k<=5.
%
% Post: tnew=tc+h, ynew is an approximate solution at t=tnew, and
% fnew = f(tnew,ynew).
if k==1
ynew = yc + h*fvals;
elseif k==2
ynew = yc + (h/2)*(fvals*[3;1]);
elseif k==3
ynew = yc + (h/12)*(fvals*[23;16;5]);
elseif k==4
ynew = yc + (h/24)*(fvals*[55;59;37;9]);
elseif k==5
ynew = yc + (h/720)*(fvals*[1901;2774;2616;1274;251]);
end
tnew = tc+h;
fnew = feval(fname,tnew,ynew);
The AdamsMoulton corrector step is taken by the following Mﬁle.
function [tnew,ynew,fnew] = AMstep(fname,tc,yc,fvals,h,k)
%
% Pre: fname is a string that names a function of the form f(t,y)
% where t is a scalar and y is a column dvector.
%
12.8. MULTISTEP PREDICTORCORRECTOR METHODS 267
% yc is an approximate solution to y’(t) = f(t,y(t)) at t=tc.
%
% fvals is an dbyk matrix where fvals(:,i) is an approximation
% to f(t,y) at t = tc +(2i)h, i=1:k
%
% h is the time step.
%
% k is the order of the AM method used, 1<=k<=5.
%
% Post: tnew=tc+h, ynew is an approximate solution at t=tnew, and
% fnew = f(tnew,ynew).
if k==1
ynew = yc + h*fvals;
elseif k==2
ynew = yc + (h/2)*(fvals*[1;1]);
elseif k==3
ynew = yc + (h/12)*(fvals*[5;8;1]);
elseif k==4
ynew = yc + (h/24)*(fvals*[9;19;5;1]);
elseif k==5
ynew = yc + (h/720)*(fvals*[251;646;264;106;19]);
end
tnew = tc+h;
fnew = feval(fname,tnew,ynew);
The predictorcorrector step is taken by the following Mﬁle.
function [tnew,yPred,fPred,yCorr,fCorr] = PCstep(fname,tc,yc,fvals,h,k)
%
% Pre: fname is a string that names a function of the form f(t,y)
% where t is a scalar and y is a column dvector.
%
% yc is an approximate solution to y’(t) = f(t,y(t)) at t=tc.
%
% fvals is an dbyk matrix where fvals(:,i) is an approximation
% to f(t,y) at t = tc +(1i)h, i=1:k
%
% h is the time step.
%
% k is the order of the RungeKutta method used, 1<=k<=5.
%
% Post: tnew=tc+h,
% yPred is the predicted solution at t=tnew
% fPred = f(tnew,yPred)
% yCorr is the corrected solution at t=tnew
% fCorr = f(tnew,yCorr).
268 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
[tnew,yPred,fPred] = ABstep(fname,tc,yc,fvals,h,k);
[tnew,yCorr,fCorr] = AMstep(fname,tc,yc,[fPred fvals(:,1:k1)],h,k);
12.8.4. Speciﬁcation of multistep methods. The lefthand side of Adams
methods is of the form
y
n+1
−y
n
.
Adams–Bashforth methods are explicit and Adams–Moulton methods are im
plicit. In the following formulae, Adams methods are obtained by taking a = 0
and b = 0. The integer k is the number of steps of the method. The integer p is
the order of the method and the constant C
p+1
is the constant of the toporder
error term.
Explicit Methods
k = 1 :
α
1
= 1,
α
0
= −1, β
0
= 1,
p = 1; C
p+1
=
1
2
.
k = 2 :
α
2
= 1,
α
1
= −1 −a, β
1
=
1
2
(3 −a),
α
0
= a, β
0
=
1
2
(−1 +a),
p = 2; C
p+1
=
1
12
(5 +a).
Absolute stability limits the order to 2.
k = 3 :
α
3
= 1,
α
2
= −1 −a, β
2
=
1
12
(23 −5a −b),
α
1
= a +b, β
1
=
1
3
(−4 −2a + 2b),
α
0
= −b, β
0
=
1
12
(5 +a + 5b),
p = 3; C
p+1
=
1
24
(9 +a +b).
Absolute stability limits the order to 3.
k = 4 :
α
4
= 1,
α
3
= −1 −a, β
3
=
1
24
(55 −9a −b −c),
α
2
= a +b, β
2
=
1
24
(−59 −19a + 13b −19c),
α
1
= −b −c, β
1
=
1
24
(37 + 5a + 13b −19c),
α
0
= c, β
0
=
1
24
(−9 −a −b −9c),
p = 4; C
p+1
=
1
720
(251 + 19a + 11b + 19c).
Absolute stability limits the order to 4.
Implicit Methods
12.8. MULTISTEP PREDICTORCORRECTOR METHODS 269
k = 1 :
α
1
= 1, β
1
=
1
2
,
α
0
= −1, β
0
=
1
2
,
p = 2; C
p+1
= −
1
12
.
k = 2 :
α
2
= 1, β
2
=
1
12
(5 +a),
α
1
= −1 −a, β
1
=
2
3
(1 −a),
α
0
= a, β
0
=
1
12
(−1 −5a),
If a ,= −1, p = 3; C
p+1
= −
1
24
(1 +a),
If a = −1, p = 4; C
p+1
= −
1
90
.
k = 3 :
α
3
= 1, β
3
=
1
24
(9 +a +b),
α
2
= −1 −a, β
2
=
1
24
(19 −13a −5b),
α
1
= a +b, β
1
=
1
24
(−5 −13a + 19b),
α
0
= −b, β
0
=
1
24
(1 +a + 9b),
p = 4; C
p+1
= −
1
720
(19 + 11a + 19b).
Absolute stability limits the order to 4.
k = 4 :
α
4
= 1, β
4
=
1
720
(251 + 19a + 11b + 19c),
α
3
= −1 −a, β
3
=
1
360
(323 −173a −37b − 53c),
α
2
= a +b, β
2
=
1
30
(−11 −19a + 19b + 11c),
α
1
= −b −c, β
1
=
1
360
(53 + 37a + 173b −323c),
α
0
= c, β
0
=
1
720
(−19 −11a −19b −251c).
If 27 + 11a + 11b + 27c ,= 0, then
p = 5; C
p+1
= −
1
1440
(27 + 11a + 11b + 27c).
If 27 + 11a + 11b + 27c = 0, then
p = 6; C
p+1
= −
1
15 120
(74 + 10a −10b −74c).
Absolute stability limits the order to 6.
The Matlab solver ode113 is a fully variable step size, PECE implementation
in terms of modiﬁed divided diﬀerences of the Adams–Bashforth–Moulton family
of formulae of orders 1 to 12. The natural “free” interpolants are used. Local
extrapolation is done. Details are to be found in The MATLAB ODE Suite, L. F.
Shampine and M. W. Reichelt, SIAM Journal on Scientiﬁc Computing, 18(1),
1997.
270 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
12.9. Stiﬀ Systems of Diﬀerential Equations
In this section, we illustrate the concept of stiﬀ systems of diﬀerential equa
tions by means of an example and mention some numerical methods that can
handle such systems.
12.9.1. The phenomenon of stiﬀness. While the intuitive meaning of
stiﬀ is clear to all specialists, much controversy is going on about its correct
mathematical deﬁnition. The most pragmatic opinion is also historically the ﬁrst
one: stiﬀ equations are equations where certain implicit methods, in particular
backward diﬀerentiation methods, perform much better than explicit ones (see
[1], p. 1).
Consider a system of n diﬀerential equations,
y
′
= f(x, y),
and let λ
1
, λ
2
, . . . , λ
n
be the eigenvalues of the n n Jacobian matrix
J =
∂f
∂y
=
_
∂f
i
∂y
j
_
, i ↓ 1, . . . , n, j →1, . . . , n, (12.36)
where Nagumo’s matrix index notation has been used. We assume that the n
eigenvalues, λ
1
, . . . , λ
n
, of the matrix J have negative real parts, Re λ
j
< 0, and
are ordered as follows:
Re λ
n
≤ ≤ Re λ
2
≤ Re λ
1
< 0. (12.37)
The following deﬁnition occurs in discussing stiﬀness.
Definition 12.6. The stiﬀness ratio of the system y
′
= f (x, y) is the
positive number
r =
Re λ
n
Re λ
1
, (12.38)
where the eigenvalues of the Jacobian matrix (12.36) of the system satisfy the
relations (12.37).
The phenomenon of stiﬀness appears under various aspects (see [2], p. 217–
221):
• A linear constant coeﬃcient system is stiﬀ if all of its eigenvalues have
negative real parts and the stiﬀness ratio is large.
• Stiﬀness occurs when stability requirements, rather than those of accu
racy, constrain the step length.
• Stiﬀness occurs when some components of the solution decay much more
rapidly than others.
• A system is said to be stiﬀ in a given interval I containing t if in I the
neighboring solution curves approach the solution curve at a rate which
is very large in comparison with the rate at which the solution varies in
that interval.
A statement that we take as a deﬁnition of stiﬀness is one which merely relates
what is observed happening in practice.
12.9. STIFF SYSTEMS OF DIFFERENTIAL EQUATIONS 271
Definition 12.7. If a numerical method with a region of absolute stability,
applied to a system of diﬀerential equation with any initial conditions, is forced
to use in a certain interval I of integration a step size which is excessively small
in relation to the smoothness of the exact solution in I, then the system is said
to be stiﬀ in I.
Explicit Runge–Kutta methods and predictorcorrector methods, which, in
fact, are explicit pairs, cannot handle stiﬀ systems in an economical way, if they
can handle them at all. Implicit methods require the solution of nonlinear equa
tions which are almost always solved by some form of Newton’s method. Two
such implicit methods are in the following two sections.
12.9.2. Backward diﬀerentiation formulae. We deﬁne a kstep back
ward diﬀerentiation formula (BDF) in standard form by
k
j=0
α
j
y
n+j−k+1
= hβ
k
f
n+1
,
where α
k
= 1. BDF’s are implicit methods. Table 12.7 lists the BDF’s of step
number 1 to 6, respectively. In the table, k is the stepnumber, p is the order,
C
p+1
is the error constant, and α is half the angle subtended at the origin by the
region of absolute stability R.
Table 12.7. Coeﬃcients of the BDF methods.
k α
6
α
5
α
4
α
3
α
2
α
1
α
0
β
k
p C
p+1
α
1 1 −1 1 1 1 90
◦
2 1 −
4
3
1
3
2
3
2 −
2
9
90
◦
3 1 −
18
11
9
11
=
2
11
6
11
3 −
3
22
86
◦
4 1 −
48
25
36
25
−
16
25
3
25
12
25
4 −
12
125
73
◦
5 1 −
300
137
300
137
−
200
137
75
137
−
12
137
60
137
5 −
110
137
51
◦
6 1 −
360
147
450
147
−
400
147
225
147
−
72
147
10
147
60
147
6 −
20
343
18
◦
The left part of Fig. 12.10 shows the upper half of the region of absolute
stability of the 1step BDF, which is the exterior of the unit disk with center 1,
and the regions of absolute stability of the 2 and 3step BDF’s which are the
exterior of closed regions in the righthand plane. The angle subtended at the
origin is α = 90
◦
in the ﬁrst two cases and α = 88
◦
in the third case. The right
part of Fig. 12.10 shows the regions of absolute stability of the 4, 5, and 6steps
BDF’s which include the negative real axis and make angles subtended at the
origin of 73
◦
, 51
◦
, and 18
◦
, respectively.
A short proof of the instability of the BDF formulae for k ≥ 7 is found in [4].
BDF methods are used to solve stiﬀ systems.
12.9.3. Numerical diﬀerentiation formulae. Numerical diﬀerentiation
formulae (NDF) are a modiﬁcation of BDF’s. Letting
∇y
n
= y
n
−y
n−1
272 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
6i
3 6
k=1
k = 2
k = 3
3 6 6 3
3i
6i
k = 6
k = 5
k = 4
Figure 12.10. Left: Regions of absolute stability for kstep
BDF for k = 1, 2 . . . , 6. These regions include the negative real
axis.
denote the backward diﬀerence of y
n
, we rewrite the kstep BDF of order p = k
in the form
k
m=1
1
m
∇
m
y
n+1
= hf
n+1
.
The algebraic equation for y
n+1
is solved with a simpliﬁed Newton (chord) iter
ation. The iteration is started with the predicted value
y
[0]
n+1
=
k
m=0
1
m
∇
m
y
n
.
Then the kstep NDF of order p = k is
k
m=1
1
m
∇
m
y
n+1
= hf
n+1
+κγ
k
_
y
n+1
−y
[0]
n+1
_
,
where κ is a scalar parameter and γ
k
=
k
j=1
1/j. The NDF of order 1 to 5 are
given in Table 12.8.
Table 12.8. Coeﬃcients of the NDF methods.
k κ α
5
α
4
α
3
α
2
α
1
α
0
β
k
p C
p+1
α
1 −37/200 1 −1 1 1 1 90
◦
2 −1/9 1 −
4
3
1
3
2
3
2 −
2
9
90
◦
3 −0.0823 1 −
18
11
9
11
−
2
11
6
11
3 −
3
22
80
◦
4 −0.0415 1 −
48
25
36
25
−
16
25
3
25
12
25
4 −
12
125
66
◦
5 0 1 −
300
137
300
137
−
200
137
75
137
−
12
137
60
137
5 −
110
137
51
◦
In [5], the choice of the number κ is a compromise made in balancing eﬃciency
in step size and stability angle. Compared with the BDF’s, there is a step ratio
gain of 26% in NDF’s of order 1, 2, and 3, 12% in NDF of order 4, and no change
in NDF of order 5. The percent change in the stability angle is 0%, 0%, −7%,
−10%, and 0%, respectively. No NDF of order 6 is considered because, in this
case, the angle α is too small.
12.9. STIFF SYSTEMS OF DIFFERENTIAL EQUATIONS 273
12.9.4. The eﬀect of a large stiﬀness ratio. In the following example,
we analyze the eﬀect of the large stiﬀness ratio of a simple decoupled system of
two diﬀerential equations with constant coeﬃcients on the step size of the ﬁve
methods of the ODE Suite. Such problems are called pseudostiﬀ since they are
quite tractable by implicit methods.
Consider the initial value problem
_
y
1
(x)
y
2
(x)
_
′
=
_
1 0
0 10
q
_ _
y
1
(x)
y
2
(x)
_
,
_
y
1
(0)
y
2
(0)
_
=
_
1
1
_
, (12.39)
or
y
′
= Ay, y(0) = y
0
.
Since the eigenvalues of A are
λ
1
= 1, λ
2
= −10
q
,
the stiﬀness ratio (12.38) of the system is
r = 10
q
.
The solution is
_
y
1
(x)
y
2
(x)
_
=
_
e
−x
e
−10
q
x
_
.
Even though the second part of the solution containing the fast decaying factor
exp(−10
q
t) for large q numerically disappears quickly, the large stiﬀness ratio
continues to restrict the step size of any explicit schemes, including predictor
corrector schemes.
Example 12.13. Study the eﬀect of the stiﬀness ratio on the number of steps
used by the ﬁve Matlab ode codes in solving problem (12.39) with q = 1 and
q = 5.
Solution. The function Mﬁle exp5_13.m is
function uprime = exp5_13(x,u); % Example 5.13
global q % global variable
A=[1 0;0 10^q]; % matrix A
uprime = A*u;
The following commands solve the nonstiﬀ initial value problem with q = 1,
and hence r = e
10
, with relative and absolute tolerances equal to 10
−12
and
10
−14
, respectively. The option stats on requires that the code keeps track of
the number of function evaluations.
clear;
global q; q=1;
tspan = [0 1]; y0 = [1 1]’;
options = odeset(’RelTol’,1e12,’AbsTol’,1e14,’Stats’,’on’);
[x23,y23] = ode23(’exp5_13’,tspan,y0,options);
[x45,y45] = ode45(’exp5_13’,tspan,y0,options);
[x113,y113] = ode113(’exp5_13’,tspan,y0,options);
[x23s,y23s] = ode23s(’exp5_13’,tspan,y0,options);
[x15s,y15s] = ode15s(’exp5_13’,tspan,y0,options);
274 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
Similarly, when q = 5, and hence r = exp(10
5
), the program solves a pseudo
stiﬀ initial value problem (12.39). Table 12.9 lists the number of steps used with
q = 1 and q = 5 by each of the ﬁve methods of the ODE suite.
Table 12.9. Number of steps used by each method with q = 1
and q = 5 with default relative and absolute tolerance RT = 10
−3
and AT = 10
−6
respectively, and same tolerance set at tolerances
10
−12
and 10
−14
, respectively.
(RT, AT) (10
−3
, 10
−6
) (10
−12
, 10
−14
)
q 1 5 1 5
ode23 29 39 823 24 450 65 944
ode45 13 30 143 601 30 856
ode113 28 62 371 132 64 317
ode23s 37 57 30 500 36 925
ode15s 43 89 773 1 128
It is seen from the table that nonstiﬀ solvers are hopelessly slow and very
expensive in solving pseudostiﬀ equations.
We consider another example of a secondorder equation, with one real pa
rameter q, which we ﬁrst solve analytically. We shall obtain a coupled system in
this case.
Example 12.14. Solve the initial value problem
y
′′
+ (10
q
+ 1)y
′
+ 10
q
= 0 on [0, 1],
with initial conditions
y(0) = 2, y
′
(0) = −10
q
−1,
and real parameter q.
Solution. Substituting
y(x) = e
λx
in the diﬀerential equation, we obtain the characteristic polynomial and eigenval
ues:
λ
2
+ (10
q
+ 1)λ + 10
q
= (λ + 10
q
)(λ + 1) = 0 =⇒ λ
1
= −10
q
, λ
2
= −1.
Two independent solutions are
y
1
= e
−10
q
x
, y
2
(x) = e
−x
.
The general solution is
y(x) = c
1
e
−10
q
x
+c
2
e
−x
.
Using the initial conditions, one ﬁnds that c
1
= 1 and c
2
= 1. Thus the unique
solution is
y(x) = e
−10
q
x
+e
−x
.
In view of solving the problem in Example 12.14 with numeric Matlab, we
reformulate it into a system of two ﬁrstorder equations.
12.9. STIFF SYSTEMS OF DIFFERENTIAL EQUATIONS 275
Example 12.15. Reformulate the initial value problem
y
′′
+ (10
q
+ 1)y
′
+ 10
q
y = 0 on [0, 1],
with initial conditions
y(0) = 2, y
′
(0) = −10
q
−1,
and real parameter q, into a system of two ﬁrstorder equations and ﬁnd its vector
solution.
Solution. Set
u
1
= y, u
2
= y
′
.
Hence,
u
2
= u
′
1
, u
′
2
= y
′′
= −10
q
u
1
−(10
q
+ 1)u
2
.
Thus we have the system u
′
= Au,
_
u
1
(x)
u
2
(x)
_
′
=
_
0 1
−10
q
−(10
q
+ 1)
_ _
u
1
(x)
u
2
(x)
_
, with
_
u
1
(0)
u
2
(0)
_
=
_
2
−10
q
−1
_
.
Substituting the vector function
u(x) = c e
λx
in the diﬀerential system, we obtain the matrix eigenvalue problem
(A −λI)c =
_
−λ 1
−10
q
−(10
q
+ 1) −λ
_
c = 0,
This problem has a nonzero solution c if and only if
det(A − λI) = λ
2
+ (10
q
+ 1)λ + 10
q
= (λ + 10
q
)(λ + 1) = 0.
Hence the eigenvalues are
λ
1
= −10
q
, λ
2
= −1.
The eigenvectors are found by solving the linear systems
(A −λ
i
I)v
i
= 0.
Thus,
_
10
q
1
−10
q
−1
_
v
1
= 0 =⇒ v
1
=
_
1
−10
q
_
and
_
1 1
−10
q
−10
q
_
v
2
= 0 =⇒ v
2
=
_
1
−1
_
.
The general solution is
u(x) = c
1
e
−10
q
x
v
1
+c
2
e
−x
v
2
.
The initial conditions implies that c
1
= 1 and c
2
= 1. Thus the unique solution is
_
u
1
(x)
u
2
(x)
_
=
_
1
−10
q
_
e
−10
q
x
+
_
1
−1
_
e
−x
.
We see that the stiﬀness ratio of the equation in Example 12.15 is
10
q
.
276 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
Example 12.16. Use the ﬁve Matlab ode solvers to solve the nonstiﬀ diﬀer
ential equations
y
′′
+ (10
q
+ 1)y
′
+ 10
q
= 0 on [0, 1],
with initial conditions
y(0) = 2, y
′
(0) = −10
q
−1,
for q = 1 and compare the number of steps used by the solvers.
Solution. The function Mﬁle exp5_16.m is
function uprime = exp5_16(x,u)
global q
A=[0 1;10^q 110^q];
uprime = A*u;
The following commands solve the initial value problem.
>> clear
>> global q; q = 1;
>> xspan = [0 1]; u0 = [2 (10^q + 1)]’;
>> [x23,u23] = ode23(’exp5_16’,xspan,u0);
>> [x45,u45] = ode45(’exp5_16’,xspan,u0);
>> [x113,u113] = ode113(’exp5_16’,xspan,u0);
>> [x23s,u23s] = ode23s(’exp5_16’,xspan,u0);
>> [x15s,u15s] = ode15s(’exp5_16’,xspan,u0);
>> whos
Name Size Bytes Class
q 1x1 8 double array (global)
u0 2x1 16 double array
u113 26x2 416 double array
u15s 32x2 512 double array
u23 20x2 320 double array
u23s 25x2 400 double array
u45 49x2 784 double array
x113 26x1 208 double array
x15s 32x1 256 double array
x23 20x1 160 double array
x23s 25x1 200 double array
x45 49x1 392 double array
xspan 1x2 16 double array
Grand total is 461 elements using 3688 bytes
From the table produced by the command whos one sees that the nonstiﬀ ode
solvers ode23, ode45, ode113, and the stiﬀ ode solvers ode23s, ode15s, use 20,
49, 26, and 25, 32 steps, respectively.
Example 12.17. Use the ﬁve Matlab ode solvers to solve the stiﬀ diﬀerential
equations
y
′′
+ (10
q
+ 1)y
′
+ 10
q
= 0 on [0, 1],
12.9. STIFF SYSTEMS OF DIFFERENTIAL EQUATIONS 277
with initial conditions
y(0) = 2, y
′
(0) = −10
q
−1,
for q = 5 and compare the number of steps used by the solvers.
Solution. Setting the value q = 5 in the program of Example 12.16 we
obtain the following results for the whos command.
clear
global q; q = 5;
xspan = [0 1]; u0 = [2 (10^q + 1)]’;
[x23,u23] = ode23(’exp5_16’,xspan,u0);
[x45,u45] = ode45(’exp5_16’,xspan,u0);
[x113,u113] = ode113(’exp5_16’,xspan,u0);
[x23s,u23s] = ode23s(’exp5_16’,xspan,u0);
[x15s,u15s] = ode15s(’exp5_16’,xspan,u0);
whos
Name Size Bytes Class
q 1x1 8 double array (global)
u0 2x1 16 double array
u113 62258x2 996128 double array
u15s 107x2 1712 double array
u23 39834x2 637344 double array
u23s 75x2 1200 double array
u45 120593x2 1929488 double array
x113 62258x1 498064 double array
x15s 107x1 856 double array
x23 39834x1 318672 double array
x23s 75x1 600 double array
x45 120593x1 964744 double array
xspan 1x2 16 double array
Grand total is 668606 elements using 5348848 bytes
From the table produced by the command whos one sees that the nonstiﬀ ode
solvers ode23, ode45, ode113, and the stiﬀ ode solvers ode23s, ode15s, use 39 834,
120 593, 62 258, and 75, 107 steps, respectively. It follows that nonstiﬀ solvers are
hopelessly slow and expensive to solve stiﬀ equations.
Numeric Matlab has four solvers with “free” interpolants for stiﬀ systems.
The ﬁrst three are low order solvers.
• The code ode23s is an implementation of a new modiﬁed Rosenbrock
(2,3) pair. Local extrapolation is not done. By default, Jacobians are
generated numerically.
• The code ode23t is an implementation of the trapezoidal rule.
• The code ode23tb is an in an implicit twostage Runge–Kutta formula.
• The variablestep variableorder Matlab solver ode15s is a quasiconstant
step size implementation in terms of backward diﬀerences of the Klopfenstein–
Shampine family of Numerical Diﬀerentiation Formulae of orders 1 to
278 12. NUMERICAL SOLUTION OF DIFFERENTIAL EQUATIONS
5. Local extrapolation is not done. By default, Jacobians are generated
numerically.
Details on these methods are to be found in The MATLAB ODE Suite, L. F.
Shampine and M. W. Reichelt, SIAM Journal on Scientiﬁc Computing, 18(1),
1997.
CHAPTER 13
The Matlab ODE Suite
13.1. Introduction
The Matlab ODE suite is a collection of seven userfriendly ﬁnitediﬀerence
codes for solving initial value problems given by ﬁrstorder systems of ordinary
diﬀerential equations and plotting their numerical solutions. The three codes
ode23, ode45, and ode113 are designed to solve nonstiﬀ problems and the four
codes ode23s, ode23t, ode23tb and ode15s are designed to solve both stiﬀ and
nonstiﬀ problems. This chapter is a survey of the seven methods of the ODE
suite. A simple example illustrates the performance of the seven methods on
a system with a small and a large stiﬀness ratio. The available options in the
Matlab codes are listed. The 19 problems solved by the Matlab odedemo are
brieﬂy described. These standard problems, which are found in the literature,
have been designed to test ode solvers.
13.2. The Methods in the Matlab ODE Suite
The Matlab ODE suite contains three explicit methods for nonstiﬀ prob
lems:
• The explicit Runge–Kutta pair ode23 of orders 3 and 2,
• The explicit Runge–Kutta pair ode45 of orders 5 and 4, of Dormand–
Prince,
• The Adams–Bashforth–Moulton predictorcorrector pairs ode113 of or
ders 1 to 13,
and fuor implicit methods for stiﬀ systems:
• The implicit Runge–Kutta pair ode23s of orders 2 and 3,
• ode23t is an implementation of the trapezoidal rule,
• ode23tb is a twostage implicit RungeKutta method,
• The implicit numerical diﬀerentiation formulae ode15s of orders 1 to 5.
All these methods have a builtin local error estimate to control the step size.
Moreover ode113 and ode15s are variableorder packages which use higher order
methods and smaller step size when the solution varies rapidly.
The command odeset lets one create or alter the ode option structure.
The ODE suite is presented in a paper by Shampine and Reichelt [5] and
the Matlab help command supplies precise information on all aspects of their
use. The codes themselves are found in the toolbox/matlab/funfun folder of
Matlab 6. For Matlab 4.2 or later, it can be downloaded for free by ftp on
ftp.mathworks.com in the
pub/mathworks/toolbox/matlab/funfun directory.
279
280 13. THE MATLAB ODE SUITE
In Matlab 6, the command
odedemo
lets one solve 4 nonstiﬀ problems and 15 stiﬀ problems by any of the ﬁve methods
in the suite. The four methods for stiﬀ problems are also designed to solve nonstiﬀ
problems. The three nonstiﬀ methods are poor at solving very stiﬀ problems.
For graphing purposes, all seven methods use interpolants to obtain, by de
fault, four or, if speciﬁed by the user, more intermediate values of y between y
n
and y
n+1
to produce smooth solution curves.
13.2.1. The ode23 method. The code ode23 consists in a fourstage pair
of embedded explicit Runge–Kutta methods of orders 2 and 3 with error con
trol. It advances from y
n
to y
n+1
with the thirdorder method (so called local
extrapolation) and controls the local error by taking the diﬀerence between the
thirdorder and the secondorder numerical solutions. The four stages are:
k1 = hf(x
n
, y
n
),
k2 = hf(x
n
+ (1/2)h, y
n
+ (1/2)k
1
),
k3 = hf(x
n
+ (3/4)h, y
n
+ (3/4)k
2
),
k4 = hf(x
n
+h, y
n
+ (2/9)k
1
+ (1/3)k
2
+ (4/9)k
3
),
The ﬁrst three stages produce the solution at the next time step:
y
n+1
= y
n
+ (2/9)k
1
+ (1/3)k
2
+ (4/9)k
3
,
and all four stages give the local error estimate:
E = −
5
72
k
1
+
1
12
k
2
+
1
9
k
2
−
1
8
k
4
.
However, this is really a threestage method since the ﬁrst step at x
n+1
is the
same as the last step at x
n
, that is k
[n+1]
1
= k
[n]
4
(that is, a FSAL method).
The natural interpolant used in ode23 is the twopoint Hermite polyno
mial of degree 3 which interpolates y
n
and f(x
n
, y
n
) at x = x
n
, and y
n+1
and
f(x
n+1
, x
n+1
) at t = x
n+1
.
13.2.2. The ode45 method. The code ode45 is the DormandPrince pair
DP(5,4)7M with a highquality “free” interpolant of order 4 that was communi
cated to Shampine and Reichelt [5] by Dormand and Prince. Since ode45 can use
long step size, the default is to use the interpolant to compute solution values at
four points equally spaced within the span of each natural step.
13.2.3. The ode113 method. The code ode113 is a variable step variable
order method which uses Adams–Bashforth–Moulton predictorcorrectors of order
1 to 13. This is accomplished by monitoring the integration very closely. In the
Matlab graphics context, the monitoring is expensive. Although more than
graphical accuracy is necessary for adequate resolution of moderately unstable
problems, the high accuracy formulae available in ode113 are not nearly as helpful
in the present context as they are in general scientiﬁc computation.
13.2. THE METHODS IN THE MATLAB ODE SUITE 281
13.2.4. The ode23s method. The code ode23s is a triple of modiﬁed im
plicit Rosenbrock methods of orders 3 and 2 with error control for stiﬀ systems.
It advances from y
n
to y
n+1
with the secondorder method (that is, without local
extrapolation) and controls the local error by taking the diﬀerence between the
third and secondorder numerical solutions. Here is the algorithm:
f
0
= hf(x
n
, y
n
),
k
1
= W
−1
(f
0
+hdT),
f
1
= f(x
n
+ 0.5h, y
n
+ 0.5hk
1
),
k
2
= W
−1
(f
1
−k
1
) +k
1
,
y
n+1
= y
n
+hk
2
,
f
2
= f(x
n+1
, y
n+1
),
k3 = W
−1
[f
2
−c
32
(k
2
−f
1
) −2(k
1
−f
0
) +hdt],
error ≈
h
6
(k
1
−2k
2
+k
3
),
where
W = I −hdJ, d = 1/(2 +
√
2 ), c
32
= 6 +
√
2,
and
J ≈
∂f
∂y
(x
n
, y
n
), T ≈
∂f
∂t
(x
n
, y
n
).
This method is FSAL (First Step As Last). The interpolant used in ode23s is
the quadratic polynomial in s:
y
n+s
= y
n
+h
_
s(1 −s)
1 −2d
k
1
+
s(s −2d)
1 −2d
k
2
_
.
13.2.5. The ode23t method. The code ode23t is an implementation of
the trapezoidal rule. It is a low order method which integrates moderately stiﬀ
systems of diﬀerential equations of the forms y
′
= f(t, y) and m(t)y
′
= f(t, y),
where the mass matrix m(t) is nonsingular and usually sparse. A free interpolant
is used.
13.2.6. The ode23tb method. The code ode23tb is an implementation
of TRBDF2, an implicit RungeKutta formula with a ﬁrst stage that is a trape
zoidal rule (TR) step and a second stage that is a backward diﬀerentiation formula
(BDF) of order two. By construction, the same iteration matrix is used in eval
uating both stages. It is a low order method which integrates moderately stiﬀ
systems of diﬀerential equations of the forms y
′
= f(t, y) and m(t)y
′
= f(t, y),
where the mass matrix m(t) is nonsingular and usually sparse. A free interpolant
is used.
13.2.7. The ode15s method. The code ode15s for stiﬀ systems is a quasi
constant step size implementation of the NDF’s of order 1 to 5 in terms of back
ward diﬀerences. Backward diﬀerences are very suitable for implementing the
NDF’s in Matlab because the basic algorithms can be coded compactly and ef
ﬁciently and the way of changing step size is wellsuited to the language. Options
allow integration with the BDF’s and integration with a maximum order less than
the default 5. Equations of the form M(t)y
′
= f(t, y) can be solved by the code
ode15s for stiﬀ problems with the Mass option set to on.
282 13. THE MATLAB ODE SUITE
13.3. The odeset Options
Options for the seven ode solvers can be listed by the odeset command (the
default values are in curly brackets):
odeset
AbsTol: [ positive scalar or vector {1e6} ]
BDF: [ on  {off} ]
Events: [ on  {off} ]
InitialStep: [ positive scalar ]
Jacobian: [ on  {off} ]
JConstant: [ on  {off} ]
JPattern: [ on  {off} ]
Mass: [ on  {off} ]
MassConstant: [ on  off ]
MaxOrder: [ 1  2  3  4  {5} ]
MaxStep: [ positive scalar ]
NormControl: [ on  {off} ]
OutputFcn: [ string ]
OutputSel: [ vector of integers ]
Refine: [ positive integer ]
RelTol: [ positive scalar {1e3} ]
Stats: [ on  {off} ]
The following commands solve a problem with diﬀerent methods and diﬀerent
options.
[t, y]=ode23(’exp2’, [0 1], 0, odeset(’RelTol’, 1e9, ’Refine’, 6));
[t, y]=ode45(’exp2’, [0 1], 0, odeset(’’AbsTol’, 1e12));
[t, y]=ode113(’exp2’, [0 1], 0, odeset(’RelTol’, 1e9, ’AbsTol’, 1e12));
[t, y]=ode23s(’exp2’, [0 1], 0, odeset(’RelTol’, 1e9, ’AbsTol’, 1e12));
[t, y]=ode15s(’exp2’, [0 1], 0, odeset(’JConstant’, ’on’));
The ode options are used in the demo problems in Sections 8 and 9 below. Others
ways of inserting the options in the ode Mﬁle are explained in [7].
The command ODESET creates or alters ODE OPTIONS structure as follows
• OPTIONS = ODESET(’NAME1’, VALUE1, ’NAME2’, VALUE2, . . . )
creates an integrator options structure OPTIONS in which the named
properties have the speciﬁed values. Any unspeciﬁed properties have
default values. It is suﬃcient to type only the leading characters that
uniquely identify the property. Case is ignored for property names.
• OPTIONS = ODESET(OLDOPTS, ’NAME1’, VALUE1, . . . ) alters an
existing options structure OLDOPTS.
• OPTIONS = ODESET(OLDOPTS, NEWOPTS) combines an existing
options structure OLDOPTS with a new options structure NEWOPTS.
Any new properties overwrite corresponding old properties.
• ODESET with no input arguments displays all property names and their
possible values.
Here is the list of the odeset properties.
• RelTol : Relative error tolerance [ positive scalar 1e3 ] This scalar
applies to all components of the solution vector and defaults to 1e3
13.3. THE ODESET OPTIONS 283
(0.1% accuracy) in all solvers. The estimated error in each integration
step satisﬁes e(i) <= max(RelTol*abs(y(i)), AbsTol(i)).
• AbsTol : Absolute error tolerance [ positive scalar or vector 1e6 ] A
scalar tolerance applies to all components of the solution vector. Ele
ments of a vector of tolerances apply to corresponding components of
the solution vector. AbsTol defaults to 1e6 in all solvers.
• Refine : Output reﬁnement factor [ positive integer ] This property
increases the number of output points by the speciﬁed factor producing
smoother output. Reﬁne defaults to 1 in all solvers except ODE45,
where it is 4. Reﬁne does not apply if length(TSPAN) > 2.
• OutputFcn : Name of installable output function [ string ] This output
function is called by the solver after each time step. When a solver
is called with no output arguments, OutputFcn defaults to ’odeplot’.
Otherwise, OutputFcn defaults to ’ ’.
• OutputSel : Output selection indices [ vector of integers ] This vector
of indices speciﬁes which components of the solution vector are passed
to the OutputFcn. OutputSel defaults to all components.
• Stats : Display computational cost statistics [ on [ ¦oﬀ¦ ]
• Jacobian : Jacobian available from ODE ﬁle [ on [ ¦oﬀ¦ ] Set this
property ’on’ if the ODE ﬁle is coded so that F(t, y, ’jacobian’) returns
dF/dy.
• JConstant : Constant Jacobian matrix dF/dy [ on [ ¦oﬀ¦ ] Set this
property ’on’ if the Jacobian matrix dF/dy is constant.
• JPattern : Jacobian sparsity pattern available from ODE ﬁle [ on [ ¦oﬀ¦
] Set this property ’on’ if the ODE ﬁle is coded so F([ ], [ ], ’jpattern’)
returns a sparse matrix with 1’s showing nonzeros of dF/dy.
• Vectorized : Vectorized ODE ﬁle [ on [ ¦oﬀ¦ ] Set this property ’on’
if the ODE ﬁle is coded so that F(t, [y1 y2 . . . ] ) returns [F(t, y1) F(t,
y2) . . . ].
• Events : Locate events [ on — oﬀ ] Set this property ’on’ if the ODE ﬁle
is coded so that F(t, y, ’events’) returns the values of the event functions.
See ODEFILE.
• Mass : Mass matrix available from ODE ﬁle [ on [ ¦oﬀ¦ ] Set this prop
erty ’on’ if the ODE ﬁle is coded so that F(t, [ ], ’mass’) returns time
dependent mass matrix M(t).
• MassConstan : Constant mass matrix available from ODE ﬁle [ on [
¦oﬀ¦ ] Set this property ’on’ if the ODE ﬁle is coded so that F(t, [ ],
’mass’) returns a constant mass matrix M.
• MaxStep : Upper bound on step size [ positive scalar ] MaxStep defaults
to onetenth of the tspan interval in all solvers.
• InitialStep : Suggested initial step size [ positive scalar ] The solver
will try this ﬁrst. By default the solvers determine an initial step size
automatically.
• MaxOrder : Maximum order of ODE15S [ 1 [ 2 [ 3 [ 4 [ ¦5¦ ]
• BDF : Use Backward Diﬀerentiation Formulae in ODE15S [ on [ ¦oﬀ¦
] This property speciﬁes whether the Backward Diﬀerentiation Formu
lae (Gear’s methods) are to be used in ODE15S instead of the default
Numerical Diﬀerentiation Formulae.
284 13. THE MATLAB ODE SUITE
• NormControl : Control error relative to norm of solution [ on [ ¦oﬀ¦ ]
Set this property ’on’ to request that the solvers control the error in each
integration step with norm(e) <= max(RelTol*norm(y), AbsTol). By
default the solvers use a more stringent componentwise error control.
13.4. Nonstiﬀ Problems of the Matlab odedemo
13.4.1. The orbitode problem. ORBITODE is a restricted threebody
problem. This is a standard test problem for nonstiﬀ solvers stated in Shampine
and Gordon, p. 246 ﬀ in [8]. The ﬁrst two solution components are coordinates
of the body of inﬁnitesimal mass, so plotting one against the other gives the orbit
of the body around the other two bodies. The initial conditions have been chosen
so as to make the orbit periodic. Moderately stringent tolerances are necessary
to reproduce the qualitative behavior of the orbit. Suitable values are 1e5 for
RelTol and 1e4 for AbsTol.
Because this function returns event function information, it can be used to
test event location capabilities.
13.4.2. The orbt2ode problem. ORBT2ODE is the nonstiﬀ problem D5
of Hull et al. [9] This is a twobody problem with an elliptical orbit of eccentricity
0.9. The ﬁrst two solution components are coordinates of one body relative to the
other body, so plotting one against the other gives the orbit. A plot of the ﬁrst
solution component as a function of time shows why this problem needs a small
step size near the points of closest approach. Moderately stringent tolerances are
necessary to reproduce the qualitative behavior of the orbit. Suitable values are
1e5 for RelTol and 1e5 for AbsTol. See [10], p. 121.
13.4.3. The rigidode problem. RIGIDODE solves Euler’s equations of a
rigid body without external forces.
This is a standard test problem for nonstiﬀ solvers proposed by Krogh. The
analytical solutions are Jacobi elliptic functions accessible in Matlab. The in
terval of integration [t
0
, t
f
] is about 1.5 periods; it is that for which solutions are
plotted on p. 243 of Shampine and Gordon [8].
RIGIDODE([ ], [ ], ’init’) returns the default TSPAN, Y0, and OPTIONS
values for this problem. These values are retrieved by an ODE Suite solver if the
solver is invoked with empty TSPAN or Y0 arguments. This example does not
set any OPTIONS, so the third output argument is set to empty [ ] instead of an
OPTIONS structure created with ODESET.
13.4.4. The vdpode problem. VDPODE is a parameterizable van der Pol
equation (stiﬀ for large mu). VDPODE(T, Y) or VDPODE(T, Y, [ ], MU) re
turns the derivatives vector for the van der Pol equation. By default, MU is 1,
and the problem is not stiﬀ. Optionally, pass in the MU parameter as an addi
tional parameter to an ODE Suite solver. The problem becomes stiﬀer as MU is
increased.
For the stiﬀ problem, see Sections 12.9 and 13.5.
13.5. Stiﬀ Problems of the Matlab odedemo
13.5. STIFF PROBLEMS OF THE MATLAB ODEDEMO 285
13.5.1. The a2ode and a3ode problems. A2ODE and A3ODE are stiﬀ
linear problems with real eigenvalues (problem A2 of [11]). These nine and four
equation systems from circuit theory have a constant tridiagonal Jacobian and
also a constant partial derivative with respect to t because they are autonomous.
Remark 13.1. When the ODE solver JConstant property is set to ’oﬀ’, these
examples test the eﬀectiveness of schemes for recognizing when Jacobians need
to be refreshed. Because the Jacobians are constant, the ODE solver property
JConstant can be set to ’on’ to prevent the solvers from unnecessarily recomputing
the Jacobian, making the integration more reliable and faster.
13.5.2. The b5ode problem. B5ODE is a stiﬀ problem, linear with com
plex eigenvalues (problem B5 of [11]). See Ex. 5, p. 298 of Shampine [10] for a
discussion of the stability of the BDFs applied to this problem and the role of
the maximum order permitted (the MaxOrder property accepted by ODE15S).
ODE15S solves this problem eﬃciently if the maximum order of the NDFs is
restricted to 2. Remark 13.1 applies to this example.
This sixequation system has a constant Jacobian and also a constant partial
derivative with respect to t because it is autonomous.
13.5.3. The buiode problem. BUIODE is a stiﬀ problem with analytical
solution due to Bui. The parameter values here correspond to the stiﬀest case of
[12]; the solution is
y(1) = e
−4t
, y(2) = e
−t
.
13.5.4. The brussode problem. BRUSSODE is a stiﬀ problem modelling
a chemical reaction (the Brusselator) [1]. The command BRUSSODE(T, Y) or
BRUSSODE(T, Y, [ ], N) returns the derivatives vector for the Brusselator prob
lem. The parameter N >= 2 is used to specify the number of grid points; the
resulting system consists of 2N equations. By default, N is 2. The problem be
comes increasingly stiﬀ and increasingly sparse as N is increased. The Jacobian
for this problem is a sparse matrix (banded with bandwidth 5).
BRUSSODE([ ], [ ], ’jpattern’) or BRUSSODE([ ], [ ], ’jpattern’, N)
returns a sparse matrix of 1’s and 0’s showing the locations of nonzeros in the Ja
cobian ∂F/∂Y . By default, the stiﬀ solvers of the ODE Suite generate Jacobians
numerically as full matrices. However, if the ODE solver property JPattern is
set to ’on’ with ODESET, a solver calls the ODE ﬁle with the ﬂag ’jpattern’. The
ODE ﬁle returns a sparsity pattern that the solver uses to generate the Jacobian
numerically as a sparse matrix. Providing a sparsity pattern can signiﬁcantly
reduce the number of function evaluations required to generate the Jacobian and
can accelerate integration. For the BRUSSODE problem, only 4 evaluations of
the function are needed to compute the 2N 2N Jacobian matrix.
13.5.5. The chm6ode problem. CHM6ODE is the stiﬀ problem CHM6
from Enright and Hull [13]. This fourequation system models catalytic ﬂuidized
bed dynamics. A small absolute error tolerance is necessary because y(:,2) ranges
from 7e10 down to 1e12. A suitable AbsTol is 1e13 for all solution compo
nents. With this choice, the solution curves computed with ode15s are plausible.
Because the step sizes span 15 orders of magnitude, a loglog plot is appropriate.
13.5.6. The chm7ode problem. CHM7ODE is the stiﬀ problem CHM7
from [13]. This twoequation system models thermal decomposition in ozone.
286 13. THE MATLAB ODE SUITE
13.5.7. The chm9ode problem. CHM9ODE is the stiﬀ problem CHM9
from [13]. It is a scaled version of the famous Belousov oscillating chemical
system. There is a discussion of this problem and plots of the solution starting
on p. 49 of Aiken [14]. Aiken provides a plot for the interval [0, 5], an interval
of rapid change in the solution. The default time interval speciﬁed here includes
two full periods and part of the next to show three periods of rapid change.
13.5.8. The d1ode problem. D1ODE is a stiﬀ problem, nonlinear with
real eigenvalues (problem D1 of [11]). This is a twoequation model from nuclear
reactor theory. In [11] the problem is converted to autonomous form, but here
it is solved in its original nonautonomous form. On page 151 in [15], van der
Houwen provides the reference solution values
t = 400, y(1) = 22.24222011, y(2) = 27.11071335
13.5.9. The fem1ode problem. FEM1ODE is a stiﬀ problem with a time
dependent mass matrix,
M(t)y
′
= f(t, y).
Remark 13.2. FEM1ODE(T, Y) or FEM1ODE(T, Y, [ ], N) returns the
derivatives vector for a ﬁnite element discretization of a partial diﬀerential equa
tion. The parameter N controls the discretization, and the resulting system
consists of N equations. By default, N is 9.
FEM1ODE(T, [ ], ’mass’) or FEM1ODE(T, [ ], ’mass’, N) returns the time
dependent mass matrix M evaluated at time T. By default, ODE15S solves sys
tems of the form
y
′
= f(t, y).
However, if the ODE solver property Mass is set to ’on’ with ODESET, the solver
calls the ODE ﬁle with the ﬂag ’mass’. The ODE ﬁle returns a mass matrix that
the solver uses to solve
M(t)y
′
= f(t, y).
If the mass matrix is a constant M, then the problem can be also be solved with
ODE23S.
FEM1ODE also responds to the ﬂag ’init’ (see RIGIDODE).
For example, to solve a 20 20 system, use
[t, y] = ode15s(’fem1ode’, [ ], [ ], [ ], 20);
13.5.10. The fem2ode problem. FEM2ODE is a stiﬀ problem with a time
independent mass matrix,
My
′
= f(t, y).
Remark 13.2 applies to this example, which can also be solved by ode23s
with the command
[t, y] = ode23s(’fem2ode’, [ ], [ ], [ ], 20).
13.5.11. The gearode problem. GEARODE is a simple stiﬀ problem due
to Gear as quoted by van der Houwen [15] who, on page 148, provides the reference
solutionvalues
t = 50, y(1) = 0.5976546988, y(2) = 1.40234334075
13.5. STIFF PROBLEMS OF THE MATLAB ODEDEMO 287
13.5.12. The hb1ode problem. HB1ODE is the stiﬀ problem 1 of Hind
marsh and Byrne [16]. This is the original Robertson chemical reaction problem
on a very long interval. Because the components tend to a constant limit, it
tests reuse of Jacobians. The equations themselves can be unstable for negative
solution components, which is admitted by the error control. Many codes can,
therefore, go unstable on a long time interval because a solution component goes
to zero and a negative approximation is entirely possible. The default interval is
the longest for which the Hindmarsh and Byrne code EPISODE is stable. The
system satisﬁes a conservation law which can be monitored:
y(1) +y(2) +y(3) = 1.
13.5.13. The hb2ode problem. HB2ODE is the stiﬀ problem 2 of [16].
This is a nonautonomous diurnal kinetics problem that strains the step size
selection scheme. It is an example for which quite small values of the absolute
error tolerance are appropriate. It is also reasonable to impose a maximum step
size so as to recognize the scale of the problem. Suitable values are an AbsTol of
1e20 and a MaxStep of 3600 (one hour). The time interval is 1/3; this interval
is used by Kahaner, Moler, and Nash, p. 312 in [17], who display the solution
on p. 313. That graph is a semilog plot using solution values only as small as
1e3. A small threshold of 1e20 speciﬁed by the absolute error control tests
whether the solver will keep the size of the solution this small during the night
time. Hindmarsh and Byrne observe that their variable order code resorts to high
orders during the day (as high as 5), so it is not surprising that relatively low
order codes like ODE23S might be comparatively ineﬃcient.
13.5.14. The hb3ode problem. HB3ODE is the stiﬀ problem 3 of Hind
marsh and Byrne [16]. This is the Hindmarsh and Byrne mockup of the diurnal
variation problem. It is not nearly as realistic as HB2ODE and is quite special in
that the Jacobian is constant, but it is interesting because the solution exhibits
quasidiscontinuities. It is posed here in its original nonautonomous form. As
with HB2ODE, it is reasonable to impose a maximum step size so as to recog
nize the scale of the problem. A suitable value is a MaxStep of 3600 (one hour).
Because y(:,1) ranges from about 1e27 to about 1.1e26, a suitable AbsTol is
1e29.
Because of the constant Jacobian, the ODE solver property JConstant pre
vents the solvers from recomputing the Jacobian, making the integration more
reliable and faster.
13.5.15. The vdpode problem. VDPODE is a parameterizable van der Pol
equation (stiﬀ for large mu) [18]. VDPODE(T, Y) or VDPODE(T, Y, [ ], MU)
returns the derivatives vector for the van der Pol equation. By default, MU is
1, and the problem is not stiﬀ. Optionally, pass in the MU parameter as an
additional parameter to an ODE Suite solver. The problem becomes more stiﬀ
as MU is increased.
When MU is 1000 the equation is in relaxation oscillation, and the problem
becomes very stiﬀ. The limit cycle has portions where the solution components
change slowly and the problem is quite stiﬀ, alternating with regions of very sharp
change where it is not stiﬀ (quasidiscontinuities). The initial conditions are close
to an area of slow change so as to test schemes for the selection of the initial step
size.
288 13. THE MATLAB ODE SUITE
VDPODE(T, Y, ’jacobian’) or VDPODE(T, Y, ’jacobian’, MU) returns the
Jacobian matrix ∂F/∂Y evaluated analytically at (T, Y). By default, the stiﬀ
solvers of the ODE Suite approximate Jacobian matrices numerically. However,
if the ODE Solver property Jacobian is set to ’on’ with ODESET, a solver calls
the ODE ﬁle with the ﬂag ’jacobian’ to obtain ∂F/∂Y . Providing the solvers
with an analytic Jacobian is not necessary, but it can improve the reliability and
eﬃciency of integration.
VDPODE([ ], [ ], ’init’) returns the default TSPAN, Y0, and OPTIONS val
ues for this problem (see RIGIDODE). The ODE solver property Vectorized is set
to ’on’ with ODESET because VDPODE is coded so that calling VDPODE(T,
[Y1 Y2 . . . ] ) returns [VDPODE(T, Y1) VDPODE(T, Y2) . . . ] for scalar time T
and vectors Y1, Y2,. . . The stiﬀ solvers of the ODE Suite take advantage of this
feature when approximating the columns of the Jacobian numerically.
13.6. Concluding Remarks
Ongoing research in explicit and implicit Runge–Kutta pairs, and hybrid
methods, which incorporate function evaluations at oﬀstep points in order to
lower the stepnumber of a linear multistep method without reducing its order,
may, in the future, improve the Matlab ODE suite.
Bibliography
[1] E. Hairer and G. Wanner, Solving ordinary diﬀerential equations II, stiﬀ and diﬀerential
algebraic problems, SpringerVerlag, Berlin, 1991, pp. 5–8.
[2] J. D. Lambert, Numerical methods for ordinary diﬀerential equations. The initial value
problem, Wiley, Chichester, 1991.
[3] J. R. Dormand and P. J. Prince, A family of embedded Runge–Kutta formulae, J. Com
putational and Applied Mathematics, 6(2) (1980), 19–26.
[4] E. Hairer and G. Wanner, On the instability of the BDF formulae, SIAM J. Numer. Anal.,
20(6) (1983), 1206–1209.
[5] L. F. Shampine and M. W. Reichelt, The Matlab ODE suite, SIAM J. Sci. Comput.,
18(1), (1997) 1–22.
[6] R. Ashino and R. Vaillancourt, Hayawakari Matlab (Introduction to Matlab), Kyoritsu
Shuppan, Tokyo, 1997, xvi–211 pp., 6th printing, 1999 (in Japanese). (Korean translation,
1998.)
[7] Using MATLAB, Version, 5.1, The MathWorks, Chapter 8, Natick, MA, 1997.
[8] L. F. Shampine and M. K. Gordon, Computer solution of ordinary diﬀerential equations,
W.H. Freeman & Co., San Francisco, 1975.
[9] T. E. Hull, W. H. Enright, B. M. Fellen, and A. E. Sedgwick, Comparing numerical
methods for ordinary diﬀerential equations, SIAM J. Numer. Anal., 9(4) (1972) 603–637.
[10] L. F. Shampine, Numerical solution of ordinary diﬀerential equations, Chapman & Hall,
New York, 1994.
[11] W. H. Enright, T. E. Hull, and B. Lindberg, Comparing numerical methods for stiﬀ
systems of ODEs, BIT 15(1) (1975), 10–48.
[12] L. F. Shampine, Measuring stiﬀness, Appl. Numer. Math., 1(2) (1985), 107–119.
[13] W. H. Enright and T. E. Hull, Comparing numerical methods for the solution of stiﬀ
systems of ODEs arising in chemistry, in Numerical Methods for Diﬀerential Systems, L.
Lapidus and W. E. Schiesser eds., Academic Press, Orlando, FL, 1976, pp. 45–67.
[14] R. C. Aiken, ed., Stiﬀ computation, Oxford Univ. Press, Oxford, 1985.
[15] P. J. van der Houwen, Construction of integration formulas for initial value problems,
NorthHolland Publishing Co., Amsterdam, 1977.
[16] A. C. Hindmarsh and G. D. Byrne, Applications of EPISODE: An experimental package
for the integration of ordinary diﬀerential equations, in Numerical Methods for Diﬀeren
tial Systems, L. Lapidus and W. E. Schiesser eds., Academic Press, Orlando, FL, 1976,
pp. 147–166.
[17] D. Kahaner, C. Moler, and S. Nash, Numerical methods and software, PrenticeHall,
Englewood Cliﬀs, NJ, 1989.
[18] L. F. Shampine, Evaluation of a test set for stiﬀ ODE solvers, ACM Trans. Math. Soft.,
7(4) (1981) 409–420.
289
Part 3
Exercises and Solutions
Exercises for Diﬀerential Equations and Laplace
Transforms
Exercises for Chapter 1
Solve the following separable diﬀerential equations.
1.1. y
′
= 2xy
2
.
1.2. y
′
=
xy
x
2
−1
.
1.3. (1 +x
2
)y
′
= cos
2
y.
1.4. (1 +e
x
)yy
′
= e
x
.
1.5. y
′
sin x = y ln y.
1.6. (1 +y
2
) dx + (1 +x
2
) dy = 0.
Solve the following initialvalue problems and plot the solutions.
1.7. y
′
sin x − y cos x = 0, y(π/2) = 1.
1.8. xsin y dx + (x
2
+ 1) cos y dy = 0, y(1) = π/2.
Solve the following diﬀerential equations.
1.9. (x
2
−3y
2
) dx + 2xy dy = 0.
1.10. (x +y) dx −xdy = 0.
1.11. xy
′
= y +
_
y
2
−x
2
.
1.12. xy
′
= y +xcos
2
(y/x).
Solve the following initialvalue problems.
1.13. (2x −5y) dx + (4x −y) dy = 0, y(1) = 4.
1.14. (3x
2
+ 9xy + 5y
2
) dx −(6x
2
+ 4xy) dy = 0, y(2) = −6.
1.15. yy
′
= −(x + 2y), y(1) = 1.
1.16. (x
2
+y
2
) dx −2xy dy = 0, y(1) = 2.
Solve the following diﬀerential equations.
1.17. x(2x
2
+y
2
) +y(x
2
+ 2y
2
)y
′
= 0.
1.18. (3x
2
y
2
−4xy)y
′
+ 2xy
3
−2y
2
= 0.
293
294 EXERCISES FOR DIFFERENTIAL EQUATIONS AND LAPLACE TRANSFORMS
1.19. (sin xy +xy cos xy) dx +x
2
cos xy dy = 0.
1.20.
_
sin 2x
y
+x
_
dx +
_
y −
sin
2
x
y
2
_
dy = 0.
Solve the following initialvalue problems.
1.21. (2xy −3) dx + (x
2
+ 4y) dy = 0, y(1) = 2.
1.22.
2x
y
3
dx +
(y
2
−3x
2
)
y
4
dy = 0, y(1) = 1.
1.23. (y e
x
+ 2 e
x
+y
2
) dx + (e
x
+ 2xy) dy = 0, y(0) = 6.
1.24. (2xcos y + 3x
2
y) dx + (x
3
−x
2
sin y −y) dy = 0, y(0) = 2.
Solve the following diﬀerential equations.
1.25. (x +y
2
) dx −2xy dy = 0.
1.26. (x
2
−2y) dx +xdy = 0.
1.27. (x
2
−y
2
+x) dx + 2xy dy = 0.
1.28. (1 −x
2
y) dx +x
2
(y −x) dy = 0.
1.29. (1 −xy)y
′
+y
2
+ 3xy
3
= 0.
1.30. (2xy
2
−3y
3
) dx + (7 −3xy
2
) dy = 0.
1.31. (2x
2
y −2y + 5) dx + (2x
3
+ 2x) dy = 0.
1.32. (x + sin x + siny) dx + cos y dy = 0.
1.33. y
′
+
2
x
y = 12.
1.34. y
′
+
2x
x
2
+ 1
y = x.
1.35. x(ln x)y
′
+y = 2 lnx.
1.36. xy
′
+ 6y = 3x + 1.
Solve the following initialvalue problems.
1.37. y
′
+ 3x
2
y = x
2
, y(0) = 2.
1.38. xy
′
−2y = 2x
4
, y(2) = 8.
1.39. y
′
+y cos x = cos x, y(0) = 1.
1.40. y
′
−y tanx =
1
cos
3
x
, y(0) = 0.
Find the orthogonal trajectories of each given family of curves. In each case sketch
several members of the family and several of the orthogonal trajectories on the
same set of axes.
1.41. x
2
+y
2
/4 = c.
1.42. y = e
x
+c.
1.43. y
2
+ 2x = c.
EXERCISES FOR CHAPTER 2 295
1.44. y = arctanx +c.
1.45. x
2
−y
2
= c
2
.
1.46. y
2
= cx
3
.
1.47. e
x
cos y = c.
1.48. y = ln x +c.
In each case draw direction ﬁelds and sketch several approximate solution curves.
1.49. y
′
= 2y/x.
1.50. y
′
= −x/y.
1.50. y
′
= −xy.
1.51. 9yy
′
+x = 0.
Exercises for Chapter 2
Solve the following diﬀerential equations.
2.1. y
′′
−3y
′
+ 2y = 0.
2.2. y
′′
+ 2y
′
+y = 0.
2.3. y
′′
−9y
′
+ 20y = 0.
Solve the following initialvalue problems, with initial conditions y(x
0
) = y
0
, and
plot the solutions y(x) for x ≥ x
0
.
2.4. y
′′
+y
′
+
1
4
y = 0, y(2) = 1, y
′
(2) = 1.
2.5. y
′′
+ 9y = 0, y(0) = 0, y
′
(0) = 1.
2.6. y
′′
−4y
′
+ 3y = 0, y(0) = 6, y
′
(0) = 0.
2.7. y
′′
−2y
′
+ 3y = 0, y(0) = 1, y
′
(0) = 3.
2.8. y
′′
+ 2y
′
+ 2y = 0, y(0) = 2, y
′
(0) = −3.
For the undamped oscillator equations below, ﬁnd the amplitude and period of
the motion.
2.9. y
′′
+ 4y = 0, y(0) = 1, y
′
(0) = 2.
2.10. y
′′
+ 16y = 0, y(0) = 0, y
′
(0) = 1.
For the critically damped oscillator equations, ﬁnd a value T ≥ 0 for which [y(T)[
is a maximum, ﬁnd that maximum, and plot the solutions y(x) for x ≥ 0.
2.11. y
′′
+ 2y
′
+y = 0, y(0) = 1, y
′
(0) = 1.
2.12. y
′′
+ 6y
′
+ 9y = 0, y(0) = 0, y
′
(0) = 2.
Solve the following Euler–Cauchy diﬀerential equations.
2.13. x
2
y
′′
+ 3xy
′
−3y = 0.
296 EXERCISES FOR DIFFERENTIAL EQUATIONS AND LAPLACE TRANSFORMS
2.14. x
2
y
′′
−xy
′
+y = 0.
2.15. 4x
2
y
′′
+y = 0.
2.16. x
2
y
′′
+xy
′
+ 4y = 0.
Solve the following initialvalue problems, with initial conditions y(x
0
) = y
0
, and
plot the solutions y(x) for x ≥ x
0
.
2.17. x
2
y
′′
+ 4xy
′
+ 2y = 0, y(1) = 1, y
′
(1) = 2.
2.18. x
2
y
′′
+ 5xy
′
+ 3y = 0, y(1) = 1, y
′
(1) = −5.
2.19. x
2
y
′′
−xy
′
+y = 0, y(1) = 1, y
′
(1) = 0.
2.20. x
2
y
′′
+
7
2
xy
′
−
3
2
y = 0, y(4) = 1, y
′
(4) = 0.
Exercises for Chapter 3
Solve the following constant coeﬃcient diﬀerential equations.
3.1. y
′′′
+ 6y
′′
= 0.
3.2. y
′′′
+ 3y
′′
−4y
′
−12y = 0.
3.3. y
′′′
−y = 0.
3.4. y
(4)
+y
′′′
−3y
′′
−y
′
+ 2y = 0.
Solve the following initialvalue problems and plot the solutions y(x) for x ≥ 0.
3.5. y
′′′
+ 12y
′′
+ 36y
′
= 0, y(0) = 0, y
′
(0) = 1, y
′′
(0) = −7.
3.6. y
(4)
−y = 0, y(0) = 0, y
′
(0) = 0, y
′′
(0) = 0, y
′′′
(0) = 1.
3.7. y
′′′
−y
′′
−y
′
+y = 0, y(0) = 0, y
′
(0) = 5, y
′′
(0) = 2.
3.8. y
′′′
−2y
′′
+ 4y
′
−8y = 0, y(0) = 2, y
′
(0) = 0, y
′′
(0) = 0.
Determine whether the given functions are linearly dependent or independent on
−∞< x < +∞.
3.9. y
1
(x) = x, y
2
(x) = x
2
, y
3
(x) = 2x −5x
2
.
3.10. y
1
(x) = 1 +x, y
2
(x) = x, y
3
(x) = x
2
.
3.11. y
1
(x) = 2, y
2
(x) = sin
2
x, y
3
(x) = cos
2
x.
3.12. y
1
(x) = e
x
, y
2
(x) = e
−x
, y
3
(x) = coshx.
Show by computing the Wronskian that the given functions are linearly indepen
dent on the indicated interval.
3.13. e
x
, e
2x
, e
−x
, −∞< x < +∞.
3.14. x + 2, x
2
, −∞< x < +∞.
3.15. x
1/3
, x
1/4
, 0 < x < +∞.
EXERCISES FOR CHAPTER 3 297
3.16. x, xln x, x
2
ln x, 0 < x < +∞.
3.17 Show that the functions
f
1
(x) = x
2
, f
2
(x) = x[x[ =
_
x
2
, x ≥ 0,
−x
2
, x < 0
are linearly independent on [−1, 1] and compute their Wronskian. Explain your
result.
Find a second solution of each diﬀerential equation if y
1
(x) is a solution.
3.18. xy
′′
+y
′
= 0, y
1
(x) = ln x.
3.19. x(x −2)y
′′
−(x
2
−2)y
′
+ 2(x −1)y = 0, y
1
(x) = e
x
.
3.20. (1 −x
2
)y
′′
−2xy
′
= 0, y
1
(x) = 1.
3.21. (1 + 2x)y
′′
+ 4xy
′
−4y = 0, y
1
(x) = e
−2x
.
Solve the following diﬀerential equations.
3.22. y
′′
+ 3y
′
+ 2y = 5 e
−2x
.
3.23. y
′′
+y
′
= 3x
2
.
3.24. y
′′
−y
′
−2y = 2xe
−x
+x
2
.
3.25. y
′′
−y
′
= e
x
sin x.
Solve the following initialvalue problems and plot the solutions y(x) for x ≥ 0.
3.26. y
′′
+y = 2 cos x, y(0) = 1, y
′
(0) = 0.
3.27. y
(4)
−y = 8 e
x
, y(0) = 0, y
′
(0) = 2, y
′′
(0) = 4, y
′′′
(0) = 6.
3.28. y
′′′
+y
′
= x, y(0) = 0, y
′
(0) = 1, y
′′
(0) = 0.
3.29. y
′′
+y = 3x
2
−4 sin x, y(0) = 0, y
′
(0) = 1.
Solve the following diﬀerential equations.
3.30. y
′′
+y =
1
sinx
.
3.31. y
′′
+y =
1
cos x
.
3.32. y
′′
+ 6y
′
+ 9y =
e
−3x
x
3
.
3.33. y
′′
−2y
′
tanx = 1.
3.34. y
′′
−2y
′
+y =
e
x
x
.
3.35. y
′′
+ 3y
′
+ 2y =
1
1 +e
x
.
Solve the following initialvalue problems, with initial conditions y(x
0
) = y
0
, and
plot the solutions y(x) for x ≥ x
0
.
298 EXERCISES FOR DIFFERENTIAL EQUATIONS AND LAPLACE TRANSFORMS
3.36. y
′′
+y = tanx, y(0) = 1, y
′
(0) = 0.
3.37. y
′′
−2y
′
+y =
e
x
x
, y(1) = e, y
′
(1) = 0.
3.38. 2x
2
y
′′
+xy
′
−3y = x
−2
, y(1) = 0, y
′
(1) = 2.
3.39. 2x
2
y
′′
+xy
′
−3y = 2x
−3
, y(1) = 0, y
′
(1) = 3.
Exercises for Chapter 4
Solve the following systems of diﬀerential equations y
′
= Ay for given matri
ces A.
4.1. A =
_
0 1
−2 −3
_
.
4.2. A =
_
_
2 0 4
0 2 0
−1 0 2
_
_
.
4.3. A =
_
−1 1
4 −1
_
.
4.4. A =
_
_
−1 1 4
−2 2 4
−1 0 4
_
_
.
4.5. A =
_
1 1
−4 1
_
.
Solve the following systems of diﬀerential equations y
′
= Ay + f(x) for given
matrices A and vectors f.
4.6. A =
_
−3 −2
1 0
_
, f(x) =
_
2 e
−x
−e
−x
_
.
4.7. A =
_
1 1
3 1
_
, f(x) =
_
1
1
_
.
4.8. A =
_
−2 1
1 −2
_
, f(x) =
_
2 e
−x
3x
_
.
4.9. A =
_
2 −1
3 −2
_
, f(x) =
_
e
x
−e
x
_
.
4.10. A =
_
1
√
3
√
3 −1
_
, f(x) =
_
1
0
_
.
Solve the initial value problem y
′
= Ay with y(0) = y
0
, for given matrices A and
vectors y
0
.
4.11. A =
_
5 −1
3 1
_
, y
0
=
_
2
−1
_
.
4.12. A =
_
−3 2
−1 −1
_
, y
0
=
_
1
−2
_
.
EXERCISES FOR CHAPTER 5 299
4.13. A =
_
1
√
3
√
3 −1
_
, y
0
=
_
1
0
_
.
Exercises for Chapter 5
Find the interval of convergence of the given series and of the term by term
ﬁrst derivative of the series.
5.1.
∞
n=1
(−1)
n
2n + 1
x
n
.
5.2.
∞
n=1
2
n
n3
n+3
x
n
.
5.3.
∞
n=2
ln n
n
x
n
.
5.4.
∞
n=1
1
n
2
+ 1
(x + 1)
n
.
5.5.
∞
n=3
n(n −1)(n −2)
4
n
x
n
.
5.6.
∞
n=0
(−1)
n
k
n
x
2n
.
5.7.
∞
n=0
(−1)
n
k
n
x
3n
.
5.8.
∞
n=1
(4n)!
(n!)
4
x
n
.
Find the power series solutions of the following ordinary diﬀerential equations.
5.9. y
′′
−3y
′
+ 2y = 0.
5.10. (1 −x
2
)y
′′
−2xy
′
+ 2y = 0.
5.11. y
′′
+x
2
y
′
+xy = 0.
5.12. y
′′
−xy
′
−y = 0.
5.13. (x
2
−1)y
′′
+ 4xy
′
+ 2y = 0.
5.14. (1 −x)y
′′
−y
′
+xy = 0.
5.15. y
′′
−4xy
′
+ (4x
2
−2)y = 0.
5.16. y
′′
−2(x −1)y
′
+ 2y = 0.
5.17. Show that the equation
sin θ
d
2
y
dθ
2
+ cos θ
dy
dθ
+n(n + 1)(sin θ)y = 0
can be transformed into Legendre’s equation by means of the substitution x =
cos θ.
5.18. Derive Rodrigues’ formula (5.10).
300 EXERCISES FOR DIFFERENTIAL EQUATIONS AND LAPLACE TRANSFORMS
0
r
r
r
A
A
1
1
2
2
θ
Figure 13.1. Distance r from point A
1
to point A
2
.
5.19. Derive the generating function (5.11).
5.20. Let A
1
and A
2
be two points in space (see Fig. 13.1). By means of (5.9)
derive the formula
1
r
=
1
_
r
2
1
+r
2
2
−2r
1
r
2
cos θ
=
1
r
2
∞
m=0
P
m
(cos θ)
_
r
1
r
2
_
m
,
which is important in potential theory.
5.21. Derive Bonnet recurrence formula,
(n + 1)P
n+1
(x) = (2n + 1)xP
n
(x) −nP
n−1
(x), n = 1, 2, . . . (13.1)
(Hint. Diﬀerentiate the generating function (5.11) with respect to t, substitute
(5.11) in the diﬀerentiated formula, and compare the coeﬃcients of t
n
.)
5.22. Compare the value of P
4
(0.7) obtained by means of the threepoint recur
rence formula (13.1) of the previous exercise with the value obtained by evaluating
P
4
(x) directly at x = 0.7.
5.23. For nonnegative integers m and n, with m ≤ n, let
p
m
n
(x) =
d
m
dx
n
P
n
(x).
Show that the function p
m
n
(x) is a solution of the diﬀerential equation
(1 −x
2
)y
′′
+ 2(m+ 1)xy
′
+ (n −m)(n +m+ 1)y = 0.
Express the following polynomials in terms of Legendre polynomials
P
0
(x), P
1
(x), . . .
5.24. p(x) = 5x
3
+ 4x
2
+ 3x + 2, −1 ≤ x ≤ 1.
5.25. p(x) = 10x
3
+ 4x
2
+ 6x + 1, −1 ≤ x ≤ 1.
5.26. p(x) = x
3
−2x
2
+ 4x + 1, −1 ≤ x ≤ 2.
Find the ﬁrst three coeﬃcients of the Fourier–Legendre expansion of the following
functions and plot f(x) and its Fourier–Legendre approximation on the same
graph.
5.27. f(x) = e
x
, −1 < x < 1.
EXERCISES FOR CHAPTER 6 301
5.28. f(x) = e
2x
, −1 < x < 1.
5.29. f(x) =
_
0 −1 < x < 0,
1 0 < x < 1.
5.30. Integrate numerically
I =
_
1
−1
(5x
5
+ 4x
4
+ 3x
3
+ 2x
2
+x + 1) dx,
by means of the threepoint Gaussian quadrature formula. Moreover, ﬁnd the
exact value of I and compute the error in the numerical value.
5.31. Evaluate
I =
_
1.5
0.2
e
−x
2
dx,
by the threepoint Gaussian quadrature formula.
5.32. Evaluate
I =
_
1.7
0.3
e
−x
2
dx,
by the threepoint Gaussian quadrature formula.
5.33. Derive the fourpoint Gaussian quadrature formula.
5.34. Obtain P
4
(x) by means of Bonnet’s formula of Exercise 5.21 or otherwise.
5.35. Find the zeros of P
4
(x) in radical form.
Hint : Put t = x
2
in the even quartic polynomial P
4
(x) and solve the quadratic
equation.
5.36. Obtain P
5
(x) by means of Bonnet’s formula of Exercise 5.21 or otherwise.
5.37. Find the zeros of P
5
(x) in radical form.
Hint : Write P
5
(x) = xQ
4
(x). Then put t = x
2
in the even quartic polynomial
Q
4
(x) and solve the quadratic equation.
Exercises for Chapter 6
Find the Laplace transforms of the given functions.
6.1. f(t) = −3t + 2.
6.2. f(t) = t
2
+at +b.
6.3. f(t) = cos(ωt +θ).
6.4. f(t) = sin(ωt +θ).
6.5. f(t) = cos
2
t.
6.6. f(t) = sin
2
t.
6.7. f(t) = 3 cosh2t + 4 sinh 5t.
6.8. f(t) = 2 e
−2t
sin t.
6.9. f(t) = e
−2t
cosh t.
6.10. f(t) =
_
1 + 2e
−t
_
2
.
6.11. f(t) = u(t −1)(t −1).
302 EXERCISES FOR DIFFERENTIAL EQUATIONS AND LAPLACE TRANSFORMS
6.12. f(t) = u(t −1)t
2
.
6.13. f(t) = u(t −1) cosht.
6.14. f(t) = u(t −π/2) sint.
Find the inverse Laplace transform of the given functions.
6.15. F(s) =
4(s + 1)
s
2
−16
.
6.16. F(s) =
2s
s
2
+ 3
.
6.17. F(s) =
2
s
2
+ 3
.
6.18. F(s) =
4
s
2
−9
.
6.19. F(s) =
4s
s
2
−9
.
6.20. F(s) =
3s −5
s
2
+ 4
.
6.21. F(s) =
1
s
2
+s −20
.
6.22. F(s) =
1
(s −2)(s
2
+ 4s + 3)
.
6.23. F(s) =
2s + 1
s
2
+ 5s + 6
.
6.24. F(s) =
s
2
−5
s
3
+s
2
+ 9s + 9
.
6.25. F(s) =
3s
2
+ 8s + 3
(s
2
+ 1)(s
2
+ 9)
.
6.26. F(s) =
s −1
s
2
(s
2
+ 1)
.
6.27. F(s) =
1
s
4
−9
.
6.28. F(s) =
(1 +e
−2s
)
2
s + 2
.
6.29. F(s) =
e
−3s
s
2
(s −1)
.
6.30. F(s) =
π
2
−arctan
s
2
.
6.31. F(s) = ln
s
2
+ 1
s
2
+ 4
.
Find the Laplace transform of the given functions.
6.32. f(t) =
_
t, 0 ≤ t < 1,
1, t ≥ 1.
EXERCISES FOR CHAPTER 6 303
6.33. f(t) =
_
2t + 3, 0 ≤ t < 2,
0, t ≥ 2.
6.34. f(t) = t sin3t.
6.35. f(t) = t cos 4t.
6.36. f(t) = e
−t
t cos t.
6.37. f(t) =
_
t
0
τe
t−τ
dτ.
6.38. f(t) = 1 ∗ e
−2t
.
6.39. f(t) = e
−t
∗ e
t
cos t.
6.40. f(t) =
e
t
−e
−t
t
.
Use Laplace transforms to solve the given initial value problems and plot the
solution.
6.41. y
′′
−6y
′
+ 13y = 0, y(0) = 0, y
′
(0) = −3.
6.42. y
′′
+y = sin3t, y(0) = 0, y
′
(0) = 0.
6.43. y
′′
+y = sint, y(0) = 0, y
′
(0) = 0.
6.44. y
′′
+y = t, y(0) = 0, y
′
(0) = 0.
6.45. y
′′
+ 5y
′
+ 6y = 3 e
−2t
, y(0) = 0, y
′
(0) = 1.
6.46. y
′′
+ 2y
′
+ 5y = 4t, y(0) = 0, y
′
(0) = 0.
6.47. y
′′
−4y
′
+ 4y = t
3
e
2t
, y(0) = 0, y
′
(0) = 0.
6.48. y
′′
+ 4y =
_
1, 0 ≤ t < 1
0, t ≥ 1
, y(0) = 0, y
′
(0) = −1.
6.49. y
′′
−5y
′
+ 6y =
_
t, 0 ≤ t < 1
0, t ≥ 1
, y(0) = 0, y
′
(0) = 1.
6.50. y
′′
+ 4y
′
+ 3y =
_
4 e
1−t
, 0 ≤ t < 1
4, t ≥ 1
, y(0) = 0, y
′
(0) = 0.
6.51. y
′′
+ 4y
′
= u(t −1), y(0) = 0, y
′
(0) = 0.
6.52. y
′′
+ 3y
′
+ 2y = 1 −u(t −1), y(0) = 0, y
′
(0) = 1.
6.53. y
′′
−y = sint +δ(t −π/2), y(0) = 3.5, y
′
(0) = −3.5.
6.54. y
′′
+ 5y
′
+ 6y = u(t −1) +δ(t −2), y(0) = 0, y
′
(0) = 1.
Using Laplace transforms solve the given integral equations and plot the solutions.
6.55. y(t) = 1 +
_
t
0
y(τ) dτ.
6.56. y(t) = sint +
_
t
0
y(τ) sin(t −τ) dτ.
6.57. y(t) = cos 3t + 2
_
t
0
y(τ) cos 3(t −τ) dτ.
304 EXERCISES FOR DIFFERENTIAL EQUATIONS AND LAPLACE TRANSFORMS
6.58. y(t) = t +e
t
+
_
t
0
y(τ) cosh(t −τ) dτ.
6.59. y(t) = t e
t
+ 2 e
t
_
t
0
e
−τ
y(τ) dτ.
Sketch the following 2πperiodic functions over three periods and ﬁnd their Laplace
transforms.
6.60. f(t) = π −t, 0 < t < 2π.
6.61. f(t) = 4π
2
−t
2
, 0 < t < 2π.
6.62. f(t) = e
−t
, 0 < t < 2π.
6.63. f(t) =
_
t, if 0 < t < π,
π −t, if π < t < 2π.
6.64. f(t) =
_
0, if 0 < t < π,
t −π, if π < t < 2π.
Exercises for Numerical Methods
Angles are always in radian measure.
Exercises for Chapter 8
8.1. Use the bisection method to ﬁnd x
3
for f(x) =
√
x −cos x on [0, 1]. Angles
in radian measure.
8.2. Use the bisection method to ﬁnd x
3
for
f(x) = 3(x + 1)(x −
1
2
)(x −1)
on the following intervals:
[−2, 1.5], [−1.25, 2.5].
8.3. Use the bisection method to ﬁnd a solution accurate to 10
−3
for f(x) =
x −tanx on [4, 4.5]. Angles in radian measure.
8.4. Use the bisection method to ﬁnd an approximation to
√
3 correct to within
10
−4
. [Hint : Consider f(x) = x
2
−3.]
8.5. Show that the ﬁxed point iteration
x
n+1
=
√
2x
n
+ 3
for the solving the equation f(x) = x
2
−2x−3 = 0 converges in the interval [2, 4].
8.6. Use a ﬁxed point iteration method, other than Newton’s method, to de
termine a solution accurate to 10
−2
for f(x) = x
3
− x − 1 = 0 on [1, 2]. Use
x
0
= 1.
8.7. Use a ﬁxed point iteration method to ﬁnd an approximation to
√
3 correct
to within 10
−4
. Compare your result and the number of iterations required with
the answer obtained in Exercise 8.4.
8.8. Do ﬁve iterations of the ﬁxed point method g(x) = cos(x −1). Take x
0
= 2.
Use at least 6 decimals. Find the order of convergence of the method. Angles in
radian measure.
8.9. Do ﬁve iterations of the ﬁxed point method g(x) = 1 + sin
2
x. Take x
0
= 1.
Use at least 6 decimals. Find the order of convergence of the method. Angles in
radian measure.
8.10. Sketch the function f(x) = 2x −tan x and compute a root of the equation
f(x) = 0 to six decimals by means of Newton’s method with x
0
= 1. Find the
order of convergence of the method.
8.11. Sketch the function f(x) = e
−x
−tan x and compute a root of the equation
f(x) = 0 to six decimals by means of Newton’s method with x
0
= 1. Find the
order of convergence of the method.
305
306 EXERCISES FOR NUMERICAL METHODS
8.12 Compute a root of the equation f(x) = 2x − tan x given in Exercise 8.10
with the secant method with starting values x
0
= 1 and x
1
= 0.5. Find the order
of convergence to the root.
8.13. Repeat Exercise 8.12 with the method of false position. Find the order of
convergence of the method.
8.14. Repeat Exercise 8.11 with the secant method with starting values x
0
= 1
and x
1
= 0.5. Find the order of convergence of the method.
8.15. Repeat Exercise 8.14 with the method of false position. Find the order of
convergence of the method.
8.16. Consider the ﬁxed point method of Exercise 8.5:
x
n+1
=
√
2x
n
+ 3.
Complete the table:
n x
n
∆x
n
∆
2
x
n
1 x
1
= 4.000
2 x
2
=
3 x
3
=
Accelerate convergence by Aitken.
a
1
= x
1
−
_
∆x
1
_
2
∆
2
x
1
=
8.17. Apply Steﬀensen’s method to the result of Exercise 8.9. Find the order of
convergence of the method.
8.18. Use M¨ uller’s method to ﬁnd the three zeros of
f(x) = x
3
+ 3x
2
−1.
8.19. Use M¨ uller’s method to ﬁnd the four zeros of
f(x) = x
4
+ 2x
2
−x −3.
8.20. Sketch the function f(x) = x − tan x. Find the multiplicity of the zero
x = 0. Compute the root x = 0 of the equation f(x) = 0 to six decimals by
means of a modiﬁed Newton method wich takes the multiplicity of the rood into
account. Start at x
0
= 1. Find the order of convergence of the modiﬁed Newton
method that was used.
EXERCISES FOR CHAPTER 9 307
Exercises for Chapter 9
9.1. Given the function f(x) = ln(x + 1) and the points x
0
= 0, x
1
= 0.6 and
x
2
= 0.9. Construct the Lagrange interpolating polynomials of degrees exactly
one and two to approximate f(0.45) and ﬁnd the actual errors.
9.2. Consider the data
f(8.1) = 16.94410, f(8.3) = 17.56492, f(8.6) = 18.50515, f(8.7) = 18.82091.
Interpolate f(8.4) by Lagrange interpolating polynomials of degree one, two and
three.
9.3. Construct the Lagrange interpolating polynomial of degree 2 for the function
f(x) = e
2x
cos 3x, using the values of f at the points x
0
= 0, x
1
= 0.3 and
x
2
= 0.6.
9.4. The three points
(0.1, 1.0100502), (0.2, 1.04081077), (0.4, 1.1735109)
lie on the graph of a certain function f(x). Use these points to estimate f(0.3).
9.5. Complete the following table of divided diﬀerences:
i x
i
f[x
i
] f[x
i
, x
i+1
] f[x
i
, x
i+1
, x
i+2
] f[x
i
, x
i+1
, x
i+2
, x
i+3
]
0 3.2 22.0
8.400
1 2.7 17.8 2.856
−0.528
2 1.0 14.2
3 4.8 38.3
4 5.6 5.17
Write the interpolating polynomial of degree 3 that ﬁts the data at all points from
x
0
= 3.2 to x
3
= 4.8.
9.6. Interpolate the data
(−1, 2), (0, 0), (1.5, −1), (2, 4),
by means of Newton’s divided diﬀerence interpolating polynomial of degree three.
Plot the data and the interpolating polynomial on the same graph.
9.7. Repeat Exercise 2.1 using Newton’s divided diﬀerence interpolating polyno
mials.
9.8. Repeat Exercise 2.2 using Newton’s divided diﬀerence interpolating polyno
mials.
308 EXERCISES FOR NUMERICAL METHODS
9.9. Interpolate the data
(−1, 2), (0, 0), (1, −1), (2, 4),
by means of Gregory–Newton’s interpolating polynomial of degree three.
9.10. Interpolate the data
(−1, 3), (0, 1), (1, 0), (2, 5),
by means of Gregory–Newton’s interpolating polynomial of degree three.
9.11. Approximate f(0.05) using the following data and Gregory–Newton’s for
ward interpolating polynomial of degree four.
x 0.0 0.2 0.4 0.6 0.8
f(x) 1.00000 1.22140 1.49182 1.82212 2.22554
9.12. Approximate f(0.65) using the data in Exercise 2.11 and Gregory–Newton’s
backward interpolating polynomial of degree four.
9.13. Construct a Hermite interpolating polynomial of degree three for the data
x f(x) f
′
(x)
8.3 17.56492 3.116256
8.6 18.50515 3.151762
Exercises for Chapter 10
10.1. Consider the formulae
(4.4) f
′
(x
0
) =
1
2h
[−3f(x
0
) + 4f(x
0
+h) −f(x
0
+ 2h)] +
h
2
3
f
(3)
(ξ),
(4.5) f
′
(x
0
) =
1
2h
[f(x
0
+h) −f(x
0
−h)] −
h
2
6
f
(3)
(ξ),
(4.6) f
′
(x
0
) =
1
12h
[f(x
0
−2h) −8f(x
0
−h) + 8f(x
0
+h) −f(x
0
+ 2h)] +
h
4
30
f
(5)
(ξ),
(4.7) f
′
(x
0
) =
1
12h
[−25f(x
0
) + 48f(x
0
+h) −36f(x
0
+ 2h) + 16f(x
0
+ 3h)
−3f(x
0
+ 4h) +
h
4
5
f
(5)
(ξ),
and the table ¦x
n
, f(x
n
)¦ :
x = 1:0.1:1.8; format long; table = [x’,(cosh(x)sinh(x))’]
table =
1.00000000000000 0.36787944117144
1.10000000000000 0.33287108369808
1.20000000000000 0.30119421191220
1.30000000000000 0.27253179303401
1.40000000000000 0.24659696394161
1.50000000000000 0.22313016014843
1.60000000000000 0.20189651799466
1.70000000000000 0.18268352405273
1.80000000000000 0.16529888822159
For each of the four formulae (4.4)–(4.7) with h = 0.1,
EXERCISES FOR CHAPTER 10 309
(a) compute the numerical values
ndf = f
′
(1.2)
(deleting the error term in the formulae),
(b) compute the exact value at x = 1.2 of the derivative df = f
′
(x) of the
given function
f(x) = coshx −sinh x,
(c) compute the error
ε = ndf −df;
(d) verify that [ε[ is bounded by the absolute value of the error term.
10.2. Use Richardson’s extrapolation with h = 0.4, h/2 and h/4 to improve the
value f
′
(1.4) obtained by formula (4.5).
10.3. Evaluate
_
1
0
dx
1 +x
by the composite trapezoidal rule with n = 10.
10.4. Evaluate
_
1
0
dx
1 +x
by the composite Simpson’s rule with n = 2m = 10.
10.5. Evaluate
_
1
0
dx
1 + 2x
2
by the composite trapezoidal rule with n = 10.
10.6. Evaluate
_
1
0
dx
1 + 2x
2
by the composite Simpson’s rule with n = 2m = 10.
10.7. Evaluate
_
1
0
dx
1 +x
3
by the composite trapezoidal rule with h for an error
of 10
−4
.
10.8. Evaluate
_
1
0
dx
1 +x
3
by the composite Simpson’s rule with with h for an
error of 10
−6
.
10.9. Determine the values of h and n to approximate
_
3
1
ln xdx
to 10
−3
by the following composite rules: trapezoidal, Simpson’s, and midpoint.
10.10. Same as Exercise 3.9 with
_
2
0
1
x + 4
dx
to 10
−5
.
10.11. Use Romberg integration to compute R
3,3
for the integral
_
1.5
1
x
2
ln xdx.
10.12. Use Romberg integration to compute R
3,3
for the integral
_
1.6
1
2x
x
2
−4
dx.
310 EXERCISES FOR NUMERICAL METHODS
10.13. Apply Romberg integration to the integral
_
1
0
x
1/3
dx
until R
n−1,n−1
and R
n,n
agree to within 10
−4
.
Exercises for Chapter 11
Solve the following system by the LU decomposition without pivoting.
11.1.
2x
1
+ 2x
2
+ 2x
3
= 4
−x
1
+ 2x
2
− 3x
3
= 32
3x
1
− 4x
3
= 17
11.2.
x
1
+ x
2
+ x
3
= 5
x
1
+ 2x
2
+ 2x
3
= 6
x
1
+ 2x
2
+ 3x
3
= 8
Solve the following system by the LU decomposition with partial pivoting.
11.3.
2x
1
− x
2
+ 5x
3
= 4
−6x
1
+ 3x
2
− 9x
3
= −6
4x
1
− 3x
2
= −2
11.4.
3x
1
+ 9x
2
+ 6x
3
= 23
18x
1
+ 48x
2
− 39x
3
= 136
9x
1
− 27x
2
+ 42x
3
= 45
11.5. Scale each equation in the l
∞
norm, so that the largest coeﬃcient of each
row on the lefthand side be equal to 1 in absolute value, and solve the scaled
system by the LU decomposition with partial pivoting.
x
1
− x
2
+ 2x
3
= 3.8
4x
1
+ 3x
2
− x
3
= −5.7
5x
1
+ 10x
2
+ 3x
3
= 2.8
11.6. Find the inverse of the Gaussian transformation
_
¸
¸
_
1 0 0 0
−a 1 0 0
−b 0 1 0
−c 0 0 1
_
¸
¸
_
.
11.7. Find the product of the three Gaussian transformations
_
¸
¸
_
1 0 0 0
a 1 0 0
b 0 1 0
c 0 0 1
_
¸
¸
_
_
¸
¸
_
1 0 0 0
0 1 0 0
0 d 1 0
0 e 0 1
_
¸
¸
_
_
¸
¸
_
1 0 0 0
0 1 0 0
0 0 1 0
0 0 f 1
_
¸
¸
_
.
EXERCISES FOR CHAPTER 11 311
11.8. Find the Cholesky decomposition of
A =
_
_
1 −1 −2
−1 5 −4
−2 −4 22
_
_
, B =
_
¸
¸
_
9 9 9 0
9 13 13 −2
9 13 14 −3
0 −2 −3 18
_
¸
¸
_
.
Solve the following systems by the Cholesky decomposition.
11.9.
_
_
16 −4 4
−4 10 −1
4 −1 5
_
_
_
_
x
1
x
2
x
3
_
_
=
_
_
−12
3
1
_
_
.
11.10.
_
_
4 10 8
10 26 26
8 26 61
_
_
_
_
x
1
x
2
x
3
_
_
=
_
_
44
128
214
_
_
.
Do three iterations of Gauss–Seidel’s scheme on the following properly permuted
systems with given initial values x
(0)
.
11.11.
6x
1
+ x
2
− x
3
= 3
−x
1
+ x
2
+ 7x
3
= −17
x
1
+ 5x
2
+ x
3
= 0
with
x
(0)
1
= 1
x
(0)
2
= 1
x
(0)
3
= 1
11.12.
−2x
1
+ x
2
+ 6x
3
= 22
x
1
+ 4x
2
+ 2x
3
= 13
7x
1
+ 2x
2
− x
3
= −6
with
x
(0)
1
= 1
x
(0)
2
= 1
x
(0)
3
= 1
11.13. Using least squares, ﬁt a straight line to (s, F):
(0.9, 10), (0.5, 5), (1.6, 15), (2.1, 20),
where s is the elongation of an elastic spring under a force F, and estimate from
it the spring modulus k = F/s. (F = ks is called Hooke’s law).
11.14. Using least squares, ﬁt a parabola to the data
(−1, 2), (0, 0), (1, 1), (2, 2).
11.15. Using least squares, ﬁt f(x) = a
0
+a
1
cos x to the data
(0, 3.7), (1, 3.0), (2, 2.4), (3, 1.8).
Note: x in radian measures.
11.16. Using leastsquares, approximate the data
x
i
−1 −0.5 0 0.25 0.5 0.75 1
y
i
e
−1
e
−1/2
1 e
1/4
e
1/2
e
3/4
e
by means of
f(x) = a
0
P
0
(x) +a
1
P
1
(x) +a
2
P
2
(x),
where P
0
, P
1
and P
2
are the Legendre polynomials of degree 0, 1 and 2 respec
tively. Plot f(x) and g(x) = e
x
on the same graph.
312 EXERCISES FOR NUMERICAL METHODS
Using Theorem 11.3, determine and sketch disks that contain the eigenvalues of
the following matrices.
11.17.
_
_
−i 0.1 + 0.1i 0.5i
0.3i 2 0.3
0.2 0.3 + 0.4i i
_
_
.
11.18.
_
_
−2 1/2 i/2
1/2 0 i/2
−i/2 −i/2 2
_
_
.
11.19. Find the l
1
norm of the matrix in exercise 17 and the l
∞
norm of the
matrix in exercise 18.
Do three iterations of the power method to ﬁnd the largest eigenvalue, in absolute
value, and the corresponding eigenvector of the following matrices.
11.20.
_
10 4
4 2
_
with x
(0)
=
_
1
1
_
.
11.21.
_
_
3 2 3
2 6 6
3 6 3
_
_
with x
(0)
=
_
_
1
1
1
_
_
.
Exercises for Chapter 12
Use Euler’s method with h = 0.1 to obtain a fourdecimal approximation for each
initial value problem on 0 ≤ x ≤ 1 and plot the numerical solution.
12.1. y
′
= e
−y
−y + 1, y(0) = 1.
12.2. y
′
= x + sin y, y(0) = 0.
12.3. y
′
= x + cos y, y(0) = 0.
12.4. y
′
= x
2
+y
2
, y(0) = 1.
12.5. y
′
= 1 +y
2
, y(0) = 0.
Use the improved Euler method with h = 0.1 to obtain a fourdecimal approx
imation for each initial value problem on 0 ≤ x ≤ 1 and plot the numerical
solution.
12.6. y
′
= e
−y
−y + 1, y(0) = 1.
12.7. y
′
= x + sin y, y(0) = 0.
12.8. y
′
= x + cos y, y(0) = 0.
12.9. y
′
= x
2
+y
2
, y(0) = 1.
12.10. y
′
= 1 +y
2
, y(0) = 0.
Use the Runge–Kutta method of order 4 with h = 0.1 to obtain a sixdecimal
approximation for each initial value problem on 0 ≤ x ≤ 1 and plot the numerical
solution.
EXERCISES FOR CHAPTER 12 313
12.11. y
′
= x
2
+y
2
, y(0) = 1.
12.12. y
′
= x + sin y, y(0) = 0.
12.13. y
′
= x + cos y, y(0) = 0.
12.14. y
′
= e
−y
, y(0) = 0.
12.15. y
′
= y
2
+ 2y −x, y(0) = 0.
Use the Matlab ode23 embedded pair of order 3 with h = 0.1 to obtain a six
decimal approximation for each initial value problem on 0 ≤ x ≤ 1 and estimate
the local truncation error by means of the given formula.
12.16. y
′
= x
2
+ 2y
2
, y(0) = 1.
12.17. y
′
= x + 2 siny, y(0) = 0.
12.18. y
′
= x + 2 cos y, y(0) = 0.
12.19. y
′
= e
−y
, y(0) = 0.
12.20. y
′
= y
2
+ 2y −x, y(0) = 0.
Use the Adams–Bashforth–Moulton threestep predictorcorrector method with
h = 0.1 to obtain a sixdecimal approximation for each initial value problem on
0 ≤ x ≤ 1, estimate the local error at x = 0.5, and plot the numerical solution.
12.21. y
′
= x + sin y, y(0) = 0.
12.22. y
′
= x + cos y, y(0) = 0.
12.23. y
′
= y
2
−y + 1, y(0) = 0.
Use the Adams–Bashforth–Moulton fourstep predictorcorrector method with
h = 0.1 to obtain a sixdecimal approximation for each initial value problem on
0 ≤ x ≤ 1, estimate the local error at x = 0.5, and plot the numerical solution.
12.24. y
′
= x + sin y, y(0) = 0.
12.25. y
′
= x + cos y, y(0) = 0.
12.26. y
′
= y
2
−y + 1, y(0) = 0.
Solutions to Exercises for Numerical Methods
Solutions to Exercises for Chapter 8
Ex. 8.11. Sketch the function
f(x) = e
−x
−tanx
and compute a root of the equation f(x) = 0 to six decimals by means of Newton’s
method with x
0
= 1.
Solution. We use the newton1_11 Mﬁle
function f = newton1_11(x); % Exercise 1.11.
f = x  (exp(x)  tan(x))/(exp(x)  sec(x)^2);
We iterate Newton’s method and monitor convergence to six decimal places.
>> xc = input(’Enter starting value:’); format long;
Enter starting value:1
>> xc = newton1_11(xc)
xc = 0.68642146135728
>> xc = newton1_11(xc)
xc = 0.54113009740473
>> xc = newton1_11(xc)
xc = 0.53141608691193
>> xc = newton1_11(xc)
xc = 0.53139085681581
>> xc = newton1_11(xc)
xc = 0.53139085665216
All the digits in the last value of xc are exact. Note the convergence of order 2.
Hence the root is xc = 0.531391 to six decimals.
We plot the two functions and their diﬀerence. The xcoordinate of the point
of intersection of the two functions is the root of their diﬀerence.
x=0:0.01:1.3;
subplot(2,2,1); plot(x,exp(x),x,tan(x));
title(’Plot of exp(x) and tan(x)’); xlabel(’x’); ylabel(’y(x)’);
subplot(2,2,2); plot(x,exp(x)tan(x),x,0);
title(’Plot of exp(x)tan(x)’); xlabel(’x’); ylabel(’y(x)’);
print deps Fig9_2
315
316 SOLUTIONS TO EXERCISES FOR NUMERICAL METHODS
0 0.5 1 1.5
0
1
2
3
4
Plot of exp(x) and tan(x)
x
y
(
x
)
0 0.5 1 1.5
4
3
2
1
0
1
Plot of exp(x)  tan(x)
x
y
(
x
)
Figure 13.2. Graph of two functions and their diﬀerence for Exercise 8.11.
Ex. 8.12 Compute a root of the equation f(x) = x − tan x given in Exer
cise 8.10 with the secant method with starting values x
0
= 1 and x
1
= 0.5. Find
the order of convergence to the root.
Solution. x0 = 1; x1 = 0.5; % starting values
x = zeros(20,1);
x(1) = x0; x(2) = x1;
for n = 3:20
x(n) = x(n1) (x(n1)x(n2)) ...
/(x(n1)tan(x(n1))x(n2)+tan(x(n2)))*(x(n1)tan(x(n1)));
end
dx = abs(diff(x));
p = 1; % checking convergence of order 1
dxr = dx(2:19)./(dx(1:18).^p);
table = [[0:19]’ x [0; dx] [0; 0; dxr]]
table =
n x_n x_n  x_{n1} x_n  x_{n1}
/x_{n1}  x_{n2}
0 1.00000000000000
1 0.50000000000000 0.50000000000000
2 0.45470356524435 0.04529643475565 0.09059286951131
3 0.32718945543123 0.12751410981312 2.81510256824784
4 0.25638399918811 0.07080545624312 0.55527546204022
5 0.19284144711319 0.06354255207491 0.89742451283310
6 0.14671560243705 0.04612584467614 0.72590481763723
7 0.11082587909404 0.03588972334302 0.77808273420254
8 0.08381567002072 0.02701020907332 0.75258894628889
9 0.06330169146740 0.02051397855331 0.75948980985777
10 0.04780894321090 0.01549274825651 0.75522884145761
11 0.03609714636358 0.01171179684732 0.75595347277403
12 0.02725293456160 0.00884421180198 0.75515413367179
13 0.02057409713542 0.00667883742618 0.75516479882196
14 0.01553163187404 0.00504246526138 0.75499146627099
SOLUTIONS TO EXERCISES FOR CHAPTER 9 317
15 0.01172476374403 0.00380686813002 0.75496169684658
16 0.00885088980844 0.00287387393559 0.75491817353192
17 0.00668139206035 0.00216949774809 0.75490358892216
18 0.00504365698583 0.00163773507452 0.75489134568691
19 0.00380735389990 0.00123630308593 0.75488588182657
An approximate solution to the triple root x = 0 is x
19
= 0.0038. Since the
ratio
[x
n
−x
n−1
[
[x
n−1
−x
n−2
[
→0.75 ≈ constant
as n grows, wee conclude that the method converges to order 1.
Convergence is slow to a triple root. In fact
f(0) = f
′
(0) = f
′′
(0) = 0, f
′′′
(0) ,= 0.
In general, the secant method may not converge at all to a multiple root.
Solutions to Exercises for Chapter 9
Ex. 9.4. The three points
(0.1, 1.0100502), (0.2, 1.04081077), (0.4, 1.1735109)
lie on the graph of a certain function f(x). Use these points to estimate f(0.3).
Solution. We have
f[0.1, 0.2] =
1.04081077 −1.0100502
0.1
= 0.307606,
f[0.2, 0.4] =
1.1735109 −1.04081077
0.2
= 0.663501
and
f[0.1, 0.2, 0, 4] =
0.663501 −0.307606
0.3
= 1.18632.
Therefore,
p
2
(x) = 1.0100502 + (x −0.1) 0.307606 + (x −0.1) (x −0.2) 1.18632
and
p
2
(0.3) = 1.0953.
Ex. 9.12. Approximate f(0.65) using the data in Exercise 2.10
x 0.0 0.2 0.4 0.6 0.8
f(x) 1.00000 1.22140 1.49182 1.82212 2.22554
and Gregory–Newton’s backward interpolating polynomial of degree four.
Solution. We construct the diﬀerence table.
f = [1 1.2214 1.49182 1.82212 2.22554];
ddt = [f’ [0 diff(f)]’ [0 0 diff(f,2)]’ [0 0 0 diff(f,3)]’ ...
[0 0 0 0 diff(f,4)]’]
318 SOLUTIONS TO EXERCISES FOR NUMERICAL METHODS
The backward diﬀerence table is
n x
n
f
n
∇f
n
∇
2
f
n
∇
3
f
n
∇
4
f
n
0 0.0 1.0000
0.22140
1 0.2 1.2214 0.04902
0.27042 0.01086
2 0.4 1.4918 0.05998 0.00238
0.33030 0.01324
3 0.6 1.8221 0.07312
0.40342
4 0.8 2.2255
s = (0.650.80)/0.2 % the variable s
s = 0.7500
format long
p4 = ddt(5,1) + s*ddt(5,2) + s*(s+1)*ddt(5,3)/2 ....
+ s*(s+1)*(s+2)*ddt(5,4)/6 + s*(s+1)*(s+2)*(s+3)*ddt(5,5)/24
p4 = 1.91555051757812
Solutions to Exercises for Chapter 11
Ex. 11.2. Solve the linear system
x
1
+ x
2
+ x
3
= 5
x
1
+ 2x
2
+ 2x
3
= 6
x
1
+ 2x
2
+ 3x
3
= 8
by the LU decomposition without pivoting.
Solution. The Matlab numeric solution.— In this case, Matlab need
not pivot since L will be unit lower triangular. Hence we can use the LU decom
position obtained by Matlab.
clear
>>A = [1 1 1; 1 2 2; 1 2 3]; b = [5 6 8]’;
>> [L,U] = lu(A) % LU decomposition of A
L =
1 0 0
1 1 0
1 1 1
U =
1 1 1
0 1 1
0 0 1
>> y = L\b % solution by forward substitution
y =
5
1
2
>> x = U\y % solution by backward substitution
SOLUTIONS TO EXERCISES FOR CHAPTER 11 319
x =
4
1
2
Ex. 11.4. Solve the linear system
3x
1
+ 9x
2
+ 6x
3
= 23
18x
1
+ 48x
2
− 39x
3
= 136
9x
1
− 27x
2
+ 42x
3
= 45
by the LU decomposition with pivoting.
Solution. The Matlab numeric solution.— In this case, Matlab will
pivot since L will be a row permutation of a unit lower triangular matrix. Hence
we can use the LU decomposition obtained by Matlab.
clear
>>A = [3 9 6; 18 48 39; 9 27 42]; b = [23 136 45]’;
>> [L,U] = lu(A) % LU decomposition of A
L =
0.1667 0.0196 1.0000
1.0000 0 0
0.5000 1.0000 0
U =
18.0000 48.0000 39.0000
0 51.0000 61.5000
0 0 13.7059
>> y = L\b % solution by forward substitution
y =
136.0000
23.0000
0.1176
>> x = U\y % solution by backward substitution
x =
6.3619
0.4406
0.0086
Ex. 11.6. Find the inverse of the Gaussian transformation
M =
_
¸
¸
_
1 0 0 0
−a 1 0 0
−b 0 1 0
−c 0 0 1
_
¸
¸
_
.
320 SOLUTIONS TO EXERCISES FOR NUMERICAL METHODS
Solution. The inverse, M
−1
, of a Gaussian transformation is obtained by
changing the signs of the multipliers, that is, of −a, −b, −c. Thus
M
−1
=
_
¸
¸
_
1 0 0 0
a 1 0 0
b 0 1 0
c 0 0 1
_
¸
¸
_
.
Ex. 11.7. Find the product of the three Gaussian transformations
L =
_
¸
¸
_
1 0 0 0
a 1 0 0
b 0 1 0
c 0 0 1
_
¸
¸
_
_
¸
¸
_
1 0 0 0
0 1 0 0
0 d 1 0
0 e 0 1
_
¸
¸
_
_
¸
¸
_
1 0 0 0
0 1 0 0
0 0 1 0
0 0 f 1
_
¸
¸
_
.
Solution. The product of three Gaussian transformation, M
1
M
2
M
3
, in the
given order is the unit lower triangular matrix whose jth column is the jth column
of M
j
.
L =
_
¸
¸
_
1 0 0 0
a 1 0 0
b d 1 0
c e f 1
_
¸
¸
_
.
Ex. 11.10. Solve the linear system
_
_
4 10 8
10 26 26
8 26 61
_
_
_
_
x
1
x
2
x
3
_
_
=
_
_
44
128
214
_
_
.
by the Cholesky decomposition.
Solution. The Matlab command chol decomposes a positive deﬁnite matrix
A in the form
A = R
T
R, where R is upper triangular.
>> A = [4 10 8; 10 26 26; 8 26 61]; b = [44 128 214]’;
>> R = chol(A) % Cholesky decomposition
R =
2 5 4
0 1 6
0 0 3
>> y = R’\b % forward substitution
y =
22
18
6
>> x = R\y % backward substitution
x =
8
6
2
SOLUTIONS TO EXERCISES FOR CHAPTER 11 321
Ex. 11.11. Do three iterations of Gauss–Seidel’s scheme on the properly
permuted system with given initial vector x
(0)
,
6x
1
+ x
2
− x
3
= 3
−x
1
+ x
2
+ 7x
3
= −17
x
1
+ 5x
2
+ x
3
= 0
with
x
(0)
1
= 1,
x
(0)
2
= 1,
x
(0)
3
= 1.
Solution. Interchanging rows 2 and 3 and solving for x
1
, x
2
and x
3
, we
have
x
(n+1)
1
=
1
6
[ 3 − x
(n)
2
+ x
(n)
3
]
x
(n+1)
2
=
1
5
[ 0 − x
(n+1)
1
− x
(n)
3
]
x
(n+1)
3
=
1
7
[−17 + x
(n+1)
1
− x
(n+1)
2
]
with
x
(0)
1
= 1,
x
(0)
2
= 1,
x
(0)
3
= 1.
Hence,
x
(1)
=
_
_
0.5
−0.3
−2.31429
_
_
, x
(2)
=
_
_
0.164 28
0.430 00
−2.466 53
_
_
, x
(3)
=
_
_
0.017 24
0.489 86
−2.496 09
_
_
.
One suspects that
x
(n)
→
_
_
0.0
0.5
−2.5
_
_
as n →∞.
Ex. 11.14. Using least squares, ﬁt a parabola to the data
(−1, 2), (0, 0), (1, 1), (2, 2).
Solution. We look for a solution of the form
f(x) = a
0
+a
1
x +a
2
x
2
.
>> x = [1 0 1 2]’;
>> A = [x.^0 x x.^2];
>> y = [2 0 1 2]’;
>> a = (A’*A\(A’*y))’
a =
0.4500 0.6500 0.7500
The parabola is
f(x) = 0.45 −0.65x + 0.75x
2
.
The Matlab command A\y produces the same answer. It uses the normal equa
tions with the Cholesky or LU decomposition, or, perhaps, the QR decomposi
tion,
Ex. 11.18. Determine and sketch the Gershgorin disks that contain the
eigenvalues of the matrix
A =
_
_
−2 1/2 i/2
1/2 0 i/2
−i/2 −i/2 2
_
_
.
322 SOLUTIONS TO EXERCISES FOR NUMERICAL METHODS
Solution. The centres, c
i
, and radii, r
i
, of the disks are
c
1
= −2, r
1
= [1/2[ +[i/2[ = 1,
c
2
= 0, r
2
= [1/2[ +[i/2[ = 1,
c
3
= 2, r
3
= [ −i/2[ +[i/2[ = 1.
Note that the eigenvalues are real since the matrix A is symmetric, A
T
= A.
Solutions to Exercises for Chapter 12
The Mﬁle exr5_25 for Exercises 12.3, 12.8, 12.13 and 12.12 is
function yprime = exr5_25(x,y); % Exercises 12.3, 12.8, 12.13 and 12.25.
yprime = x+cos(y);
Ex. 12.3. Use Euler’s method with h = 0.1 to obtain a fourdecimal ap
proximation for the initial value problem
y
′
= x + cos y, y(0) = 0
on 0 ≤ x ≤ 1 and plot the numerical solution.
Solution. The Matlab numeric solution.— Euler’s method applied to
the given diﬀerential equation:
clear
h = 0.1; x0= 0; xf= 1; y0 = 0;
n = ceil((xfx0)/h); % number of steps
%
count = 2; print_time = 1; % when to write to output
x = x0; y = y0; % initialize x and y
output1 = [0 x0 y0];
for i=1:n
z = y + h*exr5_25(x,y);
x = x + h;
if count > print_time
output1 = [output1; i x z];
count = count  print_time;
end
y = z;
count = count + 1;
end
output1
save output1 %for printing the graph
The command output1 prints the values of n, x, and y.
n x y
0 0 0
1.00000000000000 0.10000000000000 0.10000000000000
2.00000000000000 0.20000000000000 0.20950041652780
3.00000000000000 0.30000000000000 0.32731391010682
4.00000000000000 0.40000000000000 0.45200484393704
5.00000000000000 0.50000000000000 0.58196216946658
6.00000000000000 0.60000000000000 0.71550074191996
SOLUTIONS TO EXERCISES FOR CHAPTER 12 323
7.00000000000000 0.70000000000000 0.85097722706339
8.00000000000000 0.80000000000000 0.98690209299587
9.00000000000000 0.90000000000000 1.12202980842386
10.00000000000000 1.00000000000000 1.25541526027779
Ex. 12.8. Use the improved Euler method with h = 0.1 to obtain a four
decimal approximation for the initial value problem
y
′
= x + cos y, y(0) = 0
on 0 ≤ x ≤ 1 and plot the numerical solution.
Solution. The Matlab numeric solution.—The improved Euler method
applied to the given diﬀerential equation:
clear
h = 0.1; x0= 0; xf= 1; y0 = 0;
n = ceil((xfx0)/h); % number of steps
%
count = 2; print_time = 1; % when to write to output
x = x0; y = y0; % initialize x and y
output2 = [0 x0 y0];
for i=1:n
zp = y + h*exr5_25(x,y); % Euler’s method
z = y + (1/2)*h*(exr5_25(x,y)+exr5_25(x+h,zp));
x = x + h;
if count > print_time
output2 = [output2; i x z];
count = count  print_time;
end
y = z;
count = count + 1;
end
output2
save output2 %for printing the graph
The command output2 prints the values of n, x, and y.
n x y
0 0 0
1.00000000000000 0.10000000000000 0.10475020826390
2.00000000000000 0.20000000000000 0.21833345972227
3.00000000000000 0.30000000000000 0.33935117091202
4.00000000000000 0.40000000000000 0.46622105817179
5.00000000000000 0.50000000000000 0.59727677538612
6.00000000000000 0.60000000000000 0.73088021271199
7.00000000000000 0.70000000000000 0.86552867523997
8.00000000000000 0.80000000000000 0.99994084307400
9.00000000000000 0.90000000000000 1.13311147003613
10.00000000000000 1.00000000000000 1.26433264384505
324 SOLUTIONS TO EXERCISES FOR NUMERICAL METHODS
Ex. 12.13. Use the Runge–Kutta method of order 4 with h = 0.1 to obtain
a sixdecimal approximation for the initial value problem
y
′
= x + cos y, y(0) = 0
on 0 ≤ x ≤ 1 and plot the numerical solution.
Solution. The Matlab numeric solution.— The Runge–Kutta method
of order 4 applied to the given diﬀerential equation:
clear
h = 0.1; x0= 0; xf= 1; y0 = 0;
n = ceil((xfx0)/h); % number of steps
%
count = 2; print_time = 1; % when to write to output
x = x0; y = y0; % initialize x and y
output3 = [0 x0 y0];
for i=1:n
k1 = h*exr5_25(x,y);
k2 = h*exr5_25(x+h/2,y+k1/2);
k3 = h*exr5_25(x+h/2,y+k2/2);
k4 = h*exr5_25(x+h,y+k3);
z = y + (1/6)*(k1+2*k2+2*k3+k4);
x = x + h;
if count > print_time
output3 = [output3; i x z];
count = count  print_time;
end
y = z;
count = count + 1;
end
output3
save output3 % for printing the graph
The command output3 prints the values of n, x, and y.
n x y
0 0 0
1.00000000000000 0.10000000000000 0.10482097362427
2.00000000000000 0.20000000000000 0.21847505355285
3.00000000000000 0.30000000000000 0.33956414151249
4.00000000000000 0.40000000000000 0.46650622608728
5.00000000000000 0.50000000000000 0.59763447559658
6.00000000000000 0.60000000000000 0.73130914485224
7.00000000000000 0.70000000000000 0.86602471267959
8.00000000000000 0.80000000000000 1.00049620051241
9.00000000000000 0.90000000000000 1.13371450064800
10.00000000000000 1.00000000000000 1.26496830711844
SOLUTIONS TO EXERCISES FOR CHAPTER 12 325
Ex. 12.25. Use the Adams–Bashforth–Moulton fourstep predictorcorrector
method with h = 0.1 to obtain a sixdecimal approximation for the initial value
problem
y
′
= x + cos y, y(0) = 0
on 0 ≤ x ≤ 1, estimate the local error at x = 0.5, and plot the numerical solution.
Solution. The Matlab numeric solution.— The initial conditions and
the Runge–Kutta method of order 4 are used to obtain the four starting values
for the ABM fourstep method.
clear
h = 0.1; x0= 0; xf= 1; y0 = 0;
n = ceil((xfx0)/h); % number of steps
%
count = 2; print_time = 1; % when to write to output
x = x0; y = y0; % initialize x and y
output4 = [0 x0 y0 0];
%RK4
for i=1:3
k1 = h*exr5_25(x,y);
k2 = h*exr5_25(x+h/2,y+k1/2);
k3 = h*exr5_25(x+h/2,y+k2/2);
k4 = h*exr5_25(x+h,y+k3);
z = y + (1/6)*(k1+2*k2+2*k3+k4);
x = x + h;
if count > print_time
output4 = [output4; i x z 0];
count = count  print_time;
end
y = z;
count = count + 1;
end
% ABM4
for i=4:n
zp = y + (h/24)*(55*exr5_25(output4(i,2),output4(i,3))...
59*exr5_25(output4(i1,2),output4(i1,3))+...
37*exr5_25(output4(i2,2),output4(i2,3))...
9*exr5_25(output4(i3,2),output4(i3,3)) );
z = y + (h/24)*( 9*exr5_25(x+h,zp)+...
19*exr5_25(output4(i,2),output4(i,3))...
5*exr5_25(output4(i1,2),output4(i1,3))+...
exr5_25(output4(i2,2),output4(i2,3)) );
x = x + h;
if count > print_time
errest = (19/270)*(zzp);
output4 = [output4; i x z errest];
count = count  print_time;
end
y = z;
326 SOLUTIONS TO EXERCISES FOR NUMERICAL METHODS
count = count + 1;
end
output4
save output4 %for printing the grap
The command output4 prints the values of n, x, and y.
n x y Error estimate
0 0 0 0
1.00000000000000 0.10000000000000 0.10482097362427 0
2.00000000000000 0.20000000000000 0.21847505355285 0
3.00000000000000 0.30000000000000 0.33956414151249 0
4.00000000000000 0.40000000000000 0.46650952510670 0.00000234408483
5.00000000000000 0.50000000000000 0.59764142006542 0.00000292485029
6.00000000000000 0.60000000000000 0.73131943222018 0.00000304450366
7.00000000000000 0.70000000000000 0.86603741396612 0.00000269077058
8.00000000000000 0.80000000000000 1.00050998975914 0.00000195879670
9.00000000000000 0.90000000000000 1.13372798977088 0.00000104794662
10.00000000000000 1.00000000000000 1.26498035231682 0.00000017019624
The numerical solutions for Exercises 12.3, 12.8, 12.13 and 12.25 are plotted
by the commands:
load output1; load output2; load output3; load output4;
subplot(2,2,1); plot(output1(:,2),output1(:,3));
title(’Plot of solution y_n for Exercise 5.3’);
xlabel(’x_n’); ylabel(’y_n’);
subplot(2,2,2); plot(output2(:,2),output2(:,3));
title(’Plot of solution y_n for Exercise 5.8’);
xlabel(’x_n’); ylabel(’y_n’);
subplot(2,2,3); plot(output3(:,2),output3(:,3));
title(’Plot of solution y_n for Exercise 5.13’);
xlabel(’x_n’); ylabel(’y_n’);
subplot(2,2,4); plot(output4(:,2),output4(:,3));
title(’Plot of solution y_n for Exercise 5.25’);
xlabel(’x_n’); ylabel(’y_n’);
print deps Fig9_3
SOLUTIONS TO EXERCISES FOR CHAPTER 12 327
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
1.2
1.4
Plot of solution y
n
for Exercise 5.3
x
n
y
n
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
1.2
1.4
Plot of solution y
n
for Exercise 5.8
x
n
y
n
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
1.2
1.4
Plot of solution y
n
for Exercise 5.13
x
n
y
n
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
1.2
1.4
Plot of solution y
n
for Exercise 5.25
x
n
y
n
Figure 13.3. Graph of numerical solutions of Exercises 12.3
(Euler), 12.8 (improved Euler), 12.13 (RK4) and 12.25 (ABM4).
Index
absolute error, 147
absolutely stable method for ODE, 249
absolutely stable multistep method, 258
Adams–Bashforth multistep method, 258
Adams–Bashforth–Moulton method
fourstep, 261
threestep, 260
Adams–Moulton multistep method, 258
Aitken’s process, 166
amplitude, 37
analytic function, 93
backward diﬀerentiation formula, 271
BDF (backward diﬀerentiation formula, 271
bisection method, 151
Bonnet recurrence formula, 300
Butcher tableau, 241
centered formula for f
′′
(x), 188
centred formula for f
′
(x), 188
Cholesky decomposition, 215
clamped boundary, 184
clamped spline, 184
classic Runge–Kutta method, 242
composite integration rule
midpoint, 196
Simpson’s, 200
trapezoidal, 198
condition number of a matrix, 220
consistent method for ODE, 248
convergence criterion of Cauchy, 91
convergence criterion of d’Alembert, 92
convergence of series
uniform, 90
convergence of series s
absolute, 90
convergent method for ODE, 247
corrector, 259
cubic spline, 184
diagonally dominant matrix, 216
divided diﬀerence
kth, 177
ﬁrst, 175
divided diﬀerence table, 177
Dormand–Prince pair
sevenstage, 254
DP(5,4)7M, 254
eigenvalue of a matrix, 226
eigenvector, 226
equation
Legendre, 95
error, 147
Euclidean matrix norm, 220
Euler’s method, 236
exact solution of ODE, 235
existence of analytic solution, 94
explicit multistep method, 258, 268
extreme value theorem, 150
ﬁrst forward diﬀerence, 178
ﬁrstorder initial value problem, 235
ﬁxed point, 154
attractive, 154
indiﬀerent, 154
repulsive, 154
ﬂoating point number, 147
forward diﬀerence
kth, 179
second, 178
free boundary, 184
Frobenius norm of a matrix, 220
FSAL method for ODE, 255
function of order p, 235
Gauss–Seidel iteration, 222
Gaussian quadrature, 103, 204
threepoint, 104, 204
twopoint, 103, 204
Gaussian transformation, 208
inverse, 208
product, 209
generating function
for Pn(x), 100
Gershgorin
disk, 227
Theorem, 227
global Newtonbisection method, 164
329
330 INDEX
Hermite interpolating polynomial, 182
Heun’s method
of order 2, 241
Horner’s method, 169
Householder reﬂection, 230
implicit multistep method, 268
improved Euler’s method, 239
intermediate value theorem, 150
interpolating polynomial
Gregory–Newton
backwarddiﬀerence, 181
forwarddiﬀerence , 179
M¨ uller’s method, 171
Newton divided diﬀerence, 175
parabola method, 171
interval of absolute stability, 249
inverse power method, 229
iterative method, 221
Jacobi iteration, 223
Jacobi method for eigenvalues, 231
l
1
norm
of a matrix, 220
of a vector, 220
l
2
norm
of a matrix, 220
of a vector, 220
l∞norm
of a matrix, 220
of a vector, 220
Lagrange basis, 173
Lagrange interpolating polynomial, 173
Legendre polynomial Pn(x), 139
linear regression, 224
Lipschitz condition, 235
local approximation, 259
local error of method for ODE, 248
local extrapolation, 254
local truncation error, 236, 237, 248
Matlab
fzero function, 166
ode113, 269
ode15s, 277
ode23, 252
ode23s, 277
ode23t, 277
ode23tb, 277
mean value theorem, 150
for integral, 150
for sum, 150
method of false position, 163
method of order p, 248
midpoint rule, 193
multistep method, 258
natural boundary, 184
natural spline, 184
NDF (numerical diﬀerentiation formula, 271
Newton’s method, 159
modiﬁed, 161
Newton–Raphson method, 159
normal equations, 224
normal matrix, 232
numerical diﬀerentiation formula, 271
numerical solution of ODE, 235
operation
gaxpy, 219
saxpy, 218
order of an iterative method, 159
orthogonality relation
for Pn(x), 98
of Ln(x), 132
overdetermined system, 223, 231
partial pivoting, 207
PECE mode, 260
PECLE mode, 260
period, 37
phenomenon of stiﬀness, 270
pivot, 208
polynial
Legendre Pn(x), 101
polynomial
Legendre Pn(x), 97
positive deﬁnite matrix, 215
power method, 228
predictor, 259
principal minor, 215
QR
algorithm, 231
decomposition, 230
quadratic regression, 225
radius of convergence of a series s, 90
rate of convergence, 159
ratio test, 92
rational function, 89
region of absolute stability, 248
regula falsi, 163
relaltive error, 147
residual, 230
Richardson’s extrapolation, 191
RKF(4,5), 255
RKV(5,6), 257
Rodrigues’ formula
for Pn(x), 99
root test, 91
roundoﬀ error, 147, 189, 238
Runge–Kutta method
fourstage, 242
fourthorder, 242
secondorder, 241
thirdorder, 241
Runge–Kutta–Fehlberg pair
INDEX 331
sixstage, 255
Runge–Kutta–Verner pair
eightstage, 257
scaling rows, 213
Schur decomposition, 232
secant method, 162
series
Fourier–Legendre, 101
signum function sign, 149
Simpson’s rule, 194
singular value decomposition, 232
stability function, 249
stiﬀ system, 270
in an interval, 271
stiﬀness ratio, 270
stopping criterion, 158
subordinate matrix norm, 220
substitution
backward, 209
forward, 209
supremum norm
of a vector, 220
threepoint formula for f
′
(x), 188
trapezoidal rule, 194
truncation error, 147
truncation error of a method, 238
twopoint formula for f
′
(x), 187
wellposed problem, 235
zerostable method for ODE, 248
ii
CONTENTS
5.5. Fourier–Legendre Series 5.6. Derivation of Gaussian Quadratures Chapter 6. Laplace Transform 6.1. Deﬁnition 6.2. Transforms of Derivatives and Integrals 6.3. Shifts in s and in t 6.4. Dirac Delta Function 6.5. Derivatives and Integrals of Transformed Functions 6.6. Laguerre Diﬀerential Equation 6.7. Convolution 6.8. Partial Fractions 6.9. Transform of Periodic Functions Chapter 7. Formulas and Tables 7.1. Integrating Factor of M (x, y) dx + N (x, y) dy = 0 7.2. Legendre Polynomials Pn (x) on [−1, 1] 7.3. Laguerre Polynomials on 0 ≤ x < ∞ 7.4. Fourier–Legendre Series Expansion 7.5. Table of Integrals 7.6. Table of Laplace Transforms Part 2. Numerical Methods
101 103 109 109 113 117 125 127 131 133 135 136 139 139 139 140 141 141 141 145 147 147 150 150 154 159 166 168 171 173 173 175 178 181 182 183 187 187 189 191 193 195 197 199
Chapter 8. Solutions of Nonlinear Equations 8.1. Computer Arithmetics 8.2. Review of Calculus 8.3. The Bisection Method 8.4. Fixed Point Iteration 8.5. Newton’s, Secant, and False Position Methods 8.6. Aitken–Steﬀensen Accelerated Convergence 8.7. Horner’s Method and the Synthetic Division 8.8. M¨ ller’s Method u Chapter 9. Interpolation and Extrapolation 9.1. Lagrange Interpolating Polynomial 9.2. Newton’s Divided Diﬀerence Interpolating Polynomial 9.3. Gregory–Newton ForwardDiﬀerence Polynomial 9.4. Gregory–Newton BackwardDiﬀerence Polynomial 9.5. Hermite Interpolating Polynomial 9.6. Cubic Spline Interpolation Chapter 10.1. 10.2. 10.3. 10.4. 10.5. 10.6. 10.7. 10. Numerical Diﬀerentiation and Integration Numerical Diﬀerentiation The Eﬀect of Roundoﬀ and Truncation Errors Richardson’s Extrapolation Basic Numerical Integration Rules The Composite Midpoint Rule The Composite Trapezoidal Rule The Composite Simpson’s Rule
CONTENTS
iii
10.8. Romberg Integration for the Trapezoidal Rule 10.9. Adaptive Quadrature Methods 10.10. Gaussian Quadratures Chapter 11.1. 11.2. 11.3. 11.4. 11.5. 11.6. 11.7. 11.8. 11.9. Chapter 12.1. 12.2. 12.3. 12.4. 12.5. 12.6. 12.7. 12.8. 12.9. Chapter 13.1. 13.2. 13.3. 13.4. 13.5. 13.6. 11. Matrix Computations LU Solution of Ax = b Cholesky Decomposition Matrix Norms Iterative Methods Overdetermined Systems Matrix Eigenvalues and Eigenvectors The QR Decomposition The QR algorithm The Singular Value Decomposition 12. Numerical Solution of Diﬀerential Equations Initial Value Problems Euler’s and Improved Euler’s Method LowOrder Explicit Runge–Kutta Methods Convergence of Numerical Methods Absolutely Stable Numerical Methods Stability of Runge–Kutta methods Embedded Pairs of Runge–Kutta methods Multistep PredictorCorrector Methods Stiﬀ Systems of Diﬀerential Equations 13. The Matlab ODE Suite Introduction The Methods in the Matlab ODE Suite The odeset Options Nonstiﬀ Problems of the Matlab odedemo Stiﬀ Problems of the Matlab odedemo Concluding Remarks
201 203 204 207 207 215 219 221 223 226 230 231 232 235 235 236 239 247 248 249 252 257 270 279 279 279 282 284 284 288 289 291 293 293 295 296 298 299 301 305 305 307 308
Bibliography Part 3. Exercises and Solutions
Exercises for Diﬀerential Equations and Laplace Transforms Exercises for Chapter 1 Exercises for Chapter 2 Exercises for Chapter 3 Exercises for Chapter 4 Exercises for Chapter 5 Exercises for Chapter 6 Exercises for Numerical Methods Exercises for Chapter 8 Exercises for Chapter 9 Exercises for Chapter 10
iv
CONTENTS
Exercises for Chapter 11 Exercises for Chapter 12 Solutions to Solutions Solutions Solutions Solutions Index Exercises for Numerical Methods to Exercises for Chapter 8 to Exercises for Chapter 9 to Exercises for Chapter 11 to Exercises for Chapter 12
310 312 315 315 317 318 322 329
Part 1
Diﬀerential Equations and Laplace Transforms
(2) y ′′ + 4y = 0. The solution y = g(x) describes a curve. ∞[. y ′ . := 2y(x) = 2 e2x . in the xyplane. 3 . b[ is a function y = g(x) of x such that the diﬀerential equation becomes an identity in x on ]a. y) = c. respectively. b[ when g(x).S. etc. (2) and (3) are of order 1. d : dx (d) An implicit solution is a curve which is deﬁned by an equation of the form G(x. (3) x2 y ′′′ y ′ + 2 exy ′′ = (x2 + 2)y 2 .H. := y ′ (x) = 2 e2x . Here are three ordinary diﬀerential equations.H. or trajectory.S.. g ′ (x). for all x. R. are substituted for y. we have L.S. ∂x2 ∂y (b) The order of a diﬀerential equation is equal to the highestorder derivative. We thus have an identity in x on ] − ∞.H.CHAPTER 1 FirstOrder Ordinary Diﬀerential Equations 1. where ′ := (1) y ′ = cos x. The above equations (1). (c) An explicit solution of a diﬀerential equation with independent variable x on ]a. Here is a partial diﬀerential equation: ∂2u ∂2u + 2 = 0.H. = R.1.S. etc. Hence L. 2 and 3. We see that the function y(x) = e2x is an explicit solution of the diﬀerential equation dy = 2y. Fundamental Concepts (a) A diﬀerential equation contains one or several derivatives and an equal sign “=”. dx In fact. in the diﬀerential equation.
1(a)). (a) Two oneparameter families of curves: (a) y = sin x + c. Putting c = 1. (See Fig. Given an arbitrary point (x0 . there is one and only one curve of the family which goes through that point. we see that the oneparameter family of functions y(x) = c ex is the general solution of the diﬀerential equation y ′ = y.1. 1. . (b) y = c exp(x). “=”. on − 1 < x < 1. which goes through the point (0. y0 ) of the plane. y > 0. letting y be a function of x and diﬀerentiating the equation of the curve with respect to x. dx dx we obtain 2x + 2yy ′ = 0 or yy ′ = −x. is an implicit solution of the diﬀerential equation In fact. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS y c=1 1 c=0 0 –2 (a) c = –2 x 0 –1 –2 1 y c=1 x c=–1 c = –2 (b) Figure 1.4 1. The oneparameter family of functions y(x) = sin x + c is the general solution of the ﬁrstorder diﬀerential equation y ′ (x) = cos x. y(x) = sin x + 1. (e) The general solution of a diﬀerential equation of order n contains n arbitrary constants. x2 + y 2 − 1 = 0. yy ′ = −x. 1) of R2 . Thus it describes a curve in the xyplane. We remark that an implicit solution always contains an equal sign. Similarly. d 2 d (x + y 2 − 1) = 0 = 0. We see that the curve in the xyplane. followed by a constant. we have the unique solution.
3) is +c1 = ec1 e−x 2 . dx dx d d (RHS) = [F (x) + c] = F ′ (x) = f (x).1. y Taking the exponential of the solution. (1. (See Fig. the general solution dy = − 2x dx + c1 =⇒ ln y = −x2 + c1 . we have y(x) = e−x which we rewrite in the form y(x) = c e−x . SEPARABLE EQUATIONS 5 Setting c = −1.1): d d (LHS) = G (y(x)) = G′ (y(x)) y ′ (x) = g(y)y ′ .1) g(y) dx We rewrite the equation using the diﬀerentials dy and dx and separate it by grouping on the lefthand side all terms containing y and on the righthand side all terms containing x: g(y) dy = f (x) dx. −1) of R2 . since it contains an arbitrary constant. f (x) dx + c. we verify that (1.2. Given an arbitrary point (x0 . y0 ) of the plane. Solution. Separable Equations Consider a separable diﬀerential equation of the form dy = f (x). we have the unique solution. with y(0) = y0 . Letting y = y(x) be a function of x. or K(x.3) is a solution of (1.1.2. These two forms of the implicit solution deﬁne y as a function of x or x as a function of y. dx dx Example 1. Solve the initial value problem y ′ = −2xy. 1 + y2 Thus y(x) = tan(x + c) is a general solution. (1.2) The solution of a separated equation is obtained by taking the indeﬁnite integral (primitive or antiderivative) of both sides and adding an arbitrary constant: g(y) dy = that is G(y) = F (x) + c. we have dy = dx + c =⇒ arctan y = x + c. 1.2. Since the diﬀerential equation is separable. 1. Example 1. there is one and only one curve of the family which goes through that point. y) = −F (x) + G(y) = c. (1. which goes through the point (0. Solution.1(b)). Since the diﬀerential equation is separable. Solve y ′ = 1 + y 2 . 2 2 y(x) = −ex .
100 = 30 + c =⇒ c = 70. dt T − 30 then ln T − 30 = −kt + c1 T − 30 = e At t = 0. Finally. The initial temperature of the ball is 100 degrees. We remark that the additive constant c1 has become a multiplicative constant after exponentiation. 70 = 30 + 70 e−3k =⇒ e−3k = When T (t) = 31. the ball’s temperature is 70 degrees. Example 1. the rate of change of the temperature T (t) of a body in a surrounding medium of temperature T0 is proportional to the temperature diﬀerence T (t) − T0 .2 shows three bell functions which are members of the oneparameter family of the general solution. 2 c=1 x c = –2 dT = −k(T − T0 ). Three bell functions. we have t ln 3 4 7 = ln 1 70 . Figure 1. after 3 min. when will it be 31 degrees? Solution. 70 + 30 =⇒ e−3k t/3 Taking the logarithm of both sides. 4 . dt Let a copper ball be immersed in a large basin containing a liquid whose constant temperature is 30 degrees.6 1.2. This solution is unique. According to Newton’s law of cooling. 7 = 1 . Since the diﬀerential equation is separable: dT dT = −k(T − 30) =⇒ = −k dt.3. . At t = 3. If. is y(x) = y0 e−x . 31 = 70 e−3k t/3 c1 −kt (additive constant) −kt = ce −kt (multiplicative constant) T (t) = 30 + c e . FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS y 1 0 –1 –2 Figure 1. the solution which satisﬁes the initial condition.
Equations with Homogeneous Coeﬃcients Definition 1.78 min ln(4/7) −0. 2 + 1) u(u y Since integrating the lefthand side of this equation seems diﬃcult. u) x Its general solution is N (1. Solution. dy = x du + u dx. u) du = 0.56 1.3. M (1. dx = y du + u dy.1. u) du = − . y). λy) = λs M (x. for all x. Solve 2xyy ′ − y 2 + x2 = 0. u) + uN (1. xs M (1. let us restart with the substitution y = xu. We rewrite the equation in diﬀerential form: Since the coeﬃcients are homogeneous functions of degree 2 in x and y.1.25 ln(1/70) =3× = 22. u)] dx + xN (1. let x = yu. y)dy = 0. This equation separates.4) Diﬀerential equations with homogeneous coeﬃcients of the same degree are separable as follows. (1. [M (1. M (1. EQUATIONS WITH HOMOGENEOUS COEFFICIENTS 7 Hence t=3 −4. u)[x du + u dx] = 0.3. (u2 − 1)y du + [(u2 − 1)u + 2u] dy = 0.5) separable.5) Then either substitution y = xu(x) or x = yu(y) makes (1. y)dx + N (x. u) + uN (1. dx N (1. y. . and substituting in (1. u) + uN (1. (x2 − y 2 ) dx + 2xy dy = 0. A function M (x. Proof. M (x. xu) dx + N (x. we have dy = x du + u dx. xu)[x du + u dx] = 0. Letting y = xu. Theorem 1. (u2 − 1)[y du + u dy] + 2u dy = 0. Substituting these expressions in the last equation we obtain (y 2 u2 − y 2 )[y du + u dy] + 2y 2 u dy = 0. (1.4. y) is said to be homogeneous of degree s simultaneously in x and y if M (λx.5). u) Example 1. Consider a diﬀerential equation with homogeneous coeﬃcients of degree s. M (x. λ.1. dy u2 − 1 du = − . u) du = − ln x + c. u) dx + xs N (1.
Then. The general solution describes a oneparameter family of circles with centre (r.5. y 2 + x2 = cx. we have (x − r)2 + y 2 = r2 . . Oneparameter family of circles with centre (r. g y x dx − dy = 0. 0) and radius r (see Fig. Solve the diﬀerential equation y′ = g y . Rewriting this equation in diﬀerential form. x Solution. (x2 − x2 u2 ) dx + 2x2 u[x du + u dx] = 0. x Integrating this last equation is easy: ln(u2 + 1) = − ln x + c1 . dy = x du + u dx. we see that this is an equation with homogeneous coeﬃcients of degree zero in x and y. y x 2 x The general solution is + 1 = ec1 = c. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS y r3 r1 r2 x Figure 1.3. [(1 − u2 ) + 2u2 ] dx + 2ux du = 0.8 1. 2u du = − 1 + u2 dx + c1 . Putting c = 2r in this formula and adding r2 to both sides. 1. ln x(u2 + 1) = c1 . 0). Example 1. With the substitution y = xu.3).
of one single piece and without holes) set Ω ∈ R2 . y) dy = 0 is exact if and only if ∂M ∂N = . ∂x ∂u = N.7).1. we see that ∂u = M.10) is exact. y) ∈ Ω. x du = [g(u) − u] dx. Let M (x.6) It can therefore be integrated directly.2. The ﬁrstorder diﬀerential equation M (x.7) (1.11) (1. y) dy = 0 is exact if its lefthand side is the total. y) = c. y). ∂y (1. g(u) − u x Finally one substitute u = y/x in the solution after the integration.8) ∂u ∂u dx + dy ∂x ∂y (1.6) is exact.10) Proof. diﬀerential du = of some function u(x. Exact Equations Definition 1.6) and (1.4. ∂y ∂x ∂u = M.9) (1.4. y) dx + N (x. y) and N (x. or exact. dx du = . ∂u = N.6) to be exact. y) dx + N (x. 1. Theorem 1. Necessity: Suppose (1. y) be continuous functions with continuous ﬁrstorder partial derivatives on a connected and simply connected (that is. Then the diﬀerential equation M (x. EXACT EQUATIONS 9 the last equation separates: g(u) dx − x du − u dx = 0. then du = 0 and by integration we see that its general solution is u(x. ∂x Therefore.2. Then . ∂y (1. ∂y ∂y∂x ∂x∂y ∂x for all (x. x The following important theorem gives a necessary and suﬃcient condition for equation (1. Comparing the expressions (1. du = g(u) − u dx + c. ∂2u ∂2u ∂N ∂M = = = . If equation (1.
∂x∂y ∂x Integrating with respect to x. y) = Then. Taking we have dF = F (x. Let the function ϕ(x. and the solution that satisﬁes the initial condition y(1) = −1.10 1. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS where exchanging the order of diﬀerentiation with respect to x and y is allowed by the continuity of the ﬁrst and last terms. y) + B ′ (y). A practical method for solving exact diﬀerential equations will be illustrated by means of examples. ∂x For example. we may take ϕ(x.6. by (1. y) = ϕ(x. Find the general solution of 3x(xy − 2) dx + (x3 + 2y) dy = 0. y) dx. Example 1. ∂ϕ ∂ϕ dx + dy − B ′ (y) dy ∂x ∂y = M dx + N dy + B ′ (y) dy − B ′ (y) dy y ﬁxed. ∂y ∂x∂y ∂x = N (x. y) dy.11) holds. y) dx + N (x. ∂M ∂2ϕ = ∂y∂x ∂y ∂N . y) − B(y). = ∂x Since ∂2ϕ ∂ 2ϕ = ∂y∂x ∂x∂y by the continuity of both sides. we obtain ∂2ϕ ∂N ∂ϕ = dx = dx.11). = M dx + N dy. We construct a function F (x. y) such that dF (x. . Plot that solution for 1 ≤ x ≤ 4. y) = M (x. y) ∈ C 2 (Ω) be such that ∂ϕ = M. we have ∂2ϕ ∂N = . Suﬃciency: Suppose that (1. y ﬁxed. M (x.
(a) Analytic solution by the practical method. then u(x. y) = c. and from we have = x3 y − 3x2 + T (y). It is essential that T ′ (y) be a function of y only.4. a curve). (3x2 y − 6x) dx + T (y) y ﬁxed. ∂y ∂u ∂ 3 x y − 3x2 + T (y) = ∂y ∂y = x3 + T ′ (y) = N = x3 + 2y. x3 y − 3x2 + y 2 = c. containing an arbitrary constant and an equal sign “=” (that is. We integrate T ′ (y): T (y) = y 2 . EXACT EQUATIONS 11 Solution. y) = = M (x. ∂y ∂x ∂M ∂N = . y) = x3 y − 3x2 + y 2 . From ∂u = M. u(x.— We verify that the equation is exact: ∂N ∂M = 3x2 . we put x = 1 and y = −1 in the general solution and get Hence the implicit solution which satisﬁes the initial condition is x3 y − 3x2 + y 2 = −3. An integration constant is not needed at this stage since such a constant will appear in u = c. ∂x we have u(x. = 3x2 . ∂u = N. Thus T ′ (y) = 2y. is Using the initial condition y(1) = −1 to determine the value of the constant c. y) dx + T (y). . it is exact and hence can be integrated. Hence. we have the surface Since du = 0. M = 3x2 y − 6x. c = −3.1. and the (implicit) general solution. otherwise there is an error somewhere: either the equation is not exact or there is a computational mistake. ∂y ∂x Indeed. N = x3 + 2y.
%MAT 2331.y). (b) Solution by symbolic Matlab.7. 23. Find the general solution of and the solution that satisﬁes the initial condition y(1) = −1. % solution for x=1 to x=4 y0 = 1.V. title(’Plot of solution to initial value problem for Example 1.6 Example 1.6. xlabel(’x’).y0). The call to the ode23 solver and the plot command are: >> >> >> >> >> >> >> xspan = [1 4].6’).’y(1)=1’.’x’) y = 1/2*x^31/2*(x^6+12*x^212)^(1/2) (c) Solution to I. yprime = 3*x*(x*y2)/(x^3+2*y). in the preceding command: >> y = dsolve(’(x^3+2*y)*Dy=3*x*(x*y2)’.1).’x’) y = [ 1/2*x^3+1/2*(x^6+12*x^2+4*C1)^(1/2)] [ 1/2*x^31/2*(x^6+12*x^2+4*C1)^(1/2)] The solution to the initial value problem is the lower branch with C1 = −3.exp1.m is function yprime = exp1_6(x.2.12 1. by numeric Matlab. ylabel(’y(x)’). Graph of solution to Example 1.xspan.%Matlab 5 format using xspan subplot(2. Plot that solution for 1 ≤ x ≤ 4.y] = ode23(’exp1_6’.— We use the initial condition y(1) = −1.6. Exp 1. print Fig. as is seen by inserting the initial condition ’y(1)=1’. (2x3 − xy 2 − 2y + 3) dx − (x2 y + 2x) dy = 0 . p.6 0 −10 −20 y(x) −30 −40 −50 −60 −70 1 2 x 3 4 Figure 1. % initial condition [x.— The general solution is: >> y = dsolve(’(x^3+2*y)*Dy=3*x*(x*y2)’.4. plot(x.y). The Mﬁle exp1_6. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS Plot of solution to initial value problem for Example 1.P.
∂y ∂x ∂N ∂M = . = −2xy − 2. ∂y we have u(x. then u(x. is u(x. Hence the implicit solution which satisﬁes the initial condition is x4 − x2 y 2 − 4xy + 6x = 10. y) = −(x2 y + 2x) since the lefthand side of the diﬀerential equation in standard form is M dx+N dy. We verify that the equation is exact: ∂M ∂N = −2xy − 2. ∂x x ﬁxed.4. . a curve).1. We integrate T ′ (x): x4 T (x) = + 3x. 2 2 Since du = 0. From ∂u = N. we have the surface x2 y 2 x4 − 2xy + + 3x. Hence. otherwise there is an error somewhere: either the equation is not exact or there is a computational mistake. note the negative sign in N (x. ∂y ∂x Hence the equation is exact and can be integrated. Thus T ′ (x) = 2x3 + 3. (−x2 y − 2x) dy + T (x) x2 y 2 − 2xy + T (x). N (x. y) = = =− and from we have ∂u = −xy 2 − 2y + T ′ (x) = M ∂x = 2x3 − xy 2 − 2y + 3. 2 An integration constant is not needed at this stage since such a constant will appear in u = c. c = 10. It is essential that T ′ (x) be a function of x only. y) dy + T (x). y) = c. and the (implicit) general solution. 2 ∂u = M.— First. containing an arbitrary constant and an equal sign “=” (that is. y) = − Putting x = 1 and y = −1. (a) Analytic solution by the practical method. we have x4 − x2 y 2 − 4xy + 6x = c. EXACT EQUATIONS 13 Solution.
% initial condition [x. The call to the ode23 solver and theplot command: >> >> >> >> >> xspan = [1 4].1).V. by numeric Matlab. .’y(1)=1’. p.14 1.exp1.y] = ode23(’exp1_7’. subplot(2. plot(x.P. yprime = (2*x^3x*y^22*y+3)/(x^2*y+2*x).— The general solution is: >> y = dsolve(’(x^2*y+2*x)*Dy=(2*x^3x*y^22*y+3)’.8.xspan. Example 1.’x’) y =(2+(6+6*x+x^4)^(1/2))/x (c) Solution to I.5.2.y). Solve x dy − y dx = 0. Exp 1. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS Plot of solution to initial value problem for Example 1.y0). (b) Solution by symbolic Matlab. print Fig.m is function yprime = exp1_7(x.7 The following example shows that the practical method of solution breaks down if the equation is not exact. Solution.7.’x’) y = [ (2(4+6*x+x^4+2*C1)^(1/2))/x] [ (2+(4+6*x+x^4+2*C1)^(1/2))/x] The solution to the initial value problem is the lower branch with C1 = −5.y).7 4 3 2 y(x) 1 0 1 1 2 x 3 4 Figure 1.— We use the initial condition y(1) = −1. >> y = dsolve(’(x^2*y+2*x)*Dy=(2*x^3x*y^22*y+3)’.7. %MAT 2331. The Mﬁle exp1_7. Graph of solution to Example 1. % solution for x=1 to x=4 y0 = 1. We rewrite the equation in standard form: y dx − x dy = 0. 23.
Example 1. (1. My = 1 = −1 = Nx . l so that the equation is exact. My = b. Consider the diﬀerential equation (ax + by) dx + (kx + ly) dy = 0. b. Solution. l arbitrary. µ(x. (ax + by) dx = ax2 + bxy + T (y). k. Choose a. INTEGRATING FACTORS 15 The equation is not exact since Anyway. y) dy = 0. Thus. u(x. y)M (x. T ′ (y) = −2x. uy = x + T ′ (y) = N = −x. it can be made exact by multiplication by an integrating factor µ(x.12) is not exact.14). ∂x ∂y 1.5. y) dx + N (x. 2 2 a. y) dy = 0 (1. 2 ly 2 uy = bx + T ′ (y) = N = bx + ly =⇒ T ′ (y) = ly =⇒ T (y) = . (1. and equation (1. u= ux dx = M dx = Nx = k =⇒ k = b. . uy := . y). y)N (x. we have My = µy M + µMy . Integrating Factors If the diﬀerential equation M (x.9.14) ly 2 ax2 + bxy + . 2 2 The following convenient notation for partial derivatives will often be used: ∂u ∂u ux := .1. it is diﬃcult to solve the partial diﬀerential equation (1.13) Rewriting this equation in the form M (x. y) dx + µ(x. But this is impossible since T (y) must be a function of y only. y) = The general solution is ly 2 ax2 + bxy + = c1 or ax2 + 2bxy + ly 2 = c. let us try to solve the inexact equation by the proposed method: u= ux dx = M dx = y dx = yx + T (y).5. y) dx + N (x. In general. b.13) will be exact if Nx = µx N + µNx . 2 Thus. y) dy = 0. µy M + µMy = µx N + µNx .
(a) The analytic solution. . then (1. µ N Integrating this separated equation. if µ = µ(y) is a function of y only. we obtain the integration factor µ(x) = e R f (x) dx . we obtain the integration factor µ(y) = e− R g(y) dy .18) is separable: M µ′ (y) = −µ(My − Nx ). (1. µ = µ(x) or µ = µ(y). Case 1.20) One has to notice the presence of the negative sign in (1.19) dµ M y − Nx =− dy = −g(y) dy.18) (1. However. where µ is a function of one variable. then (1.16 1.14) reduces to an ordinary diﬀerential equation: If the lefthand side of the following expression M y − Nx = g(y) M is a function of y only. Thus. since M y − Nx 2x + 4y 2(x + 2y) 2 = = = = f (x) N x(x + 2y) x(x + 2y) x is a function of x only. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS We consider two particular cases. 2 Multiplying the diﬀerential equation by x2 produces the exact equation x2 (4xy + 3y 2 − x) dx + x3 (x + 2y) dy = 0.17). (1. then µx = µ′ (x) and µy = 0. we have the integrating factor µ(x) = e R (2/x) dx Nx = 2x + 2y = e2 ln x = eln x = x2 . (1. that is. Solution.14) reduces to an ordinary diﬀerential equation: If the lefthand side of the following expression M y − Nx = f (x) N is a function of x only.20) and its absence in (1.15) (1.16) M y − Nx dµ = dx = f (x) dx. If µ = µ(x) is a function of x only. (1.10. then µx = 0 and µy = µ′ (y). (1. Thus. (1. Similarly. Find the general solution of the diﬀerential equation (4xy + 3y 2 − x) dx + x(x + 2y) dy = 0.15) is separable: N µ′ (x) = µ(My − Nx ).17) Case 2. Example 1. µ M Integrating this separated equation. and M y = Nx .— This equation is not exact since My = 4x + 6y.
Solution. (a) The analytic solution. y) = (x4 + 2x3 y) dy + T (x) = x4 y + x3 y 2 + T (x). The integrating factor is µ(y) = e− R g(y) dy Since =e R (1/y) dy = eln y = y. M y(x + y + 1) y which is a function of y only. = 4x3 y + 3x2 y 2 − x3 .1.m at line 200 y = [ empty sym ] but it solves the exact equation >> y = dsolve(’x^2*(x^3+2*y)*Dy=3*x^3*(x*y2)’. Multiplying the diﬀerential equation by y produces the exact equation (xy 2 + y 3 + y 2 ) dx + (x2 y + 3xy 2 + 2xy) dy = 0. we try −(x + y + 1) 1 M y − Nx = = − = g(y).— This equation is not exact since My = x + 2y + 1 = Nx = 2x + 3y + 2. 4 No constant of integration is needed here.’x’) y = [ 1/2*x^31/2*(x^6+12*x^2+4*C1)^(1/2)] [ 1/2*x^3+1/2*(x^6+12*x^2+4*C1)^(1/2)] x4 . y) = x4 y + x3 y 2 − and the general solution is x4 = c1 or 4x4 y + 4x3 y 2 − x4 = c. Find the general solution of the diﬀerential equation y(x + y + 1) dx + x(x + 3y + 2) dy = 0.’x’) Warning: Explicit solution could not be found. . −x − y − 1 M y − Nx = N x(x + 3y + 2) is not a function of x only. it will come later.5. x4 4 Example 1. INTEGRATING FACTORS 17 This equation is solved by the practical method: u(x. ux = 4x3 y + 3x2 y 2 + T ′ (x) = µM Thus.— Matlab does not ﬁnd the general solution of the nonexact equation: x4 y + x3 y 2 − >> y = dsolve(’x*(x+2*y)*Dy=(4*x+3*y^2x)’. T ′ (x) = −x3 =⇒ T (x) = − u(x. Hence. 4 (b) The Matlab symbolic solution.1:Toolbox:symbolic:dsolve. > In HD2:Matlab5.11.
This solution does not simplify with the commands simplify and simple. >> u = u u = y^2*(1/2*x^2+y*x+x) % general solution u = c. N = x*(x+3*y+2).’x’) % solution u.— The symbolic Matlab command dsolve produces a very intricate general solution for both the nonexact and the exact equations. The general solution is x2 y 2 + xy 3 + xy 2 = c1 2 or x2 y 2 + 2xy 3 + 2xy 2 = c.’y’) . >> clear >> syms M N x y u >> M = y*(x+y+1). 2 uy = x2 y + 3xy 2 + 2xy + T ′ (y) = µN = x2 y + 3xy 2 + 2xy. 2 (b) The Matlab symbolic solution. y) = and the general solution is x2 y 2 + xy 3 + xy 2 = c1 or x2 y 2 + 2xy 3 + 2xy 2 = c.’x’))/M g = (xy1)/y/(x+y+1) >> g = simple(g) g = 1/y % a function of y only >> mu = exp(int(g.diff(N. x2 y 2 + xy 3 + xy 2 2 . NN = mu*N.NN) DT = 0 % T’(y) = 0 implies T(y) = 0.’x’) % test for exactness test = xy1 % equation is not exact >> syms mu g >> g = (diff(M. We therefore repeat the practical method having symbolic Matlab do the simple algebraic and calculus manipulations.diff(N.18 1.’y’)) % integrating factor mu = y >> syms MM NN >> MM = mu*M. u(x. Hence.’y’) . >> test = diff(M. Thus. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS This equation is solved by the practical method: u(x. T ′ (y) = 0 =⇒ T (y) = 0 since no constant of integration is needed here.’y’) . % multiply equation by integrating factor >> u = int(MM. arbitrary T(y) not included yet u = y^2*(1/2*x^2+y*x+x) >> syms DT >> DT = simple(diff(u. y) = = (xy 2 + y 3 + y 2 ) dx + T (y) x2 y 2 + xy 3 + xy 2 + T (y).
12. µ(x. −1 1 + y 2 dx − dy = 0.1. Solution. Solving this equation by the practical method for exact equations. Note that a separated equation. Hence µ(y) = e− R (2y)/(1+y 2 ) dy 2 −1 that is. g(y) dy. f (x) dx + g(y) dy = 0. 1 + y2 = eln[(1+y ) ]= 1 . y)y dx + µ(x. We have My = 2y. which separates the equation is an integrating Nx = 0. since My = 0 and Nx = 0.3). y) = f (x) dx + g(y) dy = c. xy which makes the equation separable. µ(y) = e− R 0 dy = 1. Show that the factor 1 + y 2 factor. 2y − 0 = g(y). hence it is exact. y) = Solution. INTEGRATING FACTORS 19 Remark 1. Consider the separable equation y′ = 1 + y2. Example 1. we have u(x. y) = f (x) dx + T (y). we have the integrating factors µ(x) = e R 0 dx = 1.1.5. is exact. uy = T ′ (y) = g(y) =⇒ T (y) = u(x. The factor which transforms a separable equation into a separated equation is an integrating factor since the latter equation is exact.13. In fact. This is the solution that was obtained by the method (1. is an integrating factor. y)x dy = is separated. Example 1. y) which is a function of x and y. we easily ﬁnd an integrating factor µ(x. 1 1 dx + dy = 0 x y . The diﬀerential equation µ(x.2. Remark 1. Consider the separable equation y dx + x dy = 0. Show that the factor 1 . 1 + y2 In the next example.
20 1. put u(x. by (1. we say that (1. as claimed.8 the general solution will be expressed as the sum of a general solution of the homogeneous equation (with righthand side equal to zero) and a particular solution of the nonhomogeneous equation. f (x)y dx + dy = r(x) dx. Power series solutions and numerical solutions will be considered in Chapters 5 and 12. (1.6.14. Since My = f (x) and Nx = 0.21) The lefthand side is a linear expression with respect to the dependent variable y and its ﬁrst derivative y ′ . Solve the linear ﬁrstorder diﬀerential equation x2 y ′ + 2xy = sinh 3x.21) by transforming the lefthand side into a total derivative by means of an integrating factor. In Example 3.22) and make it exact. derivative. Hence d e R f (x) dx y(x) = e R f (x) dx r(x) dx.21) is a linear diﬀerential equation. FirstOrder Linear Equations Consider the nonhomogeneous ﬁrstorder diﬀerential equation of the form y ′ + f (x)y = r(x). respectively. y R f (x) dx f (x) dx f (x)y dx + e dy = µ[f (x)y dx + dy] which is the lefthand side of (1. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS 1. we have e R f (x) dx y(x) = e R f (x) dx r(x) dx + c. or total. Solving the last equation for y(x). The ﬁrst way is to rewrite (1.21) multiplied by µ. y) = µ(x)y = e Taking the diﬀerential of u we have du = d e =e R R f (x) dx R f (x) dx y. To see this. As f (x) − 0 M y − Nx = = f (x) N 1 is a function of x only. (1. we see that the general solution of (1. In this case. Integrating both sides with respect to x. we solve equation (1.21) in diﬀerential form. or f (x)y − r(x) dx + dy = 0.17) we have the integration factor µ(x) = e R f (x) dx . this equation is not exact. .21) by µ(x) makes the lefthand side an exact.23) Example 1.21) is y(x) = e− R f (x) dx e R f (x) dx r(x) dx + c . (1. Multiplying (1. In this section.
2 Example 1. d 2 (x y) = sinh 3x. The integrating factor.15. The integrating factor.1. d y 3 e−y x = −2y 2 e−y . we have dx + dy 2 3 −1 x=− . which makes the lefthand side exact. = 2y 2 e−y − 4 = 2y 2 e−y + 4y e−y − 4 The general solution is xy 3 = 2y 2 + 4y + 4 + c ey . Solve the linear ﬁrstorder diﬀerential equation y dx + (3x − xy + 2) dy = 0. which makes the lefthand side exact. Rewriting this equation in standard form. FIRSTORDER LINEAR EQUATIONS 21 Solution. . dx Hence. R (2/x) dx = eln x = x2 . 3 that is. Hence. d(x2 y) = sinh 3x dx. we have y′ + 1 2 y = 2 sinh 3x. x2 y(x) = or y(x) = 1 c cosh 3x + 2 . 3x2 x sinh 3x dx + c = 1 cosh 3x + c. is µ(x) = e Thus. y y y = 0. Solution. is µ(y) = e Then d y 3 e−y x = −2y 2 e−y dy. Rewriting this equation in standard form for the dependent variable x(y). x x This equation is linear in y and y ′ . y 3 e−y x = −2 y 2 e−y dy + c ye−y dy + c e−y dy + c that is. dy R [(3/y)−1] dy = eln y 3 −y = y 3 e−y .6. = 2y 2 e−y + 4y e−y + 4 e−y + c.
y. or dx uy where m is the slope of the curve at the point (x. To eliminate c from this diﬀerential equation we solve the equation F (x. y ′ (x).6). In the second case we have Fx (x. In the ﬁrst case. which is implicit with respect to c.6. c) Fy x. 1. Orthogonal Families of Curves A oneparameter family of curves can be given by an equation u(x. y) dy Fx (x.22 1. a) t = (a. y. y) is a 1 ′ yorth (x) = − = − . y) = c. (1. H(x. the orthogonal family satisﬁes the diﬀerential equation 1 ′ . y. y). of the tangent is b y ′ (x) = = m (1. b) y(x) (x. y). c) = 0 for c as a function of x and y.25) b m (see Fig. Note that this diﬀerential equation does not contain the parameter c. the slope. yorth (x) = − m(x) . c) dy = 0. the curves satisfy the diﬀerential equation ux dy = m. y) Let t = (a. y. Fx x. =− =− dx Fy (x. a) be the normal to the given curve y = y(x) at the point (x. where the parameter c is explicit. Thus. y.7. y). Two curves orthogonal at the point (x. c = H(x. y. 1. yorth (x). y. =− ux dx + uy dy = 0. and substitute this function in the diﬀerential equation. y) of the curve.24) a ′ and the slope. c) = 0. of the curve yorth (x) which is orthogonal to the curve y(x) at (x. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS y n = (– b. y) yorth(x) 0 x Figure 1. y. or by an equation F (x. b) be the tangent and n = (−b. c) = m. Then. H(x. c) dx + Fy (x.
x x y2 y2 ux = − 2 + T ′ (x) = 1 − 2 . x x T ′ (x) = 1 =⇒ T (x) = x. Consider the oneparameter family of circles x2 + (y − c)2 = c2 (1. Since My = −2y and Nx = 2y. Solution. We multiply the diﬀerential equation by µ(x). y) = y2 y dy + T (x) = + T (x). y) = that is. we have (x2 − y 2 ) dx + 2xy dy = 0. 2xyorth Rewriting this equation in diﬀerential form M dx + N dy = 0. the solution x2 + y 2 = c1 x y2 + x = c1 . y−c x2 + y 2 − 2yc + c2 = c2 =⇒ c = x2 + y 2 . but M y − Nx −2y − 2y 2 = = − = f (x) N 2xy x µ(x) = e− y2 x2 R (2/x) dx is a function of x only. Find the diﬀerential equation for this family and the diﬀerential equation for the orthogonal family. and omitting the mention “orth”. 1− dx + 2 y dy = 0. 2 u(x.26) with respect to x. 2y and solving (1.1. ORTHOGONAL FAMILIES OF CURVES 23 Example 1. x 2x + 2(y − c)y ′ = 0 =⇒ y ′ = − . x . this equation is not exact.26) with centre (0. y′ = − 2 − y2 x2 +y 2 2y − x x − y2 y − 2y The diﬀerential equation of the orthogonal family is ′ yorth = − 2 x2 − yorth . c) on the yaxis and radius c. x and solve by the practical method: u(x.26) for c. Solve the latter equation and plot a few curves of both families on the same graph. We obtain the diﬀerential equation of the given family by diﬀerentiating (1.16. Hence = x−2 is an integrating factor.7. Substituting this value for c in the diﬀerential equation. we have 2xy 2xy x =− 2 = 2 .
one can sketch many solution curves at the same time. Second. We may rewrite this equation in the more explicit form: x2 − 2 c2 c2 c1 x + 1 + y2 = 1 . A few curves of each of the orthogonal families. y0 ) has the slope f (x0 . The method of direction ﬁelds apply to any diﬀerential equation of the form y ′ = f (x. short segments indicating the tangent directions of solution curves as determined by (1. A few curves of each of the orthogonal families are plotted in Fig. 2). draw along each isocline f (x. y). 1. ′ (1.27) The idea is to take y as the slope of the unknown solution curve. y) = k many lineal elements of slope k. Direction Fields and Approximate Solutions Approximate solutions of a diﬀerential equation are of practical interest if the equation has no explicit exact solution formula or if that formula is too complicated to be of practical value. Hence one can draw at various point lineal elements. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS y c1 k3 k1 c2 k2 x Figure 1. Example 1. In that case. sketch approximate solutions curves of (1. By this latter method. y0 ) at that point. or one may use the method of direction ﬁelds.27) and then ﬁt solution curves through this ﬁeld of tangent directions.8. The curve that passes through the point (x0 .24 1. f (x. called isoclines. one can use a numerical method (see Chapter 12). without actually solving the equation.17. 2 2 (x − k)2 + y 2 = k 2 . Third.27).28) . The orthogonal family is a family of circles with centre (k. y) = const. 1. (1. Graph the direction ﬁeld of the ﬁrstorder diﬀerential equation y ′ = xy and an approximation to the solution curve through the point (1. First draw curves of constant slopes. 0) on the xaxis and radius k. is a oneparameter family of circles. that is.7.7. 2 4 4 c1 2 c1 2 x− + y2 = . Thus one gets a direction ﬁeld.
y1 . y). . and Lipschitz continuous with respect to y on R. Consider the initial value problem y ′ = f (x. . y) ≤ K. for all y. yn−1 (t) dt. . yn . . deﬁned by the Picard iteration formula. . the solution of problem (1. without proof. . where α = min{a. (1.29) We note that condition (1. y(x0 ) = y0 . but not their equality. .31) converges to the solution y(x). the following existence and uniqueness theorem. Theorem 1. Direction ﬁelds for Example 1. Under the conditions of Theorem 1. y − y0  < b.17. . called Lipschitz constant. Geometrically. that is. y) is continuous and bounded. x yn (x) = y0 + x0 f t. the sequence y0 . Theorem 1.30) admits one and only one solution for all x such that x − x0  < α. (1.3 (Existence and uniqueness theorem).9. We state. Solution.3. such that f (z) − f (y) ≤ M z − y.8 1.8. z ∈]c.30) can be obtained by means of Picard’s method.30) If the function f (x. EXISTENCE AND UNIQUENESS OF SOLUTIONS 25 y 2 1 –1 –1 1 x Figure 1. d[.3. . A function f (y) is said to be Lipschitz continuous on the open interval ]c. The isoclines are the equilateral hyperbolae xy = k together with the two coordinate axes as shown in Fig. Existence and Uniqueness of Solutions Definition 1. then (1. .1. 2. . R : x − x0  < a. (1.9. d[ if there exists a constant M > 0. b/K}. d[. 1.29) implies the existence of left and right derivatives of f (y) of the ﬁrst order. . on the rectangle f (x..3 is applied to the following example. n = 1. the slope of the curve f (y) is bounded on ]c.
The Mﬁle halfcircle. y) = − x dx + y dy = c1 . we need to take the second solution. which is unique. Since y(0) = −2.— The numerical solution of this initial value problem is a little tricky because the general solution y± has two branches. that is. (b) The Matlab symbolic solution. and plot the solution. y ′ = f (x. We see that the slope y ′ (x) of the solution tends to ±∞ as y → 0±. yprime = x/y.— We rewrite the diﬀerential equation in standard form. Since the function y(0) = −2 x2 y2 + = c1 . (a) The analytic solution. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS Example 1. Solution. there will be a solution for y < 0 and another solution for y > 0. x y′ = − . To have a continuous solution in a neighbourhood of y = 0.’x’) y = (x^2+4)^(1/2) (c) The Matlab numeric solution. is y(x) = − 4 − x2 .18. Hence the solution. 2 2 x2 + y 2 = r2 . y).m is function yprime = halfcircle(x. we call the ode23 solver and the plot command as follows.’y(0)=2’. if y > 0.y). We separate the equation and integrate: f (x.26 1. − r if y < 0.— dsolve(’y*Dy=x’. We need a function Mﬁle to run the Matlab ode solver. y x y is not continuous at y = 0. −2 < x < 2. Solve the initial value problem yy ′ + x = 0. we solve for x = x(y). The two solutions are √ r2 − x2 . To handle the lower branch of the general solution. We determine the value of r by means of the initial condition: 02 + (−2)2 = r2 =⇒ r = 2. . The general solution is a oneparameter family of circles with centre at the origin and radius r. √ y± (x) = 2 − x2 .
% span from x = 0 to x = 2 y0 = [0.y0).18.xspan1. on any bounded interval 0 ≤ x ≤ a < ∞. yn−1 (t) dt. Since the function f (x. we shall solve this equation numerically.x2. ∂y f (x. y(0) = 1. Also.y0). . we shall ﬁnd a series solution to the same equation. One will notice that the three methods produce the same series solution.xspan2.y1(:. y) = x.31). . Example 1. . Graph of solution of the diﬀerential equation in Example 1. EXISTENCE AND UNIQUENESS OF SOLUTIONS 27 Plot of solution 0 −1 y −2 −2 −1 0 x 1 2 Figure 1. [x2. y) = 1 + xy has a bounded partial derivative of ﬁrstorder with respect to y. . xspan1 = [0 2].y2] = ode23(’halfcircle’.4. In the following two examples. .y1] = ode23(’halfcircle’.6.9.1. 1. n = 1. Use Picard’s recursive method to solve the initial value problem y ′ = xy + 1.9.19.9. x yn (x) = y0 + x0 f t. Picard’s recursive formula (1. 2]. % span from x = 0 to x = 2 xspan2 = [0 2]. In Example 5. in Example 12. % initial condition [x1.2)) axis(’equal’) xlabel(’x’) ylabel(’y’) title(’Plot of solution’) The numerical solution is plotted in Fig. 2. plot(x1. Solution.9.2). we ﬁnd an approximate solution to a diﬀerential equation by Picard’s method and by the method of Section 1.y2(:.
.. Since the integral cannot be expressed in closed form.’y(0)=1’. 1+x− + − − +. Multiplying the equation by µ(x). Solution. .6 for linear ﬁrstorder diﬀerential equations to solve the initial value problem y ′ − xy = 1. = 1+ 2 8 48 6 40 336 x2 x3 x4 =1+x+ + + + . . An integrating factor that makes the lefthand side an exact derivative is R 2 µ(x) = e− x dx = e−x /2 . dx and integrating from 0 to x. Hence. Putting x = 0 and y(0) = 1..28 1.20. 6 40 336 x4 x6 x3 x5 x7 x2 + + + .’x’) y=1/2*exp(1/2*x^2)*pi^(1/2)*2^(1/2)*erf(1/2*2^(1/2)*x)+exp(1/2*x^2) . Here x0 = 0 and y0 = 1. the symbolic Matlab command dsolve produces the solution in terms of the Maple error function erf(x): y(x) = ex 2 /2 x 1+ 1− >> dsolve(’Dy=x*y+1’.. we obtain e−x 2 /2 x y(x) = 0 e−t 2 /2 dt + c. FIRSTORDER ORDINARY DIFFERENTIAL EQUATIONS converges to the solution y(x). dt 2 8 48 0 2 x3 x5 x7 =ex /2 1 + x − + − − +. 2 3 8 As expected.. Hence.. integrate the second series term by term and multiply the resulting series term by term: t2 t4 t6 + − + − . 2 3 8 1 + ty2 (t) dt. y(x) = ex 2 /2 x 1+ 0 e−t 2 /2 dt .. 2 1 + t + t2 + t3 2 dt =1+x+ x y2 (x) = 1 + 0 =1+x+ x x2 x3 x4 + + . y3 (x) = 1 + 0 and so on.. we see that c = 1. x y1 (x) = 1 + 0 (1 + t) dt x2 . y(0) = 1. we expand the two exponential functions in convergent power series. we have 2 2 d e−x /2 y = e−x /2 .. Example 1. Use the method of Section 1.
Solution. It is seen that y(x) ≡ 0 is a solution of the diﬀerential equation. for a ≤ b. one gets a family of solution to the initial value problem. it is continuous on the whole xyplane. t > b. is also a solution. y) = 2y −1/3 is not even deﬁned at y = 0.9. By varying the other parameter. y) in y ′ = f (x. 3 (x − b) . The righthand side of the equation is continuous for all y and because it is independent of x.1. the solution may not be unique. has nonunique solutions. y). it is not Lipschitz continuous in y at y = 0 since fy (x. y(x) = 0. (x − a)3 . a solution curve can be made to satisfy the initial conditions. but without Lispschitz continuity of the function f (x. t < a. However. By properly choosing the value of the parameter a or b. Hence the solution is not unique. Show that the initial value problem y ′ = 3y 2/3 . a ≤ x ≤ b. Example 1. Moreover. EXISTENCE AND UNIQUENESS OF SOLUTIONS 29 The following example shows that with continuity. y(x0 ) = y0 . .21.
.
CHAPTER 2 SecondOrder Ordinary Diﬀerential Equations In this chapter. y(x) = eλx . Linear Homogeneous Equations Consider the secondorder linear nonhomogeneous diﬀerential equation y ′′ + f (x)y ′ + g(x)y = r(x). d L := an (x)Dn + an−1 (x)Dn−1 + · · · + a1 (x)D + a0 (x). Inserting this function in (2. we obtain the characteristic equation (2.4) (2. dx If the righthand side of (2. The capital letter L will often be used to denote a linear diﬀerential operator. 2.3) To solve this equation we suppose that a solution is of exponential form. (2.6) . It is nonhomogeneous if the righthand side.2) form a vector space. r(x). Further theory on linear nonhomogeneous equations of arbitrary order will be developed in Chapter 3. (2. λ2 + aλ + b = 0 31 2 Since eλx is never zero.3). ′ ′′ (2. Let y1 and y2 be two solutions of (2.2) 2. α. we introduce basic concepts for linear secondorder diﬀerential equations. is not identically zero. is homogeneous. we have λ2 eλx + aλ eλx + b eλx = 0.5) λ + aλ + b = 0.1.1) The equation is linear with respect to y. Linear Homogeneous Equations Consider the secondorder linear homogeneous diﬀerential equation with constant coeﬃcients: y ′′ + ay ′ + by = 0.2.1) is zero. The solutions of (2. Theorem 2. The result follows from the linearity of L: L(αy1 + βy2 ) = αLy1 + βLy2 = 0. β ∈ R.2). we say that the equation Ly := y ′′ + f (x)y ′ + g(x)y = 0.1. e λx (2. Proof. y and y . D= ′ = . We solve linear constant coeﬃcients equations and Euler–Cauchy’s equations.
Let y1 (x) and y2 (x) be two solutions of (2. .8) c1 = c2 = 0. (2. c1 = 0. if. Solution.2.32 2. b].10) f2 (x) then f1 and f2 are linearly independent on [a. Theorem 2.2 = . c2 ) = (0.7) Example 2. Definition 2. If f1 (x) and f2 (x) are linearly dependent on [a. b]. Then.2). is y = c1 y 1 + c2 y 2 . This characterization of linear independence of two functions will often be used. the general solution. In this case. Definition 2. Hence λ1 = −2 and λ2 = −3. 0) such that.2.1. Find the general solution of the linear homogeneous diﬀerential equation with constant coeﬃcients y ′′ + 5y ′ + 6y = 0. The functions f1 (x) and f2 (x) are said to be linearly independent on the interval [a. Otherwise the functions are said to be linearly dependent.3. we have two distinct solutions. SECONDORDER ORDINARY DIFFERENTIAL EQUATIONS √ a2 − 4b λ1.2) if and only if y1 and y2 are linearly independent on [a. for all x ∈ [a. The general solution of the homogeneous equation (2. −a ± y1 (x) = eλ1 x .2) spans the vector space of solutions of (2. b] if the identity implies that c1 f1 (x) + c2 f2 (x) ≡ 0. which contains two arbitrary constants. b]. y2 (x) = eλ2 x . (2. b]. f2 (x) c1 If (2. on [a. the solution y(x) = c1 y1 (x) + c2 y2 (x) is a general solution of (2. then there exist two numbers (c1 . for λ and the eigenvalues (2. we have c2 f1 (x) ≡ − = const. b]. and the general solution is y(x) = c1 e−2x + c2 e−3x . The characteristic equation is λ2 + 5λ + 6 = (λ + 2)(λ + 3) = 0. say. b].2) on [a.1. 2 If λ1 = λ2 . Basis of the Solution Space We generalize to functions the notion of linear independence for two vectors of R2 .9) f1 (x) = const. 2.
y(0) = c1 + c2 = 4. Solve the following initial value problem: y ′′ + y ′ − 2y = 0.— To rewrite the secondorder diﬀerential equation as a system of ﬁrstorder equations. We therefore have the linear system 1 1 Since 1 −2 c1 c2 that is.2. y2 (x) Thus. y(0) = 4.— dsolve(’D2y+Dy2*y=0’. the general solution is y = c1 ex + c2 e−2x . −3 c2 = 1 −3 1 1 4 1 = −3 = 1. are linearly independent since y1 (x) = e3x = const. Ac = 4 1 .3.’y(0)=4’. we put y1 = y. The constants are determined by the initial conditions.— The characteristic equation is λ2 + λ − 2 = (λ − 1)(λ + 2) = 0. . Hence λ1 = 1 and λ2 = −2. c1 = 1 −3 4 1 1 −2 = −9 = 3. The solution of the initial value problem is y(x) = 3 ex + e−2x . Solution. = 4 1 . y ′ (x) = c1 ex − 2c2 e−2x . The proof will be given in Chapter 3 for equations of order n. Example 2. This solution is easily computed by Cramer’s rule.’Dy(0)=1’. −3 det A = −3 = 0. The two solutions y1 (x) = ex . This solution is unique. y2 (x) = e−2x the solution c is unique.2. The next example illustrates the use of the general solution. y ′ (0) = c1 − 2c2 = 1. (b) The Matlab symbolic solution. y2 = y ′ .’x’) y = 3*exp(x)+exp(2*x) (c) The Matlab numeric solution. (a) The analytic solution. BASIS OF THE SOLUTION SPACE 33 Proof. y ′ (0) = 1.
SECONDORDER ORDINARY DIFFERENTIAL EQUATIONS Plot of solution 200 150 100 y 50 0 0 1 2 x 3 4 Figure 2. .1)) The numerical solution is plotted in Fig. we have ′ y1 = y2 . % solution for x=0 to x=4 y0 = [4.2. it was seen in Section 2. 1]. yprime = [y(2). % initial conditions [x. 2*y(1)y(2)].1). 2.4. y1 (x) = eλ1 x .12) Case I.xspan.1.y). ¯ There are three cases: λ1 = λ2 real. depends on the form of the roots λ1.y] = ode23(’exp22’. In the case of two real distinct eigenvalues. The Mﬁle exp22.2 = of the characteristic equation λ2 + aλ + b = 0.11) (2.2. The call to the ode23 solver and the plot command: xspan = [0 4]. ′ y2 = 2y1 − y2 . λ2 = λ1 complex.1.y(:. plot(x. 2. λ1 = λ2 .m: function yprime = exp22(x. y2 (x) = eλ2 x .2 that the two solutions.34 2.13) −a ± √ a2 − 4b 2 (2. Ly := y ′′ + ay ′ + by = 0. Independent Solutions The form of independent solutions of a homogeneous equation. and λ1 = λ2 real. subplot(2. Graph of solution of the linear equation in Example 2. (2. Thus.y0).
by2 (x) = bu(x)y1 (x) ′ ′ ay2 (x) = au(x)y1 (x) + ay1 (x)u′ (x) ′′ ′′ ′ y2 (x) = u(x)y1 (x) + 2y1 (x)u′ (x) + y1 (x)u′′ (x) u2 (x) = e(α−iβ)x = eαx (cos βx − i sin βx). (2. Case II. (2. or. Since λ1 = λ2 .15) the two complex solutions can be written in the form u1 (x) = e(α+iβ)x = eαx (cos βx + i sin βx).11) admits a solution of the form y1 (x) = eλx . INDEPENDENT SOLUTIONS 35 are independent. Case III.20) It is important to note that the parameter u is a function of x and that y1 is a solution of (2. (2. Therefore. we use the method of variation of parameters. the general solution is y(x) = c1 eαx cos βx + c2 eαx sin βx. Therefore.18) Ly2 = u(x)Ly1 ′ + [ay1 (x) + 2y1 (x)]u′ (x) + y1 (x)u′′ (x). Thus. We substitute y2 in (2.16) 2 1 y2 (x) = ℑu1 (x) = [u1 (x) − u2 (x)] = eαx sin βx. The second term on the righthand side is zero since a λ = − ∈ R.11). (2. (2. Thus. In the case of two distinct complex conjugate eigenvalues.14) By means of Euler’s identity. (2. equivalently we take the real and imaginary parts of u1 since a and b are real and (2. the general solution is y(x) = c1 eλ1 x + c2 eλ2 x . λ2 = α − iβ = λ1 .11).2. the solutions u1 and u2 are independent. 2 . where i = −1. eiθ = cos θ + i sin θ. we put y2 (x) = u(x)y1 (x). The ﬁrst term on the righthand side is also zero since y1 is a solution of Ly = 0. In the case of real double eigenvalues we have a λ = λ1 = λ2 = − 2 and equation (2. The lefthand side is zero since y2 is assumed to be a solution of Ly = 0.5.11) is homogeneous (since the real and imaginary parts of a complex solution of a homogeneous equation with real coeﬃcients are also solutions). which is described in greater detail in Section 3. This amounts to add the following three equations. 1 y1 (x) = ℜu1 (x) = [u1 (x) + u2 (x)] = eαx cos βx.4.19) To obtain a second independent solution. we use the following change of basis.17) 2i It is clear that y1 and y2 are independent. To have two real independent solutions. we have √ ¯ λ1 = α + iβ. (2.
Solution. It follows that u′′ (x) = 0. (2. 2.3 (Free Oscillation). y2 (x) = x eλx . ′ and y1 (x) = λy1 (x). Let s0 m be the extension of the spring due to the force of gravity acting on the mass at rest at y = 0. that is.2. (See Fig. ′ ay1 (x) + 2y1 (x) = a e−ax/2 − a e−ax/2 = 0. We may take k2 = 0 since the second term on the righthand side is already contained in the linear span of y1 . Moreover. We neglect friction. Example 2. Undamped System. SECONDORDER ORDINARY DIFFERENTIAL EQUATIONS F2 y=0 s0 m y y Ressort libre Free spring F1 Système au repos System at rest m k Système en mouvement System in motion Figure 2. we may take k1 = 1 since the general solution contains an arbitrary constant multiplying y2 . It is clear that the solutions y1 (x) = eλx . 2 . 2.5. Study the problem of the free vertical oscillation of a mass of m kg which is attached to the lower end of the spring. whence u′ (x) = k1 and u(x) = k1 x + k2 .36 2.8 m/sec .2). The general solution is y(x) = c1 eλx + c2 x eλx . The force due to gravity is F1 = mg. Let the positive Oy axis point downward. Consider a vertical spring attached to a rigid beam. The spring resists both extension and compression with Hooke’s constant equal to k. Modeling in Mechanics We consider elementary models of mechanics. where g = 9. We therefore have y2 (x) = k1 x eλx + k2 eλx .21) are linearly independent.
5. The characteristic equation of this diﬀerential equation. when the system is at rest.8 m/sec .2. of the previous system are 2π p= A = c2 + c2 .3). or y ′′ + ω 2 y = 0. 2. 2 . The damping constant is equal to c. . Now consider the system in motion in position y. The restoration force exerted by the spring is By Newton’s second law of motion. The amplitude. MODELING IN MECHANICS 37 k y=0 m c y Figure 2. F2 = −k s0 . Let the positive Oy axis point downward. then k .2 = ±iω. We see that the system oscillates freely without any loss of energy. p. where g = 9. Solution. in position y = 0. The spring resists extension and compression with Hooke’s constant equal to k. Since the acceleration is a = y ′′ . Consider a vertical spring attached to a rigid beam.4 (Damped System). (See Fig. A. m where ω/2π Hz is the frequency of the system. ω= Hence.3. Study the problem of the damped vertical motion of a mass of m kg which is attached to the lower end of the spring. 2.2). Damped system. admits the pure imaginary eigenvalues my ′′ + ky = 0. the general solution is λ1. (See Fig. λ2 + ω 2 = 0. y(t) = c1 cos ωt + c2 sin ωt. 1 2 ω Example 2. The force due to gravity is F1 = mg. the resultant is m a = −k y. By the same law. Let s0 m be the extension of the spring due to the force of gravity on the mass at rest at y = 0. and period. the resultant is zero. F1 + F2 = 0.
oscillates while decreasing exponentially to zero. m m admits the eigenvalues 1 c ± λ1. Both eigenvalues are real and negative since 1 k c c2 − 4mk < 0. my ′′ + cy ′ + ky = 0. λ1. decreases exponentially to zero with an initial increase in y(t) if c2 > 0. or y ′′ + y ′ + m m The characteristic equation of this diﬀerential equation. The diameter of the tube is 0. the resultant is zero. Case II: Underdamping. The two eigenvalues are complex conjugate to each other. λ1 λ2 = λ1 = − 2m 2m m The general solution. c i 4mk − c2 =: −α ± iβ. Example 2. λ1. the system is critically damped. Since damping opposes motion.2 = − c2 − 4mk =: −α ± β. Find the frequency of the oscillatory movement of 2 L of water in a tube in a U form. c k λ2 + λ+ = 0. Both eigenvalues are real and equal. − > 0. α > 0.2 = − ± with α > 0. If c2 > 4mk.38 2. y(t) = c1 eλ1 t + c2 eλ2 t . Since the acceleration is a = y ′′ . the system is overdamped. Case I: Overdamping. by the same law.2 = − 2m The general solution. the system is underdamped. with α > 0. F2 = −k s0 . 2m 2m The general solution. SECONDORDER ORDINARY DIFFERENTIAL EQUATIONS The restoration force exerted by the spring is By Newton’s second law of motion. the resultant for the system in motion is m a = −c y ′ − k y. when the system is at rest. y(t) = c1 e−αt + c2 t e−αt = (c1 + c2 t) e−αt .5 (Oscillation of water in a tube in a U form). 2m 2m There are three cases to consider. c = −α. y(t) = c1 e−αt cos βt + c2 e−αt sin βt. Case III: Critical damping. then k c y = 0. decreases exponentially to zero without any oscillation of the system. .04 m. If c2 < 4mk. F1 + F2 = 0. If c2 = 4mk.
of height h = 2y. 2π Hence. in radian measure.02)2 2000y L (see Fig. the orthogonal component of the force is zero. We neglect friction between the liquid and the tube wall. (See Fig. 2. the frequency is ω0 = 2π Example 2.02)2 9.02)2 9.5).2. Solution. The mass of volume V is M = π(0. m y ′′ = −M g. y ′′ + where 2 ω0 = g = 9.8 × 2000 y = 0.6 (Oscillation of a pendulum).3150. that is.5585 Hz. Find the frequency of the oscillations of small amplitude of a pendulum of mass m kg and length L = 1 m. made by the pendulum measured from the vertical axis.4). π(0. Since the length of the rod is ﬁxed. mLθ′′ = −mg sin θ ≈ −mgθ. The tangential force is m a = mLθ′′ .3150 = 0.8.8 × 2000y N. The volume.8 m/s2 .02)2 2y m3 = π(0. 2. . Vertical movement of a liquid in a U tube. Let θ be the angle. 2 √ 12. Solution. Hence it suﬃces to consider the tangential component of the restoring force due to gravity. π(0.4. By Newton’s second law of motion.02)2 2000y kg and the restoration force is M g = π(0.02)2 9.8 × 2000 = 12. responsible for the restoring force is V = πr2 h = π(0. The mass of the liquid is m = 2 kg.5. We neglect air resistance and the mass of the rod. that is. MODELING IN MECHANICS 39 y y=0 Figure 2. g = 9. 2 2 or y ′′ + ω0 y = 0.
If both roots are real and distinct. Euler–Cauchy’s Equation Consider the homogeneous Euler–Cauchy equation Ly := x2 y ′′ + axy ′ + by = 0.22) Because of the particular form of the diﬀerential operator of this equation with variable coeﬃcients. the general solution of (2. (2.5.23) in (2.6. where L Therefore.498 Hz. L 2. D= ′ = d . where sin θ ≈ θ if θ is suﬃciently small. and m1 = m2 real.22) is y(x) = c1 xm1 + c2 xm2 . m1. x>0 (2.8 = = 0. SECONDORDER ORDINARY DIFFERENTIAL EQUATIONS tangente tangent mg θ y Figure 2. m1 and m2 = m1 complex and distinct. 2π 2π 2 ω0 = g = 9. g 2 θ′′ + θ = 0. we can solve (2. (2. the frequency is √ ω0 9.8.2 = Case I. We thus obtain the characteristic equation m2 + (a − 1)m + b = 0.26) (2.24) m(m − 1)xm + amxm + bxm = xm [m(m − 1) + am + b] = 0. L = x2 D2 + axD + bI. Thus.22). with ak a constant. or θ′′ + ω0 θ = 0. . dx where each term is of the form ak xk Dk .40 2. We can divide by xm if x > 0. Pendulum in motion. The eigenvalues are 1−a 1 (a − 1)2 − 4b.25) ± 2 2 There are three cases: m1 = m2 real.22) by setting y(x) = xm (2.
The general solution of (2. (2. we have by2 (x) = bu(x)y1 (x) ′ ′ axy2 (x) = axu(x)y1 (x) + axy1 (x)u′ (x) ′ ′′ ′′ x2 y2 (x) = x2 u(x)y1 (x) + 2x2 y1 (x)u′ (x) + x2 y1 (x)u′′ (x) m2 = α − iβ. x2 y1 (x)u′′ + xm+1 u′ = xm+1 (xu′′ + u′ ) = 0. and dividing the sum and the diﬀerence by 2 and 2i. we have two independent complex solutions of the form u1 = xα xiβ = xα eiβ ln x = xα [cos(β ln x) + i sin(β ln x)] and u2 = xα x−iβ = xα e−iβ ln x = xα [cos(β ln x) − i sin(β ln x)]. The coeﬃcient of u′ is ′ axy1 (x) + 2x2 y1 (x) = axxm + 2mx2 xm−1 = axm+1 + 2mxm+1 = (a + 2m)xm+1 = Hence we have a+2 1−a 2 xm+1 = xm+1 . 2 Ly2 = u(x)Ly1 ′ + [axy1 (x) + 2x2 y1 (x)]u′ (x) + x2 y1 (x)u′′ (x). If both roots are real and equal. m1 = α + iβ. .2.27) 1−a .22) is homogeneous.6.and righthand sides of the following three expressions. we obtain two real independent solutions by adding and subtracting u1 and u2 . and dividing by x m+1 x > 0. equivalently. β = 0. or. . Adding the left. y2 (x) = xα sin(β ln x).22). we have xu′′ + u′ = 0. v ′ = u′′ . y1 (x) = xα cos(β ln x). If the roots are complex conjugates of one another. The ﬁrst term on the righthand side is also zero since y1 is a solution of Ly = 0. EULER–CAUCHY’S EQUATION 41 Case II.22) is y(x) = c1 xα cos(β ln x) + c2 xα sin(β ln x). Since u is absent from this diﬀerential equation. respectively. we can reduce the order by putting v = u′ . We ﬁnd a second independent solution by variation of parameters by putting y2 (x) = u(x)y1 (x) in (2. For x > 0. m = m1 = m2 = one solution is of the form y1 (x) = xm . by taking the real and imaginary parts of u1 since a and b are real and (2. Case III. The lefthand side is zero since y2 is assumed to be a solution of Ly = 0.
dv dx =− . we have the linear system in c1 and c2 : y(1) = c1 + c2 = 2 whose solution is Hence the unique solution is y(x) = x3 + x−2 . x No constant of integration is needed here. y(1) = 2.— y ′ (1) = 3c1 −2c2 = 1 c1 = 1. (a) The analytic solution. x dx and can be integrated.7. y ′ (1) = 1. . Solution. Solve the initial value problem x2 y ′′ − 6y = 0.— dsolve(’x^2*D2y=6*y’.— The general solution as found in Example 2. (b) The Matlab symbolic solution. The second independent solution is ln v = ln x−1 =⇒ u′ = v = y2 = (ln x)xm .8. c2 = 1. dv + v = 0.28) Example 2. From the initial conditions. (a) The analytic solution. that is. we have m(m − 1)xm − 6xm = 0.42 2. m2 = −2. SECONDORDER ORDINARY DIFFERENTIAL EQUATIONS The resulting equation is separable. (b) The Matlab symbolic solution. m2 − m − 6 = (m − 3)(m + 2) = 0. (2. Find the general solution of the Euler–Cauchy equation Solution. m1 = 3. are real and distinct. Therefore. The characteristic equation is The eigenvalues.7 is y(x) = c1 x3 + c2 x−2 . v x 1 =⇒ u = ln x. The general solution is y(x) = c1 x3 + c2 x−2 . x2 y ′′ − 6y = 0.— Putting y = xm in the diﬀerential equation.’x’) y = (C1+C2*x^5)/x^2 Example 2.22) is y(x) = c1 xm + c2 (ln x)xm . the general solution of (2.
we have ′ y1 = y2 .y).’y(1)=2’.’Dy(1)=1’. % solution for x=1 to x=4 y0 = [2.1)) The numerical solution is plotted in Fig.1). yprime = [y(2). ′ y2 = 6y1 /x2 . dsolve(’x^2*D2y=6*y’.6. 1].2. with initial conditions at x = 1: y1 (1) = 2. we put y1 = y.y0).y(:.8. 2.9. EULER–CAUCHY’S EQUATION 43 Plot of solution 70 60 50 y=y(1) 40 30 20 10 0 1 2 x 3 4 Figure 2. Find the general solution of the Euler–Cauchy equation x2 y ′′ + 7xy ′ + 9y = 0.y] = ode23(’euler2’.xspan.— To rewrite the secondorder diﬀerential equation as a system of ﬁrstorder equations.6. Example 2. subplot(2. y2 (1) = 1. The Mﬁle euler2. % initial conditions [x.’x’) y = (1+x^5)/x^2 (c) The Matlab numeric solution.6. Graph of solution of the Euler–Cauchy equation in Example 2. y2 = y ′ .2. The call to the ode23 solver and the plot command: xspan = [1 4]. 6*y(1)/x^2]. . plot(x. Thus.m: function yprime = euler2(x.
Solution. Find the general solution of the Euler–Cauchy equation . m1 = + i.10. m2 − m + 1.44 2. x2 y ′′ + 1. The characteristic equation m2 + 6m + 9 = (m + 3)2 = 0 admits a double root m = −3.25 = 0 Example 2. The characteristic equation admits a pair of complex conjuguate roots 1 1 m2 = − i. 2 2 Hence the general solution is y(x) = x1/2 [c1 cos(ln x) + c2 sin(ln x)]. Hence the general solution is y(x) = (c1 + c2 ln x)x−3 . The existence and uniqueness of solutions of initial value problems will be considered in the next chapter. SECONDORDER ORDINARY DIFFERENTIAL EQUATIONS Solution.25y = 0.
0. fn . 45 for all x ∈]a. If r ≡ 0. Theorem 3. . an−1 (x). Ly = 0.3) D := ′ = d . that is.1 proved in the previous chapter generalizes to linear homogeneous equations of arbitrary order n.1. .3) on the interval ]a. b[. yk be k solutions of Ly = 0. they are said to be linearly independent. k2 . b[ is a function y(x) n times continuously diﬀerentiable on ]a. (3. . . ci ∈ R.3) form a vector space.CHAPTER 3 Linear Diﬀerential Equations of Arbitrary Order 3. . Otherwise. . . . . Proof. f1 . Let y1 . . . are linearly dependent on the interval ]a. . The solutions of (3.1) is said to be homogeneous.1. .1) with variable coeﬃcients.2. b[ which satisﬁes identically the diﬀerential equation. kn ) = (0. Definition 3.4) . (k1 . f2 . Let L denote the diﬀerential operator on the lefthand side. a0 (x). L := Dn + an−1 (x)Dn−1 + · · · + a1 (x)D + a0 (x)I. equation (3. 0). . Lu = r(x). A solution of (3. b[ if and only if there exist n constants not all zero. y (n) + an−1 (x)y (n−1) + · · · + a1 (x)y ′ + a0 (x)y = r(x).1. . (3.1) or (3. Theorem 2. (3. The linearity of the operator L implies that L(c1 y1 + c2 y2 + · · · + ck yk ) = c1 Ly1 + c2 Ly2 + · · · + ck Lyk = 0. . . . . y (n) + an−1 (x)y (n−1) + · · · + a1 (x)y ′ + a0 (x)y = 0. Homogeneous Equations Consider the linear nonhomogeneous diﬀerential equation of order n. a1 (x). . dx (3. We say that n functions. such that k1 f1 (x) + k2 f2 (x) + · · · + kn fn (x) = 0. y2 .2) Then the nonhomogeneous equation (3.1) is written in the form Definition 3.
. 0 −a1 u2 = y ′ . . f2 .2. .3) on the interval ]a. a1 (x).. . . u1 (x0 ) u2 (x0 ) .5) admits one and only one solution.. f3 . b[ is the following determinant of order n: f1 (x) ′ f1 (x) . . y(x0 ) = k1 . f1 (n−1) W (f1 . fn (n−1) . Proof. Then the initial ′ u1 u2 . y2 . 0 −a2 ··· ··· . u(x0 ) = k. . . fn be n linearly dependent functions. . . . x0 ∈]a. One can prove the theorem by reducing the diﬀerential equation of order n to a system of n diﬀerential equations of the ﬁrst order. . yn )(x) satisﬁes the following identity: R − x a (t) dt W (x) = W (x0 ) e x0 n−1 . LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER Remark 3. . To do this. u′ (x) = A(x)u(x). let us prove Abel’s Lemma. ... we may suppose that k1 = 0 in (3. First. Lemma 3. then the initial value problem Ly = 0. deﬁne the n dependent variables u1 = y. .3. . . The matrix A(x) is called a companion matrix. .1. fn (x). y (n−1) (x0 ) = kn . . 1 f1 (x) = − [k2 f2 (x) + · · · + kn fn (x)]. . u1 u2 . y2 . . . (3. f1 (x). Without loss of generality. . . k1 k2 . . b[. b[. . fn )(x) := f2 (x) ′ f2 (x) f2 (n−1) ··· ··· ··· fn (x) ′ fn (x) . Let y1 ... 0 1 . an−1 (x) are continuous on the interval ]a.. ..46 3. Picard’s iterative procedure is as follows: x u[n] (x) = u[0] (x0 ) + x0 A(t)u[n−1] (t) dt.3) is characterized by means of their Wronskian. Let f1 .6) (x) (x) (x) The linear dependence of n solutions of the linear homogeneous diﬀerential equation (3. .7) . . f2 . . .4). one can show that this system admits one and only one solution. Theorem 3. . 0 −a0 1 0 . ··· ··· . un−1 un 0 0 . b[ and x0 ∈]a. Definition 3. . . If the functions a0 (x). un−1 (x0 ) un (x0 ) = kn−1 kn . The Wronskian of n functions. . . = . (3. y ′ (x0 ) = k2 . Then f1 is a linear combination of f2 .1 (Abel). . . . . f2 (x). . . un−1 un . in matrix and vector notation. k1 We have the following existence and uniqueness theorem. fn . yn be n solutions of (3. 0 0 0 1 −an−1 un = y (n−1) . Then the Wronskian W (x) = W (y1 . . . Using Picard’s method. (3. u[0] (x0 ) = k. n−1 times diﬀerentiable on the interval ]a. . value problem becomes or. . b[.
. . the general case is treated as easily. Adding to the third row a0 times the ﬁrst row and a1 times the second row. a1 (x).3).2 there exist n constants not all zero.3. . . 2. Let W (x) be the Wronskian of three solutions y1 . yn . dW = −a2 (x) dx. Theorem 3.8) (x0 ) · · · (x0 ) Proof. .3) are linearly dependent if and only if their Wronskian is zero at a point x0 ∈]a. (k1 . let us take n = 3. y1 (n−1) ··· ··· yn (x0 ) ′ yn (x0 ) . W The solution is ln W  = − that is W (x) = W (x0 ) e − Rx x0 a2 (x) dx + c. an−1 (x) of (3. y2 . 0. . then by Deﬁnition 3. namely. (3. . . 0). . . If the coeﬃcients a0 (x). . . y3 . y2 . 3. k2 . of (3. b[. . such that k1 y1 (x) + k2 y2 (x) + · · · + kn yn (x) = 0.1. . . y1 . . . . = y1 ′ y1 ′ ′′ −a0 y1 − a1 y1 − a2 y1 since the ﬁrst two determinants of the second line are zero because two rows are equal. W (y1 . yn )(x0 ) := y1 (x0 ) ′ y1 (x0 ) . . kn ) = (0. y2 . . we obtain the separable diﬀerential equation W ′ (x) = −a2 (x)W (x). . b[. yn (n−1) = 0. . a2 (t) dt . then n solutions. For simplicity of writing. The derivative W ′ (x) of the Wronskian is of the form W ′ (x) = y1 ′ y1 ′′ y1 ′ y1 ′ y1 ′′ y1 y2 ′ y2 ′′ y2 ′ y2 ′ y2 ′′ y2 y3 ′ y3 ′′ y3 ′ y3 ′ y3 ′′ y3 ′ = + y1 ′′ y1 ′′ y1 y2 ′′ y2 ′′ y2 y3 ′′ y3 ′′ y3 + y1 ′ y1 ′′′ y1 y2 ′ y2 ′′′ y2 y3 ′ y3 ′′′ y3 = y1 ′ y1 ′′′ y1 y2 ′ y2 ′′′ y2 y3 ′ y3 ′′′ y3 y2 ′ y2 ′ ′′ −a0 y2 − a1 y2 − a2 y2 y3 ′ y3 ′ ′′ −a0 y3 − a1 y3 − a2 y3 . b[. for all x ∈]a. is a solution of the homogeneous equation (3. . .3. . If the solutions are linearly dependent. x0 ∈]a. HOMOGENEOUS EQUATIONS 47 Proof. b[. k = 1.3) are continuous on the interval ]a. and in the last determinant we have used the fact that yk .
. .9) . . y2 . Therefore this system admits a nonzero solution k. Corollary 3. . . k1 y1 (x) + k2 y2 (x) + · · · + kn yn (x) = 0.48 3. = . 1] and are linearly independent. then n solutions. fn ) . . the solutions. and W (f1 . .3. Hence the determinant W (x) of system (3. k1 y1 (n−1) (x) + k2 y2 (n−1) (n−1) (x) + · · · + kn yn (x) = 0. fn )(x) = 0 on I. . . . W (y1 . . . . . . f1 . b[. for all x ∈]a. b[. a zero Wronskian on ]a. as can be seen from the ﬁrst part of the proof of Theorem 3. f2 (x). k2 . If the coeﬃcients a0 (x).1. The Wronskian of n linearly dependent functions. We rewrite this homogeneous algebraic linear system. an−1 (x) of (3. which are suﬃciently diﬀerentiable on ]a.3) are linearly dependent. Corollary 3. . . . yn )(x0 ) = 0. .2. . LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER Diﬀerentiating this identity n − 1 times. by hypothesis. . . y2 . b[. . but satisfy W (x3 . . yn . y1 . b[ by Abel’s Lemma 3.3) are continuous on ]a. . y1 . then it is zero for all x ∈]a. . . b[. if the Wronskian of n solutions is zero at an arbitrary point x0 . . . On the other hand. a1 (x). . y2 . y1 (x) ··· yn (x) k1 0 ′ ′ y1 (x) ··· yn (x) k2 0 (3. b[. is necessarily zero on ]a.1. Remark 3. Then there exists a unique homogeneous diﬀerential equation of order n (with coeﬃcient of y (n) one) for which these functions are linearly independent solutions. of (3. . . y2 .9) is zero for all x ∈]a. . b[ is not a suﬃcient condition for the linear dependence of these functions. Consequently. x3 ) = 0 identically. the solution k is nonzero. . But for functions which are not solutions of the same linear homogeneous diﬀerential equation. fn ) = 0. . yn . we obtain ′ ′ ′ k1 y1 (x) + k2 y2 (x) + · · · + kn yn (x) = 0. . Since. . . of (3. fn (x) are n functions which possess continuous nthorder derivatives on a real interval I. Ak = 0. det A = W (y1 . For instance. . .3) are linearly independent if and only if their Wronskian is not zero at a single point x0 ∈]a. . . . b[. .2. the determinant of the system must be zero. . . . . namely W (y. in the n unknowns k1 . . (−1)n W (f1 . u1 = x3 and u2 = x3 are of class C 1 in the interval [−1. yn )(x) = 0. . . (n−1) (n−1) kn 0 y1 (x) · · · yn (x) that is. kn in matrix form. Suppose f1 (x). . . .
In the previous solution we have used the following identity: cosh2 x − sinh2 x = = ex + e−x 2 2 − ex − e−x 2 2 1 2x e + e−2x + 2 ex e−x − e2x − e−2x + 2 ex e−x 4 = 1.3. respectively. Example 3. y1 and y2 are linearly independent.1. by Corollary 3. y2 )(x) = cosh x sinh x sinh x cosh x = cosh2 x − sinh2 x = 1. Solution. Since y1 and y2 are twice continuously diﬀerentiable and W (y1 .2. y2 )(x) = xm mxm−1 mx m−1 xm ln x ln x + xm−1 = xm xm−1 1 ln x m m ln x + 1 for all x > 0.2. By the same corollary W (y. Incidently. and y2 (x) = sinh x for all x. HOMOGENEOUS EQUATIONS 49 Example 3. = x2m−1 (1 + m ln x − m ln x) = x2m−1 = 0. x ln x)(x) = = 0. Solution. x . . y y′ y ′′ xm mxm−1 m(m − 1)xm−2 Hence.1. one gets the equivalent simpliﬁed determinantal equation y xy ′ − my x2 y ′′ − m(m − 1)y 1 ln x 0 1 0 2m − 1 = 0. dividing the second and third columns by xm . then. subtracting m times the ﬁrst row from the second row and m(m − 1) times the ﬁrst row from the third row. y1 and y2 are linearly independent. m m xm ln x mx ln x + xm−1 m−2 m(m − 1)x ln x + (2m − 1)xm−2 m−1 Multiplying the second and third rows by x and x2 . by Corollary 3. Show that the functions y1 (x) = cosh x are linearly independent. it is easy to see that y1 and y2 are solutions of the diﬀerential equation y ′′ − y = 0. Use the Wronskian of the functions y1 (x) = xm and y2 (x) = xm ln x to show that they are linearly independent for x > 0 and construct a secondorder diﬀerential equation for which they are solutions.2. We verify that the Wronskian of y1 and y2 does not vanish for x > 0: W (y1 .
Theorem 3. .5) on ]a. then the solution of the initial value problem (3. then the linear homogeneous equation (3. (n−1) (n−1) (x0 ) (x0 ) · · · yn y1 c1 c2 . is said to be a general solution of (3. .3).3) on ]a. admits one (and only one) solution yi (x) such that yi (i−1) (x0 ) = 1. .4. for each i. . . .2. . . Theorem 3. n. a1 (x). If the functions a0 (x). b[. Let y1 .5. . LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER which upon expanding by the second column produces the Euler–Cauchy equation x2 y ′′ + (1 − 2m)xy ′ + m2 y = 0. b[.3) on ]a. . . y1 . Definition 3. with y (i−1) (x0 ) = 1. i = 1.4. ··· ··· ··· yn (x0 ) ′ yn (x0 ) . b[ of the form y(x) = c1 y1 (x) + c2 y2 (x) + · · · + cn yn (x). . y2 . . . . .5). . . . . Proof. yn (n−1) Then the Wronskian W satisﬁes the following relation y1 (x0 ) ′ y1 (x0 ) . y2 . . . y (j−1) (x0 ) = 0. . . 2. Proof.3). . y2 . Let y = c1 y 1 + c2 y 2 + · · · + cn y n be a general solution of (3. . = . an−1 (x) are continuous on ]a. yn be a fundamental system for (3. It follows from Corollary 3. y1 (n−1) W (y1 . an−1 (x) are continuous on ]a. . . n. b[.3) admits a general solution on ]a. . . . cn k1 k2 .3) on ]a. yn )(x0 ) = = In  = 1. . yn . . 2. . . The system y1 (x0 ) ··· yn (x0 ) ′ ′ y1 (x0 ) ··· yn (x0 ) . .5. Ly = 0.1 that the solutions are independent. . . . b[. b[. .50 3. . i + 1. Definition 3. a1 (x). (3. We say that n linearly independent solutions. . j = i.10) where c1 . of (3. . By Theorem 3. If the functions a0 (x). j = 1. . . kn admits a unique solution c since the determinant of the system is nonzero. cn are n arbitrary constants. c2 . . . A solution of (3. b[ is obtained from a general solution. b[ form a fundamental system or basis on ]a. (x0 ) (x0 ) where In is the identity matrix of order n. the initial value problem (3. . yi (j−1) (x0 ) = 0. i − 1. .
11) with constant coeﬃcients.6. by hypothesis. a1 . a0 . (3. y (n) + an−1 y (n−1) + · · · + a1 y ′ + a0 y = 0.. (3.14) and the general solution is of the form y(x) = c1 eλ1 x + c2 eλ2 x + · · · + cn eλn x . L := Dn + an−1 Dn−1 + · · · + a1 D + a0 I.2. D := ′ = d . say. we have three independent solutions of the form y1 (x) = eλ1 x . (3. ..3. .13) If the n roots of p(λ) = 0 are distinct. ym (x) = xm−1 eµx . . . .. .. we obtain the characteristic equation p(λ) := λn + an−1 λn−1 + · · · + a1 λ + a0 = 0. 1.12) Putting y(x) = eλx in (3. y1 (x) = eλ1 x . . say.13). p(λ) = q(λ)(λ − µ)m . Let L denote the diﬀerential operator on the lefthand side. y2 (x) = eλ2 x . Linear Homogeneous Equations Consider the linear homogeneous diﬀerential equation of order n. Then the diﬀerential equation (3. . y2 (x) = x eλ1 x . we have two independent solutions of the form y1 (x) = eλ1 x . . dx (3..13) has a double root. k = 0. λ1 = λ2 = λ3 . . Similarly. Theorem 3. We prove the following theorem.2. y3 (x) = x2 eλ1 x .15) If (3. if there is a triple root. m − 1. yn (x) = eλn x . . Since. Let us write p(D)y = (Dn + an−1 Dn−1 + · · · + a1 D + a0 )y = 0. and the coeﬃcients are constant. (3. we have n independent solutions.. y2 (x) = x eλ1 x . We see by recurrence that the m functions (3.11). LINEAR HOMOGENEOUS EQUATIONS 51 3. λ1 = λ2 . the diﬀerential operator p(D) can be factored in the form p(D) = q(D)(D − µ)m . Let µ be a root of multiplicity m of the characteristic equation (3.11) has m independent solutions of the form y1 (x) = eµx . xk eµx . an−1 .16). y2 (x) = x eµx . (3.16) Proof.
k = 0. Lemma 3. .2.3. We have seen. 0! 0 × 1! × .1. y(x) = c1 e−3x + c2 e3x + c3 e−2x + c4 e2x . that (D − µ)k xk eµx = k! eµx . By Corollary 3.. . .. × . . .2 below. Solution. m − 1. . 0 0 . . Dk xk eµx = k! eµx + terms in xl eµx . 0 . be m solutions of a linear homogeneous diﬀerential equation. Dk xk eµx x=0 = k!. .i = (i − 1)!. λ4 − 13λ2 + 36 = (λ2 − 9)(λ2 − 4) Hence. It follows that the matrix M of the Wronskian is lower triangular with mi. k − 1.16) are m independent solutions of (3. Hence... .. Since m ≥ k + 1. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER satisfy the following equations: (D − µ) xk eµx = kxk−1 eµx + µxk eµx − µxk eµx = kxk−1 eµx . . (D − µ)m xk eµx = 0.52 3. that is. it suﬃces to show that the Wronskian of the solutions is nonzero at x = 0. The characteristic polynomial is easily factored..11). (D − µ)k xk eµx = k! eµx . . Proof. . m−1 W (0) = 2! . = k(k − 1)xk−2 eµx . . . 0 (m − 1)! Example 3. Let y1 (x) = eµx . 2. (D − µ)2 xk eµx = (D − µ) kxk−1 eµx . Find the general solution of (D4 − 13D2 + 36I)y = 0. = (λ + 3)(λ − 3)(λ + 2)(λ − 2). . y2 (x) = x eµx . × × 0 0 . × = k=0 k! = 0. l ≥ 1. in the proof of the preceding theorem. by Lemma 3. Dk xk+l eµx x=0 = 0. 1. ... . the functions (3. ym (x) = xm−1 eµx . Then they are independent. Hence l = 1. we have (D − µ)k+1 xk eµx = k! (eµx − eµx ) = 0.. .
0000 3.— To ﬁnd the zeros of the characteristic polynomial λ4 − 13λ2 + 36 and uses the command roots on p. Find the general solution of the diﬀerential equation (D − I)3 y = 0.0000 2. Hence: y(x) = c1 ex + c2 x ex + c3 x2 ex .5. >> C = compan(p) C = 0 13 0 36 1 0 0 0 0 1 0 0 0 0 1 0 >> eigenvalues = eig(C)’ eigenvalues = 3. p= 1 0 −13 0 36 The Matlab polynomial solver.0000 Example 3.0000 3. Find the general solution of the Euler–Cauchy equation x3 y ′′′ − 3x2 y ′′ + 6xy ′ − 6y = 0.2) 0 13 1 0 C= 0 1 0 0 matrix C of p (see the proof of Theo0 0 0 1 −36 0 0 0 and uses the QR algorithm to ﬁnd the eigenvalues of C which. >> p >> r p = [1 0 13 0 36] = 1 0 13 r = roots(p) = 3.0000 2.4.2. LINEAR HOMOGENEOUS EQUATIONS 53 with Matlab. Example 3.0000 0 36 In fact the command roots constructs a rem 3. The characteristic polynomial (λ − 1)3 admit a triple zero: λ1 = λ2 = λ3 = 1. Solution. one represents the polynomial by the vector of its coeﬃcients. are the zeros of p. >> p = [1 0 13 0 36].0000 2. .3. in fact.0000 2.
. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER Solution. we obtain the characteristic equation. we obtain ex u′′ + 4x ex − 4x ex It follows that u′′ = 0 =⇒ u′ = k1 =⇒ u = k1 x + k2 and y2 (x) = (k1 x + k2 )ex . Given that y1 (x) = ex 2 is a solution of the secondorder diﬀerential equation Ly := y ′′ − 4xy ′ + (4x2 − 2)y = 0. we have ′ Ly2 = uLy1 + (2y1 − 4xy1 )u′ + y1 u′′ .— Putting y(x) = xm in the diﬀerential equation.— dsolve(’x^3*D3y3*x^2*D2y+6*x*Dy6*y=0’. ′ ′ −4xy2 = −4xuy1 − 4xu′ y1 . Replacing y1 by its value in the diﬀerential equation for u. We note that Ly1 = 0 and Ly2 = 0 since y1 is a solution and we want y2 to be a solution. (m − 1)[m(m − 2) − 3m + 6] = (m − 1)(m2 − 5m + 6) = (m − 1)(m − 2)(m − 3) = 0. (a) The analytic solution. Noting that m − 1 is a common factor. we put y2 (x) = u(x)y1 (x) in the given diﬀerential equation and obtain (4x2 − 2)y2 = (4x2 − 2)uy1 . we have and dividing by xm . m(m − 1)(m − 2) − 3m(m − 1) + 6m − 6 = 0. (b) The Matlab symbolic solution. Thus. respectively. Solution. ′′ ′′ ′ y2 = uy1 + 2u′ y1 + u′′ y1 . y(x) = c1 x + c2 x2 + c3 x3 .6. Upon addition of the left. we have m(m − 1)(m − 2)xm − 3m(m − 1)xm + 6mxm − 6xm = 0. ﬁnd a second independent solution.and righthand sides. 2 2 2 2 u′ = 0.’x’) y = C1*x+C2*x^2+C3*x^3 Example 3.— Following the method of variation of parameters.54 3. (a) The analytic solution.
— dsolve(’D2yy3*exp(2*x)’. (b) The Matlab symbolic solution. Then. Since a general solution to the homogeneous equation is y ′′ − y = 0 =⇒ λ2 − 1 = 0 =⇒ λ = ±1. the general solution is y(x) = (c1 + c2 x) ex . yh (x) = c1 ex + c2 e−x and a general solution of the nonhomogeneous equation is yg (x) = c1 ex + c2 e−x + e2x .17). (3. In fact. (b) The Matlab symbolic solution.— It is easy to see that e2x is a particular solution. Thus.18) yh (x) = c1 y1 (x) + c2 y2 (x) + · · · + cn yn (x). Lyg = Lyh + Lyp = 0 + r(x). be a general solution of the homogeneous equation Ly = 0.17) (3.’x’) y = (exp(2*x)*exp(x)+C1*exp(x)^2+C2)/exp(x) z = expand(y) z = exp(x)^2+exp(x)*C1+1/exp(x)*C2 y ′′ − y = 3 e2x yp (x) = e2x .’x’) y = C1*exp(x^2)+C2*exp(x^2)*x 2 3. and k1 = 1 since the 2 solution x ex will be multiplied by an arbitrary constant in the general solution.3.17). Example 3.7.3.— dsolve(’D2y4*x*Dy+(4*x^22)*y=0’.3. let yp (x) be a particular solution of the nonhomogeneous equation (3. Moreover. Let Ly := y (n) + an−1 (x)y (n−1) + · · · + a1 (x)y ′ + a0 (x)y = r(x). yg (x) = yh (x) + yp (x) is a general solution of (3. Solution. Find a general solution yg (x) of if is a particular solution. LINEAR NONHOMOGENEOUS EQUATIONS 2 55 It suﬃces to take k2 = 0 since k2 ex is contained in y1 . Linear Nonhomogeneous Equations Consider the linear nonhomogeneous diﬀerential equation of order n. (a) The analytic solution.
du = e it can be integrated directly. The homogeneous equation Ly = 0 is separable: dy = −f (x) dx =⇒ ln y = − y f (x) dx =⇒ yh (x) = e− R f (x) dx (3. yp (x) = e− R f (x) dx e R f (x) dx r(x) dx. Find the general solution of the ﬁrstorder linear nonhomogeneous equation Ly := y ′ + f (x)y = r(x). Thus.56 3.and righthand sides of these expressions we have Lyp = uLyh + u′ yh = u ′ yh = r(x). Example 3. No arbitrary constant is needed here.8. Solution. which is more restrictive than the second.19) is y(x) = cyh (x) + yp (x) = e− R f (x) dx e R f (x) dx r(x) dx + c . namely. The ﬁrst method. Since the diﬀerential equation u′ yh = r is separable. Adding the left. . Hence. does not always require the general solution of the homogeneous equation. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER Here is a second method for solving linear ﬁrstorder diﬀerential equations.19) . In the next two sections we present two methods to ﬁnd particular solutions. r(x) dx. No arbitrary constant is needed here. u(x) = e R f (x) dx R f (x) dx r(x) dx. the method of undetermined coeﬃcients and the method of variation of parameters. To ﬁnd a particular solution by variation of parameters we put yp (x) = u(x)yh (x) in the nonhomogeneous equation Ly = r(x): ′ ′ yp = uyh + u′ yh f (x)yp = uf (x)yh . the general solution of (3. but the second always does.
4. Here is a list of usual functions r(x) which have a ﬁnite number of linearly independent derivatives. =⇒ dim. = 3. with constant coeﬃcients. we can use the method of undetermined coeﬃcients.20) and equating coeﬃcients. r(k) (x) = 0. . yh (x) = A cos x + B sin x. Identifying the coeﬃcients of 1. we have a = 3. METHOD OF UNDETERMINED COEFFICIENTS 57 3. = 2. k = 3. yp (x) = c1 p1 (x) + c2 p2 (x) + · · · + cl pl (x).20) is ﬁnite.3. . yp = ax2 + bx + c ′′ yp = 2a r′′ (x) = 2r′ (x) − r(x). We determine the coeﬃcients ck by substituting yp (x) in (3. respectively. r(x) = cos 2x + sin 2x. a1 .and the righthand sides. If the dimension of the space spanned by the derivatives of the functions on the righthand side of (3. r(x) = x e . We indicate the dimension of the space of derivatives. r (x) = ex + x ex . 4. r′′ (x) = −4r(x). Find a general solution yg (x) of Ly := y ′′ + y = 3x2 by the method of undetermined coeﬃcients. = 2. Example 3. r′′ (x) = 2. . . c = −2a = −6. Solution. (a) The analytic solution. The method of undetermined coeﬃcients consists in choosing for a particular solution a linear combination. . . . Method of Undetermined Coeﬃcients Consider the linear nonhomogeneous diﬀerential equation of order n. (3.9. =⇒ dim. A bad choice or a mistake leads to a contradiction. =⇒ dim. x and x2 on both sides. a0 . r′ (x) = −2 sin 2x + 2 cos 2x. the general solution of Ly = 3x2 is yg (x) = A cos x + B sin x + 3x2 − 6. b = 0. an−1 . x ′ y (n) + an−1 y (n−1) + · · · + a1 y ′ + a0 y = r(x).21) Lyp = ax2 + bx + (2a + c) = 3x2 . (3. .4.— Put yp (x) = ax2 + bx + c in the diﬀerential equation and add the terms on the left. The general solution of Ly = 0 is Hence.20) r′ (x) = 2x + 2. . r(x) = x2 + 2x + 1. of the independent derivatives of the function r(x) on the righthand side.
(a) The analytic solution.11. y ′′′ − y ′ = 4 e−x + 3 e2x . we exclude from yp the terms which are in the space of solution of the homogeneous equation since they contribute zero to the righthand side.— dsolve(’D2y+y=3*x^2’. a particular solution is of the form yp (x) = ax2 e2x + b cos x + c sin x.58 3. y ′′′ = −ax e−x + 3a e−x + 8b e2x.10. y(0) = 0. xk pj (x) is a solution of the homogeneous equation. y ′′ = Hence. we have 1 a = 2. y ′ (0) = −1. Identifying the coeﬃcients of e and e . y ′′ − 4y ′ + 4y = 3 e2x + 32 sin x Solution.21). we take a particular solution of the form yp (x) = ax e−x + b e2x . but xk+1 pj (x) is not. b= . ax e−x − 2a e−x + 4b e2x. Considering that e−x is contained in the righthand side of the diﬀerential equation. yh (x) = c1 + c2 ex + c3 e−x . 2 . Find the form of a particular solution for solving the equation by undetermined coeﬃcients. Example 3. y ′′ (0) = 2 Solution. −x 2x for all x. Example 3. y ′′′ − y ′ = 2a e−x + 6b e2x = 4 e−x + 3 e2x .’x’) y = 6+3*x^2+C1*sin(x)+C2*cos(x) Important remark. y ′ = −ax e−x + a e−x + 2b e2x . LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER (b) The Matlab symbolic solution. If for a chosen term pj (x) in (3. Solve the initial value problem and plot the solution. Naturally. Then.— The characteristic equation is The general solution of the homogeneous equation is λ3 − λ = λ(λ − 1)(λ + 1) = 0. then pj (x) must be replaced by xk+1 pj (x). Since the general solution of the homogeneous equation is yh (x) = c1 e2x + c2 x e2x .
y(2)′ = y(3). a particular solution of the nonhomogeneous equation is 1 yp (x) = 2x e−x + e2x 2 and the general solution of the nonhomogeneous equation is 1 y(x) = c1 + c2 ex + c3 e−x + 2x e−x + e2x . Thus.’D2y(0)=2’. y ′′ (0) = yielding the linear algebraic system c2 + c3 −2 = 2. METHOD OF UNDETERMINED COEFFICIENTS 59 Thus. c2 = 0. 2 2 (b) The Matlab symbolic solution. y(2) = y ′ . yprime=[y(2). whose solution is 9 c1 = − . 2 The arbitrary constants c1 . c3 = 4.m: y(3)′ = y(2) + 4 ∗ exp(−x) + 3 ∗ exp(2 ∗ x). y(3). The Mﬁle exp39.y).3. we put y(1) = y.— dsolve(’D3yDy=4*exp(x)+3*exp(2*x)’. y(2)+4*exp(x)+3*exp(2*x)]. we have y(1)′ = y(2). y(3) = y ′′ . function yprime = exp39(x. 1 c1 + c2 + c3 = − . c2 + c3 = 4. 2 and the unique solution is 9 1 y(x) = − + 4 e−x + 2x e−x + e2x .’x’) y = 1/2*(8+exp(3*x)+4*x9*exp(x))/exp(x) z =expand(y) z = 4/exp(x)+1/2*exp(x)^2+2/exp(x)*x9/2 (c) The Matlab numeric solution.— To rewrite the thirdorder diﬀerential equation as a system of ﬁrstorder equations. c2 and c3 are determined by the initial conditions: 1 y(0) = c1 + c2 + c3 + = 0.’Dy(0)=1’. 2 y ′ (0) = c2 − c3 +3 = −1. The call to the ode23 solver and the plot command: .’y(0)=0’.4. 2 c2 − c3 = −4.
(3. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER Plot of solution 25 20 15 10 5 0 −5 0 0. Ly := y ′′′ + a2 (x)y ′′ + a1 (x)y ′ + a0 (x)y = r(x). we derive the method of variation of parameters in the case n = 3. that is. Particular Solution by Variation of Parameters Consider the linear nonhomogeneous diﬀerential equation of order n. Ly := y (n) + an−1 (x)y (n−1) + · · · + a1 (x)y ′ + a0 (x)y = r(x).y0).24) The general case follows in the same way.25) where we let the parameters c1 . % initial conditions [x.y] = ode23(’exp39’.5 1 x 1. (3.y(:. in standard form.11. be a general solution of the homogeneous equation Ly = 0. xspan = [0 2]. Following an idea due to Lagrange. 3.60 3. thus giving us three degrees of freedom.1.xspan. % solution for x=0 to x=2 y0 = [0.22) (3. Let yh (x) = c1 y1 (x) + c2 y2 (x) + · · · + cn yn (x). 3. For simplicity.5 2 y Figure 3.1)) The numerical solution is plotted in Fig. plot(x.5.23) .1. the coeﬃcient of y is equal to 1.2].1. We diﬀerentiate yp (x): ′ yp (x) = c′ (x)y1 (x) + c′ (x)y2 (x) + c′ (x)y3 (x) 1 2 3 ′ ′ ′ + c1 (x)y1 (x) + c2 (x)y2 (x) + c3 (x)y3 (x) ′ ′ ′ = c1 (x)y1 (x) + c2 (x)y2 (x) + c3 (x)y3 (x). c2 and c3 of the general solution yh vary. n (3. Graph of solution of the linear equation in Example 3. we take a particular solution of the form yp (x) = c1 (x)y1 (x) + c2 (x)y2 (x) + c3 (x)y3 (x).
yp . We rewrite the three equations c′ (x) in matrix form. c′ (x)y1 (x) + c′ (x)y2 (x) + c′ (x)y3 (x) = 0. ′ ′ ′ (3.3.28) in the unknowns c′ (x). W (y1 . we let the term in square brackets be zero. we want yp to satisfy Lyp = r(x). 2 3 1 ′′ Lastly. (3. y2 and y3 form a fundamental system. r(x) Since y1 . Moreover. we have ′ ′′ ′′′ Lyp = yp + a2 yp + a1 yp + a0 yp ′′ ′′ ′′ = c′ y1 + c′ y2 + c′ y3 + c1 Ly1 + c2 Ly2 + c3 Ly3 1 2 3 ′′ ′′ ′′ = c′ y 1 + c′ y 2 + c′ y 3 1 2 3 = r(x). using another degree of freedom. using one degree of freedom.29) No constants of integrations are needed here since the general solution will contain three arbitrary constants. (3. We solve the linear system for c′ (x) and integrate the solution c(x) = c′ (x) dx.26)–(3.5. 3 y1 (x) y2 (x) ′ ′ y1 (x) y2 (x) ′′ ′′ y1 (x) y2 (x) (3. 0 M (x)c′ (x) = 0 .28) that is. y2 and y3 are solutions of Ly = 0 and hence the term in square brackets is zero.24) is yg (x) = Ay1 + By2 + Cy3 + c1 (x)y1 + c2 (x)y2 + c3 (x)y3 . we diﬀerentiate yp (x): ′′′ ′′ ′′ ′′ yp (x) = c′ (x)y1 (x) + c′ (x)y2 (x) + c′ (x)y3 (x) 1 2 3 ′′′ ′′′ ′′′ + c1 (x)y1 (x) + c2 (x)y2 (x) + c3 (x)y3 (x) .27) c′ (x)y1 (x) + c′ (x)y2 (x) + c′ (x)y3 (x) = 0. y2 . Hence we have ′′ ′′ ′′ c′ y1 + c′ y2 + c′ y3 = r(x). PARTICULAR SOLUTION BY VARIATION OF PARAMETERS 61 where.30) . since y1 . y3 ) = det M = 0. c′ (x) and 1 2 ′ y3 (x) c1 (x) 0 ′ y3 (x) c′ (x) = 0 . 2 ′′ y3 (x) c′ (x) r(x) 3 (3. 1 2 3 (3.26) where. 1 2 3 ′ We diﬀerentiate yp (x): ′′ ′ ′ ′ yp (x) = c′ (x)y1 (x) + c′ (x)y2 (x) + c′ (x)y3 (x) 1 2 3 ′′ ′′ ′′ + c1 (x)y1 (x) + c2 (x)y2 (x) + c3 (x)y3 (x) ′′ ′′ ′′ = c1 (x)y1 (x) + c2 (x)y2 (x) + c3 (x)y3 (x). which we can do by our third and last degree of freedom. yp and yp . by Corollary 3. ′ ′′ ′′′ Using the expressions obtained for yp . The general solution is (3. we let the term in square brackets be zero.1 their Wronskian does not vanish.
Q(x)c′ (x) = QQT = cos x sin x − sin x cos x cos x sin x − sin x cos x = 1 0 0 1 . that is. Cramer’s rule leads to nice formulae for the solution of this system in two and three dimensions. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER Because of the particular form of the righthand side of system (3. solve (3.33) It then follows that the inverse Q−1 of Q is the transpose QT of Q. 0 .29) by an (x). that is. the matrix Q is orthogonal. sec x tan x In this particular case. c′ = QT Qc′ = QT that is. Example 3. by the method of variation of parameters. that is. c′ (x) = 3 y2 . i Remark 3. we put yp (x) = c1 (x) cos x + c2 (x) sin x.29).62 3. Q−1 = QT . If the coeﬃcient an (x) of y (n) is not equal to 1. In this case.31) In 3D. In 2D. (3. Solution. c′ and c′ by Cramer’s rule: 1 2 3 c′ (x) = 1 . c′ (x) 1 c′ (x) 2 = cos x sin x − sin x cos x 0 sec x tan x .3. c′ (x) = − 2 .12.33) by QT . . we obtain c′ by left multiplication of (3. We know that the general solution of the homogeneous equation is yh (x) = c1 cos x + c2 sin x. we have yp (x) = −y1 (x) r W y2 ′ y2 y3 ′ y3 y2 (x)r(x) dx + y2 (x) W (x) r W y1 ′ y1 y3 ′ y3 y1 (x)r(x) dx. (a) The analytic solution.32) integrate the c′ with respect to x and form yp (x) as in (3. 0 sec x tan x . Looking for a particular solution of the nonhomogeneous equation by the method of variation of parameters. W (x) r W y1 ′ y1 (3. Find the general solution of the diﬀerential equation (D2 + 1)y = sec x tan x. and have cos x sin x − sin x cos x c′ (x) 1 c′ (x) 2 = 0 sec x tan x . replace r(x) by r(x)/an (x). the method of undetermined coeﬃcients is not useful in this case.29) for c′ . we must divide the righthand side of (3. ′ y1 (3.25).— Since the space of derivatives of the righthand side is inﬁnite.
after integration. λ2 = 1. sin x tan x = − tan2 x.— dsolve(’D2y+y=sec(x)*tan(x)’. PARTICULAR SOLUTION BY VARIATION OF PARAMETERS 63 Hence. Example 3.3. we have the system 1 ex 0 ex 0 ex ′ e−x c1 (x) 0 . c2 = − ln  cos x = ln  sec x. Find the general solution of the diﬀerential equation y ′′′ − y ′ = cosh x by the method of variation of parameters. (b) The Matlab symbolic solution. −e−x c′ (x) = 0 2 −x ′ e c3 (x) cosh x We solve this system by Gaussian elimination: ′ c1 (x) 0 1 ex e−x .5. the particular solution of the nonhomogeneous equation is yp (x) = c1 (x) + c2 (x) ex + c3 (x) e−x .’x’) y = log(cos(x))*sin(x)sin(x)+x*cos(x)+C1*sin(x)+C2*cos(x) (sec2 x − 1) dx = x − tan x. By variation of parameters. cos x cos x sin x c′ = tan x = tan x = . λ3 = −1. 2 cos x cos x which. become c′ = − 1 c1 = − Thus. Thus.13. The characteristic equation is λ3 − λ = λ(λ2 − 1) = 0 =⇒ λ1 = 0. the particular solution is yp (x) = (x − tan x) cos x + (ln  sec x) sin x and the general solution is y(x) = yh (x) + yp (x) = A cos x + B sin x + (x − tan x) cos x + (ln  sec x) sin x. Solution. The general solution of the homogeneous equation is yh (x) = c1 + c2 ex + c3 e−x . 0 ex −e−x c′ (x) = 0 2 c′ (x) cosh x 0 0 2e−x 3 .
1 2 3 2 and after integration. e cosh x = ex 2 2 2 4 1 c′ = e−2x c′ = 1 + e−2x . we obtain = cosh x.64 3. 2 4 The general solution of the nonhomogeneous equation is 1 3 yg (x) = A + B ′ ex + C ′ e−x + x cosh x − sinh x 2 4 1 = A + B ex + C e−x + x cosh x. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER Hence 1 2x ex + e−x 1 1 x = e +1 . we have c′ = 3 1 4 1 c3 = 4 c2 = The particular solution is 1 1 1 1 x x ex − e−x + e + x e−x 4 2 4 2 1 x 1 e − e−x = − sinh x + x ex + e−x + 4 8 1 3 = x cosh x − sinh x. putting yp (x) = ax cosh x + bx sinh x in the equation y ′′′ − y ′ = cosh x. since cosh x and sinh x are linear combinations of ex and e−x which are solutions of the homogeneous equation. 1 2 ′′′ ′ yp − yp = 2a cosh x + 2b sinh x c1 = − sinh x x− 1 −2x e 2 1 2x e +x . In fact. 2 3 4 1 c′ = −ex c′ − e−x c′ = − ex + e−x = − cosh x. Symbolic Matlab does not produce a general solution in such a simple form. 2 where we have used the fact that the function ex − e−x sinh x = 2 is already contained in the general solution yh of the homogeneous equation. . yp (x) = − sinh x + If one uses the method of undetermined coeﬃcients to solve this problem. one has to take a particular solution of the form yp (x) = ax cosh x + bx sinh x. 2 whence a= and b = 0.
Ly := y ′′ + 3y ′ + 2y = 1 + ex Solution. PARTICULAR SOLUTION BY VARIATION OF PARAMETERS 65 Example 3.14. syms c dc A b yp. >> clear >> syms x real. Find the general solution of the diﬀerential equation 1 . Example 3. λ2 = −2.15. The characteristic polynomial of the homogeneous equation Ly = 0 is λ2 + 3λ + 2 = (λ + 1)(λ + 2) = 0 =⇒ λ1 = −1. the general solution yh (x) to Ly = 0 is yh (x) = c1 e−x + c2 e−2x . Since the dimension of the space of derivatives of the righthand side is inﬁnite.3. the general solution of the inhomogeneous equation is y(x) = A e−x + B e−2x + [ln (1 + ex )] e−x + [ln (1 + ex )] e−2x . a particular solution of the inhomogeneous equation is searched in the form yp (x) = c1 (x) e−x + c2 (x) e−2x . By variation of parameters. It is to be noted that the symbolic Matlab command dsolve produces a severallinelong solution that is unusable. y ′ (1) = 2. y(1) = 0. The functions c1 (x) and c2 (x) are the integrals of the solutions c′ (x) and c′ (x) 1 2 of the algebraic system Ac′ = b. Hence.5. >> A = [exp(x) exp(2*x). >> b=[0 1/(1+exp(x))]’. We therefore follow the theoretical method of Lagrange but do the simple algebraic and calculus manipulations by symbolic Matlab. exp(x) 2*exp(2*x)]. one has to use the method of variation of parameters. Solve the nonhomogeneous Euler–Cauchy diﬀerential equation with given initial values: Ly := 2x2 y ′′ + xy ′ − 3y = x−3 . . >> dc = A\b % solve for c’(x) dc = [ 1/exp(x)/(1+exp(x))] [ 1/exp(2*x)/(1+exp(x))] >> c = int(dc) % get c(x) by integrating c’(x) c = [ log(1+exp(x))] [ exp(x)+log(1+exp(x))] >> yp=c’*[exp(x) exp(2*x)]’ yp = log(1+exp(x))*exp(x)+(exp(x)+log(1+exp(x)))*exp(2*x) Since −e−x is contained in yh (x). We use symbolic Matlab to solve this simple system. e−x −e−x e−2x −2 e−2x c′ 1 c′ 2 = 0 1/(1 + ex ) .
after integration. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER Solution. general solution. Putting y = xm in the homogeneous equation Ly = 0 we obtain the characteristic polynomial: 2m2 − m − 3 = 0 =⇒ m1 = Thus. c1 (x) = − and the general solution is 2 −3 1 −3 x + x 45 10 1 −3 x . where the righthand side of the linear system has been divided by the coeﬃcient 2x2 of y ′′ to have the equation in standard form with the coeﬃcient of y ′′ equal to 1. 5 1 c′ = − x−3 . For this we need the derivative. 18 3 1 y ′ (1) = A − B − = 2. We need to solve the linear system 3 2 3 . 2 5 . of y(x). y ′ (x). 2 m2 = −1. 2 6 Solving for A and B. yh (x). 2 6 2 −9/2 x . y(x) = Ax3/2 + Bx−1 − y ′ (x) = Thus. To ﬁnd a particular solution. = Ax3/2 + Bx−1 + 18 The constants A and B are uniquely determined by the initial conditions. yp (x). of Ly = 0 is yh (x) = c1 x3/2 + c2 x−1 .66 3. We put yp (x) = c1 (x)x3/2 + c2 (x)x−1 . we use the method of variation of parameters since the dimension of the space of derivatives of the righthand side is inﬁnite. 45 c2 (x) = 1 −2 x . to the nonhomogeneous equation. 10 1 3 Ax1/2 − Bx−2 − x−4 . 45 B=− 9 . 45 10 18 38 . Solving this system for c′ and c′ . we have y(1) = A + B + A= The (unique) solution is y(x) = 9 −1 1 −3 38 3/2 x − x + x . we obtain 1 2 c′ = 1 Thus. 10 1 −11/2 x . 1 = 0. x3/2 x1/2 x−1 −x−2 c′ 1 c′ 2 = 1 2 0 x−5 .
6. The spring resists both extension and compression with Hooke’s constant equal to k. (See Fig.2. Forced Oscillations We present two examples of forced vibrations of mechanical systems. Solve the initial value problem with external force Ly := y ′′ + 9y = 8 sin t. We refer to Example 2. The general solution of Ly = 8 sin t is y(t) = A cos 3t + B sin 3t + sin t.2).4 for the derivation of the diﬀerential equation governing the nonforced system. Substituting this in Ly = 8 sin t we obtain ′′ yp + 9yp = (−a + 9a) cos t + (−b + 9b) sin t Ressort/Spring Masse/Mass r(t) Asservissement/External force Amortisseur/Dashpot y(0) = 1. Consider a vertical spring attached to a rigid beam. Following the method of undetermined coeﬃcients. and plot the solution.— The general solution of Ly = 0 is yh (t) = A cos 3t + B sin 3t. FORCED OSCILLATIONS 67 Poutre/Beam k y=0 m c y Figure 3. .16 (Forced oscillation without resonance). m m m Example 3. c k 1 y ′′ + y ′ + y= r(t). and simply add the external force to the righthand side. 3. Study the problem of the forced damped vertical oscillation of a mass of m kg which is attached at the lower end of the spring. we have a = 0. 3.6. Forced damped system. The damping constant is c and the external force is r(t). (a) The analytic solution.3. y ′ (0) = 1. b = 1. = 8 sin t. we choose yp of the form yp (t) = a cos t + b sin t. Solution. Identifying coeﬃcients on both sides.
.y0). we choose yp of the form yp (t) = at cos 3t + bt sin 3t.3.y).y(:. we have ′ y1 = y2 . (b) The Matlab symbolic solution.68 3. we put y1 = y.tspan. 3. LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER We determine A and B by means of the initial conditions: y(0) = A = 1. 1].— To rewrite the secondorder diﬀerential equation as a system of ﬁrstorder equations. y2 = y ′ .m: function yprime = exp312(t.1)) The numerical solution is plotted in Fig. 9*y(1)+8*sin(t)]. and plot the solution. y ′ (0) = 3B + 1 = 1 =⇒ B = 0. plot(x. % solution for t=0 to t=7 y0 = [1. y(0) = 1. Example 3.— The general solution of Ly = 0 is yh (t) = A cos 3t + B sin 3t. The Mﬁle exp312.17 (Forced oscillation with resonance). Solve the initial value problem with external force Ly := y ′′ + 9y = 6 sin 3t.’y(0)=1’. (a) The analytic solution. y ′ (0) = 2. yprime = [y(2). The (unique) solution is y(t) = cos 3t + sin t. % initial conditions [x. y ′ (t) = −3A sin 3t + 3B cos 3t + cos t. ′ y2 = −9y1 + 8 sin t. Thus. Since the righthand side of Ly = 6 sin 3t is contained in the solution yh . Then we obtain ′′ yp + 9yp = −6a sin 3t + 6b cos 3t = 6 sin 3t. The call to the ode23 solver and the plot command: tspan = [0 7]. Solution. following the method of undetermined coeﬃcients.’t’) y = sin(t)+cos(3*t) (c) The Matlab numeric solution.— dsolve(’D2y+9*y=8*sin(t)’.y] = ode23(’exp312’.’Dy(0)=1’.
y(t) = A cos 3t + B sin 3t − t cos 3t. y ′ (0) = 3B − 1 = 2 =⇒ B = 1.3.3.— To rewrite the secondorder diﬀerential equation as a system of ﬁrstorder equations. we have ′ y1 = y2 .m: . The Mﬁle exp313. comes from the resonance of the system because the frequency of the external force coincides with the natural frequency of the system. whose amplitude is increasing. Graph of solution of the linear equation in Example 3. y ′ (t) = −3A sin 3t + 3B cos 3t − cos 3t + 3t sin 3t.’t’) y = sin(3*t)cos(3*t)*t+cos(3*t) (c) The Matlab numeric solution. y(t) = cos 3t + sin 3t − t cos 3t.— dsolve(’D2y+9*y=6*sin(3*t)’.6. b = 0. ′ y2 = −9y1 + 6 sin 3t.16. The (unique) solution is The term −t cos 3t.’Dy(0)=2’. we have The general solution of Ly = 6 sin 3t is a = −1. y(0) = A = 1. Identifying coeﬃcients on both sides. FORCED OSCILLATIONS 69 Plot of solution 2 1 0 y −1 −2 0 2 4 x 6 8 Figure 3. we put y1 = y.’y(0)=1’. We determine A and B by means of the initial conditions. Thus. y2 = y ′ . (b) The Matlab symbolic solution.
plot(x.y] = ode23(’exp313’.y(:.y). 1].y0). LINEAR DIFFERENTIAL EQUATIONS OF ARBITRARY ORDER Plot of solution 6 4 2 0 −2 −4 −6 0 2 4 x 6 8 y Figure 3.70 3. 9*y(1)+6*sin(3*t)].17.1)) The numerical solution is plotted in Fig. function yprime = exp313(t.4. yprime = [y(2).tspan. % solution for t=0 to t=7 y0 = [1. . 3.4. Graph of solution of the linear equation in Example 3. The call to the ode23 solver and the plot command: tspan = [0 7]. % initial conditions [x.
k2 and k3 . . Set up a system of diﬀerential equations for the mechanical system shown in Fig. 0 . In matrix and vector notation. . un−1 0 0 0 −a0 −a1 −a2 un u1 = y. respectively.. un−1 ··· 1 · · · −an−1 un . . . . 0 r(x) where the dependent variables are deﬁned as u2 = y ′ . 0 0 . . and the righthand side. . 4. . u(x0 ) = k. Let x1 (t) and x2 (t) be the positions of the centers of mass of m1 and m2 away from their points of equilibrium. Example 4.. y(x0 ) = k1 . un = y (n−1) . x′′ (t) and x′′ (t) measure the acceleration 1 2 71 .1 Solution. Consider a mechanical system in which two masses m1 and m2 are connected to each other by three springs as shown in Fig. Introduction In Section 3. 0 r(x) the form + 0 0 . not necessarily of the form of a companion matrix. . y (n−1) (x0 ) = kn . g(x) = . this system is written as u′ (x) = A(x)u(x) + g(x). . r(x). ﬁrstorder equations in u1 ··· 0 u2 ··· 0 . . . respectively. An example of such systems follows.1. become k1 u1 (x0 ) u2 (x0 ) k2 . un−1 (x0 ) kn−1 kn un (x0 ) . In this chapter..1.1. the positive xdirection pointing to the right.. 4. . . . = .. the n initial values. = .. .. . .. y (n) + an−1 (x)y (n−1) + · · · + a1 (x)y ′ + a0 (x)y = r(x). In this case. . . where the matrix A(x) is a companion matrix. y ′ (x0 ) = k2 .1 with Hooke’s constants k1 .CHAPTER 4 Systems of Diﬀerential Equations 4. it was seen that a linear diﬀerential equation of order n. we shall consider linear systems of n equations where the matrix A(x) is a general n × n matrix. . Then. . can be written as a linear system of n ′ u1 0 1 0 u2 0 0 1 .
1) to a ﬁrstorder system of equations by introducing two new variables y1 and y2 representing the velocities of each mass: y1 = x′ . (4. m1 x′ = y2 . Mechanical system for Example 4. y2 (0) (4. of each mass. y1 .1) as the following four simultaneous equations in the four unknowns x1 . when mass m1 has moved a distance x1 to the right of its equilibrium position. while −k2 x2 is due to the movement of m2 and its inﬂuence on the same spring. . 1 y2 = x′ . 0 x1 +k y1 − k1m 2 1 . we rewrite (4. u= A= x2 0 k2 y2 m2 the initial value problem becomes u′ = Au. each force being proportional to the distance the spring is stretched or compressed. 2 ′ y1 = ′ y2 = (4. It is to be noted that the matrix A is not in the form of a companion matrix.5) 0 x1 0 y1 1 x2 y2 0 . the coeﬃcient matrix and 1 0 k2 0 m1 0 0 +k 0 − k2m2 3 0 0 1 0 x1 (0) y (0) u0 = 1 x2 (0) . the spring to the left of m1 exerts a restoring force −k1 x1 on this mass. The spring to the right of m1 exerts a restoring force −k2 (x2 − x1 ) on it. The resulting force acting on each mass is exerted on it by the springs that are attached to it. Following Newton’s second law of motion.1. 2 (4. For instance.4) u(0) = u0 . attempting to return the mass back to its equilibrium position. we arrive at the two coupled secondorder equations: m1 x′′ = −k1 x1 + k2 (x2 − x1 ). 2 (4. which. 1 −k1 x1 + k2 (x2 − x1 ) .72 4. SYSTEMS OF DIFFERENTIAL EQUATIONS k1 m1 k2 m2 k3 Figure 4. m2 1 0 0 0 0 k2 m1 Using the following notation for the given initial conditions. the part k2 x1 reﬂects the compression of the middle spring due to the movement of m1 .3) −k2 (x2 − x1 ) − k3 x2 . x2 and y2 : x′ = y1 . become ′ 0 x1 +k ′ y1 − k1m 2 1 ′ = x2 0 ′ k2 y2 m2 0 +k − k2m2 3 unknown vector.1) We convert each equation in (4.1. in matrix form.2) Using these new dependent variables. 1 m2 x′′ = −k2 (x2 − x1 ) − k3 x2 .
The Picard iteration method used in the proof of this theorem has been stated for systems of diﬀerential equations and needs no change for the present systems. b[. . y 2 . tr A = a11 + a22 + · · · + ann . yn1 (x) yn2 (x) ··· ynn (x) for all x ∈]a. .3. . . . y(x0 ) = y 0 . . denoted by tr A.7) provided the matrix A(x) and the vectorvalued function f (x) are continuous on the interval (x0 . b[ if the identity c1 y 1 (x) + c2 y 2 (x) + · · · + y m (x) = 0. xf ). implies that c1 = c2 = · · · = cm = 0. . . 4. we deﬁne the trace of a matrix A. . y 2 (x). z ∈ Rn . for all y.3. in Deﬁnition 1. norms replace absolute values in the Lipschitz condition f (z) − f (y) ≤ M z − y . . .2 for linear system of the form y ′ = A(x)y + g(x).3 holds for general ﬁrstorder systems of the form y ′ = f (x. . y(x0 ) = y 0 . (4. FUNDAMENTAL SYSTEMS 73 4. . . Otherwise. . y).2. and in the statement of the theorem. y 2 (x).6) provided. We restate and prove Liouville’s or Abel’s Lemma 3.1 for general linear systems. y n )(x) = det . b[. In particular. are said to be linearly independent on an interval ]a. of A.4. . is a generalization of the Wronskian for a linear scalar equation. . we recall results which have been quoted for systems in the previous chapters. y n (x). For general system. Existence and Uniqueness Theorem In this section. this set of functions is said to be linearly dependent. . y 1 (x). . m vectorvalued functions. y m (x). with values in Rn . As before. . y11 (x) y12 (x) · · · y1n (x) y21 (x) y22 (x) · · · y2n (x) W (y 1 . the existence and uniqueness Theorem 1.3. For this purpose. to be the sum of the diagonal elements. aii . A similar remark holds for the existence and uniqueness Theorem 3. . the determinant W (x) of n columnvector functions.8) form a vector space since diﬀerentiation and matrix multiplication are linear operators. . . x ∈]a. (4. y 1 (x). . Fundamental Systems It is readily seen that the solutions to the linear homogeneous system y ′ = A(x)y. . (4.
Remark 4. . .8).1 (Abel). b[. however. For instance. y 2 . y 2 . . . the general case is treated as easily. f 2 (x) = . ′ y12 = a11 y12 + a12 y22 + a13 y32 . SYSTEMS OF DIFFERENTIAL EQUATIONS Lemma 4. y n )(x) satisﬁes the following identity: W (x) = W (x0 ) e − Rx x0 tr A(t) dt . Their determinant. be n solutions of the system y ′ = A(x)y on the interval ]a. (4. let us take n = 3. . We see that the ﬁrst row of the diﬀerential system ′ ′ ′ y11 y12 y13 a11 a12 a13 y11 y12 y13 ′ ′ ′ y21 y22 y23 = a21 a22 a23 y21 y22 y23 ′ ′ ′ y31 y32 y33 a31 a32 a33 y31 y32 y33 is ′ y11 = a11 y11 + a12 y21 + a13 y31 .1.8) are independent at one point. is identically zero. It is worth emphasizing the diﬀerence between linear independence of vectorvalued functions and solutions of linear systems. Corollary 4. these solutions are linearly dependent at one point.74 4. 0 0 are linearly independent. Similarly. Substituting these expressions in the ﬁrst row of the ﬁrst determinant and subtracting a12 times the second row and a13 times the third row from the ﬁrst row. y 2 (x). on the other hand. ′ y13 = a11 y13 + a12 y23 + a13 y33 .1 since f 1 and f 2 cannot be solutions to a system (4. For simplicity of writing. Let W (x) be the determinant of three solutions y 1 .1. If. If n solutions to the homogeneous diﬀerential system (4. is zero. b[. . for the second and third determinants we obtain a22 W (x) and a33 W (x). Thus W (x) satisﬁes the separable equation W ′ (x) = tr A(x) W (x) whose solution is W (x) = W (x0 ) e Rx x0 tr A(t) dt . y 3 . the two vectorvalued functions x 1+x f 1 (x) = . y n (x).9) Proof. This does not contradict Corollary 4. Let y 1 (x). . Then its derivative W ′ (x) is of the form W ′ (x) = y11 y21 y31 ′ y11 y21 y31 y12 y22 y32 ′ y12 y22 y32 y13 y23 y33 ′ y13 y23 y33 ′ = + y11 ′ y21 y31 y12 ′ y22 y32 y13 ′ y23 y33 + y11 y21 ′ y31 y12 y22 ′ y32 y13 y23 ′ y33 . we obtain a11 W (x). . We consider the ﬁrst of the last three determinants. x0 ∈]a. Then the determinant W (y 1 . The following corollary follows from Abel’s lemma. then their determinant. . W (x). then they are independent on the interval ]a. b[. and hence they are everywhere dependent. respectively.
Let C be any constant matrix.1. The proof of the second part is similar. Let Y (x) be a fundamental matrix for the system (4. then y(x) = Y (x)y 0 is the unique solution of the initial value problem y ′ = A(x)y. we have (Y −1 )′ (x)Y (x) + Y −1 (x)Y ′ (x) = 0. y(x0 ) = y 0 . FUNDAMENTAL SYSTEMS 75 is called a fundamental matrix. then Z(x) = Y (x)Y −1 (x0 ) is also a fundamental matrix such that Z(x0 ) = I. Then. .4. Diﬀerentiating the identity Y −1 (x)Y (x) = I. . If Y (x0 ) = I. . Let x0 be in the domain of z(x) and deﬁne c by c = Y −1 (x0 )z(x0 ).8). Lemma 4. If Y (x) is a fundamental matrix. (Y T )−1 (x) is a fundamental solution for the adjoint system y ′ = −AT (x)y. . Proof. Then the general solution is y(x) = Y (x)c. Deﬁne y(x) = Y (x)c. . . we shall often assume that a fundamental matrix satisﬁes the condition Y (x0 ) = I. and the corresponding invertible matrix y11 (x) y12 (x) · · · y1n (x) y21 (x) y22 (x) · · · y2n (x) Y (x) = . . Theorem 4. Since Y ′ = AY .3. We have the following theorem for linear homogeneous systems. In the following. . To prove the ﬁrst part. (4. yn1 (x) yn2 (x) ··· ynn (x) Lemma 4. Proof.2. The following lemma will be used to obtain a formula for the solution of the initial value problem (4. . let Y (x) be a fundamental matrix and z(x) be any solution of the system. Z(x0 ) = I. Obviously.10) . . . Definition 4. they must be the same solution by the uniqueness theorem. . The lemma follows by letting C = Y −1 (x0 ).7) in terms of a fundamental solution. Let Y (x) be a fundamental matrix for y ′ = A(x)y.1. where c is an arbitrary vector. The proof of both statements rely on the uniqueness theorem. Proof. it follows that (Y C)′ = Y ′ C = (AY )C = A(Y C).3. A set of n linearly independent solutions of a linear homogeneous system y ′ = A(x)y is called a fundamental system. Since both y(x) and z(x) satisfy the same diﬀerential equation and the same initial conditions.
Example 4. we can replace Y ′ (x) in the previous identity with A(x)Y (x) and obtain (Y −1 )′ (x)Y (x) = −Y −1 (x)A(x)Y (x). A and its transpose are equal. Find the general solution of the symmetric system y ′ = Ay: y′ = 2 1 1 2 y. that is. A has a corresponding eigenvector and the set of such eigenvectors are linearly independent. Substituting (4.7) by Y −1 (x) and use the result of Lemma 4. Let Y (x) be a fundamental solution matrix of the homogeneous linear system (4.12) and dividing by eλx we obtain the eigenvalue problem (A − λI)v = 0. (4. v = 0. Multiply both sides of (4.13) where the number λ and the vector v are to be determined.76 4.8).3 to get Y −1 (x)y(x) ′ = Y −1 (x)g(x). Theorem 4. (4. we seek solutions of the form y(x) = eλx v.7) is y(x) = Y (x)Y −1 (x0 )y 0 + Y (x) x x0 Y −1 (t)g(t) dt.8). (4. AT = A. Multiplying this equation on the right by Y −1 (x) and taking the transpose of both sides lead to (4. It is known that for each distinct eigenvalue.4. .13) into (4. If A is symmetric.12) where the n × n matrix A has real constant entries. The lefthand side of this determinental equation is a polynomial of degree n and the n roots of this equation are called the eigenvalues of the matrix A. (4.2 (Solution formula). The proof of the theorem follows by integrating the previous expression with respect to x from x0 to x.10). 4. The corresponding nonzero vectors v are called the eigenvectors of A. Homogeneous Linear Systems with Constant Coeﬃcients A solution of a linear system with constant coeﬃcients can be expressed in terms of the eigenvalues and eigenvectors of the coeﬃcient matrix A. Then the unique solution to the initial value problem (4.11) Proof. Given a linear homogeneous system of the form y ′ = Ay.14) This equation has a nonzero solution v if and only if det(A − λI) = 0. SYSTEMS OF DIFFERENTIAL EQUATIONS Since the matrix Y (x) is a solution of (4.2. then the eigenvalues are real and A has n eigenvectors which can be chosen to be orthonormal.
[Y. Hence. . c2] z = [ 1/2*2^(1/2)*exp(x)*c1+1/2*2^(1/2)*exp(3*x)*c2] [ 1/2*2^(1/2)*exp(x)*c1+1/2*2^(1/2)*exp(3*x)*c2] Note that Matlab normalizes the eigenvectors in the l2 norm.4. e3x e3x . the eigenvector corresponding to λ2 is obtained from the singular system (A − 3I)v = −1 1 1 −1 v= 1 1 . syms x c1 c2 z = Y*diag(exp(diag(D*x)))*[c1.4. y = Y (x)c. u1 u2 Hence the eigenvalues are The eigenvector corresponding to λ1 is obtained from the singular system (A − I)u = = 0. Taking v1 = 1 we have the eigenvector Since λ1 = λ2 . 1 2].D] = eig(A). and the fundamental system and general solution are Y (x) = The Matlab solution is A = [2 1. The solution y y = simplify(sqrt(2)*z) y = [ exp(x)*c1+exp(3*x)*c2] [ exp(x)*c1+exp(3*x)*c2] is produced by the nonnormalized eigenvectors u and v. we have two independent solutions y 1 = ex 1 −1 ex −ex . Similarly. v1 v2 = 0. λ2 = 3. the matrix Y is orthogonal since the matrix A is symmetric. 1 1 1 1 = λ2 − 4λ + 3 = (λ − 1)(λ − 3) = 0. det(A − λI) = det 2−λ 1 1 2−λ λ1 = 1. HOMOGENEOUS LINEAR SYSTEMS WITH CONSTANT COEFFICIENTS 77 Solution. Taking u1 = 1 we have the eigenvector u= 1 −1 . The eigenvalues are obtained from the characteristic polynomial of A. y 2 = e3x 1 1 .
then it is diagonalizable Y −1 AY = D.3. x2 (t) = c2 eλ2 t . 0 0 0 1.1 A= 0 0 0 0. y = y0. 1 with solutions x1 (t) = c1 eλ1 t . . for i = 1:length(t)1 yy = Y*diag(exp(diag(D)*t(i+1)))*c. This fact can be used to solve the initial value problem y ′ = Ay.. Set y = Y x.. then Y is constant and x′ = Y −1 y ′ .D] = eig(A). or x = Y −1 y. Componentwise. . it follows that c = Y −1 y 0 . Hence the given system y ′ = Ay becomes Y −1 y ′ = Y −1 AY Y −1 y. [Y.1 0 0 1 0 x2 = y0 = y1 = 0. These results are used in the following example. c = inv(Y)*y0. where the columns of the matrix Y are eigenvectors of A and the corresponding eigenvalues are the diagonal elements of the diagonal matrix D..8 0 0 0]’. t = 0:1/5:60.1 0].78 4. we have x′ (t) = λ1 x1 (t). . Since A is constant. xn (t) = cn eλn t .. k1 = k2 = k3 = 1. and initial values x1 = 0. x′ (t) = λ2 x2 (t). The Matlab solution for x(t) and y(t) and their plot are A = [0 1 0 0. m2 = 20.2 0 0. y(0) = y 0 .05 0 0. where the constants c1 . x′ = Dx. Solution...1 0. Since y 0 = Y x(0) = Y c. Solve the system of Example 4.2 0 0. SYSTEMS OF DIFFERENTIAL EQUATIONS If the constant matrix A of the system y ′ = Ay has a full set of independent eigenvectors. Example 4. that is. y = [y. and plot the solution. . 0. 2 . xn (t)′ = λn xn (t). 0. The matrix A takes the form 0 1 0 −0. cn are determined by the initial conditions.1 with m1 = 10.05 0 −0.8. y0 = [0.yy]. . .
subplot(2. 4. If there are k < m linearly independent eigenvectors associated with λ. Example 3a.2 0 0. A = [0 1 0 0.:). 0 0 0 1. % MAT 2331.1 0]. but (A − λI)s−1 u = 0.2.5 −1 0 20 40 60 Figure 4. Let A be an n × n matrix. then the integer r =m−k is called the degree of deﬁciency of λ.1 0.y(:. A vector u is called a generalized eigenvector of A associated with λ if there is an integer s > 0 such that (A − λI)s u = 0.y(:. plot(t. . end ry = real(y).ry(3.2. [t. 0.m.t.3)). we have y0 = [0.:).1).’’).2.3. In this situation.4.ry(1.1).2. HOMOGENEOUS LINEAR SYSTEMS WITH CONSTANT COEFFICIENTS 79 1 0. one has recourse to generalized eigenvectors. plot(t.1).2. tspan=[0 60]. yprime = A*y.t. The plot is shown in Fig.8 0 0 0]. Graph of solution x1 (t) (solid line) and x2 (t) (dashed line) to Example 4. We say that λ is a deﬁcient eigenvalue of A if it has multiplicity m > 1 and fewer than m eigenvectors associated with it.tspan.4. function yprime = spring(t.05 0 0. 0. The case of multiple eigenvalues may lead to a lack of eigenvectors in the construction of a fundamental solution.2. Using the Mﬁle spring.4.y]=ode45(’spring’. The Matlab ode45 command from the ode suite produces the same numerical solution. Definition 4. here the imaginary part is zero subplot(2.5 0 −0. % the solution is real.y0).y).
12): y 1 (x) = eλx u1 . and is a second linearly independent solution. .. we solve the equation (A − I)e3 = e2 . Thus. .80 4. One ﬁnds that the matrix A has a triple eigenvalue λ = 1. generate the following set of linearly independent solutions of (4.. we obtain a matrix of rank 2. 1 (A − I)e2 = e1 . 0 0 0 1 1 y 1 (x) = 1 ex . To construct a second generalized eigenvector. Solve the system y ′ = Ay: 0 1 0 0 1 y. 2 ... given a matrix A with an eigenvalue λ of degree of deﬁciency r and corresponding eigenvector u1 . Rowreducing the matrix A − I.. It is a result of linear algebra that any n × n matrix has n linearly independent generalized eigenvectors. e1 = 1 .. . y 3 (x) = eλx x2 u1 + xu2 + u3 . The eigenvector u1 and the set of generalized eigenvectors. one solution is Solution. we construct a set of generalized eigenvectors {u2 . y 2 (x) = eλx (xu1 +u2 ). To construct a ﬁrst generalized eigenvector. . we solve the equation Thus. 3 e3 = 1 0 1 −2 y 2 (x) = (xe1 + e2 ) ex = x 1 + −1 ex 1 0 −2 e2 = −1 0 . (A − λI)u3 = u2 . SYSTEMS OF DIFFERENTIAL EQUATIONS In general. ur } as solutions of the systems (A − λI)u2 = u1 . in turn. y′ = 0 1 −3 3 Thus. .4. Example 4. hence A − I admits a single eigenvector e1 : −1 1 0 1 A − I ∼ 0 −1 1 . (A − λI)ur = ur−1 .
Solve the system y ′ = Ay: 1 2 1 7 2 y. α = 2 and β = −1. 0 1 y 2 (x) = 0 e3x . Hence the construction of a generalized eigenvector is a bit more complex. the invariant subspace associated with the triple eigenvalue is onedimensional. Hence the construction of two generalized eigenvectors is straightforward. e2 = 0 . where the parameters α and β are to be chosen so that the righthand side.— One ﬁnds that the matrix A has a triple eigenvalue λ = 3.4. y ′ = −4 4 −4 1 Solution. It follows that 1 0 e4 = 2 . 2 To obtain a third independent solution we construct a generalized eigenvector by solving the equation (A − 3I)e3 = αe1 + βe2 . (a) The analytic solution.4. Since rank(A − 3I) = 1. In the next example. hence A − 3I two independent eigenvectors. we obtain a matrix of rank 1. this invariant subspace associated with the triple eigenvalue is twodimensional.5. HOMOGENEOUS LINEAR SYSTEMS WITH CONSTANT COEFFICIENTS 81 and y 3 (x) = x e1 + xe2 + e2 2 2 is a third linearly independent solution. Rowreducing the matrix A − 3I. then 1 V = span 2 −2 and we may take α+β 1 α = 2 . e3 = 0 −2 1 . 2β is in the space V spanned by the columns of the matrix (A − 3I). 2β −2 Thus. α+β e4 = αe1 + βe2 = α . two independent solutions are 1 y 1 (x) = 1 e3x . 1 −2 3 x ex = 1 + x −1 + 1 ex 2 1 0 0 2 In the previous example. 0 0 0 0 2 Thus. Example 4. e1 = 1 . e1 and e2 : −2 2 1 1 1 A − 3I ∼ 0 0 0 .
u3=[0 0 1]’. y1 = exp(3*x)*X*u1 y1 = [ 2*exp(3*x)] [ 4*exp(3*x)] [ 4*exp(3*x)] . syms x.— To solve the problem with symbolic Matlab. y 3 = e3x Xu3 .0000 and the generalized eigenvector The matrix J − 3I admits the two eigenvectors 1 0 u1 = 0 .0000 4.0000 J = 3 0 0 1 3 0 1. one uses the Jordan normal form. of the matrix A.5000 0 1.82 4. If we let y = Xw. the equation simpliﬁes to w ′ = Jw. u3 = 0 .5000 0 1. u2=[0 1 0]’.0000 0 0 3 0. J = X −1 AX. SYSTEMS OF DIFFERENTIAL EQUATIONS 1 0 y 3 (x) = (xe4 + e3 ) e3x = x 2 + 0 ex −2 1 is a third linearly independent solution.J] = jordan(A) X = 2. 0 1 0 u2 = 1 . A = 1 4 4 2 7 4 1 2 1 and [X. (b) The Matlab symbolic solution.0000 4. that is (J − 3I)u2 = u1 . u1=[1 0 0]’. 0 the latter being a solution of the equation Thus three independent solutions are y 1 = e3x Xu1 . y 2 = e3x X(xu1 + u2 ).
λ2 = −i.1. The eigenvalues of the matrix A of the system are λ1 = i.5. Nonhomogeneous Linear Systems In Chapter 3. the general solution is the sum of y p and the solution y h of the homogeneous system y ′ = Ay. the appropriate choice of y p is a linear combination of vectors in the form of the functions that appear in f (x) together with all their derivatives. exponentials.4.5. Hence the general solution of the homogeneous system is y h (x) = k1 eix 1 i + k2 e−ix 1 −i . and the corresponding eigenvectors are u1 = 1 i . To obtain real independent solutions we use the fact that the real and imaginary parts of a solution of a real homogeneous . Solution.15) is ﬁnite.15) is constant and the dimension of the vector space spanned by the derivatives of the righthand side f (x) of (4. For such problems. Example 4. (4. where k1 and k2 are complex constants. sines. NONHOMOGENEOUS LINEAR SYSTEMS 83 y2 = exp(3*x)*X*(x*u1+u2) y2 = [ 2*exp(3*x)*x+3/2*exp(3*x)] [ 4*exp(3*x)*x] [ 4*exp(3*x)*x+exp(3*x)] y3 = exp(3*x)*X*u3 y3 = [ 1/2*exp(3*x)] [ 0] [ exp(3*x)] 4. Method of undetermined coeﬃcients.5.6. The method of undetermined coeﬃcients can be used when the matrix A in (4.15) We recall that once a particular solution y p of this system has been found. and polynomials. the method of undetermined coeﬃcients and the method of variation of parameters have been used for ﬁnding particular solutions of nonhomogeneous diﬀerential equations. In this section. Find the general solution of the nonhomogeneous linear system y′ = 0 1 −1 0 y+ 4 e−3x e−2x := Ay + f (x). u2 = 1 −i . This is the case when the components of f (x) are combinations of cosines. 4. hyperbolic sines and cosines. we generalize these methods to linear systems of the form y ′ = Ay + f (x).
84
4. SYSTEMS OF DIFFERENTIAL EQUATIONS
linear equation are solutions. We see that the real and imaginary parts of the ﬁrst solution, u1 = = 1 i eix = +i 1 0 +i , 0 1 (cos x + i sin x)
cos x − sin x
sin x cos x
are independent solutions. Hence, we obtain the following realvalued general solution of the homogeneous system y h (x) = c1 cos x − sin x + c2 sin x cos x .
The function f (x) can be written in the form f (x) = 4 1 0 e−3x + 0 1 e−2x = 4e1 e−3x + e2 e−2x
with obvious deﬁnitions for e1 and e2 . Note that f (x) and y h (x) do not have any part in common. We therefore choose y p (x) in the form y p (x) = a e−3x + b e−2x . Substituting y p (x) in the given system, we obtain 0 = (3a + Aa + 4e1 ) e−3x + (2b + Ab + e2 ) e−2x . Since the functions e−3x and e−2x are linearly independent, their coeﬃcients must be zero, from which we obtain two equations for a and b, (A + 3I)a = −4e1 , Hence, a = −(A + 3I)−1 (4e1 ) = − b = −(A + 2I)−1 (e2 ) = Finally, 1 5 1 5 6 2 1 −2 . (A + 2I)b = −e2 .
The general solution is
6 −3x − 5e y h (x) = − 2 e−3x + 5
1 −2x e 5 2 −2x . e 5
y(x) = y h (x) + y p (x).
4.5. NONHOMOGENEOUS LINEAR SYSTEMS
85
4.5.2. Method of variation of parameters. The method of variation of parameters can be applied, at least theoretically, to nonhomogeneous systems with nonconstant matrix A(x) and general righthand side f (x). A fundamental matrix solution Y (x) = [y 1 , y 2 , . . . , y n ], of the homogeneous system y ′ = A(x)y satisﬁes the equation Y ′ (x) = A(x)Y (x). Since the columns of Y (x) are linearly independent, the general solution y h (x) of the homogeneous system is a linear combinations of these columns, y h (x) = Y (x)c, where c is an arbitrary nvector. The method of variation of parameter seeks a particular solution y p (x) to the nonhomogeneous system y ′ = A(x)y + f (x) in the form y p (x) = Y (x)c(x). Substituting this expression in the nonhomogeneous system, we obtain Y ′ c + Y c′ = AY c + f . Since Y ′ = AY , therefore Y ′ c = AY c. Thus, the previous expression reduces to Y c′ = f . The fundamental matrix solution being invertible, we have c′ (x) = Y −1 (x)f (x), It follows that y p (x) = Y (x)
x
or c(x) =
x
Y −1 (s)f (s) ds.
Y −1 (s)f (s) ds.
In the case of an initial value problem with y(0) = y 0 , the unique solution is y(x) = Y (x)Y −1 (0)y 0 + Y (x)
x 0
Y −1 (s)f (s) ds.
It is left to the reader to solve Example 4.6 by the method of variation of parameters.
CHAPTER 5
Analytic Solutions
5.1. The Method We illustrate the method by a very simple example. Example 5.1. Find a power series solution of the form y(x) = a0 + a1 x + a2 x2 + . . . to the initial value problem y ′′ + 25y = 0, y(0) = 3, y ′ (0) = 13.
Solution. In this simple case, we already know the general solution, y(x) = a cos 5x + b sin 5x, of the ordinary diﬀerential equation. The arbitrary constants a and b are determined by the initial conditions, y(0) = a = 3 =⇒ a = 3, y ′ (0) = 5b = 13 =⇒ b = We also know that cos 5x = 1 − and sin 5x = 5x − (5x)2 (5x)4 (5x)6 + − + −... 2! 4! 6! 13 . 5
(5x)5 (5x)7 (5x)3 + − + −... 3! 5! 7! To obtain the series solution, we substitute y(x) = a0 + a1 x + a2 x2 + a3 x3 + . . . in y ′′ + 25y = 0. Hence 25y(x) = 25a0 + 25a1 x + 25a2 x2 + 25a3 x3 + 25a4 x4 + . . . Adding each side, we have 0 = (2a2 + 25a0 ) + (3 × 2a3 + 25a1 )x + (4 × 3a4 + 25a2 )x2 + . . . , Since this is an identity in 1, x, x2 , x3 , . . . ,
87
y ′′ (x) = 2a2 + 3 × 2a3 x + 4 × 3a4 x2 + 5 × 4a5 x3 + 6 × 5a6 x4 + . . .
for all x.
88
5. ANALYTIC SOLUTIONS
we can identify the coeﬃcients of the same powers of x on the left and righthand sides. It thus follows that all the coeﬃcients are zero. Hence with undetermined values for a0 and a1 , we have 52 a0 , 2! 52 3 × 2a3 + 25a1 = 0 =⇒ a3 = − a1 , 3! 54 4 × 3a4 + 25a2 = 0 =⇒ a4 = a0 , 4! 54 5 × 4a5 + 25a3 = 0 =⇒ a5 = a1 , 5! etc. We therefore have the following expansion for y(x), 2a2 + 25a0 = 0 =⇒ a2 = − 1 1 1 (5x)2 + (5x)4 − (5x)6 + . . . 2! 4! 6! a1 1 1 + 5x − (5x)3 + (5x)5 − . . . 5 3! 5! a1 sin 5x. = a0 cos 5x + 5 The parameter a0 is determined by the initial condition y(0) = 3, y(x) = a0 1 − a0 = 3. To determine a1 , we diﬀerentiate y(x), y ′ (x) = −5a0 sin 5x + a1 cos 5x, and set x = 0. Thus, we have y ′ (0) = a1 = 13 by the initial condition y ′ (0) = 13. 5.2. Foundation of the Power Series Method It will be convenient to consider power series in the complex plane. We recall that a point z in the complex plane C admits the following representations: • Cartesian or algebraic: z = x + iy, • trigonometric: • polar or exponential: where r= x2 + y 2 , i2 = −1,
z = r(cos θ + i sin θ), z = r eiθ ,
y θ = arg z = arctan . x As usual, z = x − iy denotes the complex conjugate of z and ¯ √ z = x2 + y 2 = z z = r ¯ denotes the modulus of z (see Fig. 5.1).
5.2. FOUNDATION OF THE POWER SERIES METHOD
89
y z=x+iy = re i θ r θ 0 x
Figure 5.1. A point z = x + iy = r eiθ in the complex plane C. Example 5.2. Extend the function 1 , 1−x to the complex plane and expand in power series with centres at z0 = 0, z0 = −1, and z0 = i, respectively. f (x) = Solution. We extend the function 1 f (x) = , x ∈ R \ {1}, 1−x of a real variable to the complex plane 1 , z = x + iy ∈ C. f (z) = 1−z This is a rational function with a simple pole at z = 0. We say that z = 1 is a pole of f (z) since f (z) tends to +∞ as z → 1. Moreover, z = 1 is a simple pole since 1 − z appears to the ﬁrst power in the denominator. We expand f (z) in a Taylor series around 0, 1 1 f (z) = f (0) + f ′ (0)z + f ′′ (0)z 2 + . . . 1! 2! Since 1 f (z) = =⇒ f (0) = 1, (1 − z) 1! =⇒ f ′ (0) = 1!, f ′ (z) = (1 − z)2 2! f ′′ (z) = =⇒ f ′′ (0) = 2!, (1 − z)3 . . . f (n) (z) = it follows that n! =⇒ f (n) (0) = n!, (1 − z)n+1 1 1−z = 1 + z + z2 + z3 + . . .
∞
f (z) =
=
n=0
z n.
2 The centre of the disk of convergence is z = −1 and the radius of convergence is R = 2. We shall use the following result. 1 1 = f (z) = 1−z 1 − (z + 1 − 1) 1 1 1 = = 2 − (z + 1) 2 1 − ( z+1 ) 2 = 1 2 1+ z+1 + 2 z+1 2 2 + z+1 2 3 + z+1 2 4 + . . the radius of convergence R of the series n=0 z n is 1. This example shows that the Taylor series expansion of a function f (z).. The reciprocal of the radius of convergence R of a power series with centre z = a. or z − (−1) < 2. The series converges absolutely for z+1 < 1.1 (Convergence Criteria).2). that is z − i < 1 − i = 2. that is. Finally. with centre z = a and radius of convergence R. that is z + 1 < 2.. ∞ Thus. that is. we expand f (z) in a neighbourhood of z = i. .. zn < ∞.90 5. 1 1 = f (z) = 1−z 1 − (z − i + i) 1 1 1 = = (1 − i) − (z − i) 1 − i 1 − ( z−i ) 1−i = 1 1−i 1+ z−i + 1−i z−i 1−i 2 + z−i 1−i 3 + z−i 1−i 4 + .. Theorem 5. stops being convergent as soon as z − a ≥ R. and uniformly for z ≤ ρ < 1.3). as soon as z − a is bigger than the distance from a to the nearest singularity z1 of f (z) (see Fig. 5. n=N for all N > Nǫ and all z ≤ ρ < 1. ANALYTIC SOLUTIONS The series converges absolutely for z ≡ ∞ n=0 x2 + y 2 < 1. 5. we expand f (z) in a neighbourhood of z = −1. ∞ m=0 am (z − a)m . (5. 1−i We see that the centre of the disk of convergence is z = i and the radius of √ convergence is R = 2 = 1 − i (see Fig. for all z < 1.1) . The series converges absolutely for √ z−i < 1. given ǫ > 0 there exists Nǫ such that ∞ z n < ǫ. that is. Now.
y a 0 R z1 Figure 5.3. m→∞ Let R be maximum of z − a such that the equality m→∞ lim am 1/m R = 1 . Proof. Distance R from the centre a to the nearest singularity z1 .2) (5. FOUNDATION OF THE POWER SERIES METHOD 91 y i R=√2 0 1 x Figure 5. 1 am+1 .2.3) cm m=0 converges if m→∞ lim cm 1/m < 1. R m→∞ The following criterion also holds. is equal to the following limit superior. By the root test. the power series converges if m→∞ lim am (z − a)m 1/m = lim am 1/m z − a < 1. states that the series ∞ x (5. Distance from the centre a = i to the pole z = 1. also called Cauchy’s criterion. = lim m→∞ R am if this limit exists. The root test. 1 = lim sup am 1/m .5.2.
3. 1 1 = lim sup am 1/m = lim m→∞ k m R m→∞ Hence the radius of convergence of the series is R = k1/3 . km m=0 ∞ z 3  = w < k. Solution. This establishes criterion (5. 3m 3m−1 x . ANALYTIC SOLUTIONS is satisﬁed. km Then the radius of convergence. one must take the limit superior. m→∞ cm  By the ratio test.3). R1 m→∞ k m+1 k Therefore the original series converges for The radius of convergence R′ of the diﬀerentiated series. that is the largest limit. the power series converges if lim am+1  am+1 (z − a)m+1  = lim z − a < 1. which becomes ∞ 0 1/3m = 1 .92 5. k1/3 1 m w . This establishes criterion (5. ∞ Example 5. which states that the series ∞ cm m=0 converges if cm+1  < 1. If there are several limits. By the root test. that is z < k1/3 . Find the radius of convergence of the series 1 3m x km m=0 and of its ﬁrst termbyterm derivative. of the new series is given by 1 1 km = = lim . The second criterion follows from the ratio test. also called d’Alembert’s criterion. m m→∞ am  m→∞ am (z − a) lim lim am+1  R=1 am  Let R be maximum of z − a such that the equality m→∞ is satisﬁed.2). . we put w = z3 in the series. To use the ratio test. R1 .
R). the series is termwise inﬁnitely often diﬀerentiable. Proof. k1/3 1 k 1/(3−1/m) m→∞ lim 3m1/(3m−1) = 1. 1.2. . 2.1. A function f (z) analytic in D(a. . . . Theorem 5. Consider the secondorder ordinary diﬀerential equation y ′′ + f (x)y ′ + g(x)y = r(x). We say that a function f (z) is analytic inside a disk D(a. The following general theorem holds for ordinary diﬀerential equations with analytic coeﬃcients. R) and f (z) is diﬀerentiable in D(a. One sees by induction that all termbyterm derivatives of a given series have the same radius of convergence R. if it has a power series with centre a. in D(a. Definition 5. R) admits the power series representation ∞ f (n) (a) (z − a)n f (z) = n! n=0 uniformly and absolutely convergent in D(a. FOUNDATION OF THE POWER SERIES METHOD 93 is obtained in a similar way: 1 3m = lim m→∞ k m R′ m→∞ 1/(3m−1) = lim 3m1/(3m−1) lim = lim = since m→∞ m→∞ 1 km (1/m)(m/(3m−1) 1 . of centre a and radius R > 0.5. Theorem 5. the result follows from the facts that the diﬀerentiated series converges uniformly in every closed disk strictly contained inside D(a. R). R). R).3 (Existence of Series Solutions).2. Since the radius of convergence of the termwise diﬀerentiated series is still R. R). which is uniformly convergent in every closed subdisk strictly contained inside D(a. ∞ f (z) = n=0 an (z − a)n . and ∞ f (k) (z) = n=k f (n) (a) (z − a)n−k . (n − k)! k = 0. Moreover f (z) is inﬁnitely often diﬀerentiable. . The following theorem follows from the previous deﬁnition.
. Use the power series method to solve the initial value problem y ′ − xy − 1 = 0. This method consists in ﬁnding a series with nonnegative coeﬃcients which converges absolutely in D(a. .4.20.2 and 5. . . ∞ n=0 bn (x − a)n . The sum of the lefthand side is zero since y(x) is assumed to be a solution of the diﬀerential equation. . If R is equal to the minimum of the radii of convergence of the power series expansions of f (z).94 5. Hence. . In closing this section.19 and 1. . ANALYTIC SOLUTIONS where f (z). We shall use Theorems 5. ∞ y(x) = n=0 an (x − a)n . . the coeﬃcient of each xs . we shall obtain the power series solution of the Legendre equation and prove the orthogonality relation satisﬁed by the Legendre polynomials Pn (x). Putting y(x) = a0 + a1 x + a2 x2 + a3 x3 + . bn ≥ 0. and whose coeﬃcients majorizes the absolute value of the coeﬃcients of the solution. Proof. R). then the diﬀerential equation admits an analytic solution in a disk of centre a and radius of convergence R. is zero. This general solution contains two undetermined coeﬃcients. summing the righthand side. g(z) and r(z) with centre z = a. In the next two sections. we revisit Examples 1. 2. that is.3 to obtain power series solutions of ordinary diﬀerential equations. Solution. in the diﬀerential equation. Example 5. since the diﬀerential equation is of the ﬁrst order. 1. −xy − a0 x − a1 x2 − a2 x3 − . The proof makes use of majorizing series in the complex plane C. an  ≤ bn . g(z) and r(z) are analytic functions in a circular neighbourhood of the point a. Since this is an identity in x. . Moreover. one of the coeﬃcients . we have 0 = (a1 − 1) + (2a2 − a0 )x + (3a3 − a1)x2 + (4a4 − a2)x3 + . . . we have y ′ 1a1 + 2a2 x + 3a3 x2 + 4a4 x3 + . . = −1 −1 y(0) = 1. for s = 0. .
1 − x2 1 − x2 g(x) = − n(n + 1) . a0 2a2 − a0 = 0 =⇒ a2 = . we have a1 − 1 = 0 =⇒ a1 = 1.3. Legendre Equation and Legendre Polynomials We look for the general solution of the Legendre equation: (1 − x2 )y ′′ − 2xy ′ + n(n + 1)y = 0. 1 − x2 n(n + 1) g(x) = = n(n + 1)[1 + x2 + x4 + x6 + .3. . −1 < x < 1. −1 < x < 1. . −∞ < x < ∞. LEGENDRE EQUATION AND LEGENDRE POLYNOMIALS 95 will be undetermined. 2 a1 = 3a3 − a1 = 0 =⇒ a3 = 3 a2 4a4 − a2 = 0 =⇒ a4 = = 4 a3 5a5 − a3 = 0 =⇒ a5 = = 5 a0 arbitrary. (x − 1)(x + 1) have simple poles at x = ±1. 15 and so on. 8 1 . By Theorem 5. 3 a0 . f (x) = 2x ′ n(n + 1) y + y = 0.5. we see that f (x) and g(x) are analytic for −1 < x < 1. We rewrite the equation in standard form y ′′ + f (x)y ′ + g(x)y = r(x). Moreover Hence. The initial condition y(0) = 1 implies that a0 = 1.4) in the form of a power series with centre a = 0. 1 − x2 r(x) = 0.19 and 1.5) . ]. Set ∞ y(x) = m=0 am xm (5. they have convergent power series with centre a = 0 and radius of convergence R = 1: f (x) = − 2x = −2x[1 + x2 + x4 + x6 + . Hence the solution is x3 x4 x5 x2 + + + + . −1 < x < 1.20. we know that (5. . 1 . (5.4) has two linearly independent analytic solutions for −1 < x < 1. (x − 1)(x + 1) 2x .3.. Hence. and r(x) is everywhere analytic. . 5.. y ′′ − Since the coeﬃcients.. y(x) = 1 + x + 2 3 8 15 which coincides with the solutions of Examples 1. ].
−x2 y ′′ = ′ − 2a1 x − 2 × 2a2 x2 − 2 × 3a3 x3 − . where n(n + 1) 2 (n − 2)n(n + 1)(n + 3) 4 x + x − +.... Moreover. summing the righthand side. (n − s)(n + s + 1) as . a5 = a1 . . .. The solution can be written in the form a2 = − y(x) = a0 y1 (x) + a1 y2 (x). We remark that y1 (x) is even and y2 (x) is odd. −2 × 1a2 x2 − 3 × 2a3 x3 − . . Hence. 1. is zero.. (5. Since y1 (x) = const. ANALYTIC SOLUTIONS and substitute in (5. y2 (x) it follows that y1 (x) and y2 (x) are two independent solutions and (5.6) 2! 3! (n − 3)(n − 1)(n + 2)(n + 4) (n − 2)n(n + 1)(n + 3) a0 . 2! a0 is undetermined.. + [(s + 2)(s + 1)as+2 − s(s − 1)as − 2sas + kas ]xs for all x. . 3! (s + 2)(s + 1)as+2 + [−s(s − 1) − 2s + n(n + 1)]as = 0 =⇒ as+2 = − Therefore. y2 (x) = x − 3! 5! Each series converges for x < R = 1. (5.8) is the general solution.4) is an equation of the second order. a1 is undetermined. Since we have an identity in x. 2.. y ′′ 2 × 1a2 + 3 × 2a3 x + 4 × 3a4 x2 + 5 × 4a5 x3 + . 2! 4! (n − 1)(n + 2) 3 (n − 3)(n − 1)(n + 2)(n + 4) 5 x + x − +. (s + 2)(s + 1) s = 0.4). . 2. for s = 0. Hence. + (4 × 3a4 − 2 × 1a2 − 2 × 2a2 + ka2 )x2 + . . we have + (3 × 2a3 − 2a1 + ka1 )x + . . .. y1 (x) = 1 − (5. a3 = − a1 . . . we have 2!a2 + ka0 = 0 =⇒ a2 = − n(n + 1) a0 . with k = n(n + 1). .8) . two of the coeﬃcients will be undetermined. . n(n + 1) (n − 1)(n + 2) a0 . −2xy ka0 + ka1 x + ka2 x2 + ka3 x3 + . .5) is assumed to be a solution of the Legendre equation. since (5. .. 1. (3 × 2)a3 + (−2 + k)a1 = 0 =⇒ a3 = 2 − n(n + 1) a1 ..96 5. .7) a4 = 4! 5! etc. the coeﬃcient of xs . ky 0 = (2 × 1a2 + ka0 ) The sum of the lefthand side is zero since (5.
’x’) y = 1 >> dsolve(’(1x^2)*D2y2*x*Dy+2*y=0’.1. These zeros are simple and interlace the n − 1 zeros of Pn−1 (x). Remark 5. Similarly. 4. 2 2 1 1 P4 (x) = 35x4 − 30x2 + 3 .1. 5. P5 (x) = 63x5 − 70x3 + 15x .5 1 . .’x’) y = x P0 P 1 x P3 p2 0. of degree n. respectively. 3. 1[. For n even. y1 (x) = kn Pn (x).4. and n = 1. P3 (x) = 5x3 − 3x . . .5 −0. We notice that the n zeros of the polynomial Pn (x).’y(1)=1’.5 P4 −1 −0. It can be shown that the series for y1 (x) and y2 (x) diverge at x = ±1 if n = 0. y2 (x) = kn Pn (x). 8 8 The graphs of the ﬁrst ﬁve Pn (x) are shown in Fig. The ﬁrst six Legendre polynomials are: P0 (x) = 1. . 1 1 P2 (x) = 3x2 − 1 . y1 (x) is an even polynomial. LEGENDRE EQUATION AND LEGENDRE POLYNOMIALS 97 P (x) n 1 0. . P1 (x) = x. Symbolic Matlab can be used to obtain the Legendre polynomials if we use the condition Pn (1) = 1 as follows. 2. >> dsolve(’(1x^2)*D2y2*x*Dy=0’. . 5. lie in the open interval ] − 1. two properties that are ordinarily possessed by the zeros of orthogonal functions. Corollary 5. .3. The polynomial Pn (x) is the Legendre polynomial of degree n. for n odd.’y(1)=1’.5. y2 (x) is an odd polynomial.4.5 −1 Figure 5. normalized such that Pn (1) = 1. . The ﬁrst ﬁve Legendre polynomials.
m = n.4. rewritten in divergence form. (5. we have ′ Pn (x)(1 − x2 )Pm (x) 1 −1 1 − −1 ′ ′ Pn (x)(1 − x2 )Pm (x) dx 1 + m(m + 1) −1 ′ Pm (x)(1 − x2 )Pn (x) 1 −1 1 Pn (x)Pm (x) dx = 0.4. Pm (x)Ln (Pn ) = 0. Integrating these two expressions from −1 to 1. 5. Pn (x)Pm (x) dx = 0. Orthogonality Relations for Pn (x) Theorem 5. subtracting these equations. The integrated terms are zero and the next term is the same in both equations. respectively.’x’) y = 1/2+3/2*x^2 and so on. m = n. With the extended symbolic toolbox and the professional Matlab. −1 −1 Now integrating by parts the ﬁrst term of these expressions. We give below two proofs of the second part (m = n) of the orthogonality relation.9) Pm (x)Pn (x) dx = 2 −1 2n+1 .’y(1)=1’. ANALYTIC SOLUTIONS >> dsolve(’(1x^2)*D2y2*x*Dy+6*y=0’. −1 1 Pm (x)Pn (x) dx = 0. . we have Pn (x)Lm (Pm ) = 0.x). 1 0. Proof. − −1 ′ ′ Pm (x)(1 − x2 )Pn (x) dx 1 + n(n + 1) −1 Pm (x)Pn (x) dx = 0. we have 1 −1 1 ′ Pn (x)[(1 − x2 )Pm (x)]′ dx + m(m + 1) ′ Pm (x)[(1 − x2 )Pn (x)]′ dx + n(n + 1) 1 Ln y := [(1 − x2 )y ′ ]′ + n(n + 1)y = 0. The ﬁrst part (m = n) follows simply from the Legendre equation (1 − x2 )y ′′ − 2xy ′ + n(n + 1)y = 0. Hence. Since Pm (x) and Pn (x) are solutions of Lm y = 0 and Ln y = 0. the Legendre polynomials Pn (x) can be obtained from the full Maple kernel by using the command orthopoly[L](n. which is referenced by the command mhelp orthopoly[L].98 5. we obtain the orthogonality relation 1 [m(m + 1) − n(n + 1)] =⇒ Pm (x)Pn (x) dx = 0 −1 1 Pm (x)Pn (x) dx = 0 −1 for m = n. The Legendre polynomials Pn (x) satisfy the following orthogonality relation.
3.. Pn 2 1 := −1 [Pn (x)]2 dx = 2 .. .2.4) p4 = x^4+3*(x^21)*x^2+3/8*(x^21)^2 >> p4 = expand(p4) p4 = 3/815/4*x^2+35/8*x^4 We ﬁnally present a second proof of the formula for the norm of Pn . 1 −1 2 Pn (x) dx = 1 2n n! dn dxn x2 − 1 n . 2n + 1 2n2(n − 1)2(n − 2) · · · 2(n − (n − 1)) (−1)n (2n)! (−1)n 2n n!2n n! 1 × 3 × 5 × · · · × (2n − 1) 1 −1 x2n dx 1 −1 Remark 5. . 1 1 1 1 1 × × n × (−1)n (2n)! 1 × x2 − 1 2n n! 2 n! −1 {and integrating by parts n times} n 1 −1 dx + (−1)1 2n 1! 1 −1 x2 x2 − 1 n−1 dx = = 2n n! 1 (−1)n (−1)n (2n)! x2n+1 n n!2n n! 2 1 × 3 × 5 × · · · × (2n − 1) (2n + 1) 2 = .x. or otherwise. 2n + 1 . >> syms x >> p4 = (1/(2^4*prod(1:4)))*diff(f. .. Rodrigues’ formula can be obtained by direct computation with n = 0. 1 −1 n n dn x2 − 1 dxn 1 −1 n dx = dn x2 − 1 dxn n dn+1 dn−1 2 (x − 1)n n+1 x2 − 1 dxn−1 dx n dx = 1 1 1 1 1 x2 − 1 × × n × (−1)n 2n n! 2 n! −1 {and diﬀerentiating 2n times} d2n x2 − 1 dx2n n n dx = = (−1)n (2n)! x 2 x −1 2n n!2n n! 1 + . We compute P4 (x) using Rodrigues’ formula with the symbolic Matlab command diff. . 2.. (5.5.4. 1.10) 1 1 1 dn 1 1 × x2 − 1 × n× 2n n! 2 n! −1 dxn {and integrating by parts n times} 1 1 1 dn−1 1 × × n× x2 − 1 n 2 n! 2 n! dxn−1 + (−1)1 + . ORTHOGONALITY RELATIONS FOR Pn (x) 99 The second part (m = n) follows from Rodrigues’ formula: Pn (x) = In fact.
f = 1/(12*x*t+t^2)^(1/2). 1 1 + 1−t 1+t for all t. ∞ Pk k=0 2 2k+1 t = − ln (1 − t) + ln (1 + t) and diﬀerentiating with respect to t. Hence. we obtain ∞ Pk k=0 2 2k t =− =− 1 ln 1 − 2xt + t2 2t x=1 x=−1 1 ln (1 − t) − ln (1 + t) . 1 − 2xt + t2 and integrating from −1 to 1.t) g = 1+t*x+(1/2+3/2*x^2)*t^2 +(3/2*x+5/2*x^3)*t^3+(3/815/4*x^2+35/8*x^4)*t^4 .3. (2k + 1) Pk 2 = 2 =⇒ Pk 2 = 2 . the second term on the lefthand side is zero.11). ANALYTIC SOLUTIONS by means of the generating function for Pn (x). 2k + 1 Remark 5. as is easily done with symbolic Matlab by means of the command taylor. Since we have an identity in t.11) Pj (x)Pk (x)tj+k = 1 . 1 . we have ∞ (2k + 1) Pk k=0 2 2k t = = 2 1 − t2 = 2 1 + t2 + t4 + t6 + . 1 − 2xt + t2 Since Pj (x) and Pk (x) are orthogonal for j = k.11) can be obtained by expanding its righthand side in a Taylor series in t. . Pk (x)tk = √ 1 − 2xt + t2 k=0 Proof. ∞ 2 Pk (x)t2k + k=0 j=k ∞ (5. we have ∞ 1 −1 2 Pk (x) dx t2k + j=k 1 −1 Pj (x)Pk (x) dx tj+k = 1 −1 k=0 dx .100 5. we can identify the coeﬃcients of t2k on both sides. >> syms t x. The generating function (5. >> g = taylor(f. after integration of the righthand side.3. t < 1. . Squaring both sides of (5. t Multiplying by t.
. Aﬃne mapping of x ∈ [3.5. Thus p(x) = 2 P3 (x) + 5 2 = P3 (x) − 5 3 P1 (x) − 5 4 P2 (x) + 3 4 2 P2 (x) − P0 (x) + 4P1 (x) + P0 (x) 3 3 23 1 P1 (x) + P0 (x). Example 5.6. . . we have x = 2s + 5.12) Solving for α and β. Solution.. 1] (see Fig. 5. 7] onto s ∈ [−1. 5 3 1 P0 (x). one avoids computing integrals. FOURIER–LEGENDRE SERIES 101 −1 0 1 s 0 3 5 7 x Figure 5. To map the segment x ∈ [3. 1].. 7] onto the segment s ∈ [−1.5) we consider the aﬃne transformation s → x = αs + β. Fourier–Legendre Series We present simple examples of expansions in Fourier–Legendre series. . We express the powers of x in terms of the basis of Legendre polynomials: P0 (x) = 1 =⇒ 1 = P0 (x). 3 3 P1 (x). Example 5. P1 (x). 2 1 P2 (x) = (3x2 − 1) =⇒ x2 = P2 (x) + 2 3 1 2 3 3 P3 (x) = (5x − 3x) =⇒ x = P3 (x) + 2 5 This way.5. P1 (x). 7] in terms of the Legendre polynomials P0 (x). 5. 1 → 7 = α + β. such that − 1 → 3 = −α + β. P1 (x) = x =⇒ x = P1 (x).5. Expand the polynomial p(x) = x3 − 2x2 + 4x + 1 over [−1. 5 . Solution.5. 1] in terms of the Legendre polynomials P0 (x).5. Expand the polynomial p(x) = 2 + 3x + 5x2 over [3. . (5.
that is x = ∞ s 1 + . . −1 f (x)P0 (x) dx = −1 1 1 2 1 x dx = 0 1 1 .8. 2 3 a1 = 2 5 a2 = 2 3 f (x)P1 (x) dx = 2 −1 5 f (x)P2 (x) dx = 2 −1 1 x2 dx = 0 1 x 0 5 1 (3x2 − 1) dx = . Compute the ﬁrst three terms of the Fourier–Legendre expansion of the function f (x) = ex . −1 < x < 0. Putting ∞ 1 2 P2 (s) + P0 (s) . 2 2 −1 ≤ s ≤ 1.7. Compute the ﬁrst three terms of the Fourier–Legendre expansion of the function 0. Solution. 4 1 . Solution. To use the orthogonality of the Legendre polynomials. we transform the domain of f (x) from [0. 2 16 Thus we have the approximation 1 1 5 f (x) ≈ P0 (x) + P1 (x) + P2 (x). we have am = Hence a0 = 1 2 1 2m + 1 2 f (x)Pm (x) dx.102 5. f (x) = x. 4 2 16 Example 5. f (x) = m=0 am Pm (x). 3 3 x−5 2 40 x−5 P2 3 2 142 + 20 3 P0 x−5 2 + 106P1 + . 0 ≤ x ≤ 1. 1] by the substitution s=2 x− Then f (x) = ex = e(1+s)/2 = m=0 1 2 . Example 5. 0 < x < 1. 1] to [−1. am Pm (s). 1 −1 < x < 1. ANALYTIC SOLUTIONS Then p(x) = p(2s + 5) = 2 + 3(2s + 5) + 5(2s + 5)2 = 142 + 106s + 20s2 = 142P0 (s) + 106P1 (s) + 20 consequently. we have p(x) = .
1 I2 = −1 s2 es/2 ds = 2s2 es/2 −4 s es/2 ds −1 = 2 e1/2 − e−1/2 − 4I1 = 10 e1/2 − 26 e−1/2 . b] in order to have a smaller error in the numerical value of the integral. it is expected that the nodes will be negative to each other. Example 5. P3 (x). 5. Determine the four parameters of the twopoint Gaussian quadrature formula. the formula will be exact for polynomials of degree three or less. By Example 5. x1 = −x2 . . 2 1 5 a2 = e1/2 (3I2 − I0 ) = 35 e − 95 ≈ 0. We ﬁrst compute the following three integrals by recurrence: 1 I0 = −1 1 es/2 ds = 2 e1/2 − e−1/2 .6. 1 1 I1 = −1 s es/2 ds = 2s es/2 −1 1/2 −2 es/2 ds −1 =2 e +e −1/2 − 2I0 1 −1 1 = −2 e1/2 + 6 e−1/2 . 1].1399P2(2x − 1).6. 1 f (x) dx = af (x1 ) + bf (x2 ).1399.5. We immediately remark that the number of points n refers to the n points at which we need to evaluate the integrand over the interval [−1. it suﬃces to consider the polynomials P0 (x). Thus a0 = a1 = 1 1/2 e I0 = e − 1 ≈ 1.8452. Since . .7183P0(2x − 1) + 0. a = b. DERIVATION OF GAUSSIAN QUADRATURES 103 where am = 2m + 1 2 1 −1 e(1+s)/2 Pm (s) ds. Since there are four free parameters.7183. and the weights will be equal. 2 3 1/2 e I1 = −3 e + 9 ≈ 0.9. By symmetry. . .5. and not to the numbers of subintervals into which one usually breaks the whole interval of integration [a.8452P1(2x − 1) + 0. Derivation of Gaussian Quadratures We easily obtain the npoint Gaussian quadrature formula by means of the Legendre polynomials. We restrict ourselves to the cases n = 2 and n = 3. 2 2 We ﬁnally have the approximation f (x) ≈ 1. −1 Solution.
2.5. the extremal weights should be equal. P2 (x) = 1 1 (3x2 − 1) = 0 ⇒ −x1 = x2 = √ = 0. Thus. . and the middle node is at the origin. the formula will be exact for polynomials of degree ﬁve or less.17) Example 5. . and the central one be larger that the other two. Finally. it . (5.16) 0= −1 1 0= −1 1 0= −1 To satisfy (5.10.13). by (5. 1 × P3 (x) dx = aP3 (x1 ) + bP3 (x2 ). x2 = 0. we have a = b = 1. by (5.15) we choose x1 and x2 such that P2 (x1 ) = P2 (x2 ) = 0. 1 f (x) dx = af (x1 ) + bf (x2 ) + cf (x3 ). we have a = b.14) (5. Since there are six free parameters. (5. x1 = −x3 . it is expected that the two extremal nodes are negative to each other. . (5. −1 Solution. we have 1 2= −1 1 P0 (x) dx = aP0 (x1 ) + bP0 (x2 ) = a + b.14). n = 1. Moreover. the twopoint Gaussian quadrature formula is 1 f (x) dx = f −1 1 −√ 3 +f 1 √ 3 .15) (5. b > a = c. a = c.13) (5.104 5.577 350 27. By Example 5. 1 × P1 (x) dx = aP1 (x1 ) + bP1 (x2 ) = ax1 + bx2 . 1 × P2 (x) dx = aP2 (x1 ) + bP2 (x2 ). By symmetry.16) is automatically satisﬁed since P3 (x) is odd. 2 3 Hence. that is. ANALYTIC SOLUTIONS P0 (x) = 1 is orthogonal to Pn (x). . Determine the six parameters of the threepoint Gaussian quadrature formula. Moreover.
. by substituting a = c in (5.25) . we have a= Thus 10 8 = = 0.24) 1 2 3× 3 1 −1 +b − 5 2 +a 1 2 3× 3 −1 5 = 0.888. 8 5 10 = = 0.774 596 7. −x1 = x3 = Hence (5.20) (5. . we verify that (5.25).24) and (5. 1 1 (5x3 − 3x) = x(5x2 − 3) 2 2 2a + b = 2 or 10a + 5b = 10. P3 (x) dx = aP3 (x1 ) + bP3 (x2 ) + cP3 (x3 ). Now. P5 (x). Since b=2− P4 (x) = 1 (35x4 − 30x2 + 3).21). −1 0= To satisfy (5.23) is satisﬁed since P5 (x) is odd.22) (5.555. −1 1 (5.23) 0= 0= −1 1 P2 (x) dx = aP2 (x1 ) + bP2 (x2 ) + cP2 (x3 ).5. Adding the second expressions in (5. x2 . 9 9 Finally. x3 be the three zeros of P3 (x) = that is. 18 9 (5. P1 (x) dx = aP1 (x1 ) + bP1 (x2 ) + cP1 (x3 ). DERIVATION OF GAUSSIAN QUADRATURES 105 suﬃces to consider the basis P0 (x). .20). 3 = 0. (5. . 1 2= −1 1 P0 (x) dx = aP0 (x1 ) + bP0 (x2 ) + cP0 (x3 ). Moreover.19) (5. it follows from (5.6. P5 (x) dx = aP5 (x1 ) + bP5 (x2 ) + cP5 (x3 ). we let x1 . we have − a that is.18) that 4a − 5b + 4a = 0 or 8a − 5b = 0. 5 x2 = 0.21) (5.18) (5. −1 1 0= 0= −1 1 P4 (x) dx = aP4 (x1 ) + bP4 (x2 ) + cP4 (x3 ).19) implies 3 3 a+ c = 0 ⇒ a = c. 5 5 We immediately see that (5.22) is satisﬁed. Thus.
4 At t = −1.0 × sin (0. 2 dx = π dt. π/2]. (5. x = π/2. ANALYTIC SOLUTIONS we have 2× 5×1 9×8 35 × 9 8 3 3 8 3 2 × 5 315 − 450 + 75 + × − 30 × + 3 + × = 25 5 9 8 9×8 25 9 8 2 × 5 (−60) 8 × 3 × + = 9×8 25 9×8 −24 + 24 = 0. The interval of integration in the Gaussian quadrature formulas is normalized to [−1. at t = 1. Solving for α and β. To integrate over the interval [a.106 5.105 66π) + 1. the integral becomes b f (x) dx = a b−a 2 1 f −1 (b − a)t + b + a 2 dt. b] we use the change of independent variable from x ∈ [a. Evaluate π/2 I= 0 sin x dx by applying the twopoint Gaussian quadrature formula once over the interval [0.394 34π)] 4 = 0. 2 dx = b−a 2 dt. 1 → b = α + β. such that − 1 → a = −α + β.998 47. 1].4. b] to t ∈ [−1. π/2] and over the halfintervals [0. Hence I= π 1 πt + π dt sin 4 −1 4 π ≈ [1. Thus. Example 5. Let x= (π/2)t + π/2 .11. = 9×8 Therefore. Solution.8): t → x = αt + β. 1] (see Example 5. x = 0 and. π/4] and [π/4.26) Remark 5.0 × sin (0. we have x= (b − a)t + b + a . . the threepoint Gaussian quadrature formula is 1 f (x) dx = −1 5 f 9 − 3 5 8 5 + f (0) + f 9 9 3 5 .
Remark 5. The nodes of the four. . node = [1/sqrt(3) 1/sqrt(3)]. >> syms x t >> x = c*node+d. −1 < ξ < 1.983 × 10−5 . % evaluate the function f(t) The twopoint Gaussian quadrature is programmed as follows. The Matlab solution is as follows. c = (ba)/2. The error in the npoint formula is 2 2n (n!)2 2 f (2n) (ξ). DERIVATION OF GAUSSIAN QUADRATURES 107 The error is 1. The Gaussian quadrature formulae are the most accurate integration formulae for a given number of nodes. d= (a+b)/2. >> weight = [1 1]. See Exercises 5. it is convenient to set up a function Mﬁle exp5_10. function f=exp5_10(t) f=sin(t). For generality.6.9985 >> error1 = 1 . dt The error is 8.0015 The other part is done in a similar way.35 and 5.999 910 166 769 89. >> clear >> a = 0.m.5.5.and ﬁvepoint Gaussian quadratures can be expressed in terms of radicals. Over the halfintervals.37. we have I= π 1 π 1 πt + π πt + 3π dt + sin sin 8 −1 8 8 −1 8 π π 1 π 1 √ +1 ≈ sin − √ + 1 + sin 8 8 8 3 3 π 1 1 π √ +3 − √ + 3 + sin + sin 8 8 3 3 = 0. b = pi/2. >> nv1 = c*weight*exp5_10(x)’ % numerical value of integral nv1 = 0. En (f ) = (2n + 1)! (2n)! This formula is therefore exact for polynomials of degree 2n − 1 or less.53 × 10−3 .nv1 % error in solution error1 = 0.
.
Find the Laplace transform of the function f (t) = 1. We see that the exponential function f (t) = et 2 is not transformable since the integral (6. (6. (6. ∞).— >> f = sym(’Heaviside(t)’).2.1) does not exist for any s > 0. We illustrate the deﬁnition of Laplace transform by means of a few examples. s 1 = − (0 − 1) s (b) The Matlab symbolic solution.1.1) 0 provided the integral exists for s > γ. (a) The analytic solution. Example 6. In this case. s−a 109 s > a.2) .— ∞ L(1)(s) = e−st dt. Help for Maple functions is obtained by the command mhelp. Show that L eat (s) = 1 . Deﬁnition Definition 6. 0 1 = − e−st s 1 = .1. >> F = laplace(f) F = 1/s The function Heaviside is a Maple function. ∞ 0 s > 0. Let f (t) be a function deﬁned on [0.1. The Laplace transform F (s) of f (t) is deﬁned by the integral ∞ L(f )(s) := F (s) = e−st f (t) dt. we say that f (t) is transformable and that it is the original of F (s). Solution. Example 6.CHAPTER 6 Laplace Transform 6.
Proof. >> f = exp(a*t). Example 6.110 6. >> F = laplace(f) F = s/(s^2a^2) . LAPLACE TRANSFORM Solution. Solution. 2 we have 1 L(cosh at)(s) = L eat + L e−at 2 1 1 1 = + 2 s−a s+a s . (a) The analytic solution.— >> syms a t.— Since 1 at cosh at = e + e−at .— Assuming that s > a. >> F = laplace(f) F = 1/(sa) Theorem 6.3. (a) The analytic solution. >> f = cosh(a*t). s−a =− (b) The Matlab symbolic solution.1. Find the Laplace transform of the function f (t) = cosh at. The Laplace transform is a linear operator. = 2 s − a2 (b) The Matlab symbolic solution.— >> syms a t. we have ∞ L eat (s) = = e−st eat dt 0 ∞ 0 e−(s−a)t dt ∞ 0 1 e−(s−a)t s−a 1 = . ∞ L : f (t) → F (s) L(af + bg) = =a e−st af (t) + bg(t) dt e−st f (t) dt + b 0 ∞ 0 ∞ 0 e−st g(t) dt = aL(f )(s) + bL(g)(s).
1.1. Solution.— >> syms a t. We proceed by induction. t5 by the commands . >> f = sinh(a*t). We see that L(cosh at)(s) is an even function of a and L(sinh at)(s) is an odd function of a.— Since sinh at = we have L(sinh at)(s) = 1 L eat − L e−at 2 1 1 1 = − 2 s−a s+a a .6. 2 (b) The Matlab symbolic solution. sn 0! 1 = . we have L(tn )(s) = ∞ 0 (n − 1)! . (a) The analytic solution. = n+1 . s Symbolic Matlab ﬁnds the Laplace transform of. DEFINITION 111 Example 6. say. s1 s e−st tn dt ∞ 0 =− = 1 n −st t e s + n s ∞ 0 e−st tn−1 dt n L(tn−1 )(s).5. Suppose that L(tn−1 )(s) = This formula is true for n = 1. Solution. = 2 s − a2 1 at e − e−at . s Now. the induction hypothesis gives L(tn )(s) = n (n − 1)! s sn n! s > 0. Example 6. Find the Laplace transform of the function f (t) = tn . L(1)(s) = If s > 0. Find the Laplace transform of the function f (t) = sinh at. >> F = laplace(f) F = a/(s^2a^2) Remark 6. by integration by parts.4.
Find the Laplace transform of the functions cos ωt and sin ωt. LAPLACE TRANSFORM >> syms t >> f = t^5. s2 + ω 2 ω . we have L eiωt (s) = = e−st eiωt dt 0 ∞ (s > 0) e−(s−iω)t dt 0 =− ∞ 1 e−(s−iω)t s − iω 0 1 =− e−st eiωt −1 s − iω t→∞ 1 s + iω 1 = = s − iω s − iω s + iω s + iω = 2 . f = cos(omega*t).3) Hence. and L(sin ωt) = which is an odd function of ω. (b) The Matlab symbolic solution. i = −1. >> F = laplace(f) F = 120/s^6 or >> F = laplace(sym(’t^5’)) F = 120/s^6 or >> F = laplace(sym(’t’)^5) F = 120/s^6 Example 6. ∞ and assuming that s > 0. we have L eiωt (s) = L(cos ωt + i sin ωt) = L(cos ωt) + iL(sin ωt) ω s +i 2 = 2 2 s +ω s + ω2 s . F = laplace(f) (6. √ eiωt = cos ωt + i sin ωt.— Using Euler’s identity. Solution. g = sin(omega*t).6.112 6. s + ω2 By the linearity of L. (a) The analytic solution. s2 + ω 2 (6. L(cos ωt) = which is an even function of ω.— >> >> >> >> syms omega t.4) .
∞) and if γ0 is the abscissa of convergence of f (t).6) e−st f ′ (t) dt ∞ = e−st f (t) − (−s) e−st f (t) dt 0 = sL(f )(s) − f (0). The basis of these assumptions are found in the following deﬁnition and theorem. ′′′ 3 2 ′ (6. L(f ′′ )(s) = s2 L(f ) − sf (0) − f ′ (0). such that f (t) ≤ M eγt . The following formulae are obtained by induction. for all t > T.8) . s − γ0 6.7) ′′ (6.2. also requires the following results.5) The least upper bound γ0 of all values of γ for which (6. one needs to know how to transform the derivative of a function. TRANSFORMS OF DERIVATIVES AND INTEGRALS 113 F = s/(s^2+omega^2) >> G = laplace(g) G = omega/(s^2+omega^2) In the sequel. Integrating by parts. L(f ′ )(s) = sL(f ) − f (0). We prove only the absolute convergence: ∞ 0 ∞ 0 e−st f (t) dt ≤ M e−(s−γ0 )t dt ∞ =− M e−(s−γ0 )t s − γ0 = 0 M . M > 0 and T > 0. which is not introduced in this chapter. Proof. we shall implicitly assume that the Laplace transforms of the functions considered in this chapter exist and can be diﬀerentiated and integrated under additional conditions.6. Theorem 6. we have L(f ′ )(s) = ∞ 0 ∞ 0 (6. A function f (t) is said to be of exponential type of order γ if there are constants γ.2. Theorem 6. Transforms of Derivatives and Integrals In view of applications to ordinary diﬀerential equations. L(f )(s) = s L(f ) − s f (0) − sf (0) − f (0).3. (6. then the integral ∞ e−st f (t) dt 0 is absolutely and uniformly convergent for all s > γ0 .5) holds is called the abscissa of convergence of f (t).2. The general formula for the inverse transform. Definition 6.2. If the function f (t) is piecewise continuous on the interval [0. Remark 6. Proof.2.
The following general theorem follows by induction.2 for the cases n = 2 and n = 3. Example 6. L(y ′′ ) + 4L(y ′ ) + 3L(y) = s2 Y (s) − sy(0) − y ′ (0) + 4[sY (s) − y(0)] + 3Y (s) = 0. = s+1 s+3 y(0) = 3. f ′ (t). LAPLACE TRANSFORM In fact. Theorem 6. (6. we transform the diﬀerential equation. y ′ (0) = 1. . . L(f ′′ )(s) = sL(f ′ )(s) − f ′ (0) = s[sL(f )(s) − f (0)] − f ′ (0) = s2 L(f ) − sf (0) − f ′ (0) and L(f ′′′ )(s) = sL(f ′′ )(s) − f ′′ (0) = s[s2 L(f ) − sf (0) − f ′ (0)] − f ′′ (0) = s3 L(f ) − s2 f (0) − sf ′ (0) − f ′′ (0). Let the functions f (t). (s2 + 4s + 3)Y (s) − (s + 4)y(0) − y ′ (0) = 0. .4. Y (s) = 3s + 13 s2 + 4s + 3 3s + 13 = (s + 1)(s + 3) B A + . The proof is by induction as in Remark 6.114 6. . Use Laplace transform to solve the following initial value problem for a damped oscillator: y ′′ + 4y ′ + 3y = 0. Solution. Then we have in which we replace y(0) and y ′ (0) by their values. .9) Proof. Then L f (n) (s) = sn L(f ) − sn−1 f (0) − sn−2 f ′ (0) − · · · − f (n−1) (0). We solve for the unknown Y (s) and expand the righthand side in partial fractions. and plot the solution.7. (a) The analytic solution. (s2 + 4s + 3)Y (s) = (s + 4)y(0) + y ′ (0) = 3(s + 4) + 1 = 3s + 13.— Letting L(y)(s) = Y (s). f (n−1) (t) be continuous for t ≥ 0 and f (n) (t) be transformable for s ≥ γ.
Remark 6. Thus Therefore −3 + 13 = 2A =⇒ A = 5. 3*y(1)4*y(2)].3.s.tspan. y0 = [3.6. subplot(2.2. we can get the values of A and B by ﬁrst setting s = −1 and then s = −3 in the identity 3s + 13 = (s + 3)A + (s + 1)B. which one can solve.y).y] = ode45(’exp77’. We rewrite the ﬁrst and third terms as a linear system. and numeric Matlab solver ode45 produces the solution.1 which. we get rid of denominators by rewriting the last two expressions in the form 3s + 13 = (s + 3)A + (s + 1)B = (A + B)s + (3A + B). >> >> >> >> >> tspan = [0 4]. xlabel(’t’). 2 5 − . (b) The Matlab symbolic solution.— The function Mﬁle exp77.t) y = 2*exp(3*t)+5*exp(t) (c) The Matlab numeric solution. [t. yprime = [y(2). . title(’Plot of solution’) The command subplot is used to produce Fig.1].y0). 1 3 1 1 A B = 3 13 =⇒ A B = 5 −2 . ylabel(’y’). Y (s) = −9 + 13 = −2B =⇒ B = −2.1). >> y = ilaplace(Y. in this simple case. after reduction. still has large enough lettering. plot(t.2. s+1 s+3 We ﬁnd the original by means of the inverse Laplace transform given by formula (6. TRANSFORMS OF DERIVATIVES AND INTEGRALS 115 To compute A and B.y(:.— Using the expression for Y (s).1)). We notice that the characteristic polynomial of the original homogeneous diﬀerential equation multiplies the function Y (s) of the transformed equation.2): y(t) = L−1 (Y ) = 5L−1 1 s+1 − 2L−1 1 s+3 = 5 e−t − 2 e−3t .m is function yprime = exp77(t. we have >> syms s t >> Y = (3*s+13)/(s^2+4*s+3). However. 6.
one can foresee that the transform of the indeﬁnite integral of f (t) will be the transform of f (t) divided by s since division is the inverse of multiplication. in terms of the inverse Laplace transform. This is equivalent to the method of undetermined coefﬁcients or the method of variation of parameters.5.11) g(t) = 0 f (τ ) dτ.5 1 0. s (6. Example 6.5 0 0 1 2 t 3 4 Figure 6. (6. L−1 Proof. whence (6. Solution. we have L(f ) = sL(g).7.10) or. Theorem 6.10). Graph of solution of the diﬀerential equation in Example 6. we have Since g(0) = 0. ω . (a) The analytic solution. LAPLACE TRANSFORM Plot of solution 3.5 3 2. Since integration is the inverse of diﬀerentiation and the Laplace transform of f ′ (t) is essentially the transform of f (t) multiplied by s. Then t L f (τ ) dτ 0 = 1 L(f ). Letting t 1 F (s) s t = 0 f (τ ) dτ. Let f (t) be transformable for s ≥ γ. Find f (t) if L(f ) = 1 .— Since L−1 s2 1 + ω2 = 1 sin ωt.8.5 2 y 1. Remark 6. Solving a diﬀerential equation by the Laplace transform involves the initial values. s(s2 + ω 2 ) L f (t) = L g ′ (t) = sL g(t) − g(0).4.1.116 6.
u(t) = Theorem 6. (6. 1. Example 6.— >> syms s omega t >> F = 1/(s*(s^2+omega^2)). F (s − a) = = 0 s > γ. by (6. SHIFTS IN s AND IN t 117 F a F(s) 0 F(s – a) s Figure 6.2) ∞ 0.13) e−(s−a)t f (t) dt e−st eat f (t) dt 0 ∞ = L eat f (t) (s). cos ωt and sin ωt. Shifts in s and in t In the applications.3. (See Fig. Solution.11) we have L−1 1 s 1 s2 + ω 2 = 1 ω t sin ωτ dτ = 0 1 (1 − cos ωt). s − a > γ. if t < 0. L eat f (t) (s) = F (s − a).6.3. 6. ω2 (b) The Matlab symbolic solution.— The results are obvious and are presented in the form of a table. . >> f = ilaplace(F) f = 1/omega^21/omega^2*cos(omega*t) 6. we need the original of F (s − a) and the transform of u(t − a)f (t − a) where u(t) is the Heaviside function. Apply Theorem 6.6. Let Then Proof. if t > 0. (a) The analytic solution.2.6 to the three simple functions tn . (6.12) L(f )(s) = F (s). Function F (s) and shifted function F (s − a) for a > 0.9.
t. >> f = exp(a*t)*cos(omega*t). We solve for Y (s) and rearrange the righthand side. The translate ua (t) = u(t − a) of the Heaviside function u(t). We group the terms containing Y (s) on the lefthand side.118 6. by means of Laplace transform.3. 2s Y (s) = 2 s + 2s + 1 + 4 2(s + 1) − 2 = (s + 1)2 + 22 2 2(s + 1) − . s2 Y (s) − sy(0) − y ′ (0) + 2[sY (s) − y(0)] + 5Y (s) = 0.14) . 6.s) F = (sa)/((sa)^2+omega^2) >> G = laplace(g.3) ua (t) := u(t − a) = 0. Solution.10. Find the solution of the damped system: y ′′ + 2y ′ + 5y = 0. (6. >> F = laplace(f. 1. y(0) = 2. is the function (see Fig. (s2 + 2s + 5)Y (s) = sy(0) + y ′ (0) + 2y(0) = 2s − 4 + 4 = 2s. if t > a. Matlab gives: >> syms a t omega s. Setting we have L(y)(s) = Y (s).t. a ≥ 0. Definition 6. the solution is y(t) = 2 e−t cos 2t − e−t sin 2t.s) G = omega/((sa)^2+omega^2) Example 6. LAPLACE TRANSFORM f (t) t n cos ωt sin ωt F (s) n! n+1 s s 2 + ω2 s ω 2 + ω2 s eat f (t) e t at n eat cos ωt eat sin ωt F (s − a) n! (s − a)n+1 (s − a) (s − a)2 + ω 2 ω (s − a)2 + ω 2 (b) The Matlab symbolic solution. y ′ (0) = −4. >> g = exp(a*t)*sin(omega*t). if t < a.— For the second and third functions. = 2 + 22 (s + 1) (s + 1)2 + 22 Hence. called unit step function.
equivalently. or.16) (6. The notation α(t) or H(t) is also used for u(t).4) (6.7.6.3. that is.15) . L u(t − a)f (t − a) (s) = e−as F (s). (See Fig. the Maple Heaviside function is accessed by the commands >> sym(’Heaviside(t)’) >> u = sym(’Heaviside(t)’) u = Heaviside(t) Help to Maple functions is obtained by the command mhelp.3. Proof. a > 0. In symbolic Matlab. Theorem 6. Then L−1 e−as F (s) = u(t − a)f (t − a). Shift f (t − a) of the function f (t) for a > 0. SHIFTS IN s AND IN t 119 u u(t) u u(t – a) 1 1 0 t 0 a t Figure 6. f a f(t) f(t – a) 0 t Figure 6. Let L(f )(s) = F (s).17) (6. The Heaviside function u(t) and its translate u(t − a). 6.4. L u(t − a)f (t) (s) = e−as L f (t + a) (s).
f (t) = 0. LAPLACE TRANSFORM e−as F (s) = e−as ∞ 0 ∞ e−sτ f (τ ) dτ = 0 ∞ e−s(τ +a) f (τ ) dτ (setting τ + a = t. we see that e−as . sin t. (See Fig. 6. if 2π < t.120 6. s This formula is a direct consequence of the deﬁnition. dτ = dt) = a a e−st f (t − a) dt e−st 0f (t − a) dt + e −st ∞ a = 0 e−st 1f (t − a) dt ∞ = 0 u(t − a)f (t − a) dt = L u(t − a)f (t − a) (s).17) may simplify computation as will be seen in some of the following examples. . = e s . if 0 < t < π. L u(t − a) = ∞ L u(t − a) = = 0 e−st u(t − a) dt ∞ a −as a e−st 0 dt + ∞ a e−st 1 dt 0 1 = − e−st s Example 6. dτ = dt) ∞ = 0 e−s(τ +a) f (τ + a) dτ ∞ 0 = e−as e−st f (t + a) dt = e−as L f (t + a) (s). Find F (s) if 2. The equivalent formula (6. s > 0.11. As a particular case.17) is obtained by a similar change of variable: ∞ L u(t − a)f (t) (s) = = 0 e−st u(t − a)f (t) dt e−st f (t) dt ∞ a (setting t = τ + a. if π < t < 2π. The equivalent formula (6.5).
s s s +1 Example 6. Find F (s) if f (t) = (See Fig. if 0 < t < π. 1 2 × 1! − 2 e−πs 2 . Solution.11.5. 2π.3. by (6. t.6. Solution. The function f (t) of example 6.13.12. if 0 ≤ t < 2.12. Then F (s) = 2L(1) − 2L u(t − π)1(t − π) + L u(t − 2π) sin(t − 2π) 2 2 1 = − e−πs + e−2πs 2 .6. 2π 0 π t Figure 6. The function f (t) of example 6.6). We rewrite f (t) using the Heaviside function and the 2πperiodicity of sin t: f (t) = 2 − 2u(t − π) + u(t − 2π) sin(t − 2π). s2 s Example 6. if π < t. Find F (s) if F (s) = f (t) = 0. if 2 < t. . We rewrite f (t) using the Heaviside function: f (t) = 2t − u(t − π)(2t) + u(t − π)2π Then. 6. 2t.16) = 2t − 2u(t − π)(t − π). SHIFTS IN s AND IN t 121 f 2 2 – 2 u(t – π) u(t – 2π) sin (t – 2π) 3π 0 π 2π 4π t Figure 6.
. LAPLACE TRANSFORM f(t) = t 2 0 2 t Figure 6. The function f (t) of example 6. 0.17). Solution. if 0 ≤ t < 2. t2 . if 2 < t. by (6. The function f (t) of example 6. 1 2 .122 6. f(t) = t 2 4 0 2 t Figure 6.7.8.7). 6.13.16). + s2 s = u(t − 2)(t − 2) + u(t − 2)2.14. 6. (See Fig.14. L u(t − 2)f (t) (s) = e−2s L f (t + 2) (s) = e−2s L t + 2 (s) = e−2s Example 6. Find F (s) if f (t) = (See Fig. F (s) = e−2s = e−2s Equivalently. We rewrite f (t) using the Heaviside function: f (t) = u(t − 2)t Then.8). by (6. + s2 s 0! 1! + 2 e−2s s2 s 1 2 .
— We rewrite f (t) using the Heaviside function: f (t) = u(t − 2)t2 = u(t − 2) (t − 2) + 2 Then. (a) The analytic solution. + 2+ 3 s s s 2! 4 4 .6.9.3. by (6.15. by (6. (a) The analytic solution. Example 6. +4 Solution.— syms s t F = laplace(’Heaviside(t2)’*((t2)^2+4*(t2)+4)) F = 4*exp(2*s)/s+4*exp(2*s)/s^2+2*exp(2*s)/s^3 = e−2s L t2 + 4t + 4 (s) 4 4 2! . cos 2(t − π) = cos 2t.16).9. .— 0. Solution.17). Find f (t) if F (s) = e−πs s2 s .15. + 2+ s3 s s 2 = u(t − 2) (t − 2)2 + 4(t − 2) + 4 . if 0 ≤ t < π. The function f (t) of example 6. if π < t. (b) The Matlab symbolic solution.— We see that L−1 {F (s)}(t) = u(t − π) cos 2(t − π) = We plot f (t) in ﬁgure 6. F (s) = e−2s Equivalently. L u(t − 2)f (t) (s) = e−2s L f (t + 2) (s) = e−2s L (t + 2)2 (s) = e−2s (b) The Matlab symbolic solution. SHIFTS IN s AND IN t 123 1 π t 0 2π Figure 6.
shown in Fig. >> syms s.16. >> F = exp(pi*s)*s/(s^2+4). s2 s s 1 . Thus. π/2. LAPLACE TRANSFORM π /2 0 π /2 t Figure 6. if 0 ≤ t < π/2. Solve the following initial value problem: y ′′ + 4y = g(t) = y(0) = 0. Using the Heaviside function.124 6. s2 + 4 t.10. Thus Y (s) = G(s) . by means of Laplace transform. The function g(t) of example 6. Setting L(y) = Y (s) and L(g) = G(s) we have L(y ′′ + 4y) = s2 Y (s) − sy(0) − y ′ (0) + 4Y (s) = (s2 + 4)Y (s) = G(s). 6. if π/2 < t. in the form π g(t) = t − u(t − π/2)t + u(t − π/2) 2 = t − u(t − π/2)(t − π/2). y ′ (0) = 0. + 4)s2 . where we have used the given values of y(0) and y ′ (0). >> f = ilaplace(F) f = Heaviside(tpi)*cos(2*t) Example 6. the Laplace transform of g(t) is G(s) = It follows that Y (s) = 1 − e−(π/2)s (s2 1 1 1 − e−(π/2)s 2 = 1 − e−(π/2)s 2 .10.16. Solution. we rewrite g(t).
DIRAC DELTA FUNCTION 125 We expand the second factor on the righthand side in partial fractions. we have y(t) = 1 1 1 1 t − sin 2t − u(t − π/2)(t − π/2) + u(t − π/2) sin 2[t − π/2] . 1 4B = 1 =⇒ B = . a) dt = a 1 dt = 1. that is. a) is equal to 1. ∞ Ik = 0 fk (t.19) We denote by δ(t − a) . 0. k (6. 1 A Cs + D B = + 2+ 2 .7.4. 2 4 1 s 1 = 2 (1 − cos 2τ ) dτ = The inverse Laplace transform y(t) is obtained by (6. 1 = (s2 + 4)sA + (s2 + 4)B + s2 (Cs + D) = (A + C)s3 + (B + D)s2 + 4As + 4B. 4 A + C = 0 =⇒ C = 0. taking the inverse Laplace transform.18) We see that the integral of fk (t.11) of Theorem 6. (s2 + 4)s2 4 s2 4 s2 + 4 Y (s) = 2 1 1 1 1 2 1 1 − − e−(π/2)s 2 + e−(π/2)s 2 2 2 + 22 4 s 8 s 4 s 8 s + 22 and. 6. a+k (6. L−1 L −1 2 1 s s2 + 2 2 2 1 s s2 + 2 2 t = 0 sin 2τ dτ = t 0 1 1 − cos(2t). a) = 1/k. otherwise.6. 4 8 4 8 A second way of ﬁnding the inverse Laplace transform of the function 2 1 1 − e−(π/2)s Y (s) = 2 + 4)s2 2 (s of previous example 6.15) of Theorem 6. if a ≤ t ≤ a + k. 4A = 0 =⇒ A = 0. 2 2 1 t − sin(2t).5.4. 4 1 B + D = 0 =⇒ D = − . (s2 + 4)s2 s s s +4 We get rid of denominators. Dirac Delta Function Consider the function fk (t. and identify coeﬃcients. whence Thus 1 1 1 1 1 = − .16 is a double integration by means of formula (6.
(s + 1)(s + 2) s+1 s+2 y(0) = 0. Solve the damped system y ′′ + 3y ′ + 2y = δ(t − a). 1 fk (t. by (6. where F (s) = Then f (t) = L−1 (F ) = e−t − e−2t . By (6. The solution for a = 1 is shown in ﬁgure 6. at rest for 0 ≤ t < a and hit at time t = a.126 6. >> F = laplace(f) F = 1 Example 6. a) as k → 0 and call this limit Dirac’s delta function. we have y(t) = L−1 e−as F (s) = 1 1 1 = − . LAPLACE TRANSFORM the limit of fk (t. the transform of the diﬀerential equation is s2 Y + 3sY + 2Y = e−as . We can represent fk (t.21).17) we have L fk (t. We solve for Y (s).15). (6. k From (6. a) by means of the diﬀerence of two Heaviside functions. Hence.17.20) The quotient in the last term tends to 1 as k → 0 as one can see by L’Hˆpital’s o rule. a) = 1 −as 1 − e−ks e − e−(a+k)s = e−as . e−(t−a) − e−2(t−a) . >> f = sym(’Dirac(t)’). ks ks (6.11. . a) = [u(t − a) − u(t − (a + k))]. L δ(t − a) = e−as . y ′ (0) = 0. = u(t − a)f (t − a) 0. if 0 ≤ t < a. Solution. if t > a. Thus.21) Symbolic Matlab produces the Laplace transform of the symbolic function δ(t) by the following commands. Y (s) = e−as F (s).
.23) lim f (t) t exists. Theorem 6. then L f (t) t ∞ (s) = s F (˜) d˜.1 0 1 2 3 4 t Figure 6. t (6.6.22) (6. if the limit t→0+ (6. in terms of the inverse Laplace transform. (6. If F (s) = L{f (t)}(s).5. s s (6. Then. or. Moreover.3 0.11.5. ∞ F ′ (s) = − e−st [tf (t)] dt 0 = −L{tf (t)}(s). L−1 {F ′ (s)} = −tf (t). L−1 Proof. by Theorem 6. in terms of the inverse Laplace transform. Solution y(t) of example 6.2 0. DERIVATIVES AND INTEGRALS OF TRANSFORMED FUNCTIONS 127 y(t ) 0.8. Let ∞ ∞ F (˜) d˜ = s s s 1 f (t).2. 6. Derivatives and Integrals of Transformed Functions We derive the following formulae. then L{tf (t)}(s) = −F ′ (s).22) follows by diﬀerentiation.17.24) or.25) F (s) = 0 e−st f (t) dt.
26) (6.19.24) follows by integration. If tn f (t) is transformable. =L t = The following theorem generalizes formula (6. Use (6.128 6. ∞ ∞ ∞ 0 ∞ ∞ F (˜) d˜ = s s s s s e−˜t f (t) dt d˜ s s e−˜t d˜ dt s s=∞ ˜ = 0 ∞ f (t) s 1 s dt f (t) − e−˜t t 0 s=s ˜ ∞ 1 = e−st f (t) dt t 0 1 f (t) . Theorem 6. + β 2 )2 s . L−1 {F (n) (s)} = (−1)n tn f (t). Example 6.22). Setting d 1 =− 2 (s + 1) ds by (6. f (t) 1 [sin βt − βt cos βt] 2β 3 t sin βt 2β 1 [sin βt + βt cos βt] 2β F (s) 1 .30) 1 s+1 1 s+1 =: −F ′ (s).27) 1 . (s2 + β 2 )2 (s2 (6. then or.22) to the ﬁrst term of (6. L t sin βt (s) = − β d ds s2 + β 2 2βs . (6.22) to ﬁnd F (s) for the given functions f (t).29) (6.— We apply (6. (6. LAPLACE TRANSFORM On the other hand. (s2 + β 2 )2 s2 . by Theorem 6. Example 6.18. (a) The analytic solution. Use (6. (s + 1)2 Solution.2.29). L{tn f (t)}(s) = (−1)n F (n) (s). in terms of the inverse Laplace transform.23) to obtain the original of Solution.9. = 2 (s + β 2 )2 .23) we have L−1 {−F ′ (s)} = tf (t) = t L−1 = t e−t .28) (6.
(b) The Matlab symbolic solution. after division by 2β. using (6.22) we have L t cos βt (s) = − d s ds s2 + β 2 s2 + β 2 − 2s2 =− (s2 + β 2 )2 2 s − β2 = 2 .6. we obtain (6. >> F = laplace(f.s) F = 1/2/beta^3*(beta/(s^2+beta^2)beta*(1/(s^2+beta^2)+2*s^2/(s^2+beta^2)^2)) >> FF = simple(F) FF = 1/(s^2+beta^2)^2 >> g = t*sin(beta*t)/(2*beta).29).20. >> H = laplace(h. .s) H = 1/2/beta*(beta/(s^2+beta^2)+beta*(1/(s^2+beta^2)+2*s^2/(s^2+beta^2)^2)) >> HH = simple(H) HH = s^2/(s^2+beta^2)^2 Example 6.5.t. we obtain (6. Find L−1 ln 1 + ω2 s2 (t). >> G = laplace(g.— >> syms t beta s >> f = (sin(beta*t)beta*t*cos(beta*t))/(2*beta^3). (s2 + β 2 )2 Taking the + sign and dividing by two. we obtain the second term of (6.t.t. DERIVATIVES AND INTEGRALS OF TRANSFORMED FUNCTIONS 129 whence.s) G = 1/(s^2+beta^2)^2*s >> h = (sin(beta*t)+beta*t*cos(beta*t))/(2*beta). (s + β 2 )2 Then L s2 − β 2 1 1 ± 2 sin βt ± t cos βt (s) = 2 2 β s +β (s + β 2 )2 (s2 + β 2 ) ± (s2 − β 2 ) = .28).30). Taking the − sign and dividing by 2β 2 . Similarly.
s. LAPLACE TRANSFORM Solution. =− Thus f (t) = L−1 (F ) = 2 − 2 cos ωt. t (b) The Matlab symbolic solution. >> f = ilaplace(F.— >> syms omega t s >> F = log(1+(omega^2/s^2)). t ωt and using the fact that ∞ s F (˜) d˜ = − s s ω2 d ln 1 + 2 d˜ s s ˜ s ∞ 2 ω = − ln 1 + 2 s ˜ s = − ln 1 + ln 1 + = ln 1 + ω2 s2 ˜ .— We have − ω2 d ln 1 + 2 ds s d s2 + ω 2 ln ds s2 s2 2s3 − 2s(s2 + ω 2 ) =− 2 2 s +ω s4 2ω 2 = 2 + ω2) s(s (ω 2 + s2 ) − s2 =2 s(s2 + ω 2 ) s 2 = −2 2 s s + ω2 =: F (s).130 6.25) we have L−1 ln 1 + ω2 s2 = L−1 = ∞ F (˜) d˜ s s s 1 f (t) t 2 = (1 − cos ωt). (a) The analytic solution.t) f = 2/t2/t*cos(omega*t) . Since f (t) 1 − cos ωt = 2ω → 0 as t → 0. ω2 s2 ˜ ∞ d˜ s by (6.
t e n! dtn n = 1. We see that Ln (t) is a polynomial of degree n since the exponential functions cancel each other after diﬀerentiation.22). (s − 1)n . LAGUERRE DIFFERENTIAL EQUATION 131 6. Ln (t) = et dn n −t . In fact. n = 0. .32) Example 6. by (6.31) d 2 [s Y (s) − sy(0) − y ′ (0)] ds = −2sY (s) − s2 Y ′ (s) + y(0).6. we have L ty ′ (t) = − L ty ′′ (t) = − d [sY (s) − y(0)] ds = −Y (s) − sY ′ (s).6. we have L tn e−t (n) (s) = sn n! . sn+1 (s − 1)n . (6.33) Solution. Since by Theorem 6. sn+1 = (s − s2 )Y ′ (s) + (n + 1 − s)Y (s) = 0. (6. . (s + 1)n+1 . Laguerre Diﬀerential Equation We can solve diﬀerential equations with variable coeﬃcients of the form at+ b by means of Laplace transform. L f (n) (s) = sn F (s) − sn−1 f (0) − sn−2 f ′ (0) − · · · − f (n−1) (0).21. We show that L0 (t) = 1. The Laplace transform of equation (6. .33) is − 2sY (s) − s2 Y ′ (s) + y(0) + sY (s) − y(0) + Y (s) + sY ′ (s) + nY (s) This equation is separable: n+1−s dY = ds Y (s − 1)s n n+1 = − s−1 s whence its solution is ln Y (s) = n ln s − 1 − (n + 1) ln s = ln that is. Find the polynomial solutions Ln (t) of the Laguerre equation ty ′′ + (1 − t)y ′ + ny = 0.4.6. Ln (t) denotes the Laguerre polynomial of degree n. In fact. Ln (t) = L−1 (Y )(t). .7). (6.6) and (6. Y (s) = Set where exceptionally capital L in Ln is a function of t. 1. . . . 2. (6. ds. .
’y(0)=1’. >>L0 = dsolve(’t*D2y+(1t)*Dy=0’. 2 2 6 We can obtain Ln (x) by the recurrence formula The Laguerre polynomials satisfy the following orthogonality relations with the weight p(x) = e−x : ∞ L1 (x) = 1 − x. consequently. L et n −t t e n! (n) L2 L0 4 6 L3 8 2 n! (s − 1)n n! sn+1 = Y (s) = = L (Ln ) . >> L1 = simple(L1) L1 = 1t >> L2 = dsolve(’t*D2y+(1t)*Dy+2*y=0’. e−x Lm (x)Ln (x) dx = 0 0. The ﬁrst four Laguerre polynomials.12): L0 (x) = 1. 6. m = n. and. . Symbolic Matlab obtains the Laguerre polynomials as follows.’t’).12. LAPLACE TRANSFORM L n (x) 8 6 4 2 2 2 4 L1 6 Figure 6. 1.’t’) L0 = 1 >>L1 = dsolve(’t*D2y+(1t)*Dy+y=0’. L2 (x) = 1 − 2x + x2 .132 6. The ﬁrst four Laguerre polynomials are (see Fig.’y(0)=1’.’y(0)=1’. 3 1 1 L3 (x) = 1 − 3x + x2 − x3 .’t’). (n + 1)Ln+1 (x) = (2n + 1 − x)Ln (x) − nLn−1 (x). m = n.
Theorem 6.34) We say “f (x) convolved with g(x)”. CONVOLUTION 133 >> L2 = simple(L2) L2 = 12*t+1/2*t^2 and so on. is the function t h(t) = 0 f (τ )g(t − τ ) dτ. We verify that convolution is commutative: t (f ∗ g)(t) = 0 f (τ )g(t − τ ) dτ 0 (setting t − τ = σ. (6. Let F (s) = L(f ).16). Convolution The original of the product of two transforms is the convolution of the two originals. The symbolic Matlab command simple has the mathematically unorthodox goal of ﬁnding a simpliﬁcation of an expression that has the fewest number of characters. By deﬁnition and by (6.10.7.7. = τ . H(s) = F (s)G(s). dτ = −dσ) =− t t f (t − σ)g(σ) dσ = 0 g(σ)f (t − σ) dσ = (g ∗ f )(t). h(t) = L−1 (H). we have e−sτ G(s) = L g(t − τ )u(t − τ ) ∞ G(s) = L(g). s > 0.6. denoted by (f ∗ g)(t).35) = 0 ∞ e−st g(t − τ )u(t − τ ) dt e−st g(t − τ ) dt. The convolution of f (t) with g(t). (6.4. 6. Proof. Then h(t) = (f ∗ g)(t) = L−1 F (s)G(s) . Definition 6.
22. (s > γ) = 0 f (τ )g(t − τ ) dτ dt = L(h)(s).13 shows the region of integration in the tτ plane used in the proof of Theorem 6. Find the original of 1 .134 6.10. Find (1 ∗ 1)(t).13. 0 1 × 1 dτ = t. by the deﬁnition of F (s) we have ∞ F (s)G(s) = 0 ∞ e−sτ f (τ )G(s) dτ ∞ = 0 ∞ f (τ ) e−st τ t 0 e−st g(t − τ ) dt dτ. t et ∗ et = = eτ et−τ dτ 0 t 0 et dτ = t et . a = b. Region of integration in the tτ plane used in the proof of Theorem 6. (s − a)(s − b) by means of convolution. Solution. . LAPLACE TRANSFORM τ τ=t 0 t Figure 6.10.24. = L (f ∗ g)(t) (s) Figure 6. Example 6. Find et ∗ et . Example 6. t (1 ∗ 1)(t) = Example 6. Whence.23. Solution.
Since the last term of (6. We only mention that if p(λ) is the characteristic polynomial of a diﬀerential equation. Partial Fractions Expanding a rational function in partial fractions has been studied in elementary calculus. . In this case.36) is a convolution. Example 6. partial fractions can be obtained by using the Maple convert command. y(t) = t + 1 3 t . L−1 1 = eat ∗ ebt (s − a)(s − b) t = 0 eaτ eb(t−τ ) dτ t 0 = ebt = ebt e(a−b)τ dτ t 0 ebt e(a−b)t − 1 = a−b eat − ebt .25.8. 4 s s s 1 1 + Y (s) 2 . = a−b Some integral equations can be solved by means of Laplace transform.36) Solution. s2 s +1 6.8. is also needed to expand 1/p(s) in partial fractions when one uses the Laplace transform. Ly = r(t) with constant coeﬃcients. then y(t) = t + y ∗ sin t. The extended symbolic toolbox of the professional Matlab gives access to the complete Maple kernel. 6 s2 + 1 1 1 = 2 + 4. the factorization of p(λ) needed to ﬁnd the zeros of p and consequently the independent solutions of Ly = 0. Resonance corresponds to multiple zeros. PARTIAL FRACTIONS 135 Solution. (6. Hence Y (s) = whence Y (s) = Thus. Solve the integral equation t 1 e(a−b)τ a−b y(t) = t + 0 y(τ ) sin(t − τ ) dτ. This command is referenced by entering mhelp convert[parfrac].6.
26. (6. f (t + 2π/ω) = f (t). To use the periodicity of f (t). Halfwave rectiﬁer of example 6. 6.37) Theorem 6.14). 0. t = τ + 2p. if π/ω < t < 2π/ω. . we write L(f )(s) = = 0 e−st f (t) dt 0 p e−st f (t) dt + p 2p e−st f (t) dt + 3p 2p e−st f (t) dt + . etc. Substituting t = τ + p.11. p > 0..26. LAPLACE TRANSFORM 1 0 π /ω 2π /ω 4π /ω t Figure 6. Then L(f )(s) = ∞ 1 1 − e−ps e−st f (t) dt. A function f (t) deﬁned for all t > 0 is said to be periodic of period p. . Solution.14.38) Proof. Find the Laplace transform of the halfwave rectiﬁcation of the sine function sin ωt (see Fig. .. 0 = 1+e = +e p 0 −2sp + ··· e 0 −st f (t) dt 1 1 − e−ps e−st f (t) dt. 6. Example 6. (a) The analytic solution.— The halfrectiﬁed wave of period p = 2π/ω is f (t) = sin ωt. we have p L(f )(s) = e−st f (t) dt + 0 −sp p e−s(t+p) f (t) dt + p 0 p e−s(t+2p) f (t) dt + .136 6. third integrals.. and using the periodicity of f (t). p 0 for all t > 0. . if f (t + p) = f (t).. Let f (t) be a periodic function of period p. s > 0. if 0 < t < π/ω. . in the second. (6. Transform of Periodic Functions Definition 6. changing the limits of integration to 0 and p.5. . .9.
TRANSFORM OF PERIODIC FUNCTIONS 137 1 0 2π /ω 4π /ω t Figure 6.15).0.15. The fully rectiﬁed wave of period p = 2π/ω is f (t) =  sin ωt = sin ωt.6.9. f (t + 2π/ω) = f (t). we have L(f )(s) = π/ω 1 π/ω e(−s+iω)t dt = 0 Using the formula 1 e(−s+iω)t −s + iω π/ω 0 = −s − iω −e−sπ/ω − 1 .26. noting that the integral is the imaginary part of the following integral. Fullwave rectiﬁer of example 6. Solution.38).27. s2 + ω 2 1 − e−2πs/ω = 1 + e−πs/ω we have L(f )(s) = 1 − e−πs/ω . (s2 + ω 2 ) 1 − e−2πs/ω (s + ω 2 ) 1 − e−πs/ω syms pi s t omega G = int(exp(s*t)*sin(omega*t). L(f )(s) = 2 2 s +ω 2ω . more simply. e−st sin ωt dt.— ω 1 + e−πs/ω ω = 2 . 1 − e−2πs/ω 0 Integrating by parts or. if 0 < t < πω. Find the Laplace transform of the fullwave rectiﬁcation of f (t) = sin ωt (see Fig. we have πs ω coth . 6. − sin ωt. (b) The Matlab symbolic solution. if π < t < 2πω.pi/omega) G = omega*(exp(pi/omega*s)+1)/(s^2+omega^2) F = 1/(1exp(2*pi*s/omega))*G F = 1/(1exp(2*pi/omega*s))*omega*(exp(pi/omega*s)+1)/(s^2+omega^2) Example 6. By the method used in example 6. By (6.27.t.
.
1] 1. R = g(y) g(y) dy 7.1).1).1. If ∂N 1 ∂M − M ∂y ∂x is a function of y only. then µ(y) = e− is an integrating factor of (7.2. 1 Pn (x) = n 2 [n/2] −1 ≤ x ≤ 1. The threepoint recurrence relation is (n + 1)Pn+1 (x) = (2n + 1)xPn (x) − nPn−1 (x). 4. The square of the norm of Pn (x) is 1 −1 139 [Pn (x)]2 dx = 2 . 2n + 1 . where [n/2] denotes the greatest integer smaller than or equal to n/2. y) dy = 0.1) ∂M ∂N − ∂y ∂x = f (x) is an integrating factor of (7. 3. 2. The solution y(x) = Pn (x) is given by the series (−1)m m=0 n m 2n − 2m n xn−2m .CHAPTER 7 Formulas and Tables 7. 5. Integrating Factor of M (x. y) dy = 0 Consider the ﬁrstorder homogeneous diﬀerential equation M (x. then µ(x) = e R f (x) dx (7. Legendre Polynomials Pn (x) on [−1. The standardization is Pn (1) = 1. The Legendre diﬀerential equation is (1 − x2 )y ′′ − 2xy ′ + n(n + 1)y = 0. If 1 N is a function of x only. y) dx + N (x. y) dx + N (x.
7.5 1 1 − x2 n . 2 2 1 1 P4 (x) = 35x4 − 30x2 + 3 . The ﬁrst six Legendre polynomials are: Pn (x) ≤ 1. n = 0. L1 (x) = 1 − x.5 −0.140 7. 1 1 P2 (x) = 3x2 − 1 .2) Ln (x) = L0 (x) = 1. . P3 (x) = 5x3 − 3x . P5 (x) = 63x5 − 70x3 + 15x . P0 (x) = 1. Laguerre Polynomials on 0 ≤ x < ∞ ex dn (xn e−x ) . Rodrigues’s formula is (−1)n dn 2n n! dxn 7.1. 6. .5 −1 Figure 7. The generating function is Pn (x) = 1 √ = Pn (x)tn . 2 2 6 The Ln (x) can be obtained by the threepoint recurrence formula (n + 1)Ln+1 (x) = (2n + 1 − x)Ln (x) − nLn−1 (x). The Pn (x) satisfy the inequality 9. . 8 8 The graphs of the ﬁrst ﬁve Pn (x) are shown in Fig. 7. FORMULAS AND TABLES P (x) n 1 0. −1 ≤ x ≤ 1.1.3.5 P4 −1 −0. 1 − 2xt + t2 n=0 8. Plot of the ﬁrst ﬁve Legendre polynomials. Laguerre polynomials on 0 ≤ x < ∞ are deﬁned by the expression 1 3 1 L2 (x) = 1 − 2x + x2 . L3 (x) = 1 − 3x + x2 − x3 . −1 < x < 1. P1 (x) = x. n! dxn The ﬁrst four Laguerre polynomials are (see ﬁgure 7. . 1. t < 1. ∞ P0 P 1 x P3 p2 0.
m = n. n = 0.6. TABLE OF LAPLACE TRANSFORMS 141 L n (x) 8 6 4 2 2 2 4 L1 6 Figure 7.6.2. Table of Integrals 7. 1] is ∞ f (x) = n=0 an Pn (x). . −1 ≤ x ≤ 1. m = n. 2.5. 7.4. 1. Plot of the ﬁrst four Laguerre polynomials. Fourier–Legendre Series Expansion The FourierLegendre series expansion of a function f (x) on [−1. m = n. Table of Laplace Transforms ∞ L{f (t)} = e−st f (t) dt = F (s) 0 . 2 −1 This expansion follows from the orthogonality relations an = 1 Pm (x)Pn (x) dx = −1 0. m = n. . 2 2n+1 . 7. The Ln (x) are solutions of the diﬀerential equation and satisfy the orthogonality relations with weight p(x) = e−x ∞ 0 L2 L0 4 6 L3 8 2 xy ′′ + (1 − x)y ′ + ny = 0 e−x Lm (x)Ln (x) dx = 0. . where 2n + 1 1 f (x)Pn (x) dx. 1.7.
9. 12. 5. 6. 8. FORMULAS AND TABLES Table 7. 16. tan u du = ln  sec u + c cot u du = ln  sin u + c sec u du = ln  sec u + tan u + c csc u du = ln  csc u − cot u + c tanh u du = ln cosh u + c coth u du = ln sinh u + c u du √ = arcsin + c 2 − u2 a a du u √ = ln u + u2 + a2 + c = arcsinh + c a a2 + u 2 du u √ = ln u + u2 − a2 + c = arccosh + c a u 2 − a2 du 1 u = arctan + c a2 + u 2 a a 1 u−a du +c = ln u 2 − a2 2a u+a 1 du u+a +c = ln 2 − u2 a 2a u−a du 1 u +c = ln u(a + bu) a a + bu a + bu 1 b du =− + 2 ln +c 2 (a + bu) u au a u 1 a + bu 1 du = − 2 ln +c 2 u(a + bu) a(a + bu) a u xn+1 xn+1 +c ln ax − xn ln ax dx = n+1 (n + 1)2 . 14. 2. 15.142 7. 3. 7. 10. 1. 13.1. 4. Table of integrals. 11.
9. 4. c>0 s e−cs F (s).7. t ≥ c f (t − c)u(t − c) f1 (τ )f2 (t − τ ) dτ 1 s 1 1 tn n! sn+1 ta 1 a+1 s Γ(a + 1) 1 1 √ √ s πt 1 e−at s+a tn e−at 1 (s + a)n+1 n! k sin kt s2 + k 2 s cos kt s2 + k 2 k sinh kt 2 − k2 s s cosh kt s2 − k 2 2k 3 sin kt − kt cos kt 2 + k 2 )2 (s 2ks t sin kt 2 + k 2 )2 (s p 1 e−st f (t) dt f (t + p) = f (t). c > 0 F1 (s)F2 (s) 0 f (t) eat f (t) 1 −bt/a e f a u(t − c) := t t a 0. 14. 8. TABLE OF LAPLACE TRANSFORMS 143 Table 7. 16.6. F (s) = L{f (t)} 1. 11. 15. 10. 18. 7. 2. 17. 13. 5. for all t 1 − e−ps 0 . Table of Laplace transforms. 6. F (s − a) F (as + b) 1 −cs e .2. 0 ≤ t < c 1. 3. 12.
.
Part 2 Numerical Methods .
.
In scientiﬁc computation. a respectively. For example. ˜ 2. 4. A roundoﬀ error occurs when a computer approximates a real number by a number with only a ﬁnite number of digits to the right of the decimal point (see Subsection 8. where b1 = 0. with d = 5 and β = 10.1. is 4.2). 147 . 5. 0 ≤ bi < β. For instance. 3. The number of signiﬁcant digits of a ﬂoating point number is the number of digits counted from the ﬁrst to the last nonzero digits. respectively. The following notation and terminology will be used. with d = 4 and β = 10. Deﬁnitions. 0. −0. a ǫr  = a−a ˜ < Br . Upper bounds for the absolute and relative errors in a are numbers ˜ Ba and Br such that ǫ = ˜ − a < Ba . 3.1203 × 102 .b1 b2 · · · bd × β N .1000 × 103 .31224 × 103 . and 1.1. We call b1 b2 · · · bd the mantissa or decimal part and N the exponent of c. 0.1.27120 × 102 . 1. the number of signiﬁcant digits of the three numbers: 0. If a is the exact value of a computation and a is an approximate value ˜ for the same computation. 6. 0.1230 × 10−2 . ˜ ǫr = a−a ˜ ǫ = a a is the relative error in a. If a = 0. then ǫ=a−a ˜ is the error in a and ǫ is the absolute error. the ﬂoating point representation of a number c of length d in the base β is c = ±0.1. Computer Arithmetics 8. The term truncation error is used for the error committed when an inﬁnite series is truncated after a ﬁnite number of terms.CHAPTER 8 Solutions of Nonlinear Equations 8.
.1.1. . bk−1 bk × 10N . bm ≥ 0.998 776 0 = 1. .148 8.92 2.3. Example 8. . Thus. bk−1 bk + 0. For simplicity. The ﬂoatingpoint number.2 illustrates these points.b1 b2 .5952100 ≈ 2. Use 10digit rounded arithmetic to solve the quadratic equation x2 − 1634x + 2 = 0. bm < 0.2.5. Cancellation in computations.9850000 ≈ −4. bd × 10N is rounded to k digits as follows: (i) If 0. The usual formula yields √ x = 817 ± 2 669 948.1 × 10−k+1 ) × 10N . say in base 10. Numbers rounded to three digits: 1.001203. SOLUTIONS OF NONLINEAR EQUATIONS Remark 8.2.bk+1 bk+2 . round c to (0.04 8. c = ±0.60 1. x1 = 817 + 816. 0.99 Floatingpoint numbers are chopped to k digits by replacing the digits to the right of the kth digit by zeros. round c to Example 8. .bk+1 bk+2 . .224 000 000 × 10−3 . Cancellation due to the subtraction of two almost equal numbers leads to a loss of signiﬁcant digits.b1 b2 .9234542 ≈ 1. x2 = 1. It is better to avoid cancellation than to try to estimate the error due to cancellation. we shall often write ﬂoating point numbers without exponent and with zeros immediately to the right of the decimal point or with nonzero numbers to the left of the decimal point: 0. Solution. (ii) If 0. In this case where all digits are signiﬁcant. Rounding and chopping numbers.5. . Real numbers are rounded away from the origin. Four of the six zeros at the end of the fractional part of x2 are the result of cancellation and thus are meaningless. 12300.998 776 0 = 1.1. Example 8. .b1 b2 . 8. .1.223 991 125 × 10−3 . . x2 = 817 − 816.633 998 776 × 103 . .00 −4. A more accurate result for x2 can be obtained if we use the relation x1 x2 = 2.9950000 ≈ 2.
Solution.00126448926735 relerr1 = abserr1/pi relerr1 = 4. −1. ǫr = ǫ/π.7525 < x − y < 4. which Matlab evaluates as pp = pi pp = 3.3. COMPUTER ARITHMETICS 149 From Example 8.491367876740610e08 . r1 = 3.7515 ≤ y < 12. 1 −b − sign (b) b2 − 4ac .1.7525.024994347707008e04 Hence. 2a where the signum function is x1 = sign (x) = +1.815 and 12.9475 < x − y < −7. if x < 0. then 4. ﬁnd the smallest interval which contains the exact value of x − y. Similarly.815 − 12. respectively.81 and the value of y rounded to ﬁve digits is 12.805 − 12.14285714285714 abserr1 = r1 pi abserr1 = 0.8.4. If the value of x rounded to three digits is 4.pi abserr2 = 2.14159265358979 r1 = 22/7. Solution.14159292035398 abserr2 = r2 .805 ≤ x < 4.752. r2 = 3. if x ≥ 0.2. Matlab computes the error and relative error in 355/113 as r2 = 355/113.667641894049666e07 relerr2 = abserr2/pi relerr2 = 8. it is seen that a numerically stable formula for solving the quadratic equation ax2 + bx + c = 0. a = 0. Since 4.402 × 10−3 . Find the error and the relative error in the commonly used rational approximations 22/7 and 355/113 to the transcendental number π and express your answer in threedigit ﬂoating point numbers. the error and the relative error in 22/7 rounded to three digits are ǫ = 0.126 × 10−2 and ǫr = 0. The error and the relative error in 22/7 are ǫ = 22/7 − π.7515 ⇔ −7. Example 8.9365. ax1 Example 8. is x2 = c .
SOLUTIONS OF NONLINEAR EQUATIONS Hence. then there exists a zero of f (x) in the open interval ]a. then there exists a number c such that a < c < b and f (c) = w. A similar theorem holds for sums. Let a < b and f (x) be a continuous function on [a. If w is a number strictly between f (a) and f (b). b] which is diﬀerentiable on ]a. b[. b]. If the numbers wi all have the same sign and all the points xi ∈ [a.849 × 10−7 . b] which does not change sign on [a. b] such that n n wi f (xi ) = f (c) i=1 i=1 wi . b] and β ∈ [a. The result follows from the intermediate value theorem with w = 0. b]. . If f (a)f (b) < 0. n.3 (Mean Value Theorem). Then there exist numbers α ∈ [a. Theorem 8. then there exists a number c such that a < c < b and b b f (x) g(x) dx = f (c) a a g(x) dx. then. Proof. b]. 8.267 × 10−6 and ǫr = 0. Theorem 8. If f (a) f (b) < 0 and f is continuous on [a. if f (a) f a and 2 2 . The root is either between a+b a+b < 0. Let a < b and f (x) be a continuous function on [a. 0 lies between f (a) and f (b). be a set of n distinct real numbers and let f (x) be a continuous function on an interval [a. b[.3. i = 1.2 (Extreme Value Theorem). Let a < b and f (x) be a continuous function on [a. Theorem 8. Since f (a) and f (b) have opposite signs. b].4 (Mean Value Theorem for Integrals).2. . Then there exists a number c such that a < c < b and f (b) − f (a) . Theorem 8. 2. b]. b]. f (x) = 0 has a root between a and b. Let a < b and f (x) be a continuous function on [a. b].150 8.1. b]. . then there exists a number c ∈ [a.5 (Mean Value Theorem for Sums). 8. by Corollary 8. Review of Calculus The following results from elementary calculus are needed to justify the methods of solution presented here. we have f (α) ≤ f (x) ≤ f (β). Let {wi }. If g(x) is an integrable function on [a. b]. The Bisection Method The bisection method constructs a sequence of intervals of decreasing length which contain a root p of f (x) = 0. b] such that. . the error and the relative error in 355/113 rounded to three digits are ǫ = 0. f ′ (c) = b−a Theorem 8. Corollary 8. Let a < b and f (x) be a continuous function on [a. for all x ∈ [a. .1.1 (Intermediate Value Theorem).
b. The bisection method is programmed in the following Matlab function Mﬁle which is found in ftp://ftp. The algorithm of the bisection method is as follows. (4) and (5). N0 . Algorithm 8. The rate of convergence of the bisection method is low but the method always converges. The nth step of the bisection method.3. Repeat (2). compute an + b n . then output p (= xn+1 ) and stop. .1 (Bisection Method). (2) For n = 0.4. Else set an+1 = xn+1 and bn+1 = bn . THE BISECTION METHOD 151 y y = f (x) (a n . if f 2 2 The nth step of the bisection method is shown in Fig. 2. % % a.delta) % % Pre: % fname string that names a continuous function f(x) of % a single variable.edu/pub/cv.a. . Given that f (x) is continuous on [a.cornell. f (bn )) Figure 8. 2 If f (xn+1 ) = 0 or (bn − an )/2 < T OL. function root = Bisection(fname. tolerance T OL. set an+1 = an and bn+1 = xn+1 .1. 8.1. (3). Ouput ’Method failed after N0 iterations’ and stop. f(a)f(b) < 0 .8.b] % f is continuous. b] and f (a) f (b) < 0: (1) Choose a0 = a. . or exactly at a+b a+b = 0. maximum number of iteration N0 . Else if f (xn+1 ) and f (an ) have opposite signs. 1. . b0 = b.b define an interval [a. .cs.1. if f a+b 2 f (b) < 0. xn+1 = (3) (4) (5) (6) (7) Other stopping criteria are described in Subsection 8. f (an )) bn 0 an x n+1 p x (b n . or between a+b 2 and b.
fa = fmid. Show that the function f (x) = x3 +4 x2 −10 has a unique root in the interval [1.152 8. Solution.a).beta] % with the property that f(alpha)f(beta)<=0 and % betaalpha <= delta+eps*max(alpha. b = mid. xn+1 = Example 8. else % There is a root in [mid. and obtain recursively an + b n 2 by the bisection method.414063. Note that a root lies in the interval [1. end end root = (a+b)/2. SOLUTIONS OF NONLINEAR EQUATIONS % % delta nonnegative real number. a = mid. fmid = feval(fname. The answer is √ 2 ≈ 1. fb = feval(fname.6.1. Solution. Choose a0 = 1 and b0 = 2. The results are listed in Table 8. if fa*fmid<=0 % There is a root in [a. 2] and give an approximation to this root using eight iterations of the bisection method.mid]. We need to ﬁnd a root of f (x) = x2 − 2 = 0. Stop iterating when xn+1 − xn  < 10−2 . √ Example 8. Since f (1) = −5 < 0 and f (2) = 14 > 0. Find an approximation to 2 using the bisection method.mid).beta) % fa = feval(fname. end while abs(ab) > delta+eps*max(abs(a).abs(b)) mid = (a+b)/2. if fa*fb > 0 disp(’Initial interval is not bracketing. 1.421875]. % % Post: % root the midpoint of an interval [alpha.5.b]. . fb = fmid.’) return end if nargin==3 delta = 0. Give a bound for the absolute error.414063 with an accuracy of 10−2 .b).
Therefore.2. 2].375000 1.500000 + − 1.6.5.367187500.367187500 − f (an ) − − − − − − − − − then f (x) has a root. it is easy to see that bn − an = (2 − 1)/2n .363281250 bn f (xn ) 2 1.500000 .437500 .250000 1.031250 − − 1.250000000 1. Solution.414063 bn xn−1 − xn  f (xn ) f (an ) 2 − 1. Since.375000000 1.406250 1. p.421875 .421875 1.367187500 + 1. that is. The results are listed in Table 8.6 to have an absolute error less than 10−4 . in [1.375000000 − 1.406250 1.375000 1. After eight iterations.250000 1. n 0 1 2 3 4 5 6 7 xn 1.500000000 1. at each iteration.367187500 − 1.367187500 1. Since the root.359375000 1.500000 1.312500000 1. the length of the interval is halved. after n iterations the error is at most bn − an .500000000 − 1. THE BISECTION METHOD 153 Table 8. 2].437500 . .00390625. Results of Example 8.500000 .343750000 1.125000 − − 1.359375000 1.375000 1.421875 . Find the number of iterations needed in Example 8.2.062500 + − 1.375000000 − 1.359375000 1. Results of Example 8. n 0 1 2 3 4 5 6 7 8 xn 1.015625 + − 1.3.500000 .343750000 1.1. Therefore. we ﬁnd that p lies between 1.363281250 = 0.7. lies in each interval [an . in fact f ′ (x) = 3 x2 + 4 x > 0 for all x between 1 and 2. Example 8.363281250 an 1 1 1. or − n ln 2 < −4 ln 10. p. we want to ﬁnd n such that bn − an < 10−4 . Thus.437500 1.250000 − − 1.007812 − − Table 8.8.250000000 1.500000000 + 1.375000000 − 1. ln 2−n < ln 10−4 .414063 an 1 1 1. the absolute error in p is bounded by 1.312500000 1.375000000 + 1.250000000 1. This root is unique since f (x) is strictly increasing on [1. n satisﬁes the inequality 2−n < 10−4 .363281250 and 1. bn ].406250 1.
(8. g ′ (p) > 1. for arbitrary x0 ∈ [a. . n = 0.1. x = (9 − x3 )/9 . .2) and viceversa. x3 + 9 x − 9 = 0. is a number p such that f (p) = 0. such that g ′ (x) ≤ K for all x ∈ (a. . 3. 2. p = g(p). g ′ (p). we present iterative methods for solving equations of the form f (x) = 0. . 1. b].28771238 =⇒ n = 14. Let g(x) be a realvalued function satisfying the following conditions: 1.3) as n → ∞. or a zero of f (x). we rewrite this equation in an equivalent form x = g(x). . If g(x) is continuous. b]. b] for all x ∈ [a. .2) are equivalent (on a given interval) if any root of (8.2). Theorem 8. b]. A ﬁxed point. . g(x) = x − f (x). 2. The problem is to choose a suitable function g(x) and a suitable initial value x0 to have convergence. the sequence x0 . SOLUTIONS OF NONLINEAR EQUATIONS Thus. we say that the ﬁxed point method converges. Fixed Point Iteration Let f (x) be a realvalued function of a real variable x.4.154 8. We say that (8. of an iterative scheme xn+1 = g(xn ). . if. the sequence x0 .1). deﬁned by xn+1 = g(xn ). . of g(x) satisﬁes g ′ (p) < 1. Then g(x) has a unique attractive ﬁxed point p ∈ [a. 1. It is easily seen that the two equations are equivalent.1) is a ﬁxed point for (8. b]. we need 14 iterations. Definition 8. In this section. x2 . . is said to be attractive. 8. converges to p. There exists a number K. for a given initial value x0 . (8. x1 . g(x) is diﬀerentiable on [a. .6 (Fixed Point Theorem).1) A root of the equation f (x) = 0.2) for instance. Moreover. g(x) ∈ [a. This is seen by taking the limit in equation (8. respectively. n > 4 ln 10/ln 2 = 13.3) converges to a number p. . x1 . To treat this question we need to deﬁne the diﬀerent types of ﬁxed points. The number p is called a ﬁxed point for the function g(x) of the ﬁxed point iteration (8. 0 < K < 1. (8. deﬁned by the recurrence xn+1 = g(xn ). . . repulsive or indiﬀerent if the multiplier. Hence.1) and (8. b). To ﬁnd a root of equation (8. Conversely. or g ′ (p) = 1. . n = 0. then p = g(p).
3. there exists a number p ∈]a. there exists a number c between x and y such that g(x) − g(y) = g ′ (c)(x − y). g(p) = p and p is a ﬁxed point for g(x). FIXED POINT ITERATION 155 Proof.m is function x1 = exp8_8(x0). Repeating this procedure n + 1 times. The other conditions are also satisﬁed. In particular. Solution. b[ such that h(p) = 0. there exists a number c between p and q (and hence in [a. we have xn+1 − p ≤ K n+1 x0 − p → 0. the existence of an attractive ﬁxed point is obvious. .4. Then h is continuous on [a. To prove uniqueness. b]) such that p − q = g(p) − g(q) = g ′ (c) p − q ≤ Kp − q < p − q.8. By the Mean Value Theorem 8. By Corollary 8.6 is satisﬁed with K = 1/3 since g ′ (x) =  − x2 /3 ≤ 1/3 for all x between 0 and 1. b]. Thus the sequence {xn } converges to p. x1 = (9x0^3)/9.8. f (0)f (1) = −9 < 0. The function Mﬁle exp8_8.3. Find a root of the equation since 0 < K < 1.1. b]. suppose that p and q are distinct ﬁxed points for g(x) in [a. xn+1 − p = g(xn ) − g(p) ≤ Kxn − p. p. Thus p = q and the attractive ﬁxed point in [a. Five iterations are performed with Matlab starting with x0 = 0. 1] by a ﬁxed point iterative scheme. By the Mean Value Theorem 8.5. b] is unique. Since Corollary 8. We now prove convergence. Condition (3) of Theorem 8. between 0 and 1. then it follows that g(a) > a and g(b) < b. % Example 8.1 implies that f (x) has a root. Hence. for each pair of numbers x and y in [a. g(x) − g(y) ≤ Kx − y. f (x) = x3 + 9x − 9 = 0 in the interval [0. b] and h(a) = g(a) − a > 0. If g(a) = a or g(b) = b. Deﬁne the auxiliary function h(x) = g(x) − x. Example 8. as n → ∞. which is a contradiction. Suppose not. h(b) = g(b) − b < 0.8. Solving this equation is equivalent to ﬁnding a ﬁxed point for g(x) = (9 − x3 )/9. that is.
00584661735184 −0. x0 . In fact.3)].00045726120896 −0..4).:) = [i xt (xtxexact). > 1. . x2 . is one.5..98611111111111 0. The multiplier of a k cycle is A kcycle is attractive. (g k )′ (xj ) = g ′ (xk−1 ) · · · g ′ (x0 ). .27851839836463 The exact solution 0.07120326957745 −0. therefore the order of convergence. repulsive.2..91536510274262 0...92075445888550 0. n 0 1 2 3 4 5 xn error ǫn ǫn /ǫn−1 0. or indiﬀerent as A ﬁxed point is a 1cycle. j = 0.914 907 841 533 66 is obtained by means of some 30 iterations.. x1 . end The iterates. . SOLUTIONS OF NONLINEAR EQUATIONS Table 8. besides ﬁxed points. = 1. for i = 1:N xt=exp8_8(x(i. xk−1 . 1]. Given an iterative scheme xn+1 = g(xn ). The following iterative procedure solves the problem.17161225325185 0. .91490784153366.28080562295762 0. (g k )′ (xj ) < 1. xexact = 0. a kcycle of g(x) is a set of k distinct points.2. Definition 8. x(1. an iterative scheme may have cycles which are deﬁned in Deﬁnition 8. x0 = g k (x0 ). . g 3 (x) = g(g 2 (x)) etc. (xtxexact)/x(i.02145332573957 −0.00164176302768 −0.00000000000000 0. satisfying the relations x1 = g(x0 ).2. we shall show that the convergence of an iterative scheme xn+1 = g(xn ) to an attractive ﬁxed point depends upon a judicious rearrangement of the equation f (x) = 0 to be solved. . 1. x0 = 0.27252731920515 0.:) = [0 x0 (x0xexact).4.156 8.41490784153366 1. k − 1. In Example 8.91326607850598 −0. xk−1 = g k−1 (x0 ).3. x=zeros(N+1.3. Results of Example 8.2)). x2 = g 2 (x0 ).8. their errors and the ratios of successive errors are listed in Table 8. One sees that the ratios of successive errors are nearly constant. deﬁned in Subsection 8. N = 5. where g 2 (x) = g(g(x)). .30129691890395 0. The multiplier of a cycle is seen to be the same at every point of the cycle. x(i+1.9 below.50000000000000 −0.89345451579409 −0.
x=zeros(N+1. Six iterations are performed with the following ﬁve rearrangements x = gj (x).51. . y = [10+x(1)4*x(1)^2x(1)^3.42. 10/(4 + x).9. sqrt((10/x(2))4*x(2)). 10 − x3 .36523001341410 There is one real root. ′ g4 (x∞ ) ≈ −0.9. of the given equation f (x) = 0. x(5)(x(5)^3+4*x(5)^210)/(3*x(5)^2+8*x(5))]’. the equation f (x) = 0 has a root in the interval [1. respectively.35825935992404i 2.m is function y = exp1_9(x). We see from the table that x∞ is an attractive ﬁxed point of g3 (x). and g5 (x) converges even faster.51.365 230 013 than g3 (xn ).365. x(1. N = 6.13 ′ g5 (x∞ ) = 0. % Example 1. Since f (1)f (2) = −70 < 0.5. x0 = 1.:) = [i xt]. % the polynomial f(x) r =roots(p) r = 2. x = g5 (x) =: x − The Matlab function Mﬁle exp1_9. Find a root of the equation f (x) = x3 + 4 x2 − 10 = 0 in the interval [1. x = g1 (x) =: 10 + x − 4x2 − x3 .68261500670705 .35825935992404i 1.:) = [0 x0 x0 x0 x0]. sqrt(10/(4+x(4))). Solution. 2] by ﬁxed point iterative schemes and study their convergence properties. and a pair of complex conjugate roots.5). 4. In fact.68261500670705 + 0. The exact roots are given by the Matlab command roots p=[1 4 0 10]. sqrt(10x(3)^3)/2.0.8. The following iterative procedure is used. ′ j = 1. end The results are summarized in Table 8. in the interval [1. x = g2 (x) =: x = g3 (x) =: x = g4 (x) =: 1 2 (10/x) − 4x. 2. 15 and 4 iterations. 3x2 + 8x ′ g1 (x∞ ) ≈ −15. g4 (xn ) converges more quickly to the root 1.2:5)). which we denote by x∞ . ′ g3 (x∞ ) ≈ −0. these three ﬁxed point methods need 30. x3 + 4x2 − 10 . for i = 1:N xt=exp1_9(x(i.4. 2]. 3. 5.4. ′ g2 (x∞ ) ≈ −3. x(i+1. The derivative of gj (x) is evaluated at the real root x∞ ≈ 1. Moreover. 2]. FIXED POINT ITERATION 157 Example 8. g4 (x) and g5 (x).
An iteration started in the basin of attraction of an attractive ﬁxed point (or cycle) will converge to that ﬁxed point (or cycle). Three usual criteria that are used to decide when to stop an iteration procedure to ﬁnd a zero of f (x) are: (1) Stop after N iterations (for a given N ). Remark 8.3 × 1072 g2 (x) g (x) √3 (10/x) − 4x 0.2.375170 1. SOLUTIONS OF NONLINEAR EQUATIONS Table 8.348399 1.5 10 − x3 1. with multiplier z± = 2.158 8.365262015 1.732421875 −4.08 × 1024 1.360094 2. (3) Stop when f (xn ) < η (for a given η). Results of Example 8. 2! n . the sequence g2 (xn ) is trapped in an attractive twocycle.75 i 1.365230013 to produce a 10digit correct answer.. n 0 1 2 3 4 5 6 g1 (x) 10 + x − 4x2 − x3 1.402540 0.5 0. (2) Stop when xn+1 − xn  < ǫ (for a given ǫ).4.4.816 1.0275 × 108 −1.27475487839820 ± 3.365230 x− g5 (x) x3 +4x2 −10 2x2 +8x 1.367376 1.365225 1.5 1. Stopping criteria. an iteration cannot converge to a ﬁxed point..4.365230014 1. The usefulness of any of these criteria is problem dependent. but can be accelerated by diﬀerent acceleration processes. On the other hand.364957 1.996 1.1.38 − 3.43 i 1.8750 6.60881272309733 i.75 − 2.286953 2.5 1.94 i 1. Suppose that the function g(x) for the iterative method xn+1 = g(xn ) has a Taylor expansion about the ﬁxed point p (p = g(p)) and let Then. 8.19790433047378 which is smaller than one in absolute value..00 − 2.345458 2. we have ǫn = xn − p. An iteration started near a repulsive ﬁxed point (or cycle) will not converge to that ﬁxed point (or cycle). Convergence to an indiﬀerent ﬁxed point is very slow. Finally x∞ is a repulsive ﬁxed point of g1 (x) and xn+1 = g(xn ) diverges to −∞. 2! n xn+1 = g(xn ) = g(p + ǫn ) = g(p) + g ′ (p)ǫn + = p + g ′ (p)ǫn + g ′′ (p) 2 ǫ + .5 1.53 i 1.365264 1.367846 g4 (x) 10/(4 + x) 1.2.. We are often interested in the rate of convergence of an iterative scheme. Order and rate of convergence of an iterative method.5 −0. 8. g ′′ (p) 2 ǫ + .373333333 1.6972001 × 102 1.. ′ ′ g2 (z+ )g2 (z− ) = 0.81 − 3. Once in an attractive cycle.9.
Note that. We wish to ﬁnd a root to the equation f (x) = x2 − 2 = 0.5) 0 = f (xn ) + f ′ (xn ) (xn+1 − xn ). for a secondorder iterative scheme. In Example 8. xn+1 = xn − f (xn ) . Secant. Newton’s.9.1. 8. Solution. and False Position Methods 8. 0). Let xn be an approximation to a root. ǫ2 2 n 8. of this line with the xaxis.4) Definition 8. If f ′ (xn ) = 0. Hence. Approximate 2 by Newton’s method..2. The order of an iterative method xn+1 = g(xn ) is the order of the ﬁrst nonzero derivative of g(x) at p. Newton’s method.5. f (x n )) 0 xn p x n+1 x Figure 8. SECANT. we have ǫn+1 g ′′ (p) ≈ = constant.10. f ′ (xn ) (8.8. Stop when xn+1 − xn  < 10−4 . while g5 (x) converges to second order. NEWTON’S. . the iterative schemes g3 (x) and g4 (x) converge to ﬁrst order. The nth step of Newton’s method. xn+1 = g(xn ). AND FALSE POSITION METHODS 159 y y = f (x) Tangent (xn ..5. where g(x) = x − ′ f (x) √ Example 8. f (xn )) as shown in Fig. of f (x) = 0. p. A method of order p is said to have a rate of convergence p.2. also called the Newton–Raphson method. 2! n (8. solving this equation for xn+1 we obtain Newton’s method.5. ǫn+1 = xn+1 − p = g ′ (p)ǫn + g ′′ (p) 2 ǫ + ..3. Then xn+1 is determined by the point of intersection. (xn+1 . Draw the tangent line y = f (xn ) + f ′ (xn )(x − xn ) to the curve y = f (x) at the point (xn . Note that Newton’s method is a ﬁxed point method since it can be rewritten in the form f (x) .
f (x) = x3 + 4 x2 − 10 = 0 Solution.6.5 1.11. Results of Example 8.36526201487463 0.5.7. √ 2 ≈ 1. Theorem 8. 2] of the polynomial given in Example 8. Use six iterations of Newton’s method to approximate a root p ∈ [1. The results are listed in Table 8.22045 × 10−16 In this case. Newton’s method becomes xn+1 = xn − 2(x3 + 2x2 + 5) x3 + 4x2 − 10 f (xn ) n n = .9. If f ′′ (p) exists.5 0.5 1. Proof.6.3652300134141 2. Newton’s method becomes xn+1 = xn − x2 + 2 x2 − 2 f (xn ) = n .002451 1.414214 0. Note that the number of zeros in the errors roughly doubles as it is the case with methods of second order.3652300134141 2. then Newton’s method is at least of second order near p. n 0 1 2 3 4 xn xn − xn−1  2 1.5.0205 × 10−10 1.083333 1.00807132 1. Results of Example 8.36523001391615 0.416667 0.5.3652300134141 5.126667 1. Diﬀerentiating the function g(x) = x − f (x) f ′ (x) . In this case. Therefore. that is.37333333333333 0. SOLUTIONS OF NONLINEAR EQUATIONS Table 8.22045 × 10−16 1. Let p be a simple root of f (x) = 0. Example 8. n 0 1 2 3 4 5 6 xn xn − xn−1  1.000002 Table 8.414214. = xn − n 2 n ′ (x ) f n 3xn + 8xn 3x2 + 8xn n We take x0 = 1.160 8.414216 0.10.11.000032001 1. = xn − n f ′ (xn ) 2 xn 2xn With x0 = 2. f (p) = 0 and f ′ (p) = 0. we obtain the results listed in Table 8.
652 2.895 0.3846 0.000 0. g2 (x) = x − . Remark 8.00000000000000 0.2000 0.8.972 0.522 0. Therefore. Example 8.3. Newton′ s Method xn ǫn+1 /ǫn 0.12. NEWTON’S.99988432620012 −0.245 0. g ′′ (x) = (f ′ (x))3 If f ′′′ (p) exists. 2 f ′ (p) n which explains the doubling of the number of leading zeros in the error of Newton’s method near a simple root of f (x) = 0.512 ModiﬁedNewton xn ǫn+1 /ǫ2 n 0. AND FALSE POSITION METHODS 161 Table 8. we obtain f ′′ (p) .98461538461538 −0. x = 1.99999999331095 −0.12. We take x0 = 0. Results of Example 8. Taking the second derivative of g(x) in Newton’s method. we have (f ′ (x))2 f ′′ (x) + f (x)f ′ (x)f ′′′ (x) − 2f (x)(f ′′ (x))2 .7. SECANT. xn+1 = xn − 2 ′ f (xn ) f (xn ) to approximate the double root. = (f ′ (x))2 Since f (p) = 0.600 0.4999 1 1 n 0 1 2 3 4 5 6 we have g ′ (x) = 1 − (f ′ (x))2 − f (x) f ′′ (x) (f ′ (x))2 f (x) f ′′ (x) . Solution.806 0. we have g ′ (p) = 0.143 0. but one .4).400 0. Newton’s method is of order two near a simple zero of f . 2(x − 2) + (x − 1) (x − 2) + (x − 1) respectively.80000000000000 −0. The two methods have iteration functions (x − 1)(x − 2) (x − 1)(x − 2) g1 (x) = x − . of the polynomial f (x) = (x − 1)2 (x − 2).5.7.4887 0. Use six iterations of the ordinary and modiﬁed Newton’s methods f (xn ) f (xn ) xn+1 = xn − ′ .945 0. One sees that Newton’s method has ﬁrstorder convergence near a double zero of f (x).537 0. by (8. The results are listed in Table 8. the successive errors satisfy the approximate relation ǫn+1 ≈ − 1 f ′′ (p) 2 ǫ . g ′′ (p) = − ′ f (p) Thus.
f (xn )) Secant 0 x n1 xn p x n+1 x Figure 8. to another root. f (xn )). or to an attractive cycle. of f (x) = 0. If f (xn ) − f (xn−1 ) = 0. SOLUTIONS OF NONLINEAR EQUATIONS y y = f (x) (xn1.1).2 (Secant Method). The secant method. f (xn−1 )) and (xn . b] and has a root in [a.5. (2) Given xn−1 and xn . especially in the complex plane.6) Solving for xn+1 . b]. Draw the secant to the curve y = f (x) throu