[SciPy-user] ellipk() with negative arguments?
Mon Mar 30 03:05:01 CDT 2009
Sun, 29 Mar 2009 17:14:34 -0600, Iordan Hristov wrote:
> 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
> N[EllipticK[.1]] -> 1.61244
> Scipy: ellipk(-1) -> nan
> Mathematica: N[EllipticK[-1]] -> 1.31103
> Scipy: ellipk(3) -> nan
> Mathematica: N[EllipticK] -> 1.00108 - 1.17142 I
> How could one get the Mathematica results in Scipy?
In general the type of output is real if input is real -> nans when out
of real-valued domain.
Now, for `ellipk` there does not appear to be a complex-valued
implementation in Scipy:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: function not supported for these types, and can't coerce
safely to supported types
So at the moment, the answer is simply that it's you can't, except if you
can express ellipk in terms of other special functions that are
implemented in Scipy. But having complex-calued ellipk in Scipy would be
Please file an enhancement request in the Scipy Trac:
so that we won't forget this feature request.
As Frederik suggested, you can use the ellipk from mpmath as a work-
around, for the present.
More information about the SciPy-user