fortran-bessels
Fast, accurate Bessel functions in pure modern Fortran
Loading...
Searching...
No Matches
Bessel Functions of the Second Kind: Y

The functions \( Y_0(x) \), \( Y_1(x) \), and \( Y_\nu(x) \) are the second, linearly independent solutions of Bessel's equation

\[ x^2 \frac{d^2 y}{dx^2} + x \frac{dy}{dx} + (x^2 - \nu^2)\, y = 0, \]

singular at the origin. They are related to the first kind by

\[ Y_\nu(x) = \frac{J_\nu(x)\cos(\nu\pi) - J_{-\nu}(x)}{\sin(\nu\pi)}, \]

and share the large- \( x \) asymptotic \( Y_\nu(x) \sim \sqrt{2/(\pi x)}\,\sin\!\left(x - \nu\pi/2 - \pi/4\right) \).

Function shape

Y0 and Y1

Domain and special values

\( x \) \( Y_0(x) \) / \( Y_1(x) \)
\( x < 0 \) NaN (undefined for real \( x<0 \))
\( x \to 0^+ \) \( -\infty \) (returned as -huge(BK))
\( +\infty \) \( 0 \)

Usage

use bessels, only: bessely0, bessely1, bessely, bk
real(BK) :: x(2), y(2)
x = [1.0_bk, 7.5_bk]
y = bessely0(x) ! elemental over the array
print *, bessely1(7.5_bk)
print *, bessely(2.0_bk, 7.5_bk) ! real-order yν (integer ν here)
Definition bessels.f90:17
elemental real(bk) function, public bessely0(x)
Definition bessels.f90:593
elemental real(bk) function, public bessely1(x)
Definition bessels.f90:665
elemental real(bk) function, public bessely(nu, x)
Definition bessels.f90:286
Warning
bessely(nu, x) is validated for integer order \( \nu \) only. Non-integer \( \nu \) currently routes through variable-order paths with known port bugs (power-series argument swap, Chebyshev mapping, hankel_debye complex output) and will return incorrect values. See roadmap item 07.

Accuracy and performance

bessely0/bessely1 use rational approximations on \( x \le 5 \) (with the \( (2/\pi)\log x \, J_\nu(x) \) correction term), Hankel phase/amplitude forms on the middle range, and a sine asymptotic for large \( x \). They run roughly 2× faster than the gfortran intrinsics bessel_y0/bessel_y1 while matching them to a few ULP. The accuracy plot below is scoped to \( Y_0 \) / \( Y_1 \):

Y0 / Y1 relative error vs reference
See also
Bessel Functions of the First Kind: J
Hankel Functions
Modified Bessel Functions of the Second Kind: K
fortran-bessels