|
3 | 3 | #
|
4 | 4 | # Calculation of besselj0 is done in three branches using polynomial approximations
|
5 | 5 | #
|
6 |
| -# Branch 1: x <= 5.0 |
7 |
| -# besselj0 = (x^2 - r1^2)*(x^2 - r2^2)*P3(x^2) / Q8(x^2) |
8 |
| -# where r1 and r2 are zeros of J0 |
9 |
| -# and P3 and Q8 are a 3 and 8 degree polynomial respectively |
10 |
| -# Polynomial coefficients are from [1] which is based on [2] |
11 |
| -# For tiny arugments the power series expansion is used. |
| 6 | +# Branch 1: x <= pi/2 |
| 7 | +# besselj0 is calculated using a 9 term, even minimax polynomial |
12 | 8 | #
|
13 |
| -# Branch 2: 5.0 < x < 25.0 |
14 |
| -# besselj0 = sqrt(2/(pi*x))*(cos(x - pi/4)*R7(x) - sin(x - pi/4)*R8(x)) |
15 |
| -# Hankel's asymptotic expansion is used |
16 |
| -# where R7 and R8 are rational functions (Pn(x)/Qn(x)) of degree 7 and 8 respectively |
17 |
| -# See section 4 of [3] for more details and [1] for coefficients of polynomials |
| 9 | +# Branch 1: pi/2 < x < 26.0 |
| 10 | +# besselj0 is calculated by one of 16 different degree 13 minimax polynomials |
| 11 | +# Each polynomial is an expansion around either a root or extrema of the besselj0. |
| 12 | +# This ensures accuracy near the roots. Method taken from [2] |
18 | 13 | #
|
19 |
| -# Branch 3: x >= 25.0 |
| 14 | +# Branch 2: x >= 26.0 |
20 | 15 | # besselj0 = sqrt(2/(pi*x))*beta(x)*(cos(x - pi/4 - alpha(x))
|
21 |
| -# See modified expansions given in [3]. Exact coefficients are used |
| 16 | +# See modified expansions given in [2]. Exact coefficients are used |
22 | 17 | #
|
23 | 18 | # Calculation of besselj1 is done in a similar way as besselj0.
|
24 |
| -# See [3] for details on similarities. |
| 19 | +# See [2] for details on similarities. |
25 | 20 | #
|
26 | 21 | # [1] https://github.com/deepmind/torch-cephes
|
27 |
| -# [2] Cephes Math Library Release 2.8: June, 2000 by Stephen L. Moshier |
28 |
| -# [3] Harrison, John. "Fast and accurate Bessel function computation." |
| 22 | +# [2] Harrison, John. "Fast and accurate Bessel function computation." |
29 | 23 | # 2009 19th IEEE Symposium on Computer Arithmetic. IEEE, 2009.
|
30 | 24 | #
|
31 | 25 |
|
32 |
| -#poly = Float64.(Tuple(ratfn_minimax(x->r(x,pts[i]), ((pts[i][1]-pts[i-1][1])/2, (pts[i][1]-pts[i+1][1])/2), 13, 0)[1])) |
33 |
| - |
34 | 26 | const PTS = (( 2.404825557695773 , -1.176691651530894e-16),
|
35 | 27 | ( 3.8317059702075125, -1.5269184090088067e-16),
|
36 | 28 | ( 5.520078110286311 , 8.088597146146722e-17),
|
|
0 commit comments