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.4 Auxiliary functions<br />

While[iterations < it && Accuracy[<strong>in</strong>tlim] < ac && P<strong>re</strong>cision[<strong>in</strong>tlim] < pc,<br />

parttab = Jo<strong>in</strong>[Last[parttab],<br />

PartitionPo<strong>in</strong>ts[fzero,a,il,offs,ne+nt+1,opts]];<br />

seqtab = Jo<strong>in</strong>[seqtab,<br />

Table[NIntegrate[f[x],x,parttab[[i]],parttab[[i+1]],<br />

Method->GaussKronrod],<br />

i,1,Length[parttab]-1]];<br />

ne = ne + il;<br />

iterations++;<br />

<strong>in</strong>tlim = SequenceLimit[Take[FoldList[Plus,firstval,seqtab],<br />

-ne],WynnDeg<strong>re</strong>e->wd]<br />

];<br />

Example 7.3.2 We want to compute R 1<br />

s<strong>in</strong> x<br />

x<br />

dx to the p<strong>re</strong>cision of 10 signi cant digits. Note that<br />

0<br />

the <strong>in</strong>tegrand as well as the argument a<strong>re</strong> given as pu<strong>re</strong> functions. If we choose the work<strong>in</strong>g p<strong>re</strong>cision<br />

too low, we hit the iteration limit.<br />

In[5]:= OscIntControlled[S<strong>in</strong>[#]/#&,#&,0,<br />

Work<strong>in</strong>gP<strong>re</strong>cision->17,P<strong>re</strong>cisionControl->10]<br />

OscInt::accfail:<br />

OscInt failed to achieve the desi<strong>re</strong>d accuracy or p<strong>re</strong>cision after 6<br />

iterations. Inc<strong>re</strong>ase MaxIterations or Work<strong>in</strong>gP<strong>re</strong>cision (cur<strong>re</strong>ntly 17).<br />

Out[5]= 1.570798<br />

If we <strong>in</strong>c<strong>re</strong>ase the work<strong>in</strong>g p<strong>re</strong>cision, we obta<strong>in</strong> the desi<strong>re</strong>d <strong>re</strong>sult.<br />

In[6]:= OscIntControlled[S<strong>in</strong>[#]/#&,#&,0,<br />

Work<strong>in</strong>gP<strong>re</strong>cision->20,P<strong>re</strong>cisionControl->10]<br />

Out[6]= 1.570796327<br />

7.4 Auxiliary functions<br />

In addition to the functions that a<strong>re</strong> needed for pu<strong>re</strong> quadratu<strong>re</strong>, a number of support<strong>in</strong>g<br />

rout<strong>in</strong>es have been added to the package. These functions facilitate the use of the quadratu<strong>re</strong><br />

programs <strong>in</strong> that they provide <strong>in</strong>formation <strong>re</strong>qui<strong>re</strong>d by the quadratu<strong>re</strong> algorithm.<br />

A set of such functions <strong>re</strong>turns the zeros fx0;x1;x2;:::g of s<strong>in</strong> f(x) for quadratic and hyperbolic<br />

arguments f(x). In order to be suitable as partition po<strong>in</strong>ts for the quadratu<strong>re</strong>, they<br />

a<strong>re</strong> de ned such that the rst zero x0 always lies to the right of the ext<strong>re</strong>mum of f(x). It is<br />

thus necessary to nd solutions for the equation f(x) =(k+o) , whe<strong>re</strong> k 0 and the o set<br />

o = f(xe)= is chosen so that f(x) is monotonic for x>xe.<br />

173

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

Saved successfully!

Ooh no, something went wrong!