scipy.special.elliprg#

scipy.special.elliprg(x, y, z, out=None) = <wrapped_ufunc 'elliprg'>#

Completely-symmetric elliptic integral of the second kind.

The function RG is defined as [1]

\[R_{\mathrm{G}}(x, y, z) = \frac{1}{4} \int_0^{+\infty} [(t + x) (t + y) (t + z)]^{-1/2} \left(\frac{x}{t + x} + \frac{y}{t + y} + \frac{z}{t + z}\right) t dt\]
Parameters:
x, y, zarray_like

Real or complex input parameters. x, y, or z can be any number in the complex plane cut along the negative real axis.

outndarray, optional

Optional output array for the function values

Returns:
Rscalar or ndarray

Value of the integral. If all of x, y, and z are real, the return value is real. Otherwise, the return value is complex.

See also

elliprc

Degenerate symmetric integral.

elliprd

Symmetric elliptic integral of the second kind.

elliprf

Completely-symmetric elliptic integral of the first kind.

elliprj

Symmetric elliptic integral of the third kind.

Notes

The implementation uses the relation [1]

\[2 R_{\mathrm{G}}(x, y, z) = z R_{\mathrm{F}}(x, y, z) - \frac{1}{3} (x - z) (y - z) R_{\mathrm{D}}(x, y, z) + \sqrt{\frac{x y}{z}}\]

and the symmetry of x, y, z when at least one non-zero parameter can be chosen as the pivot. When one of the arguments is close to zero, the AGM method is applied instead. Other special cases are computed following Ref. [2]

Added in version 1.8.0.

Array API Standard Support

elliprg has support for Python Array API Standard compatible backends in addition to NumPy. The following combinations of backend and device (or other capability) are supported.

Library

CPU

GPU

NumPy

✅

n/a

CuPy

n/a

⛔

PyTorch

✅

⛔

JAX

✅

⛔

Dask

✅

n/a

For the NumPy backend, this function supports all NumPy ufunc keyword arguments. Other backends may support out, but typically none of the other ufunc kwargs. out is typically supported for CuPy and PyTorch, but not currently in cases where SciPy relies on a generic Array API implementation or, for PyTorch on CPU, falls back to the NumPy backend. out is never supported for JAX because JAX arrays are immutable. elliprg does not currently support out for the PyTorch backend.

See Support for the array API standard for more information.

References

[1] (1,2)

B. C. Carlson, “Numerical computation of real or complex elliptic integrals,” Numer. Algorithm, vol. 10, no. 1, pp. 13-26, 1995. DOI:10.1007/BF02198293. https://arxiv.org/abs/math/9409227

[2]

B. C. Carlson, ed., Chapter 19 in “Digital Library of Mathematical Functions,” NIST, US Dept. of Commerce. https://dlmf.nist.gov/19.16.E1 https://dlmf.nist.gov/19.20.ii

Examples

Basic homogeneity property:

>>> import numpy as np
>>> from scipy.special import elliprg
>>> x = 1.2 + 3.4j
>>> y = 5.
>>> z = 6.
>>> scale = 0.3 + 0.4j
>>> elliprg(scale*x, scale*y, scale*z)
(1.195936862005246+0.8470988320464167j)
>>> elliprg(x, y, z)*np.sqrt(scale)
(1.195936862005246+0.8470988320464165j)

Simplifications:

>>> elliprg(0, y, y)
1.756203682760182
>>> 0.25*np.pi*np.sqrt(y)
1.7562036827601817
>>> elliprg(0, 0, z)
1.224744871391589
>>> 0.5*np.sqrt(z)
1.224744871391589

The surface area of a triaxial ellipsoid with semiaxes a, b, and c is given by

\[S = 4 \pi a b c R_{\mathrm{G}}(1 / a^2, 1 / b^2, 1 / c^2).\]
>>> def ellipsoid_area(a, b, c):
...     r = 4.0 * np.pi * a * b * c
...     return r * elliprg(1.0 / (a * a), 1.0 / (b * b), 1.0 / (c * c))
>>> print(ellipsoid_area(1, 3, 5))
108.62688289491807