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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

100<br />

90<br />

80<br />

70<br />

60<br />

50<br />

40<br />

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

200 400 600 800 1000 1200 1400<br />

Figu<strong>re</strong> 6.2: Comput<strong>in</strong>g time for a Gauss-Kronrod rule depend<strong>in</strong>g on the number of sub<strong>in</strong>tervals for<br />

the <strong>in</strong>tegrand <strong>in</strong> (6.8) with xm = 40.<br />

In[18]:= timtab = Table[fsteps,First[<br />

Tim<strong>in</strong>g[<br />

m<strong>in</strong> = zero[0];<br />

max = zero[510];<br />

Sum[NIntegrate[f[x],fx,m<strong>in</strong> + i (max-m<strong>in</strong>)/steps,<br />

m<strong>in</strong> + (i+1) (max-m<strong>in</strong>)/stepsg,<br />

Method->GaussKronrod,MaxRecursion->15],<br />

fi,0,steps-1g]<br />

]<br />

]/Secondg,fsteps,1,1401,10g];<br />

Remark (Implementation) To speed up the computation, we evaluate the <strong>in</strong>terval<br />

bounds only once and save them as constants. The list is made up of the number of<br />

<strong>in</strong>tervals and the comput<strong>in</strong>g time for each trial, which is obta<strong>in</strong>ed by tak<strong>in</strong>g the rst<br />

element of the list <strong>re</strong>turned by the function Tim<strong>in</strong>g. To be able to plot this list, we<br />

must rst divide each evaluation time by the constant Second. The actual <strong>re</strong>sults of the<br />

<strong>in</strong>dividual computations a<strong>re</strong> not sto<strong>re</strong>d separately as they a<strong>re</strong> all cor<strong>re</strong>ct.<br />

The <strong>re</strong>sults <strong>in</strong> g. 6.2 show that with only a few subdivisions, the overall comput<strong>in</strong>g time<br />

can be dramatically dec<strong>re</strong>ased. The m<strong>in</strong>imum, however, is still above 30 seconds, which is<br />

signi cantly higher than the values <strong>in</strong> tab. 6.1 . The equidistant partition is also the <strong>re</strong>ason<br />

why it takes about 800 sub<strong>in</strong>tervals to achieve the m<strong>in</strong>imum although the<strong>re</strong> a<strong>re</strong> only 510<br />

zeros <strong>in</strong> the <strong>in</strong>tegration range. The l<strong>in</strong>ear slope beyond the m<strong>in</strong>imum stems from the time-<br />

144

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

Saved successfully!

Ooh no, something went wrong!