bugGNU Scientific Library - Bugs: bug #50343, Different value for mathieu_ce in...


You are not allowed to post comments on this tracker with your current authentication level.

bug #50343: Different value for mathieu_ce in Mathematica and GSL

Submitted by:  Patrick Alken <psa>
Submitted on:  Fri 17 Feb 2017 10:16:59 PM UTC  
Category: Runtime errorSeverity: 3 - Normal
Operating System: Status: None
Assigned to: NoneOpen/Closed: Open

Fri 22 Dec 2017 09:43:06 AM UTC, comment #2:

> What are the values returned by MathieuCharacteristicA[0, -1]

You can check this with Wolfram|Alpha (which is powered by Mathematica): http://www.wolframalpha.com/input/?i=MathieuCharacteristicA%5B0,+-1%5D

The result is


Ruslan <l0110111>
Sat 18 Feb 2017 02:53:30 PM UTC, comment #1:

from maxgacode =at= gmail =dot= com

Looking at Abramovitz and Stegun I found the following power serie for Ce(0,q,z) ( for small |q| ).

Ce(0,q,z) = ( 1/sqrt(2) ) * [ 1 - q * cos(2 z)/2 + q^2 * ((cos(4 z)/32) - 1/16) +........

for q= -1 , z = 2 pi / 180

Ce(0,q,z) =~ 1.04 + ....

That is not proving anything but my guess is that GSL implementation agrees with Abramovitz and Stegun.

Moreover Scilab (using the Mathieu Toolbox from R.Coisson & G. Vernizzi, Parma University, 2001-2002.)

-->mathieu_ang_ce(0,-1, 2 * %pi / 180 ,1)
ans =


again in agreement with GSL, Specfun and Abramovitz.

The Wolfram site says

"For nonzero q, the Mathieu functions are only periodic in z for certain values of a. Such characteristic values are given by the Wolfram Language functions MathieuCharacteristicA[r, q] and MathieuCharacteristicB[r, q] with r an integer or rational number. These values are often denoted a_r and b_r. In general, both a_r and b_r are multivalued functions with very complicated branch cut structures. Unfortunately,

there is no general agreement on how to define the branch cuts.

As a result, the Wolfram Language's implementation simply picks a convenient sheet. "

What are the values returned by

MathieuCharacteristicA[0, -1]

Patrick Alken <psa>
Project Administrator
Fri 17 Feb 2017 10:16:59 PM UTC, original submission:

from phyks =at= phyks =dot= me

I have some code that I prototyped in Mathematica and am now writing in C using GSL, that makes use of Mathieu functions. I have different results between the two of them, and I cannot figure out whether this is a bug in GSL, Mathematica or simply some misunderstanding from my part.

I am using `MathieuC` function in latest Mathematica (http://reference.wolfram.com/language/ref/MathieuC.html) which should be the same function as `gsl_sf_mathieu_ce` (https://www.gnu.org/software/gsl/manual/html_node/Angular-Mathieu-Functions.html#Angular-Mathieu-Functions) except that the former one takes a single `a` argument being the characteristic value whereas the GSL 2.3 implementation takes the order `n` and the `q` parameter directly.

So, I guess,

> N[MathieuC[MathieuCharacteristicA[0, -1], -1, 2*Pi/180]]


should be equivalent to
gsl_sf_mathieu_ce(0, -1.0, 2.0 * M_PI / 180.0)
which gives a totally different value: 0.99751942347886335.

I tried to debug with different values, and the discrepancies between Mathematica and GSL seems to appear only when the `q` parameter (-1.0 here) is negative. If I take 1.0 instead, I get values in agreement. I tried to find yet another implementation to debug it, and found Scipy (https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.mathieu_cem.html#scipy.special.mathieu_cem) which relies on Fortran SPECFUN library apparently, and is in agreement with GSL.

Patrick Alken <psa>
Project Administrator


No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by l0110111 (Posted a comment)
  • -unavailable- added by psa (Submitted the item)

    Please enter the title of George Orwell's famous dystopian book (it's a date):



    No Changes Have Been Made to This Item

    Back to the top

    Powered by Savane 3.1-cleanup1