TransWikia.com

Is MathieuC for moderately large imaginary arguments broken?

Mathematica Asked on December 22, 2020

Bug introduced in 3.0 and persisting through 12.0
(reported as CASE:3208982)


I’m trying to plot MathieuC[-3,0.3,I x] for $xin[0,10]$, and here’s what I get even with arbitrary precision arithmetic (here I use ListPlot and Table instead of Plot to make computation faster and use a regular grid):

$MaxExtraPrecision=200;
ListPlot[Table[{z,N[Re@MathieuC[-3,3/10,I z],50]},{z,0,7,1/100}],
  PlotRange->{-0.6,0.6}, Joined->True]

bad behavior of MathieuC

So, starting from about z==3.3, the results are unreliable at all. Comparing machine precision and arbitrary precision computations with N[], I get this:

N[Re@MathieuC[-3, 3/10, 5 I]]
N[Re@MathieuC[-3, 3/10, 5 I], 50]

-1.26013246174486*10^28

-1.2601324617438073657004964476674284869363635740962*10^28

So, it seems not even lack of working precision — looks like the algorithm is broken. To make sure I’m not misunderstanding the supposed behavior of Mathieu functions, I’ve also checked it by solving Mathieu equation numerically:

With[{a = -3, q = 0.3},
 sol = NDSolveValue[{
      -w''[z] - 2 q Cosh[2 z] w[z] == -a w[z],
      w[0] == Re@MathieuC[a, q, 0],
      w'[0] == 0
      }, w, {z, 0, 7}, MaxSteps -> 10^6]
 ];
$MaxExtraPrecision=200;
Show[
 Plot[sol[z],{z,0,7}, PlotStyle->Darker@Green, PlotPoints->300],
 ListPlot[Table[{z,N[Re@MathieuC[-3,3/10,I z],50]},{z,0,7,1/100}],Joined->True],
PlotRange->{-0.6,0.6}]

MathieuC versus NDSolve result

This shows that the function indeed should look nicer, but apparently MathieuC can’t calculate it for even moderately large imaginary arguments. It also appears that Mathematica versions 5 to 12 give exactly the same results (sometimes with differences in several least significant digits).

Is it a bug, or is it documented somewhere? Are there any workarounds, allowing me to evaluate Mathieu functions not as slowly as via NDSolve, and still not reimplementing them like e.g. here?

One Answer

I, you are using imaginary argument, which is suppose that it's rather a radial Mathieu Function instead of an angular one, Radial Mathieu Function are not implemented in Mathematica and are incompletely simulated by using imaginary argument on an angular Mathieu Function. Angular Mathieu Functions is defined on [0,2*Pi] and have some periodic properties... It's not surprising that functions diverge when argument > 6, since probably Mathematica use matrix or continued fraction methods. To have better estimate of the Radial mathieu functions (so called modified Mathieu Function), one uses Series of cross-product of Bessel functions. But it means that you have to deal with more theoretical matter about these functions and not just use incomplete implementation of Mathieu Function in Mathematica.

Henri Lévêque

Answered by Henri Leveque on December 22, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP