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.

];<br />

AccuracyGoal->ag,<br />

MaxIterations->ma],<br />

{k,i<strong>re</strong>l,i<strong>re</strong>l+n-1}]]<br />

],<br />

True,<br />

Message[PartitionTable::badparam,ft]]<br />

OscIntControlled[f_, fzero_, a_, opts___Rule] :=<br />

Module[{seqtab,parttab,iterations=1,offs,firstval,<strong>in</strong>tlim,<br />

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

ag = AccuracyGoal/. {opts}/.Options[OscInt],<br />

pg = P<strong>re</strong>cisionGoal/. {opts}/.Options[OscInt],<br />

mi = M<strong>in</strong>Recursion/. {opts}/.Options[OscInt],<br />

ma = MaxRecursion/. {opts}/.Options[OscInt],<br />

nt = NSumTerms/. {opts}/.Options[OscInt],<br />

ne = NSumExtraTerms/. {opts}/.Options[OscInt],<br />

wd = WynnDeg<strong>re</strong>e/. {opts}/.Options[OscInt],<br />

it = MaxIterations/. {opts}/.Options[OscInt],<br />

ac = AccuracyControl/. {opts}/.Options[OscInt],<br />

il = IterationLength/. {opts}/.Options[OscInt]},<br />

offs = PartitionOffs[zerof,a,opts];<br />

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

If[N[parttab[[1]]] < a,<br />

parttab = Select[parttab,(N[#] >= a)&];<br />

Message[OscInt::lowfirst,Length[parttab]]];<br />

firstval = If[N[parttab[[1]]] == N[a], 0,<br />

NIntegrate[f[x],{x,a,parttab[[1]]},<br />

Method->DoubleExponential,<br />

Work<strong>in</strong>gP<strong>re</strong>cision->wp,<br />

AccuracyGoal->ag,<br />

P<strong>re</strong>cisionGoal->pg,<br />

M<strong>in</strong>Recursion->mi,<br />

MaxRecursion->ma]];<br />

If[N[parttab[[1]]] =!= Inf<strong>in</strong>ity,<br />

seqtab = Table[NIntegrate[f[x],{x,parttab[[i]],parttab[[i+1]]},<br />

Method->GaussKronrod,<br />

Work<strong>in</strong>gP<strong>re</strong>cision->wp,<br />

AccuracyGoal->ag,<br />

P<strong>re</strong>cisionGoal->pg,<br />

M<strong>in</strong>Recursion->mi,<br />

MaxRecursion->ma],<br />

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

Which[N[parttab[[1]]] == Inf<strong>in</strong>ity,<br />

firstval,<br />

ac === False,<br />

SequenceLimit[Take[FoldList[Plus,firstval,seqtab],<br />

{nt+1,nt+ne}],WynnDeg<strong>re</strong>e->wd],<br />

IntegerQ[ac],<br />

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

{nt+1,nt+ne}],WynnDeg<strong>re</strong>e->wd];<br />

While[iterations < it && Accuracy[<strong>in</strong>tlim] < ac,<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 />

Work<strong>in</strong>gP<strong>re</strong>cision->wp,<br />

AccuracyGoal->ag,<br />

P<strong>re</strong>cisionGoal->pg,<br />

M<strong>in</strong>Recursion->mi,<br />

MaxRecursion->ma],<br />

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

ne = ne + il;<br />

iterations++;<br />

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

{nt+1,nt+ne}],WynnDeg<strong>re</strong>e->wd]<br />

];<br />

If[Accuracy[<strong>in</strong>tlim] < ac, Message[OscInt::accfail,iterations]];<br />

<strong>in</strong>tlim,<br />

True,<br />

Message[OscInt::badparam,ac]]<br />

];<br />

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

Module[{parttab,lowlim,<br />

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

nt = NSumTerms/. {opts}/.Options[OscInt],<br />

ne = NSumExtraTerms/. {opts}/.Options[OscInt]},<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 />

];<br />

220<br />

A Mathematica packages

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

Saved successfully!

Ooh no, something went wrong!