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.

7.3.1 OscInt<br />

ApproxLimGeneric<br />

AsymptoticExpand<br />

PolynomialDeg<strong>re</strong>e<br />

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

Approximation error control Zero computation<br />

ApproxLimQuad<br />

ApproxLimHyp<br />

QuadOffset<br />

QuadZero<br />

HypOffset<br />

HypZero<br />

Figu<strong>re</strong> 7.2: The auxiliary functions of OscInt<br />

HypOffsetExact<br />

HypZeroExact<br />

S<strong>in</strong>ce the<strong>re</strong> a<strong>re</strong> two di e<strong>re</strong>nt list of arguments that can be passed to OscInt (see also section<br />

7.1), we must specify two di e<strong>re</strong>nt rules that match these possibilities. The mo<strong>re</strong> general set<br />

of arguments is the one whe<strong>re</strong> the rst partition po<strong>in</strong>t is p<strong>re</strong>set by the user. The case whe<strong>re</strong><br />

only the lower <strong>in</strong>tegration limit is given can be easily extended to the general rule by sett<strong>in</strong>g<br />

a0 = a. The<strong>re</strong>fo<strong>re</strong> only the body of the general rule needs to conta<strong>in</strong> the enti<strong>re</strong> code, whe<strong>re</strong>as<br />

the body of the mo<strong>re</strong> special case simply calls OscInt aga<strong>in</strong> with the proper parameters,<br />

which is generally conside<strong>re</strong>d good programm<strong>in</strong>g style.<br />

OscInt[f<strong>in</strong>t_, fzero_, fa_, a0_g, opts___Rule] :=<br />

Module[fparttab,lowlim,p<strong>re</strong>c,<br />

wp = Work<strong>in</strong>gP<strong>re</strong>cision/.foptsg/.Options[OscInt],<br />

nt = NSumTerms/. foptsg/.Options[OscInt],<br />

ne = NSumExtraTerms/. foptsg/.Options[OscInt],<br />

ac = AccuracyControl/. foptsg/.Options[OscInt],<br />

pc = P<strong>re</strong>cisionControl/.foptsg/.Options[OscInt]g,<br />

If[ac === Inf<strong>in</strong>ity && pc === Inf<strong>in</strong>ity,<br />

lowlim = If[a == a0, a, N[Max[a,a0],2 wp]];<br />

parttab = PartitionTable[fzero,lowlim,ne+nt+1,opts];<br />

PartInt[f<strong>in</strong>t,parttab,a,opts],<br />

p<strong>re</strong>c = If[pc === Inf<strong>in</strong>ity,<br />

Max[wp,$Mach<strong>in</strong>eP<strong>re</strong>cision+1],<br />

Max[wp,$Mach<strong>in</strong>eP<strong>re</strong>cision+1,pc+13]];<br />

OscIntControlled[f<strong>in</strong>t,fzero,a,Work<strong>in</strong>gP<strong>re</strong>cision->p<strong>re</strong>c,opts]]<br />

];<br />

OscInt[f<strong>in</strong>t_, fzero_, a_, opts___Rule] :=<br />

OscInt[f<strong>in</strong>t,fzero,fa,ag,opts];<br />

Remark (Multiple de nitions) Note that the order of the two de nitions with<strong>in</strong> the<br />

package is essential, because Mathematica searches the list from the top to the bottom<br />

166

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

Saved successfully!

Ooh no, something went wrong!