Compute the Bessel functions I(), J(), K(), and Y(), of complex
arguments z
and real nu
,
BesselI(z, nu, expon.scaled = FALSE, nSeq = 1, verbose = 0)
BesselJ(z, nu, expon.scaled = FALSE, nSeq = 1, verbose = 0)
BesselK(z, nu, expon.scaled = FALSE, nSeq = 1, verbose = 0)
BesselY(z, nu, expon.scaled = FALSE, nSeq = 1, verbose = 0)
a complex or numeric vector (or matrix
with nSeq
columns if nSeq > 1
)
of the same length (or nrow
when nSeq > 1
) and
mode
as z
.
complex or numeric vector.
numeric (scalar).
logical indicating if the result should be scaled by an exponential factor, typically to avoid under- or over-flow. See the ‘Details’ about the specific scaling.
positive integer; if nu
values;
if nu >= 0
,nu, nu+1, ..., nu+nSeq-1
,
if nu < 0
, nu, nu-1, ..., nu-nSeq+1
.
integer defaulting to 0, indicating the level of verbosity notably from C code.
Donald E. Amos, Sandia National Laboratories, wrote the original
fortran code.
Martin Maechler did the translation to C, and partial cleanup
(replacing goto
's), in addition to the R interface.
The case nu < 0
is handled by using simple formula from
Abramowitz and Stegun, see details in besselI()
.
The scaling activated by expon.scaled = TRUE
depends on the
function and the scaled versions are
BesselJ(z, nu, expo=TRUE)
BesselY(z, nu, expo=TRUE)
BesselI(z, nu, expo=TRUE)
BesselK(z, nu, expo=TRUE)
Abramowitz, M., and Stegun, I. A. (1964, etc). Handbook of mathematical functions (NBS AMS series 55, U.S. Dept. of Commerce), https://personal.math.ubc.ca/~cbm/aands/
Wikipedia (20nn). Bessel Function, https://en.wikipedia.org/wiki/Bessel_function
D. E. Amos (1986) Algorithm 644: A portable package for Bessel functions of a complex argument and nonnegative order; ACM Trans. Math. Software 12, 3, 265--273.
D. E. Amos (1983) Computation of Bessel Functions of Complex Argument; Sand83-0083.
D. E. Amos (1983) Computation of Bessel Functions of Complex Argument and Large Order; Sand83-0643.
D. E. Amos (1985) A subroutine package for Bessel functions of a complex argument and nonnegative order; Sand85-1018.
Olver, F.W.J. (1974). Asymptotics and Special Functions; Academic Press, N.Y., p.420
The base R functions besselI()
, besselK()
, etc.
The Hankel functions (of first and second kind),
Hankel
.
The Airy functions Airy
.
For large x
and/or nu
arguments, algorithm AS~644 is not
good enough, and the results may overflow to Inf
or underflow
to zero, such that direct computation of besselI.nuAsym()
, besselIasym()
and
besselK.nuAsym(*, log= *)
, based on asymptotic expansions.
## For real small arguments, BesselI() gives the same as base::besselI() :
set.seed(47); x <- sort(round(rlnorm(20), 2))
M <- cbind(x, b = besselI(x, 3), B = BesselI(x, 3))
stopifnot(all.equal(M[,"b"], M[,"B"], tol = 2e-15)) # ~4e-16 even
M
## and this is true also for the 'exponentially scaled' version:
Mx <- cbind(x, b = besselI(x, 3, expon.scaled=TRUE),
B = BesselI(x, 3, expon.scaled=TRUE))
stopifnot(all.equal(Mx[,"b"], Mx[,"B"], tol = 2e-15)) # ~4e-16 even
Run the code above in your browser using DataLab