test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HankelFunction.cc
Go to the documentation of this file.
1 /*
2 
3 Nikolai Amelin, Ludmila Malinina, Timur Pocheptsov (C) JINR/Dubna
4 amelin@sunhe.jinr.ru, malinina@sunhe.jinr.ru, pocheptsov@sunhe.jinr.ru
5 November. 2, 2005
6 
7 */
8 
9 #include <TMath.h>
10 
12 
13 //compute Hankel function of zeroth order
14 enum {kNe = 2, kNCoeff = 9};
15 
16 const double i0Coefficient[kNCoeff][kNe] =
17  {
18  //coefficients to compute function I0
19  {1.0, 0.39894228},
20  {3.5156229, 0.01328592},
21  {3.0899424, 0.00225319},
22  {1.2067492, -0.00157565},
23  {0.2659732, 0.00916281},
24  {0.0360768, -0.02057706},
25  {0.0045813, 0.02635537},
26  {0., -0.01647633},
27  {0., 0.00392377}
28  };
29 
30 const double i1Coefficient[kNCoeff][kNe] =
31  {
32  //coefficients to compute function I1
33  {0.5, 0.39894228},
34  {0.87890594, -0.03988024},
35  {0.51498869, -0.00362018},
36  {0.15084934, 0.00163801},
37  {0.02658733, -0.01031555},
38  {0.00301532, 0.02282967},
39  {0.00032411, -0.02895312},
40  {0., 0.01787654},
41  {0., -0.00420059}
42  };
43 
44 const double k0Coefficient[kNCoeff][kNe] =
45  {
46  //coefficients to compute modified Hankel function of the zeroth order K0
47  {-0.57721566, 1.25331414},
48  {0.42278420, -0.07832358},
49  {0.23069756, 0.02189568},
50  {0.03488590, -0.01062446},
51  {0.00262698, 0.00587872},
52  {0.00010750, -0.00251540},
53  {0.0000074, 0.00053208},
54  {0., 0. },
55  {0., 0. }
56  };
57 
58 const double k1Coefficient[kNCoeff][kNe] =
59  {
60  //coefficients to compute modified Hankel function of the first order K1
61  {1.0, 1.25331414},
62  {0.15443144, 0.23498619},
63  {-0.67278579, -0.03655620},
64  {-0.18156897, 0.01504268},
65  {-0.01919402, -0.00780353},
66  {-0.00110404, 0.00325614},
67  {-0.00004686, -0.00068245},
68  { 0., 0. },
69  { 0., 0. }
70  };
71 
72 double BesselI0(double x) {
73  // (C) Copr. 1986-92 Numerical Recipes Software +7.
74  //compute Bessel function of zeroth order
75 
76  const double p1 = i0Coefficient[0][0];
77  const double p2 = i0Coefficient[1][0];
78  const double p3 = i0Coefficient[2][0];
79  const double p4 = i0Coefficient[3][0];
80  const double p5 = i0Coefficient[4][0];
81  const double p6 = i0Coefficient[5][0];
82  const double p7 = i0Coefficient[6][0];
83 
84  const double q1 = i0Coefficient[0][1];
85  const double q2 = i0Coefficient[1][1];
86  const double q3 = i0Coefficient[2][1];
87  const double q4 = i0Coefficient[3][1];
88  const double q5 = i0Coefficient[4][1];
89  const double q6 = i0Coefficient[5][1];
90  const double q7 = i0Coefficient[6][1];
91  const double q8 = i0Coefficient[7][1];
92  const double q9 = i0Coefficient[8][1];
93 
94  double i0 = 0.;
95 
96  if(TMath::Abs(x) < 3.75) {
97  double y = (x / 3.75) * (x / 3.75);
98  i0 = p1 + y * (p2 + y * (p3 + y * (p4 + y * (p5 + y * (p6 + y * p7)))));
99  }
100  else {
101  double ax = TMath::Abs(x);
102  double y = 3.75 / ax;
103  i0 = (TMath::Exp(ax)/TMath::Sqrt(ax))*(q1 + y*(q2 + y*(q3 + y*(q4 + y*(q5 + y*(q6 + y*(q7 + y*(q8 + y*q9))))))));
104  }
105 
106  return i0;
107 }
108 
109 double BesselI1(double x) {
110  // (C) Copr. 1986-92 Numerical Recipes Software +7.
111  //compute Bessel function of first order
112 
113  const double p1 = i1Coefficient[0][0];
114  const double p2 = i1Coefficient[1][0];
115  const double p3 = i1Coefficient[2][0];
116  const double p4 = i1Coefficient[3][0];
117  const double p5 = i1Coefficient[4][0];
118  const double p6 = i1Coefficient[5][0];
119  const double p7 = i1Coefficient[6][0];
120 
121  const double q1 = i1Coefficient[0][1];
122  const double q2 = i1Coefficient[1][1];
123  const double q3 = i1Coefficient[2][1];
124  const double q4 = i1Coefficient[3][1];
125  const double q5 = i1Coefficient[4][1];
126  const double q6 = i1Coefficient[5][1];
127  const double q7 = i1Coefficient[6][1];
128  const double q8 = i1Coefficient[7][1];
129  const double q9 = i1Coefficient[8][1];
130 
131  double i1 = 0.;
132 
133  if (TMath::Abs(x) < 3.75) {
134  double y = (x / 3.75) * (x / 3.75);
135  i1 = x * (p1 + y * (p2 + y * (p3 + y * (p4 + y * (p5 + y * (p6 + y * p7))))));
136  }
137  else {
138  double ax = TMath::Abs(x);
139  double y = 3.75/ax;
140  i1 = (TMath::Exp(ax)/TMath::Sqrt(ax))*(q1 + y*(q2 + y*(q3 + y*(q4 + y*(q5 + y*(q6 + y*(q7 + y*(q8 + y*q9))))))));
141  if(x < 0.) i1 = -i1;
142  }
143 
144  return i1;
145 }
146 
147 double HankelK0(double x) {
148  const double p1 = k0Coefficient[0][0];
149  const double p2 = k0Coefficient[1][0];
150  const double p3 = k0Coefficient[2][0];
151  const double p4 = k0Coefficient[3][0];
152  const double p5 = k0Coefficient[4][0];
153  const double p6 = k0Coefficient[5][0];
154  const double p7 = k0Coefficient[6][0];
155 
156  const double q1 = k0Coefficient[0][1];
157  const double q2 = k0Coefficient[1][1];
158  const double q3 = k0Coefficient[2][1];
159  const double q4 = k0Coefficient[3][1];
160  const double q5 = k0Coefficient[4][1];
161  const double q6 = k0Coefficient[5][1];
162  const double q7 = k0Coefficient[6][1];
163 
164  double k0 = 0.;
165  if(x <= 2.0) {
166  double y = x * x / 4.0;
167  k0 = (-TMath::Log(x/2.0)*BesselI0(x)) + (p1 + y*(p2 + y*(p3 + y*(p4 + y*(p5 + y*(p6 + y*p7))))));
168  }
169  else {
170  double y = (2.0 / x);
171  k0 = (TMath::Exp(-x)/TMath::Sqrt(x))*(q1 + y*(q2 + y*(q3 + y*(q4 + y*(q5 + y*(q6 + y*q7))))));
172  }
173 
174  return k0;
175 }
176 
177 double HankelK1(double x) {
178  // (C) Copr. 1986-92 Numerical Recipes Software +7.
179  // compute modified Hankel function of the first order
180  const double p1 = k1Coefficient[0][0];
181  const double p2 = k1Coefficient[1][0];
182  const double p3 = k1Coefficient[2][0];
183  const double p4 = k1Coefficient[3][0];
184  const double p5 = k1Coefficient[4][0];
185  const double p6 = k1Coefficient[5][0];
186  const double p7 = k1Coefficient[6][0];
187 
188  const double q1 = k1Coefficient[0][1];
189  const double q2 = k1Coefficient[1][1];
190  const double q3 = k1Coefficient[2][1];
191  const double q4 = k1Coefficient[3][1];
192  const double q5 = k1Coefficient[4][1];
193  const double q6 = k1Coefficient[5][1];
194  const double q7 = k1Coefficient[6][1];
195 
196  double k1 = 0.;
197 
198  if(x <= 2.0) {
199  double y = x * x / 4.0;
200  k1 = (TMath::Log(x/2.0)*BesselI1(x)) + (1.0/x)*(p1 + y*(p2 + y*(p3 + y*(p4 + y*(p5 + y*(p6 + y*p7))))));
201  }
202  else {
203  double y = 2.0 / x;
204  k1 = (TMath::Exp(-x)/TMath::Sqrt(x))*(q1 + y*(q2 + y*(q3 + y*(q4 + y*(q5 + y*(q6 + y*q7))))));
205  }
206 
207  return k1;
208 }
209 
210 double HankelKn(int n, double x) {
211  // (C) Copr. 1986-92 Numerical Recipes Software +7.
212  // compute modified Hankel function of the first order
213  if(n < 2) throw "Bad argument n in Kn";
214 
215  double tox = 2.0 / x;
216  double km = HankelK0(x);
217  double k = HankelK1(x);
218  double kp = 0.;
219 
220  for(int c = 1; c <= n-1; ++c) {
221  kp = km + c * tox * k;
222  km = k;
223  k = kp;
224  }
225 
226  return k;
227 }
228 
int kp
double HankelK0(double x)
double BesselI0(double x)
double HankelKn(int n, double x)
double q2[4]
Definition: TauolaWrapper.h:88
const double i1Coefficient[kNCoeff][kNe]
const double k0Coefficient[kNCoeff][kNe]
T x() const
Cartesian x coordinate.
double p4[4]
Definition: TauolaWrapper.h:92
T Abs(T a)
Definition: MathUtil.h:49
const double k1Coefficient[kNCoeff][kNe]
double p2[4]
Definition: TauolaWrapper.h:90
double HankelK1(double x)
const double i0Coefficient[kNCoeff][kNe]
double q1[4]
Definition: TauolaWrapper.h:87
double p1[4]
Definition: TauolaWrapper.h:89
double BesselI1(double x)
double p3[4]
Definition: TauolaWrapper.h:91