Skip to main content
`Ctrl`+`K`

# scipy.special.yn

scipy.special.yn(n, x, out=None) = <ufunc 'yn'>

  Bessel function of the second kind of integer order and real argument.

  Parameters:
    n array_like

      Order (integer).

    x array_like

      Argument (float).

    out ndarray, optional

      Optional output array for the function results

  Returns:
    Y scalar or ndarray

      Value of the Bessel function, \(Y_n(x)\).

  See also

  `yv`

    For real order and real or complex argument.

  `y0`

    faster implementation of this function for order 0

  `y1`

    faster implementation of this function for order 1

  Notes

  Wrapper for the Cephes [1] routine `yn`.

  The function is evaluated by forward recurrence on n, starting with values computed by the Cephes routines `y0` and `y1`. If `n = 0` or 1, the routine for `y0` or `y1` is called directly.

  References

  [1]

  Cephes Mathematical Functions Library, http://www.netlib.org/cephes/

  Examples

  Evaluate the function of order 0 at one point.

      >>> from scipy.special import yn
      >>> yn(0, 1.)
      0.08825696421567697

  Evaluate the function at one point for different orders.

      >>> yn(0, 1.), yn(1, 1.), yn(2, 1.)
      (0.08825696421567697, -0.7812128213002888, -1.6506826068162546)

  The evaluation for different orders can be carried out in one call by providing a list or NumPy array as argument for the v parameter:

      >>> yn([0, 1, 2], 1.)
      array([ 0.08825696, -0.78121282, -1.65068261])

  Evaluate the function at several points for order 0 by providing an array for z.

      >>> import numpy as np
      >>> points = np.array([0.5, 3., 8.])
      >>> yn(0, points)
      array([-0.44451873,  0.37685001,  0.22352149])

  If z is an array, the order parameter v must be broadcastable to the correct shape if different orders shall be computed in one call. To calculate the orders 0 and 1 for an 1D array:

      >>> orders = np.array([[0], [1]])
      >>> orders.shape
      (2, 1)

      >>> yn(orders, points)
      array([[-0.44451873,  0.37685001,  0.22352149],
             [-1.47147239,  0.32467442, -0.15806046]])

  Plot the functions of order 0 to 3 from 0 to 10.

      >>> import matplotlib.pyplot as plt
      >>> fig, ax = plt.subplots()
      >>> x = np.linspace(0., 10., 1000)
      >>> for i in range(4):
      ...     ax.plot(x, yn(i, x), label=f'$Y_{i!r}$')
      >>> ax.set_ylim(-3, 1)
      >>> ax.legend()
      >>> plt.show()