Class BesselJ
java.lang.Object
org.apache.commons.math3.special.BesselJ
- All Implemented Interfaces:
UnivariateFunction
This class provides computation methods related to Bessel
functions of the first kind. Detailed descriptions of these functions are
available in Wikipedia, Abrabowitz and
Stegun (Ch. 9-11), and DLMF (Ch. 10).
This implementation is based on the rjbesl Fortran routine at Netlib.
From the Fortran code:
This program is based on a program written by David J. Sookne (2) that computes values of the Bessel functions J or I of real argument and integer order. Modifications include the restriction of the computation to the J Bessel function of non-negative real argument, the extension of the computation to arbitrary positive order, and the elimination of most underflow.
References:
- "A Note on Backward Recurrence Algorithms," Olver, F. W. J., and Sookne, D. J., Math. Comp. 26, 1972, pp 941-947.
- "Bessel Functions of Real Argument and Integer Order," Sookne, D. J., NBS Jour. of Res. B. 77B, 1973, pp 125-132.
- Since:
- 3.4
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classEncapsulates the results returned byrjBesl(double, double, int). -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final doubleSmallest ABS(X) such that X/4 does not underflowprivate static final doubleDecimal significance desired.private static final double10.0^K, where K is the largest integer such that ENTEN is machine-representable in working precisionprivate static final double[]First 25 factorials as doublesprivate final doubleOrder of the function computed whenvalue(double)is usedprivate static final double-2 / piprivate static final double10.0 ** (-K) for the smallest integer K such that K >= NSIG/4private static final doublefirst few significant digits of 2piprivate static final doubleTOWPI1 + TWOPI2private static final double2pi - TWOPI1 to working precisionprivate static final doubleUpper limit on the magnitude of x.private static final doubleMinimum acceptable value for x -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BesselJ.BesselJResultrjBesl(double x, double alpha, int nb) Calculates Bessel functions \(J_{n+alpha}(x)\) for non-negative argument x, and non-negative order n + alpha.doublevalue(double x) Returns the value of the constructed Bessel function of the first kind, for the passed argument.static doublevalue(double order, double x) Returns the first Bessel function, \(J_{order}(x)\).
-
Field Details
-
PI2
private static final double PI2-2 / pi- See Also:
-
TOWPI1
private static final double TOWPI1first few significant digits of 2pi- See Also:
-
TWOPI2
private static final double TWOPI22pi - TWOPI1 to working precision- See Also:
-
TWOPI
private static final double TWOPITOWPI1 + TWOPI2- See Also:
-
ENTEN
private static final double ENTEN10.0^K, where K is the largest integer such that ENTEN is machine-representable in working precision- See Also:
-
ENSIG
private static final double ENSIGDecimal significance desired. Should be set to (INT(log_{10}(2) * (it)+1)). Setting NSIG lower will result in decreased accuracy while setting NSIG higher will increase CPU time without increasing accuracy. The truncation error is limited to a relative error of T=.5(10^(-NSIG)).- See Also:
-
RTNSIG
private static final double RTNSIG10.0 ** (-K) for the smallest integer K such that K >= NSIG/4- See Also:
-
ENMTEN
private static final double ENMTENSmallest ABS(X) such that X/4 does not underflow- See Also:
-
X_MIN
private static final double X_MINMinimum acceptable value for x- See Also:
-
X_MAX
private static final double X_MAXUpper limit on the magnitude of x. If abs(x) = n, then at least n iterations of the backward recursion will be executed. The value of 10.0 ** 4 is used on every machine.- See Also:
-
FACT
private static final double[] FACTFirst 25 factorials as doubles -
order
private final double orderOrder of the function computed whenvalue(double)is used
-
-
Constructor Details
-
BesselJ
public BesselJ(double order) Create a new BesselJ with the given order.- Parameters:
order- order of the function computed when usingvalue(double).
-
-
Method Details
-
value
Returns the value of the constructed Bessel function of the first kind, for the passed argument.- Specified by:
valuein interfaceUnivariateFunction- Parameters:
x- Argument- Returns:
- Value of the Bessel function at x
- Throws:
MathIllegalArgumentException- ifxis too large relative toorderConvergenceException- if the algorithm fails to converge
-
value
public static double value(double order, double x) throws MathIllegalArgumentException, ConvergenceException Returns the first Bessel function, \(J_{order}(x)\).- Parameters:
order- Order of the Bessel functionx- Argument- Returns:
- Value of the Bessel function of the first kind, \(J_{order}(x)\)
- Throws:
MathIllegalArgumentException- ifxis too large relative toorderConvergenceException- if the algorithm fails to converge
-
rjBesl
Calculates Bessel functions \(J_{n+alpha}(x)\) for non-negative argument x, and non-negative order n + alpha.Before using the output vector, the user should check that nVals = nb, i.e., all orders have been calculated to the desired accuracy. See BesselResult class javadoc for details on return values.
- Parameters:
x- non-negative real argument for which J's are to be calculatedalpha- fractional part of order for which J's or exponentially scaled J's (\(J\cdot e^{x}\)) are to be calculated. 0 invalid input: '<'= alpha invalid input: '<' 1.0.nb- integer number of functions to be calculated, nb > 0. The first function calculated is of order alpha, and the last is of order nb - 1 + alpha.- Returns:
- BesselJResult a vector of the functions \(J_{alpha}(x)\) through \(J_{nb-1+alpha}(x)\), or the corresponding exponentially scaled functions and an integer output variable indicating possible errors
-