home *** CD-ROM | disk | FTP | other *** search
- bessj(x1,b1,y1)
-
- /* function to find the Bessel J function of integer or */
- /* fractional order for any x greater than zero. */
-
- float x1,b1,*y1;
-
- {
-
- int ib1,iflag;
- float c[6],d[6],a,aa,bb,bbo,a1,b,c1,p1,t,t2,term1,x,xx1,y,yy1,z1;
- static float
- s[26]={-3.375,54.4921875,-272.953125,354.375,-2.0625,
- 13.7578125,-19.6875,-1.0625,1.875,-.375,.0030381944,
- -.4861111111,10.28645833333,-58.,78.75,
- .0005580357,-.4241071428,3.6026785714,-5.625,.0125,
- -.35,.75,.0416666666,.25,3.1415926535,1.5707963267};
- extern double cos(),fabs(),pow(),sqrt();
-
-
- *y1 = 0.0;
- if(b1 < 0.0) return;
- if(x1 < 8.0)
- {
- c1 = b1 + 1.;
- gamma(c1,&z1);
- term1 = pow((x1*0.5),b1)/z1;
- p1 = 1.;
- *y1 = term1;
- while((fabs(*y1) * .00000000001) <= fabs(term1))
- {
- term1 = -term1 * x1 * x1 / (4.0 * (b1 + p1) * p1);
- *y1 = *y1 + term1;
- p1 = p1 + 1.;
- }
- return;
- }
- if(b1 <= 1.)
- {
- iflag = 1;
- x = x1;
- b = b1;
- y = *y1;
- }
- else
- {
- ib1 = b1;
- a1 = b1 - ib1;
- iflag = 2;
- x = x1;
- b = a1;
- xx1 = 0.;
- y = xx1;
- }
- reit: ;
- a = b * b - 0.25;
- t = 1./x;
- t2 = t * t;
- c[0] = (((s[0] * a + s[1]) * a + s[2]) * a +s[3]) * a;
- c[1] = ((s[4] * a + s[5]) * a + s[6]) * a;
- c[2] = (s[7] * a + s[8]) * a;
- c[3] = s[9] * a;
- bbo = (((c[0] * t2 + c[1]) * t2 + c[2]) * t2 + c[3]) * t2 * t2 + 1.;
- bb = bbo * sqrt(2. * t / (s[24] * sqrt(1. - a * t2)));
- d[0] = ((((s[10] * a + s[11]) * a + s[12]) * a + s[13]) * a + s[14])*a;
- d[1] = (((s[15] * a + s[16]) * a + s[17]) * a + s[18]) * a;
- d[2] = ((s[19] * a + s[20]) * a + s[21]) * a;
- d[3] = (s[22] * a + s[23]) * a;
- d[4] = .5 * a;
- aa = ((((d[0]* t2+ d[1])* t2+ d[2])* t2+ d[3])* t2 +d[4])* t2+1.;
- aa = aa * x - (b + .5) * s[25];
- y = bb * cos(aa);
- if(iflag == 1) return;
- if(iflag == 2)
- {
- p1 = a1 - 1.;
- iflag = 3;
- x = x1;
- b = p1;
- yy1 = 0.;
- y = yy1;
- goto reit;
- }
- while(a1 != b1)
- {
- *y1 = 2. * pow(a1,x1) / x1 - yy1;
- if(a1 == 0) *y1 = 0;
- a1 = a1 + 1.;
- yy1 = xx1;
- xx1 = *y1;
- }
- }