Skip to content

Spherical Bessel functions #319

@tpudlik

Description

@tpudlik

Spherical Bessel functions of the first kind are defined as,

from mpmath import mpf, sqrt, pi, besselj

def sph_jn(n, z):
    return besselj(n + mpf(1)/2, z)*sqrt(pi/(2*z))

For positive integer n, these functions have closed-form expressions in terms of trigonometric functions. For example, sph_jn(0, x) = sin(x)/x (see http://dlmf.nist.gov/10.49.E3).

For negative values of x, the mpmath implementation of these functions has the wrong sign. For example,

>>> sph_jn(0, -1)
mpc(real='-0.84147098480789639', imag='0.0')

The magnitude is correct, but the sign is not!

EDIT: The same problem plagues spherical Bessel functions of the second kind, defined analogously in terms of bessely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementnew feature requests (or implementation)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions