Computational Methods in Physics and Engineering
Computational Methods in Physics and Engineering
Computational Methods in Physics and Engineering
com
by 169.149.142.3 on 05/21/17. For personal use only.
COMPUTATIONAL
AND ENGINEERING
METHODS IN PHYSICS
A-PDF Deskew DEMO: Purchase from www.A-PDF.com to remove the wa
Computational Methods in Physics and Engineering Downloaded from www.worldscientific.com
by 169.149.142.3 on 05/21/17. For personal use only.
METHODS IN PHYSICS
AND ENGINEERING
by 169.149.142.3 on 05/21/17. For personal use only.
2nd edition
Samuel S M Wong
University of Toronto
\ \ f e World Scientific
I N T Singapore New Jersey London* Hong Kong
Published by
World Scientific Publishing Co. Pte. Ltd.
P O Box 128, Fairer Road, Singapore 912805
USA office: Suite IB, 1060 Main Street, River Edge, NJ 07661
UK office: 57 Shelton Street, Covent Garden, London WC2H 9HE
Computational Methods in Physics and Engineering Downloaded from www.worldscientific.com
For photocopying of material in this volume, please pay a copying fee through the Copyright Clearance
Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, USA. In this case permission to photocopy is not
required from the publisher.
1 Computational Methods 1
1-1 Numerical calculations and beyond 1
1-2 Integers and floating numbers 5
1-3 Programming language and program library 7
1-4 Examples of algebraic, integer and floating number calculations ... 11
1-5 Examples of unconventional techniques 17
Problems 25
v
vi Contents
5 Matrices 155
5-1 System of linear equations 155
5-2 Matrix inversion and L/-decomposition 164
5-3 Matrix approach to the eigenvalue problem 175
5-4 Tridiagonalization method 188
by 169.149.142.3 on 05/21/17. For personal use only.
Problems 476
Appendix A 477
A-l Decomposition into prime numbers 477
A-2 Bit-reversed order 479
A-3 Gaussian elimination of a tridiagonal matrix 480
A-4 Random bit generator 482
A-5 Reduction of higher-order ODE to first-order 483
Bibliography 487
Index 493
Computational Methods in Physics and Engineering Downloaded from www.worldscientific.com
by 169.149.142.3 on 05/21/17. For personal use only.
physics. That is, the chapters and sections are grouped around methods, with physical
problems used as the motivation and examples. One attractive alternative is to group
around physical phenomena. The difficulty of following this way of organization is the
heavy reliance on the physics background of the readers, thus making it harder to follow for
students at early stages of their education. For this reason, such an approach is rejected.
The intimate relation between physics and mathematics may be seen by the way that
physics is usually taught in the undergraduate curriculum. With a knowledge of calculus,
for example, the subject of mechanics is discussed in a more rigorous manner. By the
time the student is introduced to differential equations, topics such as harmonic oscillators
and alternating current circuits, are brought in. Long experience in the community has
shown this way of teaching to be very successful. The major problem here is the delay
in introducing certain other basic concepts, because of the need to acquire first a certain
maturity in mathematics. The fault is not with the mathematics required but the way it is
used. For example, discussions on a pendulum are usually limited to small amplitudes at the
early years. For finite amplitudes, the differential equation is nonlinear and the necessary
skill to solve such equations by analytical methods comes only in later years. On the other
hand, it is possible to use the same numerical methods to solve both types of differential
equations for the pendulum problem and they are no more difficult than analytical methods.
In this way, the discussion on pendulum does not have to be limited to small amplitude
oscillations.
Until quite recently, the mathematics required in undergraduate physics and engineer
ing, to a large extent, consists of analytical techniques to manipulate algebraic equations,
to carry out integrals, and to solve simple differential equations. In addition to these "alge
braic" methods, there is also a large class of numerical approaches that can be used to solve
physical problems. While it is true that computers have made numerical calculations pop
ular, many of the methods have their origins with the same group of mathematicians as the
algebraic methods, such as Gauss and Newton. In the intervening years since the introduc
tion of these mathematical techniques, numerical calculations have lost out to "algebraic"
ones, perhaps because of the tedium of carrying out numerical calculations by hand. This
reason is certainly no longer true, as attested by the explosion of numerical solutions in
research papers. In spite of its popularity in research, the introduction of computational
physics to the undergraduate syllabus is only starting.
IX
X Preface to the First Edition
To carry out numerical calculations on a computer, the usual practice is to write one or
more programs in one of the high-level languages, such as FORTRAN or C. To simplify the
process, one may make use of standard subroutine libraries to take over specific tasks, such
as inverting a determinant or diagonalizing a matrix. In contrast, the general approach
to algebraic computation is to make use of one of the symbolic manipulation packages.
Most of these packages are very powerful and are able to carry out a large variety of
complicated calculations. Although a substantial amount of "programming" can be done
Computational Methods in Physics and Engineering Downloaded from www.worldscientific.com
in most cases, the symbolic manipulation instructions are not programming languages on
the same level as, for example, FORTRAN or C. Furthermore, there has been little attempt
to standardize the instructions between diflFerent packages. As a result, any discussions of
algebraic calculations in a volume on computational methods must either be very abstract
or very specific in terms of one of these packages. The choice made here is the former, as it
is not clear what is available to the average reader.
The results obtained from computer calculations often appear in the form of a large
by 169.149.142.3 on 05/21/17. For personal use only.
table of numbers. For human beings to comprehend such huge quantities of information,
graphical presentations are essential. For this reason, graphical techniques are essential
parts of computational methods. On the other hand, it is not possible to cover all three
aspects, numerical, symbolic, and graphical, in a single volume. The choice made here is
to select a few of the standard topics in physics covered in the undergraduate curriculum
and present them in ways that computers may be useful for their solutions. Even this
is too big a task. The compromise is to put the emphasis on numerical techniques. For
reasons mentioned in the previous paragraph, only an introduction is made to symbolic
manipulation techniques. Computer graphics is perhaps one of the fastest growing areas in
computing. For this reason also, it is best to leave everything beyond an introduction to
volumes specializing on the subject.
There is quite a bit of interest in the physics community in developing courses in compu
tational physics, as has already been done in many places. Such courses should be regarded
as in parallel with the more traditional ones in mathematical physics and experimental
physics. It is one of the aims of this volume to serve as a textbook or major reference for
such a course. At the same time, many graduate students and senior undergraduates may
not have benefited from such a course. It is also the intention here to serve this group of
physicists. Engineers and other professional people who make use of computational tech
niques in physics may also find it useful to examine some of the background involved in
solving some of the physical problems on computers.
Although a set of computer program is present here, it is not the primary intention
of the author to provide a library of subroutines for common problems in physics. The
computer programs used as examples and included in the accompanying diskette are in
tended as illustrations for some of the materials discussed. They can be modified for other
applications. However, before one does that, as with any computer program, the programs
should be thoroughly tested first for the intended purpose.
S. S. M. Wong
Preface to the Second Edition
Computational Methods in Physics and Engineering Downloaded from www.worldscientific.com
The excellent reception of the first edition by the reader community worldwide makes
it imperative for a new edition. Many subtle changes have taken place in scientific
by 169.149.142.3 on 05/21/17. For personal use only.
computation in the time interval. Most of these are driven by the tremendous increase
in computational power available to the individual user, making it possible to carry
out work almost unthinkable a little while ago and there is every indication that the
trend will continue in the near future. As a result, computational techniques become
even more indispensable to engineers and scientists than ever before. At the same
time, the convenience of communication through internet is also having an impact
on how computers are used and how some of the computations are carried out these
days.
The main changes in the second edition include the addition of a chapter on
finite element methods. The growth of available computing power makes it more and
more attractive to solve many complicated differential equations numerically and a
different approach from the traditional finite difference methods is getting increasing
attention, especially in the physics community. In order to keep the volume from
expanding into unmanageable size, some sacrifices have to be made. These include
introductory chapters on graphics and computer algebra and a couple of sections
on topics that are less popular. Some derivations that can be left to references are
also omitted. In order to accommodate these changes, most of chapters have been
substantially rewritten. The end result is a volume that is more ideal in size both for
the classroom and on the desk.
Many valuable suggestions have been received from readers and they have been
incorporated, as far as possible, into the new edition. The author is greatly indebted
to colleagues for caring to communicate and share their thoughts. The strong en
couragement and support from World Scientific also form an essential ingredient in
making the decision to finish on the second edition.
XI