public final class BesselFunction
extends java.lang.Object
Utility case for computing various Bessel functions that are not included in the Java API.
Implementations for integer-order cylindrical Bessel functions of the first and second kind (i.e., Jn(x) and Yn(x), n = 1,2,3,... )were taken from www.koders.com and the copyright notice is included in the Java source file. The implementation is based upon that presented in Numerical Recipes by W.H. Press, et. al.
Spherical Bessel functions jn(x)
can be represented as cylindrical Bessel functions
with half-integer order. Specifically, we have
jn(x) = (π/2x)1/2Jn+½(x).
However, since half-order cylindrical Bessel functions are not included in
this class
(they are more difficult to implement), an implementation based upon the
above formula is not feasible. Instead,
spherical Bessel functions jn(x)
for n = 0, 1, 2, 3, 4 are implemented using their trigonometric
representations.
NOTES: (CKA)
· There exists a recurrence relationship between Bessel functions of
different orders. For example, if Bn(x) is any
cylindrical Bessel function of order n, we have the following:
Bn+1(x) = (2n/x)Bn(x) -
Bn-1(x).
However, this formula is numerically unstable for Bessel functions of the first
kind Jn(x). Thus, it cannot be used to compute the
higher order Jn(x) using recursion over lower orders.
· We can apply the above recurrence relation to spherical Bessel
functions by expressing them in terms of cylindrical Bessel functions. Letting
bn(x) represent any spherical Bessel function we have
bn+1(x) = [(2n+1)/x]bn(x)
- bn-1(x).
Again, this formula is numerically unstable for the Bessel functions of the first
kind jn(x). However, it can be used to determine the
representation of each Bessel function in terms of trigonometric functions.
Math
,
gov.sns.tools.math.ElementaryFunction
Modifier and Type | Field and Description |
---|---|
static double |
EPS
smallest tolerance value - not used at the moment
|
static double |
PI_BY_2
the value PI/2
|
static double |
SMALL_ARG
Conditional value where polynomial expansions are employed
|
static int |
ULPS_BRACKET
number of Units in the Last Place (ULPs) used for bracketing approximately equal values
|
Constructor and Description |
---|
BesselFunction() |
Modifier and Type | Method and Description |
---|---|
static double |
j0(double x)
Zero-Order Spherical Bessel Function of the First Kind
|
static double |
J0(double x)
Compute the zeroth order Bessel function of the
first kind, J0(x).
|
static double |
j1(double x)
First-Order Spherical Bessel Function of the First Kind
|
static double |
J1(double x)
Compute the first-order Bessel function of the
first kind, J1(x).
|
static double |
j2(double x)
Second-Order Spherical Bessel Function of the First Kind
|
static double |
j3(double x)
Third-Order Spherical Bessel Function of the First Kind
|
static double |
j4(double x)
Fourth-Order Spherical Bessel Function of the First Kind
|
static double |
Jn(int n,
double x)
Arbitrary Order Bessel Function of First Kind
|
static double |
sinc(double x)
Implementation of the sinc Function
|
static double |
Y0(double x)
Compute the zeroth order Bessel function of the
second kind, Y0(x).
|
static double |
Y1(double x)
Compute the first-order Bessel function of the
second kind, Y1(x).
|
static double |
Yn(int n,
double x)
Arbitrary Order Bessel Function of Second Kind
|
public static final int ULPS_BRACKET
public static final double PI_BY_2
public static final double EPS
public static final double SMALL_ARG
public static double J0(double x)
x
- a double valuepublic static double J1(double x)
x
- a double valuepublic static double Jn(int n, double x)
Computes integer order Bessel function of the first kind, Jn(x).
This implementation relies upon evaluation of the zero and first order Bessel functions J0(x) and J1(x)..
n
- integer orderx
- a double valueJ0(double)
,
J1(double)
public static double Y0(double x)
Compute the zeroth order Bessel function of the second kind, Y0(x).
This implementation relies upon evaluation of the zero order Bessel function Y0(x).
x
- a double valueJ0(double)
public static double Y1(double x)
Compute the first-order Bessel function of the second kind, Y1(x).
This implementation relies upon evaluation of the first order Bessel function Y1(x).
x
- a double valueJ1(double)
public static double Yn(int n, double x)
Computes integer order Bessel function of the second kind, Yn(x).
This implementation relies upon evaluation of the zero and first order Bessel functions Y0(x) and Y1(x).
n
- integer orderx
- a double valuepublic static double sinc(double x)
The sinc function arises frequency in engineering
applications, especially communications and signal
processing. It is defined as follows:
sinc(x) ≡ sin(x)/x.
The function is not singular at
x = 0, which may easily be verified with
L'hopital's rule.
To avoid numerical instability, for small values of
x we Taylor expand sinc(x)
to sixth order about x = 0.
sinc(x) ≈ 1 - x2/6 +
x4/120 -
x6/5040 +
O(x8).
otherwise we return sin(x)/x.
NOTE: (CKA)
· The sinc function is the zeroth order
spherical bessel function j0.
x
- any real numberpublic static double j0(double x)
This function is simply an alias for the sinc
function, which is the first spherical Bessel function,
j0(x).
x
- any real number (double value)ElementaryFunction.sinc(double)
,
sinc(double)
public static double j1(double x)
Direct computation of the first-order spherical Bessel function of the first kind, j1(x) in terms of trigonometric functions.
To avoid numerical instability, for small values of
x we Taylor expand j1(x)
to seventh order about x = 0.
j1(x) ≈
x/3 -
x3/30 +
x5/840 -
x7/45360 +
O(x9).
otherwise we return
j1(x) = sin(x)/x2 -
cos(x)/x.
x
- any real number (double value)public static double j2(double x)
Direct computation of the second-order spherical Bessel function of the first kind, j2(x) in terms of trigonometric functions.
To avoid numerical instability, for small values of
x we Taylor expand j2(x)
to eighth order about x = 0.
j2(x) ≈
x2/15 -
x4/210 +
x6/7560 -
x8/498960 +
O(x10).
otherwise we return
j2(x) = (3/x - 1)sin(x)/x -
3cos(x)/x2.
x
- any real number (double value)public static double j3(double x)
Direct computation of the third-order spherical Bessel function of the first kind, j3(x) in terms of trigonometric functions.
To avoid numerical instability, for small values of
x we Taylor expand j3(x)
to seventh order about x = 0.
j3(x) ≈
x3/105 +
x5/1890 -
x7/83160 +
O(x9).
otherwise we return
j3(x) =
(15/x3 - 6/x)sin(x)/x -
(1 - 15/x2)cos(x)/x.
x
- any real number (double value)public static double j4(double x)
Direct computation of the fourth-order spherical Bessel function of the first kind, j4(x) in terms of trigonometric functions.
To avoid numerical instability, for small values of
x we Taylor expand j4(x)
to eighth order about x = 0.
j2(x) ≈
x4/945 -
x6/20790 +
x8/1081080 +
O(x10).
otherwise we return
j4(x) =
(1 - 45/x2 + 105/x4)sin(x)/x
+ (10/x - 105/x3)cos(x)/x.
x
- any real number (double value)