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.

6Towards a quadratu<strong>re</strong> rout<strong>in</strong>e<br />

Example 6.3.1 The function P<strong>re</strong>cision <strong>re</strong>turns the number of digits a oat<strong>in</strong>g-po<strong>in</strong>t number<br />

posesses. For exact numbers, such as <strong>in</strong>tegers or fractions of <strong>in</strong>tegers, it <strong>re</strong>turns Inf<strong>in</strong>ity. For<br />

ord<strong>in</strong>ary mach<strong>in</strong>e p<strong>re</strong>cision numbers, the <strong>re</strong>sult is $Mach<strong>in</strong>eP<strong>re</strong>cision, even if the number has less<br />

digits [146].<br />

In[12]:= P<strong>re</strong>cision[1234.5678901234567890]<br />

Out[12]= 19<br />

In[13]:= P<strong>re</strong>cision[1234.56]<br />

Out[13]= 16<br />

The function Accuracy, on the other hand, <strong>re</strong>fers to the digits to the right of the decimal po<strong>in</strong>t. Like<br />

befo<strong>re</strong>, it <strong>re</strong>turns Inf<strong>in</strong>ity if the number is exact, and assumes mach<strong>in</strong>e p<strong>re</strong>cision numbers if the<br />

argument has less than | <strong>in</strong> our case | 16 digits.<br />

In[14]:= Accuracy[1234.5678901234567890]<br />

Out[14]= 16<br />

In[15]:= Accuracy[1234.56]<br />

Out[15]= 13<br />

In fact, both functions signify the error bounds of a oat<strong>in</strong>g-po<strong>in</strong>t number <strong>in</strong> Mathematica. The<br />

accuracy of a number x then is the absolute error bound log j j while the p<strong>re</strong>cision means the<br />

<strong>re</strong>lative error bound log jx= j [144]. The maximum error clearly depends on the work<strong>in</strong>g p<strong>re</strong>cision.<br />

Both values a<strong>re</strong> rounded to the nea<strong>re</strong>st <strong>in</strong>teger and thus look like numbers of signi cant digits although<br />

they can be <strong>in</strong>cor<strong>re</strong>ct by one digit due to the round<strong>in</strong>g.<br />

All other parameters of NIntegrate a<strong>re</strong> not of primary importance for our purpose he<strong>re</strong> and<br />

will be expla<strong>in</strong>ed as needed <strong>in</strong> the follow<strong>in</strong>g chapters.<br />

We will now explo<strong>re</strong> the two di e<strong>re</strong>nt quadratu<strong>re</strong> algorithms as they a<strong>re</strong> applied to the rst<br />

partial <strong>in</strong>tegral over the <strong>in</strong>terval [a; x0] between the left <strong>in</strong>tegration limit and the rst partition<br />

po<strong>in</strong>t. Let us <strong>re</strong>turn to the example (6.8) of the p<strong>re</strong>vious section. If we set xm = 40, we obta<strong>in</strong><br />

an <strong>in</strong>dex o set for the step <strong>in</strong> the sequence of partial sums o = 509 such that we select our rst<br />

partition po<strong>in</strong>t to be the 510-th zero. We then want to know how long it takes to compute<br />

this <strong>in</strong>tegral <strong>in</strong> one.<br />

In[16]:= Tim<strong>in</strong>g[<br />

NIntegrate[f[x],fx,zero[0],zero[510]g,MaxRecursion->10,<br />

Method->GaussKronrod]<br />

]<br />

142

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

Saved successfully!

Ooh no, something went wrong!