[3936ad3] | 1 | /* j1.c |
---|
| 2 | * |
---|
| 3 | * Bessel function of order one |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * |
---|
| 7 | * SYNOPSIS: |
---|
| 8 | * |
---|
| 9 | * double x, y, j1(); |
---|
| 10 | * |
---|
| 11 | * y = j1( x ); |
---|
| 12 | * |
---|
| 13 | * |
---|
| 14 | * |
---|
| 15 | * DESCRIPTION: |
---|
| 16 | * |
---|
| 17 | * Returns Bessel function of order one of the argument. |
---|
| 18 | * |
---|
| 19 | * The domain is divided into the intervals [0, 8] and |
---|
| 20 | * (8, infinity). In the first interval a 24 term Chebyshev |
---|
| 21 | * expansion is used. In the second, the asymptotic |
---|
| 22 | * trigonometric representation is employed using two |
---|
| 23 | * rational functions of degree 5/5. |
---|
| 24 | * |
---|
| 25 | * |
---|
| 26 | * |
---|
| 27 | * ACCURACY: |
---|
| 28 | * |
---|
| 29 | * Absolute error: |
---|
| 30 | * arithmetic domain # trials peak rms |
---|
| 31 | * DEC 0, 30 10000 4.0e-17 1.1e-17 |
---|
| 32 | * IEEE 0, 30 30000 2.6e-16 1.1e-16 |
---|
| 33 | * |
---|
| 34 | * |
---|
| 35 | */ |
---|
| 36 | /* y1.c |
---|
| 37 | * |
---|
| 38 | * Bessel function of second kind of order one |
---|
| 39 | * |
---|
| 40 | * |
---|
| 41 | * |
---|
| 42 | * SYNOPSIS: |
---|
| 43 | * |
---|
| 44 | * double x, y, y1(); |
---|
| 45 | * |
---|
| 46 | * y = y1( x ); |
---|
| 47 | * |
---|
| 48 | * |
---|
| 49 | * |
---|
| 50 | * DESCRIPTION: |
---|
| 51 | * |
---|
| 52 | * Returns Bessel function of the second kind of order one |
---|
| 53 | * of the argument. |
---|
| 54 | * |
---|
| 55 | * The domain is divided into the intervals [0, 8] and |
---|
| 56 | * (8, infinity). In the first interval a 25 term Chebyshev |
---|
| 57 | * expansion is used, and a call to j1() is required. |
---|
| 58 | * In the second, the asymptotic trigonometric representation |
---|
| 59 | * is employed using two rational functions of degree 5/5. |
---|
| 60 | * |
---|
| 61 | * |
---|
| 62 | * |
---|
| 63 | * ACCURACY: |
---|
| 64 | * |
---|
| 65 | * Absolute error: |
---|
| 66 | * arithmetic domain # trials peak rms |
---|
| 67 | * DEC 0, 30 10000 8.6e-17 1.3e-17 |
---|
| 68 | * IEEE 0, 30 30000 1.0e-15 1.3e-16 |
---|
| 69 | * |
---|
| 70 | * (error criterion relative when |y1| > 1). |
---|
| 71 | * |
---|
| 72 | */ |
---|
| 73 | |
---|
| 74 | /* |
---|
| 75 | Cephes Math Library Release 2.8: June, 2000 |
---|
| 76 | Copyright 1984, 1987, 1989, 2000 by Stephen L. Moshier |
---|
| 77 | */ |
---|
| 78 | double j1(double ); |
---|
| 79 | |
---|
| 80 | double j1(double x) { |
---|
| 81 | |
---|
[0a9d219] | 82 | //Cephes double pression function |
---|
[07142f3] | 83 | #if FLOAT_SIZE>4 |
---|
[0a9d219] | 84 | |
---|
[3936ad3] | 85 | double w, z, p, q, xn; |
---|
| 86 | |
---|
| 87 | const double DR1 = 5.78318596294678452118E0; |
---|
| 88 | const double DR2 = 3.04712623436620863991E1; |
---|
| 89 | const double Z1 = 1.46819706421238932572E1; |
---|
| 90 | const double Z2 = 4.92184563216946036703E1; |
---|
| 91 | const double THPIO4 = 2.35619449019234492885; |
---|
| 92 | const double SQ2OPI = 0.79788456080286535588; |
---|
| 93 | |
---|
| 94 | double RP[8] = { |
---|
| 95 | -8.99971225705559398224E8, |
---|
| 96 | 4.52228297998194034323E11, |
---|
| 97 | -7.27494245221818276015E13, |
---|
| 98 | 3.68295732863852883286E15, |
---|
| 99 | 0.0, |
---|
| 100 | 0.0, |
---|
| 101 | 0.0, |
---|
| 102 | 0.0 |
---|
| 103 | }; |
---|
| 104 | |
---|
| 105 | double RQ[8] = { |
---|
| 106 | /* 1.00000000000000000000E0,*/ |
---|
| 107 | 6.20836478118054335476E2, |
---|
| 108 | 2.56987256757748830383E5, |
---|
| 109 | 8.35146791431949253037E7, |
---|
| 110 | 2.21511595479792499675E10, |
---|
| 111 | 4.74914122079991414898E12, |
---|
| 112 | 7.84369607876235854894E14, |
---|
| 113 | 8.95222336184627338078E16, |
---|
| 114 | 5.32278620332680085395E18, |
---|
| 115 | }; |
---|
| 116 | |
---|
| 117 | double PP[8] = { |
---|
| 118 | 7.62125616208173112003E-4, |
---|
| 119 | 7.31397056940917570436E-2, |
---|
| 120 | 1.12719608129684925192E0, |
---|
| 121 | 5.11207951146807644818E0, |
---|
| 122 | 8.42404590141772420927E0, |
---|
| 123 | 5.21451598682361504063E0, |
---|
| 124 | 1.00000000000000000254E0, |
---|
| 125 | 0.0, |
---|
| 126 | }; |
---|
| 127 | double PQ[8] = { |
---|
| 128 | 5.71323128072548699714E-4, |
---|
| 129 | 6.88455908754495404082E-2, |
---|
| 130 | 1.10514232634061696926E0, |
---|
| 131 | 5.07386386128601488557E0, |
---|
| 132 | 8.39985554327604159757E0, |
---|
| 133 | 5.20982848682361821619E0, |
---|
| 134 | 9.99999999999999997461E-1, |
---|
| 135 | 0.0, |
---|
| 136 | }; |
---|
| 137 | |
---|
| 138 | double QP[8] = { |
---|
| 139 | 5.10862594750176621635E-2, |
---|
| 140 | 4.98213872951233449420E0, |
---|
| 141 | 7.58238284132545283818E1, |
---|
| 142 | 3.66779609360150777800E2, |
---|
| 143 | 7.10856304998926107277E2, |
---|
| 144 | 5.97489612400613639965E2, |
---|
| 145 | 2.11688757100572135698E2, |
---|
| 146 | 2.52070205858023719784E1, |
---|
| 147 | }; |
---|
| 148 | |
---|
| 149 | double QQ[8] = { |
---|
| 150 | /* 1.00000000000000000000E0,*/ |
---|
| 151 | 7.42373277035675149943E1, |
---|
| 152 | 1.05644886038262816351E3, |
---|
| 153 | 4.98641058337653607651E3, |
---|
| 154 | 9.56231892404756170795E3, |
---|
| 155 | 7.99704160447350683650E3, |
---|
| 156 | 2.82619278517639096600E3, |
---|
| 157 | 3.36093607810698293419E2, |
---|
| 158 | 0.0, |
---|
| 159 | }; |
---|
| 160 | |
---|
| 161 | w = x; |
---|
| 162 | if( x < 0 ) |
---|
| 163 | w = -x; |
---|
| 164 | |
---|
| 165 | if( w <= 5.0 ) |
---|
| 166 | { |
---|
| 167 | z = x * x; |
---|
| 168 | w = polevl( z, RP, 3 ) / p1evl( z, RQ, 8 ); |
---|
| 169 | w = w * x * (z - Z1) * (z - Z2); |
---|
| 170 | return( w ); |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | w = 5.0/x; |
---|
| 174 | z = w * w; |
---|
| 175 | p = polevl( z, PP, 6)/polevl( z, PQ, 6 ); |
---|
| 176 | q = polevl( z, QP, 7)/p1evl( z, QQ, 7 ); |
---|
| 177 | xn = x - THPIO4; |
---|
| 178 | |
---|
| 179 | double sn, cn; |
---|
| 180 | SINCOS(xn, sn, cn); |
---|
| 181 | p = p * cn - w * q * sn; |
---|
| 182 | |
---|
| 183 | return( p * SQ2OPI / sqrt(x) ); |
---|
[0a9d219] | 184 | |
---|
[07142f3] | 185 | |
---|
[0a9d219] | 186 | //Single precission version of cephes |
---|
[07142f3] | 187 | #else |
---|
[0a9d219] | 188 | double xx, w, z, p, q, xn; |
---|
| 189 | |
---|
| 190 | const double Z1 = 1.46819706421238932572E1; |
---|
| 191 | const double THPIO4F = 2.35619449019234492885; /* 3*pi/4 */ |
---|
| 192 | |
---|
| 193 | |
---|
| 194 | double JP[8] = { |
---|
| 195 | -4.878788132172128E-009, |
---|
| 196 | 6.009061827883699E-007, |
---|
| 197 | -4.541343896997497E-005, |
---|
| 198 | 1.937383947804541E-003, |
---|
| 199 | -3.405537384615824E-002, |
---|
| 200 | 0.0, |
---|
| 201 | 0.0, |
---|
| 202 | 0.0 |
---|
| 203 | }; |
---|
| 204 | |
---|
| 205 | double MO1[8] = { |
---|
| 206 | 6.913942741265801E-002, |
---|
| 207 | -2.284801500053359E-001, |
---|
| 208 | 3.138238455499697E-001, |
---|
| 209 | -2.102302420403875E-001, |
---|
| 210 | 5.435364690523026E-003, |
---|
| 211 | 1.493389585089498E-001, |
---|
| 212 | 4.976029650847191E-006, |
---|
| 213 | 7.978845453073848E-001 |
---|
| 214 | }; |
---|
| 215 | |
---|
| 216 | double PH1[8] = { |
---|
| 217 | -4.497014141919556E+001, |
---|
| 218 | 5.073465654089319E+001, |
---|
| 219 | -2.485774108720340E+001, |
---|
| 220 | 7.222973196770240E+000, |
---|
| 221 | -1.544842782180211E+000, |
---|
| 222 | 3.503787691653334E-001, |
---|
| 223 | -1.637986776941202E-001, |
---|
| 224 | 3.749989509080821E-001 |
---|
| 225 | }; |
---|
| 226 | |
---|
| 227 | xx = x; |
---|
| 228 | if( xx < 0 ) |
---|
| 229 | xx = -x; |
---|
| 230 | |
---|
| 231 | if( xx <= 2.0 ) |
---|
| 232 | { |
---|
| 233 | z = xx * xx; |
---|
| 234 | p = (z-Z1) * xx * polevl( z, JP, 4 ); |
---|
| 235 | return( p ); |
---|
| 236 | } |
---|
| 237 | |
---|
| 238 | q = 1.0/x; |
---|
| 239 | w = sqrt(q); |
---|
| 240 | |
---|
| 241 | p = w * polevl( q, MO1, 7); |
---|
| 242 | w = q*q; |
---|
| 243 | xn = q * polevl( w, PH1, 7) - THPIO4F; |
---|
| 244 | p = p * cos(xn + xx); |
---|
| 245 | |
---|
| 246 | return(p); |
---|
[07142f3] | 247 | #endif |
---|
[0a9d219] | 248 | } |
---|
| 249 | |
---|