COM
IONAL
PHYSICS
COMPUTAT
L
S
Version
Professor
of
Theoretical Physics
Calvomzia
instituteof
Rchmlogy
Dawn C. Meredith
Assistant
Professor
of
Physics
Univmsity of
New
Ham-pshire
This book was tmtsset by Elkabeth K, Wmd ushg the 'Q@ &xt-processing syskm running on a Bigibl Equipment Gomodion n 2@m cornpuk~ Camera-read~ f i i d COPY ww produced on an Appb WerWrikr.
FoElswing is a list ofbadernsks used in tke book:
V M , VMsMion, W S , W axe &&emaks af Bi@M Equipment Copoaion. UES, HCFJIS***
CA-DISSPM is a &&emmk of Computer b o c i - s In&rn&iond, E nc.
W= is a bdernmk ofAT&T.
XBM-PC is a. W e m m k of Xnteraliond Bushess Mitchhes, MackWsh is a Wademmk of Apple Compukr, Inc,
%Won& 4010 iisl a &demwk of%k&anix Enc. GO-235 is a mdentak af Graphon Copomtion. WDS3200 is a trdemwk of Humizn Dwiped Sys&ms. %X is a trMemwk of the A m e ~ c m Mahernaied Society. PST is a Wemask sf Mme Computers, Enc.
Kermit Is a Mexnwk af Wdt Bisnq &oduc:tiox1s,
S;m
is a r e g b k ~ d of SW Mcrasp&ms,Inc.Koonin, Skven E.
version) I SWen E. Koonb, Dawn Nereditk. p. cm.
Includes index.
physie+D@ processing, 2. Physic+Computer p r a g m s , 3. puter program lmguage) 4. Nume~cal malysis. I, Meredith, Dawn, IE. Title,
Q620.XE4K66 1M 530.1 "W02855133-d~L9 90- 129 ISBN 0-201 -X 2774-2 ( h ~ d ~ ~ e r )
ISBN 0-201 -38623-2 [pperback)
Copyight 8 199l)byWestviecv Press, a member of the Per~eus Books Group
All rim& resemed. No part of this text publiatjon may be reproduced, stored in a reeied system, or kansmitbd, in my fom or by my me=, ekc&anic, mechicat, phoacopyhg, recordhg, or o t h e m h , wigbout the prior Wtten permimion of the publisher. Prinkb in the Unikd S b k s o f b e f i c a . Prxblhfied simulkneously in CmiltZa,
Preface
Computation is an integral part of modern science and the ability to exploit effectively the power offered by computers is therefore essential to a working physicist. The proper application of a computer to modeling physical systems is far more than blind "number crunching," and the successful computational physicist draws on a bdanced mix of analytically soluble examples, physicd intuition, and numerical work to solve problems that x e otherwige intractable.
Unfortunately, the ability "to computen is seldom cultivated by the stmdard zrniwrsity-level physics crtrri culum, as it requires an inteaation of three disciplines (physics, numerical analysis, and computer program- ming) covered in disjoint courses. Few physics students finish their un- dergraduate education knowing how to compute; those that do usually leara a L i ~ t e d get of techniques in the coufse of independent work, such as a research projed or a senior thesis.
The materid in. this book is ~ m e d r e f i ~ n g eomputationd sEns in advanced undergraduate ar be@nning graduate students by providixrg experimce in using a computer to model physical systems. Its s q e includes the minimam set of numerical techaiques needed to do'" physics"
on a mmputer. Each of these is developed In the text, often hmristicdy, and is then applied t o solve non-trivial problems in classical, qnantum, and statisticd physics, The= latter have been chosen to enrich or a t e n d the standard undergraduate physics curriculum, and so haw considerable intrinsic interest, quite independent of the comput ationd principles they illustrate,
This book should not be thought of as setting out a rigid or defini- tive curriculum. I have restricted its scope to calculations that satisfy simultaneously the criteria of illustrating a widely applicable numerical technique, of being tractable on a microcomputer, and of having some parhicalm physics interest. Several import ant numeric& techniques have therefore been o ~ t t e d , spEae iaterpdatim asld the F a t Fburier Trans- form among them. Computational Physics is perhaps best thought of as
establishing m environment rer ring opportunities for further eqloration. There are =my possible extensions and embelEshmerrts of the materid prescjnted; using mevs iana&nation dong these liaw is one of the mom rewwding parts of working through the book.
C"omp.utat%'onal Pltysz'cb? is primwily a physics text, For xnknrum benefit, the student should have taken, or be taking, undergrad- uate courses in dwsical meclzanic~, quantum mechanics, stat;jstical me- chmics, and advanced cafculus m the mathematical methods of physics. Tbis is slot a text on aurnerical analysis, as there hahs been no attempt at rigor or completeness in any of the expositions of numerical techniques. However, a prior course in that subject is probabb not essential; the dis-
cussions of numerical techniques should be accessible to a student with the physics background outlined above, perhaps with gome reference to any one of the excellent texts on numerical andysis (for example, [AC~O],
[Bu81], or [Sh84]). This is dso not a text on computer programming. AI-
though I have tried to follow the principles of good programming through- out (see Appendix B), there has been no attempt to teach programming per se. Indeed, techniques for organizing and writing code are somewhat peripheral to the main gods of the book. Some familiarity with program- ming, at least to the extent of a one-semester introductory course in any
of the standard high-level languages (BASIC, FORTRAN, PASCAL, C),
is therefore essentid.
The choice of language invariably invokes strong feelings among sci- entists who use computers. Any language is, after
d,
only a mews ofexpressing the concqts underlying a program. The contents
of
this book are therefore rdevant no m&ter what lanpae;e one vvorfis in. However,some laneage had to be elrosen to implement the programs, and I have selected the Microsoft dialect of BASIC standard on the IBM PC/XT/AT
computers for this purpose. The BASIC language has many well-known deficiencies, foremost among them being a lack of local subroutine vari- ables and an awkwardness in expressing structured code. Nevertheless, I
believe that these are more than balanced by the simplicity of the language and the widespread ftuency in it, BASIC'S almost universal avdability on the microcomputers most likely to be used with this book, the exis- tence of both BASIC interpreters convenient for writing and debugging programs and of compilers for producing rapidly executing finished pro- grams, and the powerful graphics and I/O statements in this language. I expect that readers familiar with some other high-level language can learn enough BASIC "on the Ay'' to be able to use this book. A synopsis of the language is contained in Appendix A to help in this regard, and further information can be found in readily available manuds. The reader may, of course, elect to write the programs suggested in the text in any convenient 1anguag;e.
This book arose out of the Advanced Computational Physics Lab-
at Csiltech during the Winter m d Spring of 1984, The content ilnd pre- sentation have benefitted grea;t.ly fram the many inspired suggestims af
M,-C. Chtt, V. PGnisc11, R. WiUiarns, md D. Meredith. Mrs. Mereditb
wads also af great wsistance in producing the find fom of the mannscript
and programs. I. also wish to thank my wife, Laarie, ibr her extraordinary galienct;, anderstanang, and support during my twa-year involvemeat in this project.
Preface to
the
FOR
Edition
At the request of the readers of the BASIC edition of Computational
Physics we offer this FORTRAN version. Although we stand by our original choice of BASIC for the reasons cited in the preface t o the BASIC edition it is dear that many of our readers strongly prefer FORTRAN, and so we gladly oblige. The text of the book is essentially unchanged,
but ofthe codes haw been trmslated into standard FQRTRAN-7had
will run (with some modification) on a variety of machines. Although the programs will run significmtly faster on mainframe computers than on PC%$ we have not increased the mope or complegty af the calculations. Resdts, therefore, are still produced in "red time'" and the codes r e m ~ n . suitable for interactive use,
Another development since the BASIC edition is the publication of an
excellent new text on numerical analysis (Nclmerical Recipes [Pr86]) which providecs detajled discussions md code for state-of-th-at dgorithms. We
highly recommend it as a compaaion to this text.
The FORTRAN versions of the code were written with the help of
T.
Berke (who designed the menu), G . Buzzell, and J. Parley. We havealso profited from the suggestions of many colleagues who have generously tested the new codes or pointed out errors in the BASIC edition, VVe
gratefully acknowledge a grant from the University of New Hampshire DIS Covery Computer Aided Instruction Program which provided the initial impetus for the translation. Lastly, our thanks go to E. Wood for typesetting the text in T&jX.
Stevetn E Koonz'n Pasadeaa, CA August, 1989
Dawn C. 1Medith
How
to Use
This Book
This book is organized into chapters, each containing a text section, an example, and a project. Each text section is a brief discussion of one or several related numerical techniques, often illustrated with simple mathematical examples. Throughout the text are a number of exercises, in which the student's understanding of the material is solidified or ex- tended by an andyticd derivation or through the writing and rnnning of a simple program. These exercises are indicated by the symbol m.
Also located throughout the text are tables of numerical errors. Note that the values listed in t h a e tables w r e taken from runs udng BASIC
code on an IBM-PC. When the machine precision dominates the error, your values obtained with FORTRAN code may diger.
The example and project in each chqter are applications of the nu- mericd techniques to particular physical problems. Each includes a brid expmition of Ihe physics, f~llowed by a discussim of how the numericd techniques are "c be applied, The examples and projects diRer mly in that the student is expected to use (and perhaps modify) the program that is @ven for the forxner in Appendix B, while the book provides &uid-
anee in writing progrms to treizt the latter through a series of steps, dso indicated by the symbol m. However, programs for the projiects have dso b e n included in Appendk C; these can swve as models far the student's
o m p r o g r a or as a means of investigating the physics without having to write a major progrm "from ~cratch", A number of susetated studies &c- company each example and project; these guide the student in exploiting the programs and understanding the physical principles and numerical techniques invdved.
The progFrams for b d h the examples and projects are avdfable either sver the Internet network or on diskedtes. Appendix E: describes how to obtain files over the network; &ernativdy, there is aa order form in the back of the book .far IBM-PC or Macintosh formatted diskettes. The codes are suitable for running on any computer that h a a FORTRAM-
77 standard compiler. (The IBM BASIC versions of the code are also
available over the network.) Detailed instructions for revising and running the codes are @ven in Appendix A.
A "laboratory" format has proved to be one effective mode of pre- senting this material in a university setting. Students are quite able to
z i i Rout t o U@e mis Book
m k throagh the text on their w n , with the instmctor being a v d 1 d e
for consultation and to monitor prosess t;Broup;h brief personat interviews
on each chapter. Three chaptens in teen weeks (60 hours) af instruction has proved to be a reasonal>le pace, with students typicdy writing two
of the p r o j ~ t s during this time, and usiag the "cmned" codes t s work through the physics of the remaining project a~nd the examples. The dgkrt chapters in this book should therefore be more than sufficient for a one-semester course. Alterrr;n;tively, this book em be nsed ta provide supplementary material far the usud m r s e s in cla@icat, quantum, and statisticd mechanics. Many of the examples and proJects are vivid ill=- tratims of basic concepts in these subjects and are therefore suitable for clasgroom dennonstratims os independeIll study.
Contents
Preface, u
Preface Lia the FORTRAN Editiaa, iz
Haw to use this baak, zi
Chapter 1: Basic Mathematical Operations, 1 2 -1 Numerical diEerentiatioa, 2
1.2 Nnnterieal quadratwe, 6
1.3 Finding roots, 11
1.4 Sernidz~ssicd quantiz-atioa of molecular vibrations,
14
Project I: Scattering by a central potential,&O
Chapter 2: Ordinary DiEerential Equations, 25
2.1 Simple methods, 26
2.2 Multistep and impEcit method@, 89 2.3 Range-Kutta methods, $2
2.4 StabiEdy,
$4
2.5 Order and chaos in. two-disniensiand zndion, $7 Project 11: The stmcture of white dwmf s t a s , 46
11.1 The equations of eqailibrium, 46
11.2 The equation of state,
4
7 11.3 S e d i ~ g the equations, 50B.4 Solving the equalians, 51
Chapter 3: Boundary Value and Eigenvalue Prablems, 55
3*1 The Numerov dgorithm, 56
3.2 Direct intepatian of boundav value problems, 57 3.3 Green" function solution of boundary value problems, 61 3.4 Eigenvalues of the wave equ;t;tion, 64
3.5 St ittioaary solutions of the one-dimensional Schroedinger equ* tion, 67
ziu Contends
Project 111: Atomic structure in the Martree-Fa& approximation, Y23 f 11.1. Basis af the Hartre@- Fock approximation, 72
IfI,2 The tw-electron problem, 75
112.3 Many-electron systems, 78
If 1.4 S~Iving the equations, 80
Chapter 4: Special Functions and Gausshn Quadrature, 85
4.1 Specid funcZlion~, 85
4.2 Gaussian quadrature, 9b
4.3 Born and eiXcond qproSrnadions ta quantum scattering, 96
Project IV: Partial wave solution of quantum scattering, 108
IV.1 Partial wave decomposition of the wave function, 109
IV.2 Finding the phase shifes, 104
IV.3 Sdving the equations, 1135
Chapter 5: Matrix Operations, 109 5.1 M;xtrix inversion, 109
5.2 Eigenvalues of a tri-diagonal matrix, 11 2
5.3 &duction to tri-diagond fom, f L5
5.4 Determining nudear charge densities, Id0
Project V: A schematic shell model, 188 V.1 Definition of the model, 184
KZ The exact dgenstates, 196
V.3 Approximat;e eigenstates, 158
V.4 Solving the model, 149
Chapter 6: Elliptic Partial Differential Equations, 145
6.1 Disercdizatian and the varizttiond principle, 24 7 6.2 An idesstiw method for boundav value problems, 151
6.3 More on, discretizatio~, 1155
6.4 Elliptic equations in two dimensions, 157
Project VI: S teady-state hydrodynamics in two dimensions, 158
VI.l The equations and their diseretization, 159
VI.2 Boundary conditions, f 68
Chapter 7: Pwrabofie Partial DiEerenlial Eqaatiarzs, 169 7.1 Naive discretiz;ztion and instabilities, l69
7.2 Impfici t schemes m d the inversion of tri-diagond matrices, 174
"7.3 DiRusion and boundary value problems in tw dimensians, 179
7.4 Iterative methods for eigenvdue problems, 181
7.5
he
time-dependent Schroedinger equation, 186Prdect VXI: Self-osganizaeion in chemical. rextions, 189
V11.1 Descriptiolz of the model, I89
V"11.2 Lillear st abi2ity andysis, 191
VE.3 Nun2erirzd solution of the model,
r"$d
Chapter 8: Monte Carto Methods, 1978.1 The basic Mmte Carlo strategy, 198
8.2 Generating random. variables with a spedfied &&ribation, 205
8.3 The algorithm of Metropolis et al., 210
8.4 The Isiag model in two dimensions, 215
Project VIIZ: Quantum Mm& Cado for the
H2
mdecule, 221 VIII.1 S t&ement of the problem, 231VIII.2 Variational Monte Carlo and the trial wave function, 288
VIII.3 Monte Carlo evaluation of the exact energy, $85
VXII.4 Solving the problem, 229
Appendix A: How to use the programs, 231
AI Insfaflation, 231 A.2 Files, $32 A.3 CompiZatian, 233 A.4 Execution, 635 A5 Graphics, L97 A.6 P r w ~ a m Structure, $88
A.7 Menu Structure, 259
A.8 Default Value Revision, 241
Appendix B: Programs for the Examples, 849
B,l Example 1, 243 B.2 Exanlplc 2, 256 B.3 Exa~nple 3, $73 B.$ Exampks 4, 295 B.5 Exan113le 5, 316 B.6 Exan3ple G, $89
B.7 Example 7, 370
B.8 Example 8, 991
Appendix C: Programs far the Projects,
C.1 Project I, 409 6.2 Project If, 421 C.3 Project XII,
4914
C.4 Project W , 454 6.5 Project V, $W C.6 Project,VX,
494 C.7 Project VII, 580 C.8 Project VIfI, @SAppendix D: Cornman UGilif;y Code@, 567
D.1 Standardization Code, 567
D.2 Hardware and Compiler Specific Code, 570 D.3 General Input/oatpu% Codes, 574
D.4 Graphics Codes, 598
Appendix
E:
NeLwork Fife =ans&r, 681Index, 631"
The problem with computers is that they only give answers
Chapter
I
Basic
Mathematics
Operations
Three numerical operations
--
differentiation, quadrature, and the finding of roots-
are central to mhst computer modeling of physical sys- tems. Suppose that we have the ability to calculate the value of a function, f ( s ) , at any value of the independent variable z. In digerentiation, weseek one of the derivatives of f at a given value of x. Quadrature, roughly the inverse of differentiation, requires us to calculate the definite integral off between two specified limits (we reserve the term "integration" for the process of solving ordinary differential equations, as discussed in Chap-
ter 21, while in root finding we seek the d u e s of s (there may be several) at which f vanishes,
If f is knourn mafyticatly, it is almost always possible, with
ensue
fortitude, to derive expEcit formulas for the defivatives of f , aad it is aften possible t s do so for its degnite integal as well. However, it is often the ease that an m d y t i d method cannot be used, even though pife cm evaluate f (S) itself. This might be either because some very complicatednumerid procedure is rquired to e d u a t e f and we have no suitable analytical formula upon which to apply the rules of digerentiation and quadraturn, or, even worse, because the wily we can. generate f provides ns with its values at only a set; of discrete abseissm, In these situations, we
must employ qpro&m&e form&% expressing the derjvatives and integrd in terms of the values of f we can compnte. Moreover, the root8 of 41
but the simplest functions cannot be found anatyticdly, and nuzrrericd methods are therefore essentialt.
This chapter dealfs d t h the computer redigation of these three ba- sic operations. The centrd technique is to appradmate f by a simple function (such as first- or second-degree polynomial) upon which these
2 2. Basic Mathematical Qpervrdians
Figure 3.1 W u e s of f on an equdEy-spud ladtice. Dmhed lines how the hear interpslalion.
operaLioas caa be performed easily, We will derive only the Simpleet and
mo& commonly used fomdas; fufbr treatments can be h n d in many textbooks an n m e r i c d andysis.
1
.l
NumericaldiEerentiatiolz
Let us suppose that we we interested in the derivative at z = 0,
f
'(0). (The formulas we will derive can be generalized simply to arbitrary z by translation.) Let us also suppose that we know f on an equally-spaced lattice of z vdnes,and that our god is to compute an approximate value of fE(0) in terms
of the f, (see Figure 1.1).
We begin by using a Taylor series to expand f in the neighborhood
whem
all
derimtives are evduated at z = 0. It is then simple to verifywhere O(h4) means terms of order h4 or higher. To estimate the size of such terns, we c m assume that J and its derivatives are aJ1 of the same order of magnitude, as is the case for many functions of physical rdemnee.
Upon subtracting from f i as given by (1.2a), we find, after a
sEght rcjarrangea;lc?n%,
'
The term involving f f N vanishes as h becomes small and is the dominant error associat;ecl with the finige dfference q p r o ~ m i t t i m that Tetijtin~ mly the f i r ~ t term:
This "%point" formula would be exact if f were a second-deetje poly~o- mid in the 3-point interval [-h, +h], because the third- and all higher- order derivatives would then vanish. Hence, the essence of Eq. (1.3b) is the assannptian that a quadratic p o l y n o ~ d inticrrpolatiofi of f throu& the thrw points z = &h, O i s v&d.
Equation (1.3b) is a very naturd result, reminiscent of the formulas used to define the derivative in elementary calculus. The error term (of order h2) can, in principle, be made as small as is desired by using s m d e r and s m d e r d u e s of h. Note
also
that the 8ynmetric difirence aboutz = O is used, as it is more aecurate (by one order in h) than the forward or badward CliRerenm form~las:
These "2-pointw formulas are based on the assumption that f i s well
agproSma2ed by a fineas fanctian over the intervds between z =
O
andz = &h*
As a concrete example, consider evaluating ff(z = 1) when f ( g ) =
sin 2. The exact answer is, of course, cos 1 = 0.540302. The following
FORTRAN program evaluates Eq. (1.3b) in this case for the value of h
4 1. Basic Mathemalical Operations
10 FRIlT
*
,
%HT= VALUE OF ftC.
LE, O TO STOP) READ*,
WI IF (B .LE, 0) STOP F P R ~ E = ( S X W (x+E>-SXN(X-B] > / ( 2 * ~ > DIW=EXACT-FPRIME PRTMT 28,W,BIFF 20 FOMAT(~=',Elb.$,5X,%MOR=~,E1668) GOT15 10 ElD(If you are a beginner in FORTRAN, note the way the value of H is requested from the keyboard, the fact that the code will stop if a non- positive d u e of R is entered, the natural way in whi& variable names are chosen and the mathematical formula (1.3b) is transcribed using the SIN function in the sixth line, the way in which the number of significant digits is specified when the result is to be output to the screen in line 20,
and the jump in program control at the end of the program.)
Result8 generated urlth this progrm, as W& as with s i d a r ones
evaluating the forward and backward difference formulas Eqs. (1.4a,b), are shown in Table 1.1. (AU. of the tables of errors presented in the text wre generilted f f ~ m BASIC p r o g r a s ; the numbers may vary from those obtdned from FQRTRATJ code, especidy when numerical roundoff
dominates.) Note that the result improves as we decrease h, but only up
to a point;, after which it becomes worse, This is because arithmetic in the computer i s performed with only a limited precision (5-6 decimai digits for a single precision BASIC variable), so that when the difference in the numentor of f;he appro~mafsions is formed, it is subject to large "round-
off"
erfors if h is smdl and fi and diger very little. For example, ifh = 10-7 then
f 2 = sin (1.000001) = 0.841472 ; f-l = sin (0.999999) = 0.841470
,
so that fi-lml
= 0.000002 to six significant digits. When substituted into (1.3b) we find f t m 1.000000, a very poor result. However, if we dothe arithmetic with 10 significant digits, then
which gives a respectable f' rr: 0.540300 in Eq. (1.3b). In this sense, nu- merical differe~ltiation is an intrinsically unstable process (no well-defined limit as h --+ 01, aud so must be carried out with caution.
Table 3.1 Error in cvduating d;sin t / d ~ l ~ = ~ = 0.5403@
S ~ e ( ; r i e Forward B s c k w d Symmetric
h $point %point 2-point &point
Eq. (1.3b) Eq. (1.4a) Eq. (1.4b) Eq. (1.5) 0,50000 0.022233 0.228254 -0,183789 0,001092 0,20000 01003595 0,087461 -0.080272 0.000028 0,10000 0,000899 0.042938 -0,041139 0.000001 0,05000 0.000225 0,021258 -0.020808 0,000000 0.02000 0.000037 0.008453 -0.008380 0.000001 0.01000 01000010 0,004224 -0,004204 0.000002 0,00500 0,0000X0 0,002108 -0,002088 0.000006 0.00200 -0,000014 0,000820 -0.000848 -0,000017 0,00100 -0,000014 0,000403 -.0.000431 -O.O00019 0,00050 0,000105 0,000403 -0.000193 0.000115 0,00020 -0,000163 -0.000014 -0.000312 -0,000188 0,00010 -0.000312 --0.000312 --0,000312 -0.000411 0.00005 0.000284 0.001476 -0.00090Zf 0.000681 0.00002 0,000880 0,000880 0.000880 0.000873 0,00001 01000880 0.003860 -0,002100 0,000880 It is poasible to improve on the Spoint formula (1.3b) by rdating f to lattice points fnrther removed from z
=
0.For
example, usingEqs. (1.2), it is easy to show that the U5point" f o d a
caneels dl derivatives in the Taylm series through fourth order. Com-
puting the derivative in this way amumee that f is well-appdmated by a fonrth-degree polynomial over the &point !interval [-21r,2h]. Although
reqniring more computation, this approximation is considerably more ae-
curate, as can be e e n from Tabfe 1.1. In fact, an curacy earnparable
to Eq. (1.3b) is obtained with a step some 10 times larger.
This
eanbe an important eonsideration when many d u e s of f must be stored in the computer, as the greater accnracy dows a sparser tabnlatibn and so saves storage space. However, because (1.5) requires more mathematical operations than does (1.3b) and there is considerable urncellation among
the varions terns (they have both positive and negative coefficients), pre-
cision p m b l ~ m ~ show up at a larger value of he
6 l. Basic Mathematical Ogrzrations
Table f .2 4- and S-pint BiRerence: formulas for de~vativw
priate combinations of Eqs. (1.2). For example, it is easy to see that
so that an appraximation to the second derivative accurate to order h2 is
DiEerence formulm for the various derivative^ of f th& are accurate to a higher order in h can be derived straightforwardly. Table 1.2 is a summary of the 4 &ad 5-pdnt ewressiaas.
Exercise 1.1 Using any function for which you can evduate the
derivatives analytically, investigate the accuracy of the formulas in Ta- ble 1.2 for various vdues af h.
1.2 Numerical quadrature
In quadrature, we are interested in calculating the definite integral of f
between two limits, a
<
b. We can easily arrange for these values to bepoints of the lattice separated by an even number of lattice spacings; i.e.,
is an even integer. It is then sufident for us to derive a formula for the integral from -h to +h, since this formula can be composed many times:
b a+2h a+4h
f (s)
dz
=f
(4
+
f(.)dz+
* * *+
f
(4
62% *The basic idea &hind all of the quadrature formulas we wilI discuss
(technically of the closed Newton-Cotes type) is to approximate f between
-h and +h by a function that can be integrated exactly. For example, the
simplest approximation can be had by considering the intervals [-h, 01 and
[O, h] separately, and assuming that f is linear in each of these intervals (see Figure 1.1). The enor made by this interpolation is of order h2 f
",
so that the approximale iate& is
which is the weU-known trapezoidaf rule.
A better approximation can be had by realizing that the Taylor se- ries (1.1) can provide an improved interpolation of f. Using the difference formulas (1.3b) and (1.7) for f' and f
",
respectively, for 1sput
which can be intepated readily ta give
This is Sinnpsonk rule, wEch em be seen to be accurate to two orders higher than the trapezoidd rule (1.9). Note that the error i s actually
better than would be expected naively from (1.10) since the x3 term
gives no contribution to the integral. Composing this formula according to Eq. (1.8) gives
As an example, the following FORTRAN program calculates
1
e"dz = e
-
I = 1.718282using Simpson's rule for the value of N =
l l h
input. [Source code forthe lmger program like this that are embedded in the text are con- t;ained m tbe Gmplubats'oncrl Phgaics diskette or avdlabIe over Xaterne~,
(see Appendix E); the shorter codes can be easily entered into the reader's computer from the keyboard.]
8 I , Basic Mathematical QpraEdons
C chaplb.rS"or
m C ( X ) =EP(X) ! Sact;ion t o i a % e p a t e
E X A ~ = E ~ ( I . 1-2,
30 PRZRT
*
,
"ETER I EVm ( ,LT, 2 'B3 STIZP) @Rm*, 1
ZP (1 .LT. 2) SmP
IF (NOD(1,2) .HE. 0 ) I=@+$ E=%. /#l
S W = m C ( 0
.
) !contribation from X=OFAC=2 !factor for Siapson% rule
DO 10 X = l , W - I !loop over Xattice paints f F (FAC .Eq, 2.) T H D ?factors altemage
FAG4 ELSE:
FAC=2.
m
IFX=S*LI !X at thfe point
SW=Sm+FAG*mC (X) icontribution t o the fntegsa2
10 COrnICrnE S W = S ~ + ~ C ( 1 , ) ?contribatioa fron X=% XXBfT=Srn*H/3. L ) I ~ = ~ A C * I " - X Z I I T PRIBT 20,I,DIW 20 FO~AT(6X,i#=i,XS,6X,8~WR=\ElEi.Ef) 60TQ 30 !get motker v a u a oQ I EED
Resdts are shown in Table 1.3 for variaus d m s of N , together Prith
the v d w s obtained nsine; the trapezoidd rule. The improvement from
the kigber-order f a m d a i s evident. Note that the resdts are skabltj in
the sense that a wdI-dehed limit is obt~xred as N becomes very lztrge
and ths! mesh spacing h becams @m&; round-aff arms me unimportant because dl vdue8 of f enter irzte, the quadratare formda Pvith the same s i p , in corrtrast to what happens in numerical diRert?ntiation,
An important issue in quadraturn is how s a d an h is necessary to
compute the integral to a Egiwn accuracy, Although it is passible to derive rigorous error bounds for the formulas we have discussed, the simplest thing to do in practice is to run the computation again with a smaller h and ob~erve the chmges in the results.
1
Table 1.3 Errors in evaluating eZdz = 1.718282
W, ~ ~
Trapezoidal Simpson's Bode's N h Eq. (1.9) Eq. (1.12) Eq. (1.13b)
4 0.2500000 -0,008940 --0.000037 -0.00QO01 8 0.1250000 -0,002237 0.000002 0.000000 16 0.0625000 --0.000559 0.000000 0.000000
32 0.0312500 -0.000146 0.000000 0.000000
64 0,0156250 -0.000035 0,000000 0.000000
Higher-order quadrature formulas can be derived by retaining more terms in the Taylor expansion (1.10) used to interpolate f between the mesh points and, of course, using commensurately better finite-difference approximations for the derivatives. The generalizations of Simpson's rule using cubic and quartic polynomials to interpolate (Simpson's
$
and Bode's rule, respectiveb) are:The! results olE applying Bode's rule are &so @ven in Table 1.3, where the improvement is evident, afthough a;t the expense of a more involvt3d computation. (Note that for this method to be applicable, N must be
a multiple of 4.) Although one might think that formulas based on in- terpolation using polynomials of a very high degree would be even m r e suitable, this is not the cme; s;u& p d p o r n i d s tend to osciUate vidently and lead go an inaccurate interpolation, Moreover, the coefFicients of the vailues of f at the vaious lattice paints em have both positive aad neg-
a i v e signs in higher-order farxnulas, maEng rouad-oE error a potentid problem. It is therefore usually safer to improve accuracy by using a low-order method and making h s m d e r rather than by resorting to a higher-order formula. Quadr ature formulas accurate to a very high order cm be derived if we give up the requirement of equdlycspaeed abscissae; these are discussed irr Chapter 4.
m Exercise 1.2 Using any function whose definite i n t e p d you can com- pate anitlytically, investigate the acuracy of the mrious guadrat;ure nreth-
10 d . Ba@ie IkPh&ematieol Operations
ads discussed above far aBerent vdaes of h,
Same care and G on sense must be! exerciwd in the wpfication of the numericat quadrature formulas discussed above.
For
example, anintegral in which the upper limit is very large is best handled by a change
in vaiable. Thus, the Simpsonk s l e e d u a t i o n of
with g(z) constant at large z, would result in a (finite) sum converging very slowly as b becomes large for fixed h (and taking a very long time to compute!). However, changing variables to t = r -l gives
whi& can then be evdualed by any of tlne formulas ure hwe discnssed. Integrable sinmlar4tiies, vvhich caase the naive Ibrmdas "co give non- sense, can dso be hmdled in a simple way. For example,
has an integrable singularity at = 1 (if g is regular there) and is a
finite number. However, since f ( z = 1) = m, the quadrature f o m d a s &scussed above @v@ an infinite result, An accurae result can
bc?
obtainedby changing variables to t = (1
-
z)'i2 t o obtainwhich is then approdmated vvith no trou'ble.
Integrable singularities can also be handled by deriving quadrature formulas especidy adapted to tl~em, Sunpose we me intefested in
where f (2) b e h m s as Cs-'I2 near 5 = O
,
with C a. constan%. The integralfrom h to 1 is regular and can be handled easily, while the integral from
O to h can be approximated as 2ch'I2 = 2h
f
(h).%sing one of the quadraturn formula8 diswssed above and investigate its accuracy for various values of h. (Hint: Split the range of integration into tvm parts and make a agerent dhange of variable h each integral ta
handle the siagufafities.)
1.3
Finding
rootsThe find deznentary operation that is commmly mqnired is to find a
root of a function f that we can compute for arbitrary z. One sure- fire method, when the appraxim;bte location of a root (say at I = %@)
is known, i s to guess a trial value of z guaranteed to be less than the root, and then to inerease this trM d u e by smdl positive steps, backing
up and halving the step size every time f changes sign. The values of x
generated by this procedure evidently converge to $0, so that the search
can be terminated whenever the step size falls helm the mqnired talef-
ance, Thus, the fanowing FORTRAN proe;rano finds the positive root of
the function f (g) = z2
-
5, 50 = = 2.236068, to a. tolerance of 1 0 ~ ~using z = f as an initid guess and m initid step size of 0.5:
C ch&plc.for
FWCCX) =X*X-5, !fmction wkosa root i s sought
TOLX=1,E-OB !toleruce fox %hie sewch
X=%. !inf.lsia guess
FOD=WBC(X) l i n i t f a i l i m c f i o n
DX=
.
fr ? i n i t i d stepITER=@ ! i n i t i a i z s come
10 COaTSME
XmR=SITm+I !increfaen* iteration, corn$
X=X+E)X !step, X
PRIIT *,XTER,X,SQET(&,)-X !ou.lspat cummt values
IF ((FQm+FWC(X)) .LT. 0) TZfEg
X=X-DX ! f f sign change, back up
xlX=DX/Z ! arrd havet the attap EID SF
IF (ABSCDX)
.
GT. TOLX) GOTO 10 STOPEHD
Results far the sequence of z d u e s me shown in Table 1,4, evidently convergiatg to the correct answer, dthough orrly after some 33 iterattions.
One must be careful when using this method, since if the initid step size
Table 2.4 Error in finding the pwitivr: root o f f (z) = z2 -- 5
Iteration Sear& Hewton Secant
Eq. (1.14) Eq. (1.15)
if3 too large, it is possible t a step over the root desimd when f has several. roots,
r Exercise 1-4 &an the code above far vmious t~lermces, irr;itid guesses, and ini.t;id ~ t e p sizeis. Note that sometimes you might find con-
vergence to the negative root. What happens if you start with an initial gGess of -3 with a step ~ i z e olt 6?
A more efficient algorithm, Newton-Raphson, is available if we can
evaltuate the derivative of f
for
ubitrary a. Tfiis method generates a sequence of values, g', eonverljng to zo under the assumption thatf
islocally linear near $0 (see Figure 1.2). That is,
f
(g')l
f '(S') '
The application of this method to finding is also shown in Table 1.4,
where the rapid convergence (5 iterations) is evident. This is the algo- rithm usually used in the computer evaluation of square roots; a lineariza- tion of (1.14) about shows that the number of significant digits doubles tvith ea& itmation, as is evident in Table 1.4.
The secant method provides a happy compromise between the eg
ficiency of Newton-Raphson and the bother of having to evduate the de~vative. If the derivative in Eq. (1.14) is approximated by the differ-
F i v e 1.2 Geometrical bases of tbe Newton-Rrtphm (left) and se- cant (fight) methods.
ence formula related to (1.4b),
we obtain the following 3-term recursion formula giving S'+' in terms of I'and zi-l (see Figure 1.2):
Any two approximate values of $0 can be used for
+@
and s' t o start thealgorithm, which is terminated when the change in z from one iteration to the next is less than the required tolerance. The results of the secmt method for our model problem, starting with values z0 = 0.5 and z' = 1.0, m also s h w a in Table 1.4, Prcrvided that the initid gue8s;aes ase
dose to the true root, convergenm to- the exact answer is dmast as rapid
as that of the Newton-Rapksan dgorithm,
D Exercise 1.5 Write programs to solve for the positive root of sZ
-
5using the Newton-Raphsan a d secant methods. Invwtigate the behavisr
of the latter vvith changes in the initial guesse~ for the rmt.
When the function is badly behaved near its root (e.g., there i s m
inflection point near s o ) or when there are several roots, the "automatic" ME?wt;on-Raphson afld secant methodts can fail to converge at dl m con-
verge to the wrong mswer if the initid guess for the root is poox. Henee, a safe and conservative procedure is to use the seaeh dgorithm to loe&e $0 a p p ~ o ~ m a t e l y and then to uae one of the wtomatic meehods.
14 1. Basic Mathernatiurl Qperatians
Exercise 1.6 The function f ( s ) = tanh z has a root at
+
= 0. Writea p r q r m to show that the Newton-Rqhson method does not co~verge for an iaStid gueshi of z X l. Cm you understand what's going wrong
by considering a graph of tanh I? From the explicit form of (1.14) for this problem, desive the critical value of the initid guess abave which coavergence will not occur, Try to solve the problem using the secant method. m a t happens for vmious initial guesses if you try to find the
z == O mot of tan z usiw either method?
1.4 Semiclassical quantization
of
molecular vibrationsAs an =ample combining several basic mathematicall operations, we con- sider the problem of describing a diatomic molecule such as 02, which wnsists of two nuclei bound together by the electroas that; orbit about
them. Sinm the nnclei are much heavier than the electrons we czm as-
sume that the latter move fat enough to readjust inst;arrtmeously to the changing position of the nudei (Born-Oppenheimer approximation). The problem is therefore reduced to one in which the motion of the two nu-
dei is governed by a potential, V, depending only upon r , the distance between them. The physical principh mspmsibb for generating V will be discussed in detair in Project VIII, but on generd grounds one c m say that the potential is attractive at large distances (van der W d s in-
teraction) and repulsive at short distances (Coulomb interaction of the nuclei and Pauli repulsion of the electrons). A commonly used form for
V embodying these features is the Lennard-Jones or 6-12 potential,
which has the shape shown in the upper portion of Figure 1.3, the mini- mum occurring at rmim = 2'j6a with a depth %. We will assume this form in most of the discussion below. A thorough treatment of the physics of diatomic molecules can be found in [He501 while the Born-Oppenheimer approximation is discussed in [Me68].
The great mass of the nudei allows the problem to be simplified even further by dewupling the slow rotation of the nuclei from the more rapid changes in their separation. The former is well described by the quantum mechanical rotation of a rigid dumbbell, while the vibrational states of relative motion, with energies E,, are described by the bound
Fignre 1.3 (Upper portion) The Leaamd-Janes potentrid and the inner and outer turning point8 kLt, a neg&ive energy. The &;take& tine show8 Ch~f p~rabolic approxhation to the potential, (Lawer parlion) The corresponding trajectory in ghatcie spwe.
state solutions, +%(F), of a one-dimension$ Schroedinger equation,
Here, m i s the r f ~ d ~ ~ e d mws of the two nucfei,
Our ~ a l in. this exampb i s to find tht! enerdes E,, given a par- ticular potential. This can be done wwtly by salving the &Rerentid eigenvdue equation (1.17); numerical methods for doing so will be dis-
cussed in Clrapter 3. Hawever, the great mass of the audei. implies that
their motion i s neafly dasical, so that approdmate values of the vibra- tiond ener@es
cE,
can be obtaliwd by conrjidering the clmsieal motionof the nuclei in V and then applying '"quantization ruks" to d e t e r ~ n e the energies, These quantizatio~ rdes, origindly postulatd by N. Bobr
I6 1. Basic XkialFhematiml Operations
from which the modern formulation of quantum mechanics arose. How- ever, they can also be obtained by considering the WKB appraximation to the wave equation (1.17). (See [Me681 for details.)
Confined dassical motion of the internudear separation in the poten- tial V(7) can occur for energies -Vo
<
E < 0. The distance between the nuclei osdllates periodically (but not necessarily harmonically) between inner and outer turning points, q, and rout, as shown in Figure 1.3. Dur- ing these oscillations, energy is exchanged between the kinetic energy of relative motion and the potential energy such that the total energy,is a constant (p is the relative momentum of the nuclei). We can therefore think of the oscillations at any (jven energy as defining a dosed trajectory in phase space (coordinates r and p) along which Eq. (1.18) is satisfied,
ab; s h m in the lower portion of Figzlre 1.3, An explieit eqnaLim for this
trajectory can be obtained by solving (1.18) for p:
The classid motion desaibed above occurs at any enerw between.
-6
a;nd 0. To qnmtize the motion, and hence obtain approximationsto the eigenvdues E, appearing in (1 .IT), we consider the dimensionless action at a, @ven energy,
where k ( r ) = h-lp(r) is the local de Braglie wave number and the integral is over one complete cyde of oscillation. This action is just the area (in units of h) enclosed by the phase space trajectory. The quantization rules state that, a t the allowed energies E,, the action is a hdf-integral multiple of 2a. Thus, upon using (1.19) and recalling that the oscillation passes through each value of r twice (once with positive p and once with negative
p), we have
where n is a nonnegative integer. At the limits of this integral, the turning points Q, and rout, the integrand vanishes.
To specialize the quantization condition to the Lennard-Jones poten- tial (l.16), we define the dimensionless quantities
so that (1.21) becomes
is the scded potentid.
The quantity 7 is a dimensionless measure of the quantum nature of
the problem. In the dassical limit
(a
small or m large), 7 becomes large.By knowing the moment of inertia of the moleeule (from the energies
of its rotational motion) and the dissociation energy (energy reqnired to separate the molecule into i t s two constituent atoms), it is possible to determine from observation the parameters a and 'Vo and hence the quantity 7. For the
H2
molecule, 7 = 21.7, while for the HD molecule,7 = 24.8 (only m, but not
h,
changes when one of the protona is replaced by a deuteron), and for the much heavier O2 molecule made of two lBOnuclei, 7 = 150. These rather I q e vdues indicate that a s e ~ c l u s i c d appro~xnation is a valid dwcription of the vibratianal motion.
The F O R T U N program for Exmple 1, whose source code is can-
tained in Appendix B asld in the file EXMPLI.FOR, findg, for the d u e
of y input, the values of the E, for which Eq. (1.22) is satisfied. After
all
of the ener@es have been h n d , the corresponding phase pace trajwt*
ries we dram. (Befora attempting to gun this code on yovr camputer
syaern, you should review the m&t3rid on the progrms in ""How to use
this book" and in Appendix A.)
The following exercises are aimed at increasing yovr undemtmding of the physical principles and numerical. methods demonstrawd in this example.
m Exwcise l.'? One of the most important aspects of using ie computer
;as a tool to do pbysics is knovving when to have confidence that the pro-
gram is giving the correct answers. In this regard, an egsential teat ia the
d e t ~ l e d quantitative comparison of results urith what is known in =a-
18 1. Basic Malhematic-al Operations
(in subroutine POT, taking care to heed the instructions given there), for which the Bohr-Sommerfeld quantization gives the exact eigenvdues
of the Schroedinger equation: a series of equdly-spaced energes, with the lowest being one-half of the level spaeing above the minimum of the potentid. Far sever& vdues of 7, compare the numerical resalts .for this case with what you obtain by solving Eq. (1.22) a n e t i c d y . Are the phase spwe trajectosies what you e q e c t ?
B Exercise L8 Another important test of a- working code i s to compare
its results with what is expected on the basis of physical intuition. Re- store the code to use the Lemard-Jones potential and run it for 7 = 50.
Note that, as in the case of the purely pmabolic potentid discussed in the previous exerdse, the first excited state is roughly three times as high above the bottom of the well as is the ground state and that the spacing8 between the few lowest states are rougllly constant. This is because the Lennard-Jones potentid is roughly parabolic about its minimum (see Fig- ure 1.3). By calculating the second derivative of V at the minimum, find the ""spriag conatat" and show that the fi.equency
of
small-amplitude motion is expected ta be:Verify that this is wnslstent with the numerical resuks and explore tbis agreement
for
different values of y. Can you understand why the higher energies are more densely spaced than the lower ones by comparing the Lennard-Jones potential with its parabolic approximation?=
Exwcisos %.Q bvwianceof
results under changes in the numerical algorithms or their parameters can give additional confidence in a calcu- lation. Change the tolerances for the turning point and energy searchesor the number of Simpson's rule points (this 'be done at mn-time by choosing menu option 2) and observe the effects on the results. Note that because of the way in which the expected number of bound states is calculated (see the end of subroutine PARAM) this quantity can change
if the energy toferance is vwied.
B Exareise 1.10 Replace the searches for the inner and outer turning points by the Newton-Raphson method or the secant method. (When
ILEVELZ 0, the turning points for ILEVEL
-
l are excellent starting values.) Replace the Simpson's rule quadratare for s by a higher-order formula [Eqs. (l.13a) or (1.13b)I and observe the improvement.Table 1.5 Experiment& vvibraLional e n e r g i ~ af the E2 molecule
r Exercise 1.1% Plot the E , of the Lennard-Jones potential as functions of 7 for 7 running from 20 to 200 and interpret the results. (As with many
other short calculations, you may find it more efficient simply to run the code and plot the results by hand as you go along, rather than trying to automate the plotting operation.)
Exercise 1. 12 Fbr the Hlz mofecufe, observations show &at the depth
of the potedial is
6
== 4.747 elf and the locationof
the pdentid mini-mum is Tmjn = 0.74166
A.
These two quantities, together with Eq. (1.23),imply a vibrationd frequency of
mare t h m four times lager t h m the experiraentdly absemed energy dif- ference between the ground and first vibrationd state, 0.525 eV. The Zennard-Jones shillpe is therefore not a very good description of the po-
tentid sf the
Hz
molecnk. Another defect is that it predicts 6 h a n d states, while 15 are known to exist. (See Table 1.5, whose entries are derived from the data quoted in [Wa67].) A better andytic form of the potentid, with more parametws, is required to repmduce gimdtaneou6ly the depth and location of the minimum, the frequency of smaU amplitude vibratians about it, and the total number of bound states. One such f o mi~ the Morse potentid,
which &so C= be ~olved analyticrzlly. The Marse potentid has a minimum a;t the expected locat;ian a d the parameter
P
can be a u s t e d to ht the curvature of the miaiI-nurn to the observed excitatioa enerw of the first2Q l. Basic Mathematical Qperatians
Figure X,% Quantitim involved h the krcatte~i~g of a particle by a,
central patentid.
vibrational state. Find the value of
P
appropriate for theHz
molecule, modify the pf~gram above to use the Morm potent;iaI, and cdcdate the spectmm of vibrational statas. Show that st much more reasonable nu=-ber of levels is now obtained. Compare the energies with experiment
and with those of the Lennard-Jones potential and interpret the latter digererrces.
Project
I:
Scattering by a central potentialh this, project, urt; uriU investigate the dassical scattering of a particle of
mms nz by a centrd poteatid, in particula the Lennad-$ones potentid c0nsiderci.d in Section 1.4 above,
h
a scattePing event, the partide, with. initial kinetic t?nergy E z~nd impact parameter b, approaches the potential from a large distance, It is deflected during its pasage n e ae h
force center and eveatudy emergee with the same enera, but moving at an.angle
O
with respect to its original direction. Since the potentid depends'
upon an& the distance of the partide fronn the force center, the aagular momentum is conserved and the trajedory Lies in a plane. Thcr pdarcoordinates of the partide, (P,@), are a convenient way to describe its
motion, as shown in Figure 1.1. (For details, see any textbook on dasdcal
mechanics, such M [Go80].)
Of basic interest is the deflection function, O(b), giving the final
scattering angle, 0, as a function of the impact parameter; this function
also depends upon the inddent energy. The differential cross section for
related to the defiection function by
Thus, if d O l d b = (dbldO)-l can be computed, then the cross section is
known..
Expressions for the deflection function c m be found analytically for only a very few potentials, so that numerical methods usually must be
employed. One way to solve the problem would be t o integfate the equa- tions of motion in time (i.e., Newton's law relating the acceleration t o the force) to find the trajectories corresponding to various impact parameters and then t o tabulate the final directions of the motion (scattering angles).
Tbis would involve integrating four coupled first-order differential e q u a tions Eos two coordinates and t h i r velocities in the scattering plane, discussed in Section 2.5 bebw. However, since a n p l a r rxramerrtum is con- served, the evdution of B is related dire6tly to the radial motion, and the probhrn can be reduced t o a one-dimensiond one, wEch can be s d v d by quadratare. This fatter approach, which i s simpler and more accurate, is the one we will, pursae here.
To d e ~ v e an clbppropriaGe expression for 8 , we begin vvjth the conser- vation of arrgular momentum, which implie8 &hat
is a constant o-f the motion. Here, dB/& is the augtrlas velocity and v is the asymptotic velocity, related t o the bombarding energy by E = i m v 2 .
The radid motion owurs in an eRective potentid th& is the sum of V and the centrifugal potential, so that energy conservation implies
If we use F as the independent variable in (1.21, rather than the time, we can write
22 2 . Basic Mathematical Ofterations
Recalling that 0 = n when r = oo on the incoming branch of the tra- jectory and that B is always decreasing, this equation can be integrated immediately to give the scattering ande,
where r,i. is the distance of closest approach (the turning point, deter- mined by the outermost zero of the argument of the square root) and the factor of 2 in front of the integral accounts for the incoming and out- going branches of the trajectory, which give equal contributions to the scatterixlg angle.
One find transformation is useful before beginning a numerical cal- culation. Suppose th& there exist8 a distmce rr,,, beyond which vve can safely nedect V. In this case, the integrand in (1.6) m i s h e s as T - ~ for
large r , so that numericd quadrature could be very ineRcient. In fact,
since the p o t e ~ t i d hap aa eEect for r
>
rm,,,
we would just be "wasting time" "describing stra;igJRt-line nrotisn, To hanae this situation &cientXy, note that since 63 = O when V = 0, Eq. (1.6) implies thatwhich, when substituted into (I.6), results in
The integrals here extend only to rm,, since the integands becme equd when T
>
Our goal will be to study scattering by the Lennard-Jones poten- tial (1.16), which we can s a f e set to zero beyond P,,, = 3a if we are
not interested in e n e e e s smaller than about
The study is best done in the hlloMring sequence of steps:
Step 1 Before beginning any numerical computation, it is important to have some idea of what the results should look Like. Sketch what you think the deflection function is at relatively low energies, E 6 where the peripheral collisions at large b
5
,,,F will take place in a predominantlyat tractive potential and the more central collisions will LLbounce" against the repulsive core. What happens at much higher energies, E
>
Vo, where1. Scattering by( a cent& potential 23
the attractive pocket in V can be neglected? Note that for values of b
where the deflection function has a maximum or a minimum, Eq. (1.1) shows that the cross section will be infinite, as occurs in the r&nbow formed when light scatters from water drops.
Step 2 To have analytically soluble cases against which to test your program, calculate the deflection function for a square potential, where
V ( r ) = U. for r
<
Fmax and vanishes for r>
r,,,. What happens whenU. is negative? What happens when U. is positive and E < Uo? when
E
>
U@?
Step 3 Write a program that calculates, for a specified energy E, the deflection function by a numerical quadrature to evaluate both integrals in Eq. (1.8) at a number of equally spaced b values between O and F,,.
(Note that the singularities in the integrands require some special treat- ment .) Check that the program is working properly and is accurate by
cafculating deflection functions for the square-well potentid discussed in Step 2. Campwe the accuracy with that of asl dterndive procedure in
which the first intepal in (1.8) is evdaated andytiea;lly5 rather than m-
meri cdy.
Step 4 Use your propam to cdc.ulilLee the degection function far scat- tering from the Lennard-Jones potential at selected values of E ranging from 0.1 to 1 0 0 h . Reconcile your answrs in Step I with the result8 you obtGn. Calcu1;at;e the diflerentid cross section as a function of @ at these energies.
Step 5 E your progrm is working comectly, ycru &odd observe, for
ener@w E
K t
a siqulmity in the deflection function whese O appeaasto apprawh -m at some critical vdue of b,
brit,
that depends on E. This singularity, which disappears when E becomes larger than aboutV@, is characteristic of Uorbiting." In this phenomenon, the integrmd in
Eq. (1.6) has a linear, rather than a square root, singularity at the turning poiat, 80 thitt the scattering aggle becomes logiurithrnically iagnite. That
is, the eEective pohential,
has a parabolic maximum and, when 6 = bcrit, the peak of this parabola is equal to the incident energy. The trajectory thus spends a very long time at the radius where this parabola peaks and the particle spirals many times around the force center. By tracing bcrit as a function of energy
24 1. Basic Mathematical Operations
and by plotting a few of the effective potential8 involved, convince yourself that this is indeyed what's happening. Determine the x n ~ m u a n e n e r ~ far
vvbich the Lennard-Jones potenkid exhibits orbiting, either by a d u t i o n of an agprcfpriate set of equatons invalviag Y and its derivatiw~ ar by
a systematic numerical investiwtion of the deflection function. If you pufsue the latter approach, ysu Iulight have to reemider the treatment
Chapter 2
Ordinary
Differentia
Equations
Many of the laws of physics are most conveniently formulated in terms of differential equations. It is therefore not surprising that the nurnericd sdution af differentid equations is one of the mast common tasks in modeling physicd systems. The most general form of an ordinary differentid equation is a set of M coupled first-order equations
where is the independent variablt? and y is a set of M dependent vari- ables (f is thus an M-component vector). Differentid equations of higher order can be written in this first-order form by introducing auxiliary func- tions. For example, the one-dimensional motion of a partide of mws m
under a force field F ( z ) is described by the second-order equation
If we define the morne~rtum
then (2.2) becomes the two coupled first-order (Hamilton's) equations
0% P
~~~
.
*
= F ( z ),
dt nz "dt
which are in the h r m of (22). It is therefore suficient ta ccznsjdes in detGl anly nnetlrods for firs t-order equations, Since the matrix structure