27.12.2012 Views

Wave Propagation in Linear Media | re-examined

Wave Propagation in Linear Media | re-examined

Wave Propagation in Linear Media | re-examined

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

7 Mathematica implementation of a quadratu<strong>re</strong> function<br />

Work<strong>in</strong>gP<strong>re</strong>cision is the standard option to set the p<strong>re</strong>cision of the <strong>in</strong>ternal calculations,<br />

with $Mach<strong>in</strong>eP<strong>re</strong>cision as default value. Normally it may be set by the user<br />

to any arbitrary value (between the bounds $M<strong>in</strong>P<strong>re</strong>cision and $MaxP<strong>re</strong>cision, of<br />

course). If accuracy or p<strong>re</strong>cision control a<strong>re</strong> used, then its t<strong>re</strong>atment is slightly diffe<strong>re</strong>nt,<br />

because these functions need high-p<strong>re</strong>cision arithmetic which <strong>in</strong> turn <strong>re</strong>qui<strong>re</strong>s a<br />

work<strong>in</strong>g p<strong>re</strong>cision that is higher than the mach<strong>in</strong>e p<strong>re</strong>cision. Thus Work<strong>in</strong>gP<strong>re</strong>cision<br />

is set to the maximum of $Mach<strong>in</strong>eP<strong>re</strong>cision plus one digit, the p<strong>re</strong>cision probably<br />

speci ed by the user, and the value of P<strong>re</strong>cisionControl plus 13 digits | provided<br />

that p<strong>re</strong>cision control is used at all. The value of AccuracyControl cannot be used to<br />

set the work<strong>in</strong>g p<strong>re</strong>cision s<strong>in</strong>ce this would <strong>re</strong>qui<strong>re</strong> one to know the order of magnitude<br />

of the <strong>in</strong>tegral befo<strong>re</strong>hand.<br />

FunctionType 2 fS<strong>in</strong>Argument, CosArgument, ZeroListg selects how the function<br />

fzero is to be <strong>in</strong>terp<strong>re</strong>ted. ZeroList means that the function <strong>re</strong>turns consecutive<br />

partition po<strong>in</strong>ts. The other possibilities specify the circular function whose zeros a<strong>re</strong><br />

computed for the use as subdivision po<strong>in</strong>ts. For S<strong>in</strong>Argument, which is also the default<br />

value, the equation (x) = k is solved, for CosArgument, it is the equation<br />

(x) = k + =2. If the oscillat<strong>in</strong>g factor u( ) is a pu<strong>re</strong> circular function, then this<br />

option additionally allows one to choose the ext<strong>re</strong>ma rather than the zeros as partition<br />

po<strong>in</strong>ts.<br />

The default options of OscInt cause the function to run at mach<strong>in</strong>e p<strong>re</strong>cision and with the<br />

control loop for the p<strong>re</strong>cision of the <strong>re</strong>sult disabled. The second argument is <strong>in</strong> this case<br />

<strong>re</strong>garded as the argument (x) of the oscillation. These default sett<strong>in</strong>gs make up the fastest<br />

and most user-friendly con guration.<br />

7.2 Structu<strong>re</strong> of the package<br />

The function OscInt is actually noth<strong>in</strong>g but a driver that calls other functions depend<strong>in</strong>g on<br />

the sett<strong>in</strong>gs of various options. Fig. 7.1 shows the <strong>re</strong>spective functions and their dependencies.<br />

The most important dist<strong>in</strong>ction <strong>in</strong>side the package is that between the use of error control<br />

for the extrapolation and the pla<strong>in</strong> computation of the <strong>in</strong>tegral without any feedback loop.<br />

Depend<strong>in</strong>g on this decision, OscInt <strong>in</strong>vokes the follow<strong>in</strong>g functions:<br />

PartitionTable computes a list of subdivision po<strong>in</strong>ts with a given length, start<strong>in</strong>g at<br />

a suitable po<strong>in</strong>t above the lower <strong>in</strong>tegration limit. In fact it only calls the functions<br />

PartitionOffs and PartitionPo<strong>in</strong>ts with a <strong>re</strong>duced set of <strong>in</strong>put parameters.<br />

PartInt takes as <strong>in</strong>put a set of subdivision po<strong>in</strong>ts and computes the <strong>in</strong>tegral by extrapolation.<br />

Like PartitionTable, itis used only for straightforward quadratu<strong>re</strong> without<br />

error control.<br />

OscIntControlled is the version of OscInt used with error control. It comprises a<br />

control loop that monitors the p<strong>re</strong>cision of the extrapolation <strong>re</strong>sult and <strong>in</strong>c<strong>re</strong>ases the<br />

length of the sequence of partial sums if needed.<br />

164

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!