SPHERICAL_YN

The spherical Bessel function of the second kind, y_n(z), is the second independent spherical solution paired with j_n(z) in radial problems.

It is related to the cylindrical Bessel function by:

y_n(z) = \sqrt{\frac{\pi}{2z}}\,Y_{n+1/2}(z)

This function evaluates either y_n(z) or its derivative depending on the derivative flag.

Excel Usage

=SPHERICAL_YN(n, z, derivative)
  • n (int, required): Nonnegative integer order of the spherical Bessel function (dimensionless).
  • z (float, required): Positive argument where the function is evaluated (dimensionless).
  • derivative (bool, optional, default: false): Whether to return the derivative instead of the function value (true or false).

Returns (float): Value of the spherical Bessel function of the second kind (or derivative) at order n and argument z.

Example 1: Zero order function value

Inputs:

n z derivative
0 1 false

Excel formula:

=SPHERICAL_YN(0, 1, FALSE)

Expected output:

-0.540302

Example 2: First order function value

Inputs:

n z derivative
1 2 false

Excel formula:

=SPHERICAL_YN(1, 2, FALSE)

Expected output:

-0.350612

Example 3: Second order derivative value

Inputs:

n z derivative
2 1.5 true

Excel formula:

=SPHERICAL_YN(2, 1.5, TRUE)

Expected output:

1.99499

Example 4: Third order at moderate argument

Inputs:

n z derivative
3 4 false

Excel formula:

=SPHERICAL_YN(3, 4, FALSE)

Expected output:

-0.218642

Python Code

from scipy.special import spherical_yn as scipy_spherical_yn

def spherical_yn(n, z, derivative=False):
    """
    Compute the spherical Bessel function of the second kind or its derivative.

    See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.spherical_yn.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        n (int): Nonnegative integer order of the spherical Bessel function (dimensionless).
        z (float): Positive argument where the function is evaluated (dimensionless).
        derivative (bool, optional): Whether to return the derivative instead of the function value (true or false). Default is False.

    Returns:
        float: Value of the spherical Bessel function of the second kind (or derivative) at order n and argument z.
    """
    try:
        n = int(n)
        z = float(z)
        derivative = bool(derivative)
        if n < 0:
            return "Error: n must be greater than or equal to 0"
        if z <= 0:
            return "Error: z must be greater than 0 for real-valued output"
        return float(scipy_spherical_yn(n, z, derivative=derivative))
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Nonnegative integer order of the spherical Bessel function (dimensionless).
Positive argument where the function is evaluated (dimensionless).
Whether to return the derivative instead of the function value (true or false).