[SciPy-user] ellipk() with negative arguments?

Fredrik Johansson fredrik.johansson@gmail....
Sun Mar 29 18:58:09 CDT 2009


On Mon, Mar 30, 2009 at 1:14 AM, Iordan Hristov <hristov@ucalgary.ca> wrote:
> Hello,
>
> I'm implementing a Mathematica equation which has EllipticK[x], x<0.
> It seems the domain of  ellipk() is between 0 and 1 and anything
> outside gives nan. For example:
>
> Scipy:                  ellipk(.1) -> 1.6124413487202192
> Mathematica:    N[EllipticK[.1]] -> 1.61244
>
> Scipy:                  ellipk(-1) -> nan
> Mathematica:    N[EllipticK[-1]] -> 1.31103
>
> Scipy:                  ellipk(3) -> nan
> Mathematica:    N[EllipticK[3]] -> 1.00108 - 1.17142 I
>
> How could one get the Mathematica results in Scipy?

A simple workaround would be to use the ellipk function in mpmath:

>>> from mpmath import ellipk
>>> ellipk(-1)
mpf('1.3110287771460598')
>>> ellipk(3)
mpc(real='1.0010773804561062', imag='-1.1714200841467699')

Fredrik


More information about the SciPy-user mailing list