# [SciPy-User] scipy.special.mathieu_modcem1 is not equal to the corresponding function in gsl Classic List Threaded 3 messages Open this post in threaded view
|

## [SciPy-User] scipy.special.mathieu_modcem1 is not equal to the corresponding function in gsl

 Consider this code in python: import scipy.special as sp q=24 x=1.83 sp.mathieu_modcem1(0,q,x) the result is: -0.094807461318619515 Translate into c++ with gsl: # include                                                                 # include                                                                                                                                                 int main()  {                                                                           double q = 24;                                                                      double x = 1.83;                                                                    double y = gsl_sf_mathieu_Mc(1,0,q,x);                                              std::cout << y << std::endl;                                                        return 0;                                                                       }  the result is: -0.118824 What's the problem? _______________________________________________ SciPy-User mailing list [hidden email] https://mail.python.org/mailman/listinfo/scipy-user
Open this post in threaded view
|

## Re: scipy.special.mathieu_modcem1 is not equal to the corresponding function in gsl

 GSL has prefactor of sqrt(pi/2). scipy iirc follows abramowitz&stegun. Ming Lu kirjoitti 23.06.2017 klo 09:07: > Consider this code in python: > > > import scipy.special as sp > q=24 > x=1.83 > sp.mathieu_modcem1(0,q,x) > > > the result is: -0.094807461318619515 > > > Translate into c++ with gsl: > > > # include > # include > > int main()  { >      double q = 24; >      double x = 1.83; >      double y = gsl_sf_mathieu_Mc(1,0,q,x); >      std::cout << y << std::endl; >      return 0; > } > > > the result is: -0.118824 > > > What's the problem? > > > > _______________________________________________ > SciPy-User mailing list > [hidden email] > https://mail.python.org/mailman/listinfo/scipy-user> _______________________________________________ SciPy-User mailing list [hidden email] https://mail.python.org/mailman/listinfo/scipy-user
Open this post in threaded view
|

## [SciPy-User] 答复: scipy.special.mathieu_modcem1 is not equal to the corresponding function in gsl

Thanks for this comment, after I add that prefactor. It really works, i.e. the python's value equals the gsl value.

However, it works only in the lower order. If I increase the order beyond 65, they deviates dramatically. "order" means the second argument in the gsl function.

You can see from the figure, when order is between 0~60, they have the same value. But beyond that, they goes crazy.

One of them must have problem, or even both. Anyone can tell me which one and how to figure it... A related question have been asked on stackoverflow: https://stackoverflow.com/questions/44713610/strange-behavior-of-scipy-special-mathieu-modcem-is-it-a-bug

 stackoverflow.com Consider the following code, the value seems to vanish as m increases: import scipy.special as sp import numpy as np import matplotlib.pyplot as plt q=24 mu0=1.83 m = range(50) y = sp.mathieu_modc...  GSL has prefactor of sqrt(pi/2).
scipy iirc follows abramowitz&stegun.

Ming Lu kirjoitti 23.06.2017 klo 09:07:
> Consider this code in python:
>
>
> import scipy.special as sp
> q=24
> x=1.83
> sp.mathieu_modcem1(0,q,x)
>
>
> the result is: -0.094807461318619515
>
>
> Translate into c++ with gsl:
>
>
> # include <iostream>
> # include <gsl/gsl_sf.h>
>
> int main()  {
>      double q = 24;
>      double x = 1.83;
>      double y = gsl_sf_mathieu_Mc(1,0,q,x);
>      std::cout << y << std::endl;
>      return 0;
> }
>
>
> the result is: -0.118824
>
>
> What's the problem?
>
>
>
> _______________________________________________
> SciPy-User mailing list
> [hidden email]
> https://mail.python.org/mailman/listinfo/scipy-user
>
_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user

_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user =?gb2312?B?xsHEu7/s1dUgMjAxNy0wNi0yNCAxMS4xMi40NC5wbmc=?= (589K) Download Attachment =?gb2312?B?xsHEu7/s1dUgMjAxNy0wNi0yNCAxMS4xNC4zOS5wbmc=?= (304K) Download Attachment