j0(), j1(), jn() — Bessel functions of the first kind

Standards

Standards / Extensions C or C++ Dependencies

SAA
XPG4
XPG4.2
Single UNIX Specification, Version 3

both  

Format

#include <math.h>

double j0(double x);

double j1(double x);

double jn(int n, double x);
Compiler option: LANGLVL(SAA), LANGLVL(SAAL2), or LANGLVL(EXTENDED)

General description

The j0(), j1(), and jn() functions are Bessel functions of the first kind, for orders 0, 1, and n, respectively. Bessel functions are solutions to certain types of differential equations. The argument x must be positive. The argument n should be greater than or equal to 0. If n is less than 0, there will be a negative exponent in the result.
Note: This function works in both IEEE Binary Floating-Point and hexadecimal floating-point formats. See IEEE binary floating-point for more information about IEEE Binary Floating-Point.

Returned value

If successful, the calculated value is returned.

For j0(), j1(), y0(), or y1(), if the absolute value of x is too large, the function sets errno to ERANGE to indicate a value that is out of range, and returns 0.

Special behavior for IEEE: If x is negative, y0(), y1(), and yn() return the value NaNQ. If x is 0, y0(), y1(), and yn() return the value -HUGE_VAL. In all cases, errno remains unchanged.

Example

CELEBJ01
⁄* CELEBJ01                                       

   This example computes y to be the order 0 Bessel function of                 
   the first kind for x, and z to be the order 3 Bessel function                
   of the second kind for x.                                                    
                                                                                
 *⁄                                                                             
#include <math.h>                                                               
#include <stdio.h>                                                              
                                                                                
int main(void)                                                                  
{                                                                               
    double x, y, z;                                                             
    x = 4.27;                                                                   
                                                                                
    y = j0(x);      ⁄* y = -0.3660 is the order 0 bessel *⁄                     
                     ⁄* function of the first kind for x  *⁄                    
    z = yn(3,x);    ⁄* z = -0.0875 is the order 3 bessel *⁄                     
                     ⁄* function of the second kind for x *⁄                    
    printf("x = %f\n  y = %f\n  z = %f\n", x, y, z);                            
}                                                                               

Related information