Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Spheroidal Wave Functions

Synopsis
#include <boost/math/special_functions/spheroidal.hpp>

namespace boost { namespace math {

// Eigenvalues λ_n^m(c²) and λ_n^m(-c²):
template <class T>
calculated-result-type prolate_spheroidal_eigenvalue(unsigned n, unsigned m, T c);
template <class T>
calculated-result-type oblate_spheroidal_eigenvalue(unsigned n, unsigned m, T c);

// Angular functions Ps_n^m(η, ±c²):
template <class T1, class T2>
calculated-result-type prolate_spheroidal_angular(unsigned n, unsigned m, T1 c, T2 eta, calculated-result-type* derivative = nullptr);
template <class T1, class T2>
calculated-result-type oblate_spheroidal_angular(unsigned n, unsigned m, T1 c, T2 eta, calculated-result-type* derivative = nullptr);

// Radial functions of the first and second kind:
template <class T1, class T2>
calculated-result-type prolate_spheroidal_radial_1(unsigned n, unsigned m, T1 c, T2 xi, calculated-result-type* derivative = nullptr);
template <class T1, class T2>
calculated-result-type prolate_spheroidal_radial_2(unsigned n, unsigned m, T1 c, T2 xi, calculated-result-type* derivative = nullptr);
template <class T1, class T2>
calculated-result-type oblate_spheroidal_radial_1(unsigned n, unsigned m, T1 c, T2 xi, calculated-result-type* derivative = nullptr);
template <class T1, class T2>
calculated-result-type oblate_spheroidal_radial_2(unsigned n, unsigned m, T1 c, T2 xi, calculated-result-type* derivative = nullptr);

// All of the above for one (n, m, c), at many arguments:
template <class Real, class Policy = policies::policy<>>
class prolate_spheroidal
{
public:
    prolate_spheroidal(unsigned n, unsigned m, Real c);
    Real eigenvalue() const;
    Real angular(Real eta, Real* derivative = nullptr) const;
    Real radial_1(Real xi, Real* derivative = nullptr) const;
    Real radial_2(Real xi, Real* derivative = nullptr) const;
};
template <class Real, class Policy = policies::policy<>>
class oblate_spheroidal; // the same members

}} // namespaces

Each function also has an overload taking a trailing Policy argument (after the derivative pointer). When derivative is not null it receives the derivative with respect to η or ξ; the two share the expensive part of the computation, so asking for both costs little more than the value alone. The derivatives are computed from forms that avoid the cancellation an automatic differentiation of the value would inherit near ξ = 1.

Most of the cost of each call, 15-30 μs in double, is the eigenvalue and the expansion coefficients, which depend only on n, m and c. The classes compute them once, in the constructor, and their members return exactly what the free functions do, so evaluating at many arguments is up to 20 times faster:

boost::math::prolate_spheroidal<double> f(4, 1, 16.0);
for (double xi : grid)
{
    double d;
    double R2 = f.radial_2(xi, &d);
}

The members are const and an object may be shared between threads. Domain errors in n, m or c are raised by the constructor.

Description

Separating the Helmholtz equation in prolate or oblate spheroidal coordinates gives the angular equation (DLMF 30.2.1)

d/dη((1-η2) dw/dη) + (λ + γ2(1-η2) - m2/(1-η2)) w = 0

with γ2 = c2 for prolate and γ2 = -c2 for oblate spheroids, together with a radial equation of the same form. For each order m and degree n >= m the equation has a solution bounded at η = ±1 only when λ is the eigenvalue λnm(γ2) (DLMF 30.3), which prolate_spheroidal_eigenvalue and oblate_spheroidal_eigenvalue return.

The angular functions are DLMF's Psnm(η, γ2) (DLMF 30.4): they are normalized like the Ferrers functions legendre_p, with the same Condon-Shortley phase,

∫-11 Psnm(η, γ2)2 dη = 2(n+m)! / ((2n+1)(n-m)!)

and their sign makes Psnm(0) (for even n - m) or its derivative at 0 (for odd n - m) have the sign of the Ferrers function's. At c = 0 they reduce to the Ferrers functions Pnm(η).

The radial functions are Flammer's Rmn(1) and Rmn(2), DLMF's Snm(1) and Snm(2) (DLMF 30.11) for the prolate case, normalized to behave like the spherical Bessel functions jn(cξ) and yn(cξ) as ξ → ∞. The prolate functions are defined for ξ >= 1 and the oblate ones for ξ >= 0. Their Wronskian is

R(1) R(2)' - R(1)' R(2) = 1 / (c(ξ2 - 1)) (prolate), 1 / (c(ξ2 + 1)) (oblate)

Relation to other conventions

Flammer, Abramowitz and Stegun, and scipy.special use the eigenvalue λ + γ2: pro_cv(m, n, c) is prolate_spheroidal_eigenvalue(n, m, c) + c*c and obl_cv(m, n, c) is oblate_spheroidal_eigenvalue(n, m, c) - c*c. Their angular functions (pro_ang1, obl_ang1) use Flammer's normalization, Smn(c, 0) = Pnm(0) (or the same for the derivatives when n - m is odd), without the Condon-Shortley phase; they are (-1)m Pnm(0) / Psnm(0) times ours. Flammer's normalization is avoided here because for oblate functions with large c the function's value at 0 is exponentially small compared with its norm: at c = 60 Flammer-normalized oblate functions have norms near 1024. The radial functions agree in all of these conventions.

Domain

c may be negative: the eigenvalues and angular functions depend only on c2, and the radial functions of the first and second kinds are multiplied by (-1)n and (-1)n+1 when the sign of c changes, as in Mathematica. n < m, |η| > 1, ξ < 1 (prolate) or ξ < 0 (oblate), non-finite arguments, and c = 0 for the radial functions are domain errors. The prolate radial functions of the second kind, and the derivative of the first kind for m = 1, are infinite at ξ = 1 and raise an overflow error there, as does a request for the derivative of the angular function at η = ±1 for m = 1.

Accuracy

Errors measured against 384-bit references (Arb via Nemo, with the radial functions checked against their Wronskian to 40 digits) on a grid with c <= 50, m <= 5, n - m <= 10, scaled by the local envelope max(|f|, |x f'|, |f'|/k) so that zeros of these oscillating functions do not dominate, are at most

Function

prolate, c <= 8

prolate, c <= 50

oblate, c <= 8

oblate, c <= 50

eigenvalue

1 ε

1 ε

1 ε

1 ε

angular

6 ε

16 ε

10 ε

15 ε

angular derivative

26 ε

36 ε

51 ε

49 ε

radial, first kind

3 ε

4 ε

6 ε

10 ε

radial, second kind

2 ε

3 ε

6 ε

25 ε

The eigenvalues are correctly rounded in all but a few cases (at most 0.84 ulp). Where the angular functions are exponentially small (oblate, near η = 0, large c) they are also ill-conditioned in c: at c = 30, |c ∂Ps/∂c / Ps| ≈ 28 at η = 0, so errors of a few ε there are within the conditioning. For ξ - 1 down to 10-6 the prolate radial functions stay within a few ε, and the second kind within a few times its condition number |(ξ - 1)R'/R| in ξ - 1 (which is exact for a double ξ near 1), and for large cξ the radial functions oscillate rapidly, so their condition number |ξR'/R| is at least about cξ. At large ξ the phase c√(ξ2 - τ) is carried in two parts, so the radial functions stay within a few times their condition number. On the same grid scipy.special.pro_rad2 and obl_rad2 (SciPy 1.18) have no correct digits at many points. With cpp_bin_float_50 the radial functions of the first kind are accurate to a few ε and those of the second kind to within about a hundred.

Implementation

The eigenvalue is bracketed by Sturm bisection on the symmetrized tridiagonal matrix of the three-term recurrence for the Legendre expansion coefficients dk (Abramowitz and Stegun 21.7.3) and polished with Newton's method on Bouwkamp's continued fraction. The coefficients come from the continued fractions, matched at the largest |dk| so that both run in their stable directions. For large c the eigenvalue and the denominators of these continued fractions are small differences of terms of size c2, so rounding the eigenvalue alone costs an absolute error of about c2ε: 17 ulps of the eigenvalue, 1000 ε in the low-order dk at c = 50, and a bias of several ε in solutions integrated where they grow exponentially. As Arb does with guard bits, the step that amplifies the rounding is repeated at higher precision: Bouwkamp's residual at the rounded eigenvalue, in double length, gives its low part by one Newton step, and the continued fractions for the dk are rerun in double length with the eigenvalue to that precision. The integrations use the low part in the coefficient λ - sη2 of the equation.

The angular functions are sums of Ferrers functions. Where that sum cancels, near η = 0 for oblate and near η = ±1 for prolate functions with large c, the angular equation is integrated by Taylor series from η = 0 (by parity) or from the regular solution's power series at η = 1, in the direction in which the function grows, and matched to the sum where it is accurate. The same integration fixes the sign of the oblate functions when their value at 0 is too small to determine.

For the radial functions of the first kind the classic expansion in jm+k(cξ) is normalized by ∑ dk(2m+k)!k!, which cancels catastrophically for prolate functions with large /c (at c = 50 to 16 digits). The prolate functions use instead the expansion in jm+k(c√(ξ2-1)) normalized by Flammer's sum, as Van Buren and Boisvert do; for oblate functions the roles are reversed, and the classic expansion is used.

The radial functions of the second kind come from the expansion in spherical Neumann functions where it converges without cancellation (small c), and otherwise from the asymptotic expansion of R(1) + iR(2) in powers of 1/ξ with the phase c√(ξ2 - τ), τ = ±1 - λ/c2, chosen to match the local wavenumber so that its coefficients do not grow with c. Either is evaluated at the nearest point where it is accurate and integrated inward by Taylor series, the direction in which the second-kind function dominates. The integration's rounding adds a few ε times R(1), which near ξ = 1, where R(1) is several times R(2), is far outside the conditioning in ξ - 1. There (prolate, c > 8, ξ - 1 < 1/8) it runs in double length, from the asymptotic expansion at ξ = min(1 + c/8, 4); this costs up to five times as much.

Near ξ = 0 (for ξ < min(1, 4/c)) the oblate R(2) is a combination A ue + B uo of the even and odd solutions at 0. The Wronskian gives the coefficient of the solution with the parity of Psnm exactly. The other one, R(2)(0) or R(2)'(0), is exponentially small for large c and is lost to cancellation by any inward integration. For large c the oblate eigenvalues come in pairs, degrees n and n ± 1, split by an exponentially small Δ = λo - λe. With f = R(2) of degree n and g the first-kind function of its partner, the radial equation gives d/dξ[(ξ2+1) W(f, g)] = (λg - λf) f g, and W vanishes at infinity, so the coefficient is -Δ ∫0∞ f g dξ divided by g(0) or g'(0). The same identity for the angular functions on [0, 1] gives Δ = Pse(0) Pso'(0) / ∫01 Pse Pso dη to full relative accuracy. These are computed by an exact product of Taylor series out to ξ = max(1, (10 - 0.6 ln ε)/c), and beyond that from the asymptotic expansion: the slowly varying part term by term, the oscillating part by repeated integration by parts.

References

PrevUpHomeNext