Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.

  >  Docs Center  >  IDL Reference  >  Math - Special Functions  >  BESELJ



The BESELJ function returns the J Bessel function of order N for the argument X.


The following lines create the map shown at the top of this topic.

; Plot the J and Y Bessel functions for orders 0, 1, and 2
X = FINDGEN(100)/10
; Plot J and Y Bessel Functions
pj0 = PLOT(X, BESELJ(X, 0), '2', $
  XTITLE='X', YTITLE='$J_n(x)$ or $Y_n(x)$', $
  TITLE='J and Y Bessel Functions', YRANGE=[-0.5,1])
pj1 = PLOT(X, BESELJ(X, 1), 'r2', /OVERPLOT)
pj2 = PLOT(X, BESELJ(X, 2), 'b2', /OVERPLOT)
py0 = PLOT(X, BESELY(X, 0), "--2", /OVERPLOT)
py1 = PLOT(X, BESELY(X, 1), "r--2", /OVERPLOT)
py2 = PLOT(X, BESELY(X, 2), "b--2", /OVERPLOT)
; Annotate the plot
xcoords = [1, 1.66, 3, .7, 1.7, 2.65]
ycoords = [.8, .62,.52, -.42, -.42, -.42]
labels = '$\it' + ['J_0','J_1','J_2','Y_0','Y_1','Y_2'] + '$'
t = TEXT(xcoords, ycoords, labels, /DATA)


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.



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


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.



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.


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.

Version History




Added DOUBLE and ITER keywords

Resources and References

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.

See Also


© 2018 Harris Geospatial Solutions, Inc. |  Privacy Policy
My Account    |    Store    |    Contact Us