Mathematical Methods for Physics and Engineering : A Comprehensive Guide

(lu) #1

27.4 NUMERICAL INTEGRATION


It will be seen that, by replacing eachnmin the summation byf(x, y, z)nm,

this procedure could be extended to estimate the integral of the functionfover


the volume of the solid. The method has special valueiffis too complicated to


have analytic integrals with respect tox, yandzor if the limits of any of these


integrals are determined by anything other than the simplest combinations of the


other variables. If large values offare known to be concentrated in particular


regions of the integration volume, then some form of stratified sampling should


be used.


It will be apparent that this general method can be extended to integrals

of general functions, bounded but not necessarily continuous, over volumes with


complicated bounding surfaces and, if appropriate, in more than three dimensions.


Random number generation

Earlier in this subsection we showed how to evaluate integrals using sequences of


numbers that we took to be distributed uniformly on the interval 0≤ξ<1. In


reality the sequence of numbers is not truly random, since each is generated in


a mechanistic way from its predecessor and eventually the sequence will repeat


itself. However, the cycle is so long that in practice this is unlikely to be a problem,


and the reproducibility of the sequence can even be turned to advantage when


checking the accuracy of the rest of a calculational program. Much research has


gone into the best ways to produce such ‘pseudo-random’ sequences of numbers.


We do not have space to pursue them here and will limit ourselves to one recipe


that works well in practice.


Given any particular starting (integer) valuex 0 , the following algorithm will

generate a full cycle ofmvalues forξi, uniformly distributed on 0≤ξi<1,


before repeats appear:


xi=axi− 1 +c (modm); ξi=

xi
m

.

Herecis an odd integer andahas the forma=4k+ 1, withkan integer. For


practical reasons, in computers and calculatorsmis taken as a (fairly high) power


of 2, typically the 32nd power.


The uniform distribution can be used to generate random numbersydistributed

according to a more general probability distributionf(y) on the rangea≤y≤b


if the inverse of the indefinite integral offcan be found, either analytically or by


means of a look-up table. In other words, if


F(y)=

∫y

a

f(t)dt,

for whichF(a)=0andF(b)=1,thenF(y) is uniformly distributed on (0,1).


This approach is not limited to finiteaandb;acould be−∞andbcould be∞.


The procedure is thus to select a random numberξfrom a uniform distribution
Free download pdf