Re: Re: bad Mathieu functions
- To: mathgroup at smc.vnet.net
- Subject: [mg108309] Re: [mg108281] Re: bad Mathieu functions
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Sat, 13 Mar 2010 07:57:05 -0500 (EST)
- References: <hnakhc$5p5$1@smc.vnet.net> <201003121212.HAA13776@smc.vnet.net>
- Reply-to: drmajorbob at yahoo.com
A fourth option is to set $MinPrecision. Help for it has the following examples: Block[{$MinPrecision = $MachinePrecision}, N[Pi, 50] - 265099323460521503743/84383735478118508040] 4.066722320572635*10^-41 Block[{$MinPrecision = 20, $MaxPrecision = 20}, 1 - Sqrt[1 - Exp[-10`20]]] 0.000022700222531293910900 In both cases, you start with an "arbitrary precision" number, and $MinPrecision prevents calculations from dropping to zero precision. If you start with a machine precision number, you lose that advantage, so that $MinPrecision has no effect in this code: Block[{$MinPrecision = $MachinePrecision}, N@Pi - 265099323460521503743/84383735478118508040] 4.44089*10^-16 Block[{$MinPrecision = 50}, N@Pi - 265099323460521503743/84383735478118508040] 4.44089*10^-16 This throws an error, too, because you're starting with too little precision to satisfy $MinPrecision: Block[{$MinPrecision = 50}, N[Pi, 20] - 265099323460521503743/84383735478118508040] 4.0667223205726345135327471876400850811855821022270*10^-41 (Yet it seems to have worked.) Bobby On Fri, 12 Mar 2010 06:12:26 -0600, gekko <pfalloon at gmail.com> wrote: > On Mar 11, 10:35 pm, becko BECKO <becko... at hotmail.com> wrote: >> I am no expert in Mathieu functions, but I don't think this gives the >> right result: >> >> ce1[r_, q_, z_] := MathieuCPrime[MathieuCharacteristicA[r, q], q, z] >> >> Plot[I ce1[3, q, I], {q, 0, 1000}] >> >> In another system you get a smooth graph, making very small >> oscillations about zer o as q increases. I've read that Mathieu >> functions are difficult to deal with. I guess that Mathematica's >> implementation doesn't support arbitrary values of the parameters. I >> made a bug report in the WRI site. Maybe someone here has some comments >> to share? It would be nice if there were a package or something with >> more robust implementations of Mathieu functions. > > > Au contraire, Mathematica is one of the few systems that does support > arbitrary precision evaluation of all special for arbitrary values of > parameters. However, there is no getting around the fact that some > regions of parameter space are just hard to compute! > > In the case of Mathieu functions, the series expansion by which they > are computed converges more slowly as the parameter q becomes larger. > As a consequence, to get meaningful values for large q you need to > work with higher precision. > > Compare the following three cases (using your ce1 function): > > In[179]:= {ce1[3, 1000., I], ce1[3, 1000`20, I], ce1[3, 1000`60, I]} > > Out[179]= {0. + 1608.56 I, 0.*10^2 I, 7.293885910335973*10^-22 I} > > In order, what's going on here is: > > 1. Machine-precision evaluation: all internal computations are done to > machine precision, which is insufficient in this case, and hence the > final answer is (machine-precision) garbage. > > 2. High-precision evaluation, using 20 significant digits: here > Mathematica pays attention to significant figures and correctly > returns a zero-precision result, since 20 digits is not enough to > compute the underlying sum. > > 3. High-precision evaluation, using 60 significant digits: here 60 > digits is high enough to compute the sum and hence return a meaningful > answer. Notice that the final answer has far fewer significant digits > than the input, since precision is lost evaluating the sum. > > > Now, you could legitimately argue that Mathematica should be "smarter" > in cases 1 and 2 above. For case 1, I would say that the current > behaviour reasonable (and somewhat "expected") since it is a general > design decision that machine precision computation should be fast at > the expense of complete control over precision. > > For case 2 I would tend to agree that Mathematica *could* be smarter: > there is no reason why the internal algorithm couldn't recognize that > the output has insufficient precision, and thus increase the internal > working precision. > > > In any case, to return to your original example: if you want to get > your plot "working", you can simply force it to use higher precision: > > LogPlot[Abs[I ce1[3, SetPrecision[q,100], I]], {q, 0, 1000}, PlotRange- >> All] > > Hope this helps. > > Cheers, P. > -- DrMajorBob at yahoo.com
- References:
- Re: bad Mathieu functions
- From: gekko <pfalloon@gmail.com>
- Re: bad Mathieu functions