Wave Propagation in Linear Media | re-examined
Wave Propagation in Linear Media | re-examined
Wave Propagation in Linear Media | re-examined
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
6.3 How to compute the rst <strong>in</strong>tegral<br />
GaussKronrod DoubleExponential Trapezoidal<br />
xm =40<br />
R z510<br />
0 f(x)dx 103.81 20.59 2968.07<br />
P 509<br />
k=0<br />
R z6<br />
0<br />
xm =4<br />
P 5<br />
k=0<br />
R zk+1<br />
z k<br />
f(x)dx 20.05 169.56 3119.32<br />
f(x)dx 0.61 0.82 47.78<br />
R zk+1<br />
z k<br />
f(x)dx 0.38 1.59 36.63<br />
Table 6.1: Comput<strong>in</strong>g times <strong>in</strong> seconds for di e<strong>re</strong>nt quadratu<strong>re</strong> algorithms.<br />
Out[16]= f103.81 Second, 0.0491901g<br />
Remark (Recursion depth) The function Tim<strong>in</strong>g <strong>re</strong>turns the evaluation time as well<br />
as the <strong>re</strong>sult. Note that because the <strong>in</strong>tegration <strong>in</strong>terval spans many zeros of f(x), we<br />
must <strong>in</strong>c<strong>re</strong>ase the maximum number of <strong>re</strong>cursive subdivisions Mathematica tries. The<br />
accord<strong>in</strong>g option is MaxRecursion. Otherwise the evaluation would term<strong>in</strong>ate with an<br />
error message and most likely a wrong <strong>re</strong>sult.<br />
Another possibility istosubdivide the <strong>in</strong>tegration range at the zeros of the <strong>in</strong>tegrand | as<br />
we would do for the <strong>in</strong>terval to the right of the rst partition po<strong>in</strong>t | and to compute the<br />
sum of these partial <strong>in</strong>tegrals. The computation is now much faster because the <strong>in</strong>dividual<br />
<strong>in</strong>tegrals a<strong>re</strong> smooth and we thus bene t from the simplicity of the Gauss-Kronrod formula.<br />
In[17]:= Tim<strong>in</strong>g[<br />
Sum[NIntegrate[f[x],fx,zero[i],zero[i+1]g,<br />
Method->GaussKronrod],fi,0,509g]<br />
]<br />
Out[17]= f20.05 Second, 0.0491901g<br />
We can carry out the same computations for the double exponential quadratu<strong>re</strong> formula and<br />
for a di e<strong>re</strong>nt value of xm = 4, which yields o = 5. The various <strong>re</strong>sults a<strong>re</strong> summarised <strong>in</strong><br />
tab. 6.1 . We <strong>re</strong>cognise rst of all that the trapezoidal rule <strong>in</strong>deed has a poor performance.<br />
The double exponential algorithm seems to be a suitable choice, even if the transformation of<br />
the <strong>in</strong>tegration variable takes some time, which slows down the computation <strong>in</strong> comparison<br />
to the Gauss-Kronrod method if the<strong>re</strong> a<strong>re</strong> only few zeros <strong>in</strong> the <strong>in</strong>tegration <strong>in</strong>terval. The<br />
DE rule, on the other hand, needs no evaluation of any zeros, which can be a signi cant<br />
advantage if the zeros cannot be found explicitly. In such a case, a subdivision strategy us<strong>in</strong>g<br />
Gauss-Kronrod quadratu<strong>re</strong> would be <strong>in</strong>ferior as well. To demonstrate this, we assume that<br />
we have no <strong>in</strong>formation about the zeros of the <strong>in</strong>tegrand <strong>in</strong> (6.8). Instead, we use equidistant<br />
po<strong>in</strong>ts to partition the <strong>in</strong>terval and determ<strong>in</strong>e the total comput<strong>in</strong>g time depend<strong>in</strong>g on the<br />
number of sub<strong>in</strong>tervals (aga<strong>in</strong> with xm = 40).<br />
143