BESELJ

Syntax | Return Value | Arguments | Keywords | Examples | Version History | See Also

The BESELJ function returns the J Bessel function of order N for the argument X. The BESELJ function is adapted from "SPECFUN - A Portable FORTRAN Package of Special Functions and Test Drivers", W. J. Cody, Algorithm 715, ACM Transactions on Mathematical Software, Vol 19, No. 1, March 1993.

Syntax

Result = BESELJ(X, N [, /DOUBLE] [, ITER=variable])

Return Value

If both arguments are scalars, the function returns a scalar. If both arguments are arrays, the function matches up the corresponding elements of X and N, returning an array with the same dimensions as the smallest array. If one argument is a scalar and the other argument is an array, the function uses the scalar value with each element of the array, and returns an array with the same dimensions as the smallest input array.

If X is double-precision, the result is double-precision, otherwise the result is single-precision.

Note
If the function does not converge for an element of X, the corresponding element of the Result array will be set to the IEEE floating-point value NaN.

Arguments

X

A scalar or array specifying the values for which the Bessel function is required. Values for X must be in the range -108 to 108.

Note
If X is negative then N must be an integer (either positive or negative).

N

A scalar or array specifying the order of the Bessel function to calculate. Values for N can be integers or real numbers. If N is negative then it must be an integer.

Keywords

DOUBLE

Set this keyword equal to one to return a double-precision result, or to zero to return a single-precision result. The computations will always be done using double precision. The default is to return a single-precision result if both inputs are single precision, and to return a double-precision result in all other cases.

ITER

Set this keyword equal to a named variable that will contain the number of iterations performed. If the routine converged, the stored value will be equal to the order N. If X or N are arrays, ITER will contain a scalar representing the maximum number of iterations.

Note
If the routine did not converge for an element of X, the corresponding element of the Result array will be set to the IEEE floating-point value NaN, and ITER will contain the largest order that would have converged for that X value.

Examples

Example 1

The example beselj_ex1_doc.pro plots the J and Y Bessel functions for orders 0, 1, and 2. This example file is installed in the IDL installation's /examples/doc/language directory. To view the example code, enter .edit beselj_ex1_doc.pro at the IDL command line. To execute the code, enter beselj_ex1_doc at the IDL command line. Executing the file results in the following plot:

Figure 4-4: The J and Y Bessel Functions.

beselj1.gif

Example 2

Different order Bessel functions have recurrence relationships to each other. These relationships can be used to determine how accurately IDL is computing the Bessel functions. In the following example, the recurrence relationships for each order are set to zero and the left side of the equations are plotted. The plots show how close the left side of the equations are to zero, and therefore, how accurate IDL's computation of the Bessel functions are.

This example uses the following recurrence relationship:

BESELJ-18.jpg

where J(x) is the Bessel function of the first kind of order n –1, n, or n + 1. (Similar recurrence relationships could be used for the other forms of the Bessel function.) Results are plotted for n equal to 1 through 6.

The example file beselj_ex2_doc.pro is installed in the IDL installation's /example/doc/language directory. To view the example code, enter .edit beselj_ex2_doc.pro at the IDL command line. To execute the code, enter beselj_ex2_doc at the IDL command line.

Executing the file results in the following plot:

Figure 4-5: Recurrence Relationship for J(x)

beselj2.gif

All of these plots show that this Bessel function is calculated accurately within machine tolerance.

Version History

Original

Introduced

5.6

Added DOUBLE and ITER keywords

See Also

BESELI, BESELK, BESELY