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:
| Modifier and Type | Class and Description |
|---|---|
| public static class | BesselJ.
Encapsulates the results returned by |
| Modifier and Type | Field and Description |
|---|---|
| private static final double | ENMTEN
Smallest ABS(X) such that X/4 does not underflow |
| private static final double | ENSIG
Decimal significance desired. |
| private static final double | ENTEN
10.0^K, where K is the largest integer such that ENTEN is machine-representable in working precision |
| private static final double[] | FACT
First 25 factorials as doubles |
| private final double | order
Order of the function computed when |
| private static final double | PI2
-2 / pi |
| private static final double | RTNSIG
10.0 ** (-K) for the smallest integer K such that K >= NSIG/4 |
| private static final double | TOWPI1
first few significant digits of 2pi |
| private static final double | TWOPI
TOWPI1 + TWOPI2 |
| private static final double | TWOPI2
2pi - TWOPI1 to working precision |
| private static final double | X_MAX
Upper limit on the magnitude of x. |
| private static final double | X_MIN
Minimum acceptable value for x |
| Access | Constructor and Description |
|---|---|
| public | BesselJ(double
order of the function computed when using order)value(double).Create a new BesselJ with the given order. |
| Modifier and Type | Method and Description |
|---|---|
| public static BesselJ. | 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 errorsnon-negative real argument for which J's are to be calculated x, double fractional part of order for which J's or exponentially
scaled J's (\(J\cdot e^{x}\)) are to be calculated. 0 <= alpha < 1.0. alpha, int 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. nb)Calculates Bessel functions \(J_{n+alpha}(x)\) for non-negative argument x, and non-negative order n + alpha. |
| public double | Returns: Value of the Bessel function at xArgument x)Implements org. Returns the value of the constructed Bessel function of the first kind, for the passed argument. |
| public static double | Returns: Value of the Bessel function of the first kind, \(J_{order}(x)\)Order of the Bessel function order, double Argument x)Returns the first Bessel function, \(J_{order}(x)\). |
| ENMTEN | back to summary |
|---|---|
| private static final double ENMTEN Smallest ABS(X) such that X/4 does not underflow | |
| ENSIG | back to summary |
|---|---|
| private static final double ENSIG Decimal 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)). | |
| ENTEN | back to summary |
|---|---|
| private static final double ENTEN 10.0^K, where K is the largest integer such that ENTEN is machine-representable in working precision | |
| FACT | back to summary |
|---|---|
| private static final double[] FACT First 25 factorials as doubles | |
| order | back to summary |
|---|---|
| private final double order Order of the function computed when | |
| PI2 | back to summary |
|---|---|
| private static final double PI2 -2 / pi | |
| RTNSIG | back to summary |
|---|---|
| private static final double RTNSIG 10.0 ** (-K) for the smallest integer K such that K >= NSIG/4 | |
| TOWPI1 | back to summary |
|---|---|
| private static final double TOWPI1 first few significant digits of 2pi | |
| TWOPI | back to summary |
|---|---|
| private static final double TWOPI TOWPI1 + TWOPI2 | |
| TWOPI2 | back to summary |
|---|---|
| private static final double TWOPI2 2pi - TWOPI1 to working precision | |
| X_MAX | back to summary |
|---|---|
| private static final double X_MAX Upper 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. | |
| X_MIN | back to summary |
|---|---|
| private static final double X_MIN Minimum acceptable value for x | |
| BesselJ | back to summary |
|---|---|
| public BesselJ(double order) Create a new BesselJ with the given order.
| |
| rjBesl | back to summary |
|---|---|
| public static BesselJ. 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.
| |
| value | back to summary |
|---|---|
| public double value(double x) throws MathIllegalArgumentException, ConvergenceException Implements org. Returns the value of the constructed Bessel function of the first kind, for the passed argument.
| |
| value | back to summary |
|---|---|
| public static double value(double order, double x) throws MathIllegalArgumentException, ConvergenceException Returns the first Bessel function, \(J_{order}(x)\).
| |
BesselJ#rjBesl(double, double, int).
getVals() returns the computed function values.
getnVals() is the number of values among those returned by getnVals()
that can be considered accurate.
| Modifier and Type | Field and Description |
|---|---|
| private final int | nVals
Valid value count |
| private final double[] | vals
Bessel function values |
| Access | Constructor and Description |
|---|---|
| public | BesselJResult(double[]
values b, int count of valid values n)Create a new BesselJResult with the given values and valid value count. |
| Modifier and Type | Method and Description |
|---|---|
| public int | Returns: the number of valid function values (normally the same as the length of the array returned bygetnVals())
|
| public double[] |
| nVals | back to summary |
|---|---|
| private final int nVals Valid value count | |
| vals | back to summary |
|---|---|
| private final double[] vals Bessel function values | |
| BesselJResult | back to summary |
|---|---|
| public BesselJResult(double[] b, int n) Create a new BesselJResult with the given values and valid value count.
| |
| getnVals | back to summary |
|---|---|
public int getnVals()
| |
| getVals | back to summary |
|---|---|
public double[] getVals()
| |