2 /* @(#)w_jn.c 5.1 93/09/24 */
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7 * Developed at SunPro, a Sun Microsystems, Inc. business.
8 * Permission to use, copy, modify, and distribute this
9 * software is freely granted, provided that this notice
11 * ====================================================
16 <<jN>>, <<jNf>>, <<yN>>, <<yNf>>---Bessel functions
45 double j0(double <[x]>);
46 float j0f(float <[x]>);
47 double j1(double <[x]>);
48 float j1f(float <[x]>);
49 double jn(int <[n]>, double <[x]>);
50 float jnf(int <[n]>, float <[x]>);
51 double y0(double <[x]>);
52 float y0f(float <[x]>);
53 double y1(double <[x]>);
54 float y1f(float <[x]>);
55 double yn(int <[n]>, double <[x]>);
56 float ynf(int <[n]>, float <[x]>);
59 The Bessel functions are a family of functions that solve the
63 . x y'' + xy' + (x - p )y = 0
66 $$x^2{d^2y\over dx^2} + x{dy\over dx} + (x^2-p^2)y = 0$$
68 These functions have many applications in engineering and physics.
70 <<jn>> calculates the Bessel function of the first kind of order
71 <[n]>. <<j0>> and <<j1>> are special cases for order 0 and order
74 Similarly, <<yn>> calculates the Bessel function of the second kind of
75 order <[n]>, and <<y0>> and <<y1>> are special cases for order 0 and
78 <<jnf>>, <<j0f>>, <<j1f>>, <<ynf>>, <<y0f>>, and <<y1f>> perform the
79 same calculations, but on <<float>> rather than <<double>> values.
82 The value of each Bessel function at <[x]> is returned.
85 None of the Bessel functions are in ANSI C.
89 * wrapper jn(int n, double x), yn(int n, double x)
90 * floating point Bessel's function of the 1st and 2nd kind
94 * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal;
95 * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal.
96 * Note 2. About jn(n,x), yn(n,x)
97 * For n=0, j0(x) is called,
98 * for n=1, j1(x) is called,
99 * for n<x, forward recursion us used starting
100 * from values of j0(x) and j1(x).
101 * for n>x, a continued fraction approximation to
102 * j(n,x)/j(n-1,x) is evaluated and then backward
103 * recursion is used starting from a supposed value
104 * for j(n,x). The resulting value of j(0,x) is
105 * compared with the actual value to correct the
106 * supposed value of j(n,x).
108 * yn(n,x) is similar in all respects, except
109 * that forward recursion is used for all
117 #ifndef _DOUBLE_IS_32BITS
120 double jn(int n
, double x
) /* wrapper jn */
122 double jn(n
,x
) /* wrapper jn */
131 if(_LIB_VERSION
== _IEEE_
|| isnan(x
) ) return z
;
132 if(fabs(x
)>X_TLOSS
) {
133 /* jn(|x|>X_TLOSS) */
142 double yn(int n
, double x
) /* wrapper yn */
144 double yn(n
,x
) /* wrapper yn */
153 if(_LIB_VERSION
== _IEEE_
|| isnan(x
) ) return z
;
155 /* yn(n,0) = -inf or yn(x<0) = NaN */
160 SET_HIGH_WORD(inf
,0x7ff00000); /* set inf to infinite */
174 #endif /* defined(_DOUBLE_IS_32BITS) */