Description Usage Arguments Details Value Author(s) References See Also Examples
Compute the Bessel functions I(), J(), K(), and Y(), of complex
arguments z
and real nu
,
1 2 3 4 |
z |
complex or numeric vector. |
nu |
numeric (scalar). |
expon.scaled |
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. |
nSeq |
positive integer; if > 1, computes the result for
a whole sequence of |
verbose |
integer defaulting to 0, indicating the level of verbosity notably from C code. |
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)
:= exp(-|Im(z)|) J[nu](z)
BesselY(z, nu, expo=TRUE)
:= exp(-|Im(z)|) Y[nu](z)
BesselI(z, nu, expo=TRUE)
:= exp(-|Re(z)|) I[nu](z)
BesselK(z, nu, expo=TRUE)
:= exp(z) K[nu](z)
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
.
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.
Abramowitz, M., and Stegun, I. A. (1955, etc). Handbook of mathematical functions (NBS AMS series 55, U.S. Dept. of Commerce), http://people.math.sfu.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),
H_{ν}^{(1)}(z) and H_{ν}^{(2)}(z): Hankel
.
The Airy functions Ai() and Bi() and their first
derivatives, 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 log(I[nu](x)) and
log(K[nu](x)) are desirable. For this, we provide
besselI.nuAsym()
, besselIasym()
and
besselK.nuAsym(*, log= *)
, based on asymptotic expansions.
1 2 3 4 5 6 7 8 9 10 | ## 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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.