Numerical Solution of Differential Equations: Introduction To Finite Difference and Finite Element Methods 1st Edition Zhilin Li
Numerical Solution of Differential Equations: Introduction To Finite Difference and Finite Element Methods 1st Edition Zhilin Li
Numerical Solution of Differential Equations: Introduction To Finite Difference and Finite Element Methods 1st Edition Zhilin Li
https://textbookfull.com/product/numerical-differential-
equations-theory-and-technique-ode-methods-finite-differences-
finite-elements-and-collocation-john-loustau/
https://textbookfull.com/product/extended-finite-element-and-
meshfree-methods-timon-rabczuk/
https://textbookfull.com/product/computational-finite-element-
methods-in-nanotechnology-sarhan-m-musaeditor/
https://textbookfull.com/product/mathematical-theory-of-
subdivision-finite-element-and-wavelet-methods-1st-edition-
sandeep-kumar-author/
Finite Difference Methods in Heat Transfer, Second
Edition M. Necati Özi■ik
https://textbookfull.com/product/finite-difference-methods-in-
heat-transfer-second-edition-m-necati-ozisik/
https://textbookfull.com/product/fundamentals-of-rcs-prediction-
methodology-using-parallelized-numerical-electromagnetics-code-
nec-and-finite-element-pre-processor-vineetha-joy/
https://textbookfull.com/product/electromagnetics-through-the-
finite-element-method-a-simplified-approach-using-maxwells-
equations-1st-edition-jose-roberto-cardoso/
https://textbookfull.com/product/finite-element-analysis-a-
primer-2nd-edition-musa/
https://textbookfull.com/product/pricing-derivatives-under-levy-
models-modern-finite-difference-and-pseudo-differential-
operators-approach-1st-edition-andrey-itkin-auth/
NUMERICAL SOLUTION OF
DIFFERENTIAL EQUATIONS
ZHILIN LI is a tenured full professor at the Center for Scientific Computation &
Department of Mathematics at North Carolina State University. His research
area is in applied mathematics in general, particularly in numerical analysis
for partial differential equations, moving interface/free boundary problems,
irregular domain problems, computational mathematical biology, and sci-
entific computing and simulations for interdisciplinary applications. Li has
authored one monograph, The Immersed Interface Method, and also edited sev-
eral books and proceedings.
ZHONGHUA QIAO is an associate professor in the Department of Applied
Mathematics at the Hong Kong Polytechnic University.
TAO TANG is a professor in the Department of Mathematics at Southern
University of Science and Technology, China.
ZH I L I N LI
North Carolina State University, USA
Z H O N G H UA QIAO
Hong Kong Polytechnic University, China
T A O T ANG
Southern University of Science and Technology, China
www.cambridge.org
Information on this title: www.cambridge.org/9781107163225
DOI: 10.1017/9781316678725
© Zhilin Li, Zhonghua Qiao, and Tao Tang 2018
This publication is in copyright. Subject to statutory exception
and to the provisions of relevant collective licensing agreements,
no reproduction of any part may take place without the written
permission of Cambridge University Press.
First published 2018
Printed in the United Kingdom by Clays, St Ives plc
A catalogue record for this publication is available from the British Library.
ISBN 978-1-107-16322-5 Hardback
ISBN 978-1-316-61510-2 Paperback
Cambridge University Press has no responsibility for the persistence or accuracy
of URLs for external or third-party internet websites referred to in this publication
and does not guarantee that any content on such websites is, or will remain,
accurate or appropriate.
Preface page ix
1 Introduction 1
1.1 Boundary Value Problems of Differential Equations 1
1.2 Further Reading 5
Analytic/exact
Solution techniques
Approximated
Use computers
Visualization Products
Experiments
Prediction
Better models
takes some complicated form that is unhelpful to use, we may try to find an
approximate solution. There are two traditional approaches:
1. Semi-analytic methods. Sometimes we can use series, integral equations,
perturbation techniques, or asymptotic methods to obtain an approximate
solution expressed in terms of simpler functions.
2. Numerical solutions. Discrete numerical values may represent the solution
to a certain accuracy. Nowadays, these number arrays (and associated tables
or plots) are obtained using computers, to provide effective solutions of
many problems that were impossible to obtain before.
In this book, we mainly adopt the second approach and focus on numeri-
cal solutions using computers, especially the use of finite difference (FD) or
finite element (FE) methods for differential equations. In Figure 1.1, we show
a flowchart of the problem-solving process.
Some examples of ODE/PDEs are as follows.
1. Initial value problems (IVP). A canonical first-order system is
dy
= f(t, y), y(t0 ) = y0 ; (1.1)
dt
and a single higher-order differential equation may be rewritten as a first-
order system. For example, a second-order ODE
u′′ (t) + a(t)u′ (t) + b(t)u(t) = f(t),
(1.2)
u(0) = u0 , u′ (0) = v0 .
In this example, both the function u(x) (the eigenfunction) and the scalar λ
(the eigenvalue) are unknowns.
5. Diffusion and reaction equations, e.g.,
∂u
= ∇ · (β∇u) + a · ∇u + f(u) (1.7)
∂t
where a is a vector, ∇ · (β∇u) is a diffusion term, a · ∇u is called an
advection term, and f(u) a reaction term.
∂u ∂u
= A(x) , (1.10)
∂t ∂x
1. Generate a grid. A grid is a finite set of points on which we seek the function
values that represent an approximate solution to the differential equa-
tion. For example, given an integer parameter n > 0, we can use a uniform
Cartesian grid
1
xi = i h, i = 0, 1, . . . , n, h= .
n
The parameter n can be chosen according to accuracy requirement. If we
wish that the approximate solution has four significant digits, then we can
take n = 100 or larger, for example.
2. Represent the derivative by some finite difference formula at every grid point
where the solution is unknown, to get an algebraic system of equations. Note
that for a twice differentiable function ϕ(x), we have
Thus at a grid point xi , we can approximate u′′ (xi ) using nearby function
values to get a finite difference formula for the second-order derivative
u(xi − h) − 2u(xi ) + u(xi + h)
u′′ (xi ) ≈ ,
h2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This matlab function two_point solves the following %
% two-point boundary value problem: u''(x) = f(x) %
% using the centered finite difference scheme. %
% Input: %
% a, b: Two end points. %
% ua, ub: Dirichlet boundary conditions at a and b %
% f: external function f(x). %
% n: number of grid points. %
% Output: %
% x: x(1),x(2),...x(n-1) are grid points %
% U: U(1),U(2),...U(n-1) are approximate solution at %
% grid points %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
h = (b-a)/n; h1=h*h;
A = sparse(n-1,n-1);
F = zeros(n-1,1);
for i=1:n-2,
A(i,i) = -2/h1; A(i+1,i) = 1/h1; A(i,i+1)= 1/h1;
end
A(n-1,n-1) = -2/h1;
for i=1:n-1,
x(i) = a+i*h;
F(i) = feval(f,x(i));
end
F(1) = F(1) - ua/h1;
F(n-1) = F(n-1) - ub/h1;
U = A\F;
return
%%%%%--------- End of the program -------------------------
[x,U] = two_point(a,b,ua,ub,'f',n);
u=zeros(n-1,1);
for i=1:n-1,
u(i) = cos(pi*x(i));
end
plot(x,u) %%% Plot the true solution at the grid
%%% points on the same plot.
%%%%%%% Plot the error
figure(2); plot(x,U-u)
It is easy to check that the exact solution of the BVP is cos(πx). If we plot
the computed solution, the finite difference approximation to the true solution
at the grid points (use plot(x, u, ′o′ ), and the exact solution represented by the
(a) (b)
1 × 10−4
1.5
0.8
0.6 1
0.4
0.5
0.2
0 0
−0.2
−0.4 −0.5
−0.6
−1
−0.8
−1 −1.5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Figure 2.1. (a) A plot of the computed solution (little ‘o’s) with n = 40, and
the exact solution (solid line). (b) The plot of the error.
solid line in Figure 2.1(a), the difference at the grid points is not too evident.
However, if we plot the difference of the computed solution and the exact solu-
tion, which we call the error, we see that there is indeed a small difference of
O(10−3 ), cf. Figure 2.1(b), but in practice we may nevertheless be content with
the accuracy of the computed numerical solution.
h2 ′′ hk
u(x + h) = u(x) + hu′ (x) + u (x) + · · · + u(k) (x) + · · · (2.2)
2 k!
if u(x) is “analytic” (differentiable to any order), or as a finite sum
h2 ′′ hk
u(x + h) = u(x) + hu′ (x) + u (x) + · · · + u(k) (ξ), (2.3)
2 k!
where x < ξ < x + h (or x + h < ξ < x if h < 0), if u(x) is differentiable up to
k-th order. The second form of the Taylor expansion is sometimes called the
extended mean value theorem. As indicated earlier, we may represent deriva-
tives of a differential equation by finite difference formulas at grid points to get
a linear or nonlinear algebraic system. There are several kinds of finite differ-
ence formulas to consider, but in general their accuracy is directly related to the
magnitude of h (typically small).
Assume |h| is small and u′ (x) is continuous, then we expect that u(x̄+h)−u(x̄)
h
is close to but usually not exactly u′ (x̄). Thus an approximation to the first
u(x̄ + h) − u(x̄) 1
Ef (h) = − u′ (x̄) = u′′ (ξ)h = O(h), (2.9)
h 2
so the error, defined as the difference of the approximate value and the exact
one, is proportional to h and the discretization (2.7) is called first-order accurate.
In general, if the error has the form
u(x̄) − u(x̄ − h)
∆− u(x̄) = , h > 0, (2.11)
h
for approximating u′ (x̄), where the error estimate is
u(x̄) − u(x̄ − h) 1
Eb (h) = − u′ (x̄) = − u′′ (ξ) h = O(h) , (2.12)
h 2
so this formula is also first-order accurate.
Geometrically (see Figure 2.2), one may expect the slope of the secant line
that passes through (x̄ + h, u(x̄ + h)) and (x̄ − h, u(x̄ − h)) is a better approxi-
mation to the slope of the tangent line of u(x̄) at (x̄, u(x̄)), suggesting that the
corresponding central finite difference formula
u(x̄ + h) − u(x̄ − h)
δu(x̄) = , h > 0, (2.13)
2h
Tangent line at x̄
u(x)
x̄ − h x̄ x̄ + h
Figure 2.2. Geometric illustration of the forward, backward, and central
finite difference formulas for approximating u′ (x̄).
for approximating the first-order derivative may be more accurate. In order
to get the relevant error estimate, we need to retain more terms in the Taylor
expansion:
1 1 1
u(x + h) = u(x) + hu′ (x) + u′′ (x)h2 + u′′′ (x)h3 + u(4) (x)h4 + · · · ,
2 6 24
1 1 1
u(x − h) = u(x) − hu′ (x) + u′′ (x)h2 − u′′′ (x)h3 + u(4) (x)h4 + · · · ,
2 6 24
which leads to
u(x̄ + h) − u(x̄ − h) 1
Ec (h) = − u′ (x̄) = u′′′ (x̄)h2 + · · · = O(h2 ) (2.14)
2h 6
where · · · stands for higher-order terms, so the central finite difference formula
is second-order accurate. It is easy to show that (2.13) can be rewritten as
u(x̄ + h) − u(x̄ − h) 1 ( )
δu(x̄) = = ∆+ + ∆− u(x̄).
2h 2
There are other higher-order accurate formulas too, e.g., the third-order
accurate finite difference formula
2u(x̄ + h) + 3u(x̄) − 6u(x̄ − h) + u(x̄ − 2h)
δ3 u(x̄) = . (2.15)
6h
100
10−2
Slope of FW and BW = 1
10−4
Error
10−6
10−8
Slope of CT = 2
10−10
10−12
10−12 10−10 10−8 10−6 10−4 10−2 100
Step size h
see how the error changes. For a first-order method, the error should decrease
by a factor of two, cf. (2.9), and for a second-order method the error should
be decrease by a factor of four, cf. (2.14), etc. We can plot the errors versus
h in a log–log scale, where the slope is the order of convergence if the scales
are identical on both axes. The forward, backward, and central finite difference
formula rendered in a Matlab script file compare.m are shown below. For exam-
ple, consider the function u(x) = sin x at x = 1, where the exact derivative is of
course cos 1. We plot the errors versus h in log–log scale in Figure 2.3, where
we see that the slopes do indeed correctly produce the convergence order. As
h decreases further, the round-off errors become dominant, which affects the
actual errors. Thus for finite difference methods, we cannot take h arbitrarily
small hoping to improve the accuracy. For this example, the best h that would
“You got this old timer running round in circles, Miss Tavia, when
you ask about a feller named Garford Knapp anywhere in this
latitude, and working for a feller named Bob. There’s more ‘Bobs’
running ranches out here than there is bobwhites down there East
where you live. Too bad you can’t remember this here Bob’s last
name, or his brand.
“Now, come to think, there was a feller named ‘Dimples’ Knapp
used to be found in Desert City, but not in Hardin. And you ought to
see Hardin—it’s growing some!”
This was a part of what was in Lance Petterby’s letter. Had Nat
White been allowed to read it he would have learned something else
—something that not only would have surprised him and his brother
and cousin, but would have served to burn away at once the debris
of trouble that seemed suddenly heaped between Tavia and himself.
It was true that Tavia had kept up her correspondence with the
good-natured and good-looking cowboy in whom, while she was
West, she had become interested, and that against the advice of
Dorothy Dale. She did this for a reason deeper than mere mischief.
Lance Petterby had confided in her more than in any of the other
Easterners of the party that had come to the big Hardin ranch. Lance
was in love with a school teacher of the district while the party from
the East was at Hardin; and now he had been some months married
to the woman of his choice.
When Tavia read bits of his letters, even to Dorothy, she skipped
all mention of Lance’s romance and his marriage. This she did, it is
true, because of a mischievous desire to plague her chum and Ned
and Nat. Of late, since affairs had become truly serious between Nat
and herself, she would have at any time explained the joke to Nat
had she thought of it, or had he asked her about Lance.
The very evening previous to the arrival of this letter from the
cowpuncher to which Nat had so unwisely objected, Nat and Tavia
had gone for a walk together in the crisp December moonlight and
had talked very seriously.
Nat, although as full of fun as Tavia herself, could be grave; and
he made his intention and his desires very plain to the girl. Tavia
would not show him all that was in her heart. That was not her way.
She was always inclined to hide her deeper feelings beneath a light
manner and light words. But she was brave and she was honest.
When he pinned her right down to the question, yes or no, Tavia
looked courageously into Nat’s eyes and said:
“Yes, Nat. I do. But somebody besides you must ask me before I
will agree to—to ‘make you happy’ as you call it.”
“For the good land’s sake!” gasped Nat. “Who’s business is it but
ours? If you love me as I love you——”
“Yes, I know,” interrupted Tavia, with laughter breaking forth. “‘No
knife can cut our love in two.’ But, dear——”
“Oh, Tavia!”
“Wait, honey,” she whispered, with her face close pressed against
his shoulder. “No! don’t kiss me now. You’ve kissed me before—in
fun. The next time you kiss me it must be in solemn earnest.”
“By heaven, girl!” exclaimed Nat, hoarsely. “Do you think I am
fooling now?”
“No, boy,” she whispered, looking up at him again suddenly. “But
somebody else must ask me before I have a right to promise what
you want.”
“Who?” demanded Nat, in alarm.
“You know that I am a poor girl. Not only that, but I do not come
from the same stock that you do. There is no blue blood in my
veins,” and she uttered a little laugh that might have sounded bitter
had there not been the tremor of tears in it.
“What nonsense, Tavia!” the young man cried, shaking her gently
by the shoulders.
“Oh no, Nat! Wait! I am a poor girl and I come of very, very
common stock. I don’t mean I am ashamed of my poverty, or of the
fact that my father and mother both sprang from the laboring class.
“But you might be expected when you marry to take for a wife a
girl from a family whose forebears were something. Mine were not.
Why, one of my grandfathers was an immigrant and dug ditches
——”
“Pshaw! I had a relative who dug a ditch, too. In Revolutionary
times——”
“That is it exactly,” Tavia hastened to say. “I know about him. He
helped dig the breastworks on Breeds Hill and was wounded in the
Battle of Bunker Hill. I know all about that. Your people were Pilgrim
and Dutch stock.”
“Immigrants, too,” said Nat, muttering. “And maybe some of them
left their country across the seas for their country’s good.”
“It doesn’t matter,” said the shrewd Tavia. “Being an immigrant in
America in sixteen hundred is one thing. Being an immigrant in the
latter end of the nineteenth century is an entirely different pair of
boots.”
“Oh, Tavia!”
“No. Your mother has been as kind to me—and for years and
years—as though I were her niece, too, instead of just one of
Dorothy’s friends. She may have other plans for her sons, Nat.”
“Nonsense!”
“I will not answer you,” the girl cried, a little wildly now, and began
to sob. “Oh, Nat! Nat! I have thought of this so much. Your mother
must ask me, or I can never tell you what I want to tell you!”
Nat respected her desire and did not kiss her although she clung,
sobbing, to him for some moments. But after she had wiped away
her tears and had begun to joke again in her usual way, they went
back to the house.
And Nat White knew he was walking on air! He could not feel the
path beneath his feet.
He was obliged to go to town early the next morning, and when he
returned, as we have seen, just before dinner, he brought the mail
bag up from the North Birchland post-office.
He could not understand Tavia’s attitude regarding Lance
Petterby’s letter, and he was both hurt and jealous. Actually he was
jealous!
“Do you understand Tavia?” he asked his cousin Dorothy, right
after dinner.
“My dear boy,” Dorothy Dale said, “I never claimed to be a seer.
Who understands Tavia—fully?”
“But you know her better than anybody else.”
“Better than Tavia knows herself, perhaps,” admitted Dorothy.
“Well, see here! I’ve asked her to marry me——”
“Oh, Nat! my dear boy! I am so glad!” Dorothy cried, and she
kissed her cousin warmly.
“Don’t be so hasty with your congratulations,” growled Nat, still red
and fuming. “She didn’t tell me ‘yes.’ I don’t know now that I want her
to. I want to know what she means, getting letters from that fellow
out West.”
“Oh, Nat!” sighed Dorothy, looking at him levelly. “Are you sure you
love her?”
He said nothing more, and Dorothy did not add a word. But Tavia
waited in vain that evening for Mrs. White to come to her and ask the
question which she had told Nat his mother must ask for him.
CHAPTER XVIII
CROSS PURPOSES
Four days before Christmas Dorothy Dale, her cousins, and Tavia
all boarded the train with Jennie Hapgood, bound for the latter’s
home in Pennsylvania. On Christmas Eve Jennie’s brother Jack was
to be married, and he had written jointly with the young lady who was
to be “Mrs. Jack” after that date, that the ceremony could not
possibly take place unless the North Birchland crowd of young folk
crossed the better part of two states, to be “in at the finish.”
“Goodness me,” drawled Tavia, when this letter had come from
Sunnyside Farm. “He talks as though wedded bliss were something
like a sentence to the penitentiary. How horrid!”
“It is. For a lot of us men,” Nat said, grinning. “No more stag
parties with the fellows for one thing. Cut out half the time one might
spend at the club. And then, there is the pocket peril.”
“The—the what?” demanded Jennie. “What under the sun is that?”
“A new one on me,” said Ned. “Out with it. ’Thaniel. What is the
‘pocket peril’?”
“Why, after a fellow is married they tell me that he never knows
when he puts his hand in his pocket whether he will find money there
or not. Maybe Friend Wife has beaten him to it.”
“For shame!” cried Dorothy. “You certainly deserve never to know
what Tavia calls ’wedded bliss.’”
“I have my doubts as to my ever doing so,” muttered Nat, his face
suddenly expressing gloom; and he marched away.
Jennie and Ned did not observe this. Indeed, it was becoming so
with them that they saw nobody but each other. Their infatuation was
so plain that sometimes it was really funny. Yet even Tavia, with her
sharp tongue, spared the happy couple any gibes. Sometimes when
she looked at them her eyes were bright with moisture. Dorothy saw
this, if nobody else did.
However, the trip to western Pennsylvania was very pleasant,
indeed. Dorothy posed as chaperon, and the boys voted that she
made an excellent one.
The party got off gaily; but after a while Ned and Jennie slipped
away to the observation platform, cold as the weather was, and Nat
plainly felt ill at ease with his cousin and Tavia. He grumbled
something about Ned having become “an old poke,” and sauntered
into another car, leaving Tavia alone with Dorothy Dale in their
compartment. Almost at once Dorothy said to her chum:
“Tavia, dear, are you going to let this thing go on, and become
worse and worse?”
“What’s that?” demanded Tavia, a little tartly.
“This misunderstanding between you and Nat? Aren’t you risking
your own happiness as well as his?”
“Dorothy——”
“Don’t be angry, dear,” her chum hastened to say. “Please don’t. I
hate to see both you and Nat in such a false position.”
“How false?” demanded Tavia.
“Because you are neither of you satisfied with yourselves. You are
both wrong, perhaps; but I think that under the circumstances you,
dear, should put forth the first effort for reconciliation.”
“With Nat?” gasped Tavia.
“Yes.”
“Not to save my life!” cried her friend. “Never!”
“Oh, Tavia!”
“You take his side because of that letter,” Tavia said accusingly.
“Well, if that’s the idea, here’s another letter from Lance!” and she
opened her bag and produced an envelope on which appeared the
cowboy’s scrawling handwriting. Dorothy knew it well.
“Oh, Tavia!”
“Don’t ‘Oh, Tavia’ me!” exclaimed the other girl, her eyes bright
with anger. “Nobody has a right to choose my correspondents for
me.”
“You know that all the matter is with Nat, he is jealous,” Dorothy
said frankly.
“What right has he to be?” demanded Tavia in a hard voice, but
looking away quickly.
“Dear,” said Dorothy softly, laying her hand on Tavia’s arm, “he told
me he—he asked you to marry him.”
“He never!”
“But you knew that was what he meant,” Dorothy said shrewdly.
Tavia was silent, and her friend went on to say:
“You know he thinks the world of you, dear. If he didn’t he would
not have been angered. And I do think—considering everything—
that you ought not to continue to let that fellow out West write to you
——”
Tavia turned on her with hard, flashing eyes. She held out the
letter, saying in a voice quite different from her usual tone:
“I want you to read this letter—but only on condition that you say
nothing to Nat White about it, not a word! Do you understand,
Dorothy Dale?”
“No,” said Dorothy, wondering. “I do not understand.”
“You understand that I am binding you to secrecy, at least,” Tavia
continued in the same tone.
“Why—yes—that,” admitted her friend.
“Very well, then, read it,” said Tavia and turned to look out of the
window while Dorothy withdrew the closely written, penciled pages
from the envelope and unfolded them.
In a moment Dorothy cried aloud: