i1.c
Go to the documentation of this file.
1 /* i1.c
2  *
3  * Modified Bessel function of order one
4  *
5  *
6  *
7  * SYNOPSIS:
8  *
9  * double x, y, i1();
10  *
11  * y = i1( x );
12  *
13  *
14  *
15  * DESCRIPTION:
16  *
17  * Returns modified Bessel function of order one of the
18  * argument.
19  *
20  * The function is defined as i1(x) = -i j1( ix ).
21  *
22  * The range is partitioned into the two intervals [0,8] and
23  * (8, infinity). Chebyshev polynomial expansions are employed
24  * in each interval.
25  *
26  *
27  *
28  * ACCURACY:
29  *
30  * Relative error:
31  * arithmetic domain # trials peak rms
32  * IEEE 0, 30 30000 1.9e-15 2.1e-16
33  *
34  *
35  */
36  /* i1e.c
37  *
38  * Modified Bessel function of order one,
39  * exponentially scaled
40  *
41  *
42  *
43  * SYNOPSIS:
44  *
45  * double x, y, i1e();
46  *
47  * y = i1e( x );
48  *
49  *
50  *
51  * DESCRIPTION:
52  *
53  * Returns exponentially scaled modified Bessel function
54  * of order one of the argument.
55  *
56  * The function is defined as i1(x) = -i exp(-|x|) j1( ix ).
57  *
58  *
59  *
60  * ACCURACY:
61  *
62  * Relative error:
63  * arithmetic domain # trials peak rms
64  * IEEE 0, 30 30000 2.0e-15 2.0e-16
65  * See i1().
66  *
67  */
68 
69 /* i1.c 2 */
70 
71 
72 /*
73  * Cephes Math Library Release 2.8: June, 2000
74  * Copyright 1985, 1987, 2000 by Stephen L. Moshier
75  */
76 
77 #include "mconf.h"
78 
79 /* Chebyshev coefficients for exp(-x) I1(x) / x
80  * in the interval [0,8].
81  *
82  * lim(x->0){ exp(-x) I1(x) / x } = 1/2.
83  */
84 
85 static double A[] = {
86  2.77791411276104639959E-18,
87  -2.11142121435816608115E-17,
88  1.55363195773620046921E-16,
89  -1.10559694773538630805E-15,
90  7.60068429473540693410E-15,
91  -5.04218550472791168711E-14,
92  3.22379336594557470981E-13,
93  -1.98397439776494371520E-12,
94  1.17361862988909016308E-11,
95  -6.66348972350202774223E-11,
96  3.62559028155211703701E-10,
97  -1.88724975172282928790E-9,
98  9.38153738649577178388E-9,
99  -4.44505912879632808065E-8,
100  2.00329475355213526229E-7,
101  -8.56872026469545474066E-7,
102  3.47025130813767847674E-6,
103  -1.32731636560394358279E-5,
104  4.78156510755005422638E-5,
105  -1.61760815825896745588E-4,
106  5.12285956168575772895E-4,
107  -1.51357245063125314899E-3,
108  4.15642294431288815669E-3,
109  -1.05640848946261981558E-2,
110  2.47264490306265168283E-2,
111  -5.29459812080949914269E-2,
112  1.02643658689847095384E-1,
113  -1.76416518357834055153E-1,
114  2.52587186443633654823E-1
115 };
116 
117 /* Chebyshev coefficients for exp(-x) sqrt(x) I1(x)
118  * in the inverted interval [8,infinity].
119  *
120  * lim(x->inf){ exp(-x) sqrt(x) I1(x) } = 1/sqrt(2pi).
121  */
122 static double B[] = {
123  7.51729631084210481353E-18,
124  4.41434832307170791151E-18,
125  -4.65030536848935832153E-17,
126  -3.20952592199342395980E-17,
127  2.96262899764595013876E-16,
128  3.30820231092092828324E-16,
129  -1.88035477551078244854E-15,
130  -3.81440307243700780478E-15,
131  1.04202769841288027642E-14,
132  4.27244001671195135429E-14,
133  -2.10154184277266431302E-14,
134  -4.08355111109219731823E-13,
135  -7.19855177624590851209E-13,
136  2.03562854414708950722E-12,
137  1.41258074366137813316E-11,
138  3.25260358301548823856E-11,
139  -1.89749581235054123450E-11,
140  -5.58974346219658380687E-10,
141  -3.83538038596423702205E-9,
142  -2.63146884688951950684E-8,
143  -2.51223623787020892529E-7,
144  -3.88256480887769039346E-6,
145  -1.10588938762623716291E-4,
146  -9.76109749136146840777E-3,
147  7.78576235018280120474E-1
148 };
149 
150 double i1(double x)
151 {
152  double y, z;
153 
154  z = fabs(x);
155  if (z <= 8.0) {
156  y = (z / 2.0) - 2.0;
157  z = chbevl(y, A, 29) * z * exp(z);
158  }
159  else {
160  z = exp(z) * chbevl(32.0 / z - 2.0, B, 25) / sqrt(z);
161  }
162  if (x < 0.0)
163  z = -z;
164  return (z);
165 }
166 
167 /* i1e() */
168 
169 double i1e(double x)
170 {
171  double y, z;
172 
173  z = fabs(x);
174  if (z <= 8.0) {
175  y = (z / 2.0) - 2.0;
176  z = chbevl(y, A, 29) * z;
177  }
178  else {
179  z = chbevl(32.0 / z - 2.0, B, 25) / sqrt(z);
180  }
181  if (x < 0.0)
182  z = -z;
183  return (z);
184 }
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
B
Definition: test_numpy_dtypes.cpp:299
exp
const EIGEN_DEVICE_FUNC ExpReturnType exp() const
Definition: ArrayCwiseUnaryOps.h:97
chbevl
double chbevl(double x, double array[], int n)
Definition: chbevl.c:63
boost::multiprecision::fabs
Real fabs(const Real &a)
Definition: boostmultiprec.cpp:119
A
Definition: test_numpy_dtypes.cpp:298
pybind_wrapper_test_script.z
z
Definition: pybind_wrapper_test_script.py:61
i1e
double i1e(double x)
Definition: i1.c:169
y
Scalar * y
Definition: level1_cplx_impl.h:124
mconf.h
i1
double i1(double x)
Definition: i1.c:150
ceres::sqrt
Jet< T, N > sqrt(const Jet< T, N > &f)
Definition: jet.h:418


gtsam
Author(s):
autogenerated on Thu Jun 13 2024 03:02:34