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.
7.4 Auxiliary functions<br />
Out[8]= 3<br />
f0, -, 1g<br />
2<br />
The cor<strong>re</strong>ct asymptotic expansion comprises all terms <strong>in</strong> x down to x 0 , but of course no error term.<br />
In[9]:= AsymptoticExpand[x+Sqrt[x^4+x^3-x+1],x]<br />
Out[9]= 1 3 x 2<br />
-(-) + --- + x<br />
8 2<br />
These support<strong>in</strong>g functions a<strong>re</strong> used <strong>in</strong>side a mo<strong>re</strong> <strong>in</strong>tricate module that rst determ<strong>in</strong>es the<br />
asymptotic expansion, then solves the equation given above and <strong>re</strong>turns the largest <strong>re</strong>al-valued<br />
solution. The<strong>re</strong> a<strong>re</strong> several cases that lead to error or warn<strong>in</strong>g messages:<br />
As the asymptotic expansion must be of the form (x) =xpP1ai i=0 xi , p be<strong>in</strong>g a nonnegative<br />
<strong>in</strong>teger, all expansions with other than <strong>in</strong>teger exponents a<strong>re</strong> <strong>re</strong>jected (for <strong>in</strong>stance<br />
(x) = p x3 ).<br />
If no solution exists, an error is issued.<br />
The existence of mo<strong>re</strong> than one solution is <strong>re</strong>ported to the user, and the largest solution<br />
is <strong>re</strong>turned.<br />
The function ApproxLimGeneric takes as <strong>in</strong>puts the argument function that is to be approximated<br />
and the number of subdivision po<strong>in</strong>ts that a<strong>re</strong> sought with<strong>in</strong> one wavepacket.<br />
ApproxLimGeneric[f_,goal_] :=<br />
Module[fx,fapprox,g,coeffs,<strong>re</strong>spos,<strong>re</strong>sneg,<strong>re</strong>sg,<br />
fapprox = AsymptoticExpand[f[x],x];<br />
coeffs = CoefficientList[fapprox,x];<br />
If[D[coeffs,x] =!= Table[0,fLength[coeffs]g],<br />
Message[ApproxLimGeneric::nopoly],<br />
g = D[fapprox,x] / D[fapprox - f[x],x];<br />
<strong>re</strong>spos = Select[NSolve[g == goal,x],(Im[x/.#] == 0)&];<br />
<strong>re</strong>sneg = Select[NSolve[g == -goal,x],(Im[x/.#] == 0)&];<br />
<strong>re</strong>s = Select[Jo<strong>in</strong>[<strong>re</strong>spos,<strong>re</strong>sneg],Positive[x/.#]&];<br />
If[Length[<strong>re</strong>s] == 0,<br />
Message[ApproxLimGeneric::nosolution],<br />
If[Length[<strong>re</strong>s] > 1,<br />
Message[ApproxLimGeneric::nounique,Length[<strong>re</strong>s],<br />
Map[x/.#&,<strong>re</strong>s]]];<br />
x/.Last[Sort[<strong>re</strong>s]]]]<br />
]<br />
179