From: becko BECKO on 11 Mar 2010 06:35 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.
From: becko BECKO on 12 Mar 2010 07:11 Thanks Carl, Peter and Daniel. Guess I was too hasty to send that bug report... Though it would be useful to issue a warning or something (perhaps putting it in the Possible Issues section of the help on Mathieu functions). I'm kind of falling in love with Mathematica, so it's reassuring to know that this was my mistake and not Mathematica's. Another question. How do I know that WorkingPrecision->50 is enough? What if I wanted to Plot all the way to q=100000? > Date: Thu, 11 Mar 2010 08:26:43 -0500 > From: carlw(a)wolfram.com > To: becko565(a)hotmail.com > CC: mathgroup(a)smc.vnet.net > Subject: Re: bad Mathieu functions > > On 3/11/2010 6:35 AM, becko BECKO 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. > > > > > > > > The problem is that for large q ce1 will return incorrect values for > machine numbers. On the other hand, for extended precision numbers it > will return correct values. Compare: > > Machine number input: > > In[16]:= ce1[3, 1000., I] > > Out[16]= 0. - 2200.76 I > > Extended precision number input: > > In[17]:= ce1[3, 1000`50, I] > > Out[17]= 7.29389*10^-22 I > > If you want to plot this, try instead: > > Plot[I ce1[3, q, I], {q, 0, 1000}, PlotRange->{-5,5}, WorkingPrecision->50] > > Carl Woll > Wolfram Research >
From: gekko on 12 Mar 2010 07:12 On Mar 11, 10:35 pm, becko BECKO <becko...(a)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.
From: Carl K. Woll on 12 Mar 2010 07:13 On 3/11/2010 6:35 AM, becko BECKO 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. > > > The problem is that for large q ce1 will return incorrect values for machine numbers. On the other hand, for extended precision numbers it will return correct values. Compare: Machine number input: In[16]:= ce1[3, 1000., I] Out[16]= 0. - 2200.76 I Extended precision number input: In[17]:= ce1[3, 1000`50, I] Out[17]= 7.29389*10^-22 I If you want to plot this, try instead: Plot[I ce1[3, q, I], {q, 0, 1000}, PlotRange->{-5,5}, WorkingPrecision->50] Carl Woll Wolfram Research
From: Peter Pein on 12 Mar 2010 07:13 Am 11.03.2010 12:35, schrieb becko BECKO: > 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. .... Oh yes, these oscillations are really tiny as you can see with Mathematica using: Plot[I ce1[3,q,I] /. q->SetPrecision[qq,123], {qq, 750, 1000}, Frame->True, Axes->None]
|
Next
|
Last
Pages: 1 2 Prev: ParametricPlot3D with three parameters Next: elementary questio about packages |