3
* Bessel function of integer order
18
* Returns Bessel function of order n, where n is a
19
* (possibly negative) integer.
21
* The ratio of jn(x) to j0(x) is computed by backward
22
* recurrence. First the ratio jn/jn-1 is found by a
23
* continued fraction expansion. Then the recurrence
24
* relating successive orders is applied until j0 or j1 is
27
* If n = 0 or 1 the routine for j0 or j1 is called
35
* arithmetic range # trials peak rms
36
* DEC 0, 30 5500 6.9e-17 9.3e-18
37
* IEEE 0, 30 5000 4.4e-16 7.9e-17
40
* Not suitable for large n or x. Use jv() instead.
45
Cephes Math Library Release 2.8: June, 2000
46
Copyright 1984, 1987, 2000 by Stephen L. Moshier
50
extern double fabs ( double );
51
extern double j0 ( double );
52
extern double j1 ( double );
54
double fabs(), j0(), j1();
62
double pkm2, pkm1, pk, xk, r, ans;
68
if( (n & 1) == 0 ) /* -1**n */
84
return( sign * j0(x) );
86
return( sign * j1(x) );
90
return sign * 0.125 * y * (1 - y / 12.);
92
return( sign * (2.0 * j1(x) / x - j0(x)) );
99
/* continued fraction */
118
/* backward recurrence */
127
pkm2 = (pkm1 * r - pk * x) / x;
134
if( fabs(pk) > fabs(pkm1) )
138
return( sign * ans );