Top Description Inners Fields Constructors Methods
org.apache.commons.math3.special

public Class BesselJ

extends Object
implements UnivariateFunction
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.analysis.UnivariateFunction
Imports
org.apache.commons.math3.analysis.UnivariateFunction, org.apache.commons.math3.exception.ConvergenceException, .MathIllegalArgumentException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.util.FastMath, .MathArrays

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:

Since
3.4

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
BesselJ.BesselJResult

Encapsulates the results returned by BesselJ#rjBesl(double, double, int).

Field Summary

Modifier and TypeField 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 value(double) is used

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

Constructor Summary

AccessConstructor and Description
public
BesselJ(double
order of the function computed when using value(double).
order
)

Create a new BesselJ with the given order.

Method Summary

Modifier and TypeMethod and Description
public static BesselJ.BesselJResult

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
rjBesl
(double
non-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 x
value
(double
Argument
x
)

Implements org.apache.commons.math3.analysis.UnivariateFunction.value.

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)\)
value
(double
Order of the Bessel function
order
,
double
Argument
x
)

Returns the first Bessel function, \(J_{order}(x)\).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ENMTENback to summary
private static final double ENMTEN

Smallest ABS(X) such that X/4 does not underflow

ENSIGback 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)).

ENTENback 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

FACTback to summary
private static final double[] FACT

First 25 factorials as doubles

orderback to summary
private final double order

Order of the function computed when value(double) is used

PI2back to summary
private static final double PI2

-2 / pi

RTNSIGback to summary
private static final double RTNSIG

10.0 ** (-K) for the smallest integer K such that K >= NSIG/4

TOWPI1back to summary
private static final double TOWPI1

first few significant digits of 2pi

TWOPIback to summary
private static final double TWOPI

TOWPI1 + TWOPI2

TWOPI2back to summary
private static final double TWOPI2

2pi - TWOPI1 to working precision

X_MAXback 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_MINback to summary
private static final double X_MIN

Minimum acceptable value for x

Constructor Detail

BesselJback to summary
public BesselJ(double order)

Create a new BesselJ with the given order.

Parameters
order:double

order of the function computed when using value(double).

Method Detail

rjBeslback to summary
public static BesselJ.BesselJResult rjBesl(double x, double alpha, int nb)

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:double

non-negative real argument for which J's are to be calculated

alpha: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.

nb: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.

Returns:BesselJ.BesselJResult

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

valueback to summary
public double value(double x) throws MathIllegalArgumentException, ConvergenceException

Implements org.apache.commons.math3.analysis.UnivariateFunction.value.

Returns the value of the constructed Bessel function of the first kind, for the passed argument.

Parameters
x:double

Argument

Returns:double

Value of the Bessel function at x

Exceptions
MathIllegalArgumentException:
if x is too large relative to order
ConvergenceException:
if the algorithm fails to converge
valueback to summary
public static double value(double order, double x) throws MathIllegalArgumentException, ConvergenceException

Returns the first Bessel function, \(J_{order}(x)\).

Parameters
order:double

Order of the Bessel function

x:double

Argument

Returns:double

Value of the Bessel function of the first kind, \(J_{order}(x)\)

Exceptions
MathIllegalArgumentException:
if x is too large relative to order
ConvergenceException:
if the algorithm fails to converge
org.apache.commons.math3.special back to summary

public Class BesselJ.BesselJResult

extends Object
Class Inheritance

Encapsulates the results returned by 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.

Field Summary

Modifier and TypeField and Description
private final int
nVals

Valid value count

private final double[]
vals

Bessel function values

Constructor Summary

AccessConstructor 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.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the number of valid function values (normally the same as the length of the array returned by getnVals())
getnVals
()

public double[]

Returns:

the computed function values
getVals
()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nValsback to summary
private final int nVals

Valid value count

valsback to summary
private final double[] vals

Bessel function values

Constructor Detail

BesselJResultback to summary
public BesselJResult(double[] b, int n)

Create a new BesselJResult with the given values and valid value count.

Parameters
b:double[]

values

n:int

count of valid values

Method Detail

getnValsback to summary
public int getnVals()
Returns:int

the number of valid function values (normally the same as the length of the array returned by getnVals())

getValsback to summary
public double[] getVals()
Returns:double[]

the computed function values