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.

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

Remark (Implementation) To check whether the exponential expansion comprises<br />

only terms with <strong>in</strong>teger exponents, we simply form the derivative of the list of coe cients.<br />

S<strong>in</strong>ce terms with non-<strong>in</strong>teger exponents a<strong>re</strong> listed together with the constant terms, the<br />

derivative <strong>in</strong>such cases is di e<strong>re</strong>nt from zero. Note that to check this, we must test the<br />

two exp<strong>re</strong>ssions for symbolic identity with the <strong>re</strong>lational operator =!=, because a simple<br />

test for equality with != will not be evaluated if the variables <strong>in</strong> the symbolic exp<strong>re</strong>ssion<br />

D[f, x] a<strong>re</strong> not assigned any values.<br />

S<strong>in</strong>ce it is not possible to numerically solve equations that <strong>in</strong>volve functions like Abs,<br />

NSolve must be <strong>in</strong>voked twice with both the positive and negative possibility for the<br />

variable goal. The <strong>re</strong>sults a<strong>re</strong> lte<strong>re</strong>d such that only the <strong>re</strong>al and positive solutions a<strong>re</strong><br />

<strong>re</strong>ta<strong>in</strong>ed. As NSolve <strong>re</strong>turns a list of <strong>re</strong>placement rules fx->x1, x->x2 ...g, wemust<br />

apply the <strong>re</strong>placement operator /. to the elements to enable test<strong>in</strong>g for a vanish<strong>in</strong>g<br />

imag<strong>in</strong>ary part or the like. The operation of the Select command has been described <strong>in</strong><br />

section 7.3.5 .<br />

Example 7.4.2 The next two examples show the error check<strong>in</strong>g mechanisms. The function <strong>in</strong> the<br />

rst one cannot be exp<strong>re</strong>ssed as apower series with <strong>in</strong>teger exponents, whe<strong>re</strong>as the second one has<br />

multiple solutions. Note that the functions a<strong>re</strong> speci ed as pu<strong>re</strong> functions that need no separate<br />

declaration.<br />

In[10]:= ApproxLimGeneric[Sqrt[#^3]&,10]<br />

ApproxLimGeneric::nopoly:<br />

Function has no polynomial expansion with <strong>in</strong>teger exponents.<br />

In[11]:= ApproxLimGeneric[(#^2-20 Sqrt[#^2+1])&,20]<br />

ApproxLimGeneric::nounique:<br />

The<strong>re</strong> a<strong>re</strong> 3 <strong>re</strong>al solutions f3.98475, 8.68827, 10.8449g,<br />

he<strong>re</strong> is the largest.<br />

Out[11]= 10.8449<br />

The<strong>re</strong> a<strong>re</strong> also two special cases of this module <strong>in</strong>cluded <strong>in</strong> the package: ApproxLimQuad<br />

for parabola-like functions ax 2 + b p x 2 + c + d and ApproxLimHyp for functions of the form<br />

ax + b p x 2 + c + d. They can be found together with the code list<strong>in</strong>g of the package <strong>in</strong> the<br />

appendix.<br />

180

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

Saved successfully!

Ooh no, something went wrong!