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.

A.1 Numerical quadratu<strong>re</strong><br />

Which[ft === ZeroList,<br />

If[N[zerof[0]] < N[a],<br />

ofs = Ceil<strong>in</strong>g[x/.F<strong>in</strong>dRoot[zerof[x] == a,{x,0,1},<br />

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

AccuracyGoal->ag,<br />

MaxIterations->ma]]];<br />

Table[zerof[x],{x,ofs,ofs+n-1}],<br />

ft === S<strong>in</strong>Argument || ft === CosArgument,<br />

If[ft === CosArgument, cfoffs=1/2];<br />

ext<strong>re</strong>ma = Select[NSolve[zerof'[x] == 0,x,Work<strong>in</strong>gP<strong>re</strong>cision->wp],<br />

(Im[x/.#] == 0)&];<br />

xoffs = If[Length[ext<strong>re</strong>ma] == 0, a,<br />

Max[x/.Last[ext<strong>re</strong>ma],a]];<br />

Which[NumberQ[Limit[zerof[x],x->Inf<strong>in</strong>ity]],<br />

Table[Inf<strong>in</strong>ity,{k,0,n-1}],<br />

N[zerof'[xoffs+1]] > 0,<br />

koffs = N[Ceil<strong>in</strong>g[zerof[xoffs]/Pi],2 wp];<br />

Re[Table[x/.F<strong>in</strong>dRoot[zerof[x] == (k+koffs+cfoffs) Pi,<br />

{x,xoffs,xoffs+1},<br />

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

AccuracyGoal->ag,<br />

MaxIterations->ma],<br />

{k,0,n-1}]],<br />

True,<br />

koffs = N[Floor[zerof[xoffs]/Pi],2 wp];<br />

Re[Table[x/.F<strong>in</strong>dRoot[zerof[x] == (-k+koffs-cfoffs) Pi,<br />

{x,xoffs,xoffs+1},<br />

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

AccuracyGoal->ag,<br />

MaxIterations->ma],<br />

{k,0,n-1}]]<br />

],<br />

True,<br />

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

];<br />

PartitionOffs[zerof_, a_, opts___Rule] :=<br />

Module[{x,ext<strong>re</strong>ma,cfoffs=0,<br />

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

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

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

ft = FunctionType/. {opts}/.Options[PartitionTable]},<br />

Which[ft === ZeroList,<br />

If[N[zerof[0]] < N[a],<br />

Ceil<strong>in</strong>g[x/.F<strong>in</strong>dRoot[zerof[x] == a,{x,0,1},<br />

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

AccuracyGoal->ag,<br />

MaxIterations->ma]],<br />

0],<br />

ft === S<strong>in</strong>Argument || ft === CosArgument,<br />

If[ft === CosArgument, cfoffs=1/2];<br />

ext<strong>re</strong>ma = Select[NSolve[zerof'[x] == 0,x,Work<strong>in</strong>gP<strong>re</strong>cision->wp],<br />

(Im[x/.#] == 0)&];<br />

If[Length[ext<strong>re</strong>ma] == 0, a,<br />

Max[x/.Last[ext<strong>re</strong>ma],a]],<br />

True,<br />

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

];<br />

PartitionPo<strong>in</strong>ts[zerof_, a_, n_, offs_, i<strong>re</strong>l_, opts___Rule] :=<br />

Module[{x,koffs,cfoffs=0,<br />

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

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

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

ft = FunctionType/. {opts}/.Options[PartitionTable]},<br />

Which[ft === ZeroList,<br />

Table[zerof[x],{x,offs+i<strong>re</strong>l,offs+i<strong>re</strong>l+n-1}],<br />

ft === S<strong>in</strong>Argument || ft === CosArgument,<br />

If[ft === CosArgument, cfoffs=1/2];<br />

Which[NumberQ[Limit[zerof[x],x->Inf<strong>in</strong>ity]],<br />

Table[Inf<strong>in</strong>ity,{k,0,n-1}],<br />

N[zerof'[offs+1]] > 0,<br />

koffs = N[Ceil<strong>in</strong>g[zerof[offs]/Pi],2 wp];<br />

Re[Table[x/.F<strong>in</strong>dRoot[zerof[x] == (k+koffs+cfoffs) Pi,<br />

{x,offs,offs+1},<br />

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

AccuracyGoal->ag,<br />

MaxIterations->ma],<br />

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

True,<br />

koffs = N[Floor[zerof[offs]/Pi],2 wp];<br />

Re[Table[x/.F<strong>in</strong>dRoot[zerof[x] == (-k+koffs-cfoffs) Pi,<br />

{x,offs,offs+1},<br />

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

219

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

Saved successfully!

Ooh no, something went wrong!