1math::special(n) Tcl Math Library math::special(n)
2
3
4
5______________________________________________________________________________
6
8 math::special - Special mathematical functions
9
11 package require Tcl ?8.3?
12
13 package require math::special ?0.2?
14
15 ::math::special::Beta x y
16
17 ::math::special::Gamma x y
18
19 ::math::special::erf x
20
21 ::math::special::erfc x
22
23 ::math::special::J0 x
24
25 ::math::special::J1 x
26
27 ::math::special::Jn n x
28
29 ::math::special::J1/2 x
30
31 ::math::special::J-1/2 x
32
33 ::math::special::I_n x
34
35 ::math::special::cn u k
36
37 ::math::special::dn u k
38
39 ::math::special::sn u k
40
41 ::math::special::elliptic_K k
42
43 ::math::special::elliptic_E k
44
45 ::math::special::exponential_Ei x
46
47 ::math::special::exponential_En n x
48
49 ::math::special::exponential_li x
50
51 ::math::special::exponential_Ci x
52
53 ::math::special::exponential_Si x
54
55 ::math::special::exponential_Chi x
56
57 ::math::special::exponential_Shi x
58
59 ::math::special::fresnel_C x
60
61 ::math::special::fresnel_S x
62
63 ::math::special::sinc x
64
65 ::math::special::legendre n
66
67 ::math::special::chebyshev n
68
69 ::math::special::laguerre alpha n
70
71 ::math::special::hermite n
72
73_________________________________________________________________
74
76 This package implements several so-called special functions, like the
77 Gamma function, the Bessel functions and such.
78
79 Each function is implemented by a procedure that bears its name (well,
80 in close approximation):
81
82 · J0 for the zeroth-order Bessel function of the first kind
83
84 · J1 for the first-order Bessel function of the first kind
85
86 · Jn for the nth-order Bessel function of the first kind
87
88 · J1/2 for the half-order Bessel function of the first kind
89
90 · J-1/2 for the minus-half-order Bessel function of the first kind
91
92 · I_n for the modified Bessel function of the first kind of order
93 n
94
95 · Gamma for the Gamma function, erf and erfc for the error func‐
96 tion and the complementary error function
97
98 · fresnel_C and fresnel_S for the Fresnel integrals
99
100 · elliptic_K and elliptic_E (complete elliptic integrals)
101
102 · exponent_Ei and other functions related to the so-called expo‐
103 nential integrals
104
105 · legendre, hermite: some of the classical orthogonal polynomials.
106
108 In the following table several characteristics of the functions in this
109 package are summarized: the domain for the argument, the values for the
110 parameters and error bounds.
111
112 Family | Function | Domain x | Parameter | Error bound
113 -------------+-------------+-------------+-------------+--------------
114 Bessel | J0, J1, | all of R | n = integer | < 1.0e-8
115 | Jn | | | (|x|<20, n<20)
116 Bessel | J1/2, J-1/2,| x > 0 | n = integer | exact
117 Bessel | I_n | all of R | n = integer | < 1.0e-6
118 | | | |
119 Elliptic | cn | 0 <= x <= 1 | -- | < 1.0e-10
120 functions | dn | 0 <= x <= 1 | -- | < 1.0e-10
121 | sn | 0 <= x <= 1 | -- | < 1.0e-10
122 Elliptic | K | 0 <= x < 1 | -- | < 1.0e-6
123 integrals | E | 0 <= x < 1 | -- | < 1.0e-6
124 | | | |
125 Error | erf | | -- |
126 functions | erfc | | |
127 | ierfc_n | | |
128 | | | |
129 Exponential | Ei | x != 0 | -- | < 1.0e-10 (relative)
130 integrals | En | x > 0 | -- | as Ei
131 | li | x > 0 | -- | as Ei
132 | Chi | x > 0 | -- | < 1.0e-8
133 | Shi | x > 0 | -- | < 1.0e-8
134 | Ci | x > 0 | -- | < 2.0e-4
135 | Si | x > 0 | -- | < 2.0e-4
136 | | | |
137 Fresnel | C | all of R | -- | < 2.0e-3
138 integrals | S | all of R | -- | < 2.0e-3
139 | | | |
140 general | Beta | (see Gamma) | -- | < 1.0e-9
141 | Gamma | x != 0,-1, | -- | < 1.0e-9
142 | | -2, ... | |
143 | sinc | all of R | -- | exact
144 | | | |
145 orthogonal | Legendre | all of R | n = 0,1,... | exact
146 polynomials | Chebyshev | all of R | n = 0,1,... | exact
147 | Laguerre | all of R | n = 0,1,... | exact
148 | | | alpha el. R |
149 | Hermite | all of R | n = 0,1,... | exact
150
151 Note: Some of the error bounds are estimated, as no "formal" bounds
152 were available with the implemented approximation method, others hold
153 for the auxiliary functions used for estimating the primary functions.
154
155 The following well-known functions are currently missing from the pack‐
156 age:
157
158 · Bessel functions of the second kind (Y_n, K_n)
159
160 · Bessel functions of arbitrary order (and hence the Airy func‐
161 tions)
162
163 · Chebyshev polynomials of the second kind (U_n)
164
165 · The digamma function (psi)
166
167 · The incomplete gamma and beta functions
168
170 The package defines the following public procedures:
171
172 ::math::special::Beta x y
173 Compute the Beta function for arguments "x" and "y"
174
175 float x
176 First argument for the Beta function
177
178 float y
179 Second argument for the Beta function
180
181
182 ::math::special::Gamma x y
183 Compute the Gamma function for argument "x"
184
185 float x
186 Argument for the Gamma function
187
188
189 ::math::special::erf x
190 Compute the error function for argument "x"
191
192 float x
193 Argument for the error function
194
195
196 ::math::special::erfc x
197 Compute the complementary error function for argument "x"
198
199 float x
200 Argument for the complementary error function
201
202
203 ::math::special::J0 x
204 Compute the zeroth-order Bessel function of the first kind for
205 the argument "x"
206
207 float x
208 Argument for the Bessel function
209
210 ::math::special::J1 x
211 Compute the first-order Bessel function of the first kind for
212 the argument "x"
213
214 float x
215 Argument for the Bessel function
216
217 ::math::special::Jn n x
218 Compute the nth-order Bessel function of the first kind for the
219 argument "x"
220
221 integer n
222 Order of the Bessel function
223
224 float x
225 Argument for the Bessel function
226
227 ::math::special::J1/2 x
228 Compute the half-order Bessel function of the first kind for the
229 argument "x"
230
231 float x
232 Argument for the Bessel function
233
234 ::math::special::J-1/2 x
235 Compute the minus-half-order Bessel function of the first kind
236 for the argument "x"
237
238 float x
239 Argument for the Bessel function
240
241 ::math::special::I_n x
242 Compute the modified Bessel function of the first kind of order
243 n for the argument "x"
244
245 int x Positive integer order of the function
246
247 float x
248 Argument for the function
249
250 ::math::special::cn u k
251 Compute the elliptic function cn for the argument "u" and param‐
252 eter "k".
253
254 float u
255 Argument for the function
256
257 float k
258 Parameter
259
260 ::math::special::dn u k
261 Compute the elliptic function dn for the argument "u" and param‐
262 eter "k".
263
264 float u
265 Argument for the function
266
267 float k
268 Parameter
269
270 ::math::special::sn u k
271 Compute the elliptic function sn for the argument "u" and param‐
272 eter "k".
273
274 float u
275 Argument for the function
276
277 float k
278 Parameter
279
280 ::math::special::elliptic_K k
281 Compute the complete elliptic integral of the first kind for the
282 argument "k"
283
284 float k
285 Argument for the function
286
287 ::math::special::elliptic_E k
288 Compute the complete elliptic integral of the second kind for
289 the argument "k"
290
291 float k
292 Argument for the function
293
294 ::math::special::exponential_Ei x
295 Compute the exponential integral of the second kind for the
296 argument "x"
297
298 float x
299 Argument for the function (x != 0)
300
301 ::math::special::exponential_En n x
302 Compute the exponential integral of the first kind for the argu‐
303 ment "x" and order n
304
305 int n Order of the integral (n >= 0)
306
307 float x
308 Argument for the function (x >= 0)
309
310 ::math::special::exponential_li x
311 Compute the logarithmic integral for the argument "x"
312
313 float x
314 Argument for the function (x > 0)
315
316 ::math::special::exponential_Ci x
317 Compute the cosine integral for the argument "x"
318
319 float x
320 Argument for the function (x > 0)
321
322 ::math::special::exponential_Si x
323 Compute the sine integral for the argument "x"
324
325 float x
326 Argument for the function (x > 0)
327
328 ::math::special::exponential_Chi x
329 Compute the hyperbolic cosine integral for the argument "x"
330
331 float x
332 Argument for the function (x > 0)
333
334 ::math::special::exponential_Shi x
335 Compute the hyperbolic sine integral for the argument "x"
336
337 float x
338 Argument for the function (x > 0)
339
340 ::math::special::fresnel_C x
341 Compute the Fresnel cosine integral for real argument x
342
343 float x
344 Argument for the function
345
346 ::math::special::fresnel_S x
347 Compute the Fresnel sine integral for real argument x
348
349 float x
350 Argument for the function
351
352 ::math::special::sinc x
353 Compute the sinc function for real argument x
354
355 float x
356 Argument for the function
357
358 ::math::special::legendre n
359 Return the Legendre polynomial of degree n (see THE ORTHOGONAL
360 POLYNOMIALS)
361
362 int n Degree of the polynomial
363
364
365 ::math::special::chebyshev n
366 Return the Chebyshev polynomial of degree n (of the first kind)
367
368 int n Degree of the polynomial
369
370
371 ::math::special::laguerre alpha n
372 Return the Laguerre polynomial of degree n with parameter alpha
373
374 float alpha
375 Parameter of the Laguerre polynomial
376
377 int n Degree of the polynomial
378
379
380 ::math::special::hermite n
381 Return the Hermite polynomial of degree n
382
383 int n Degree of the polynomial
384
385
387 For dealing with the classical families of orthogonal polynomials, the
388 package relies on the math::polynomials package. To evaluate the poly‐
389 nomial at some coordinate, use the evalPolyn command:
390
391 set leg2 [::math::special::legendre 2]
392 puts "Value at x=$x: [::math::polynomials::evalPolyn $leg2 $x]"
393
394
395 The return value from the legendre and other commands is actually the
396 definition of the corresponding polynomial as used in that package.
397
399 It should be noted, that the actual implementation of J0 and J1 depends
400 on straightforward Gaussian quadrature formulas. The (absolute) accu‐
401 racy of the results is of the order 1.0e-4 or better. The main reason
402 to implement them like that was that it was fast to do (the formulas
403 are simple) and the computations are fast too.
404
405 The implementation of J1/2 does not suffer from this: this function can
406 be expressed exactly in terms of elementary functions.
407
408 The functions J0 and J1 are the ones you will encounter most frequently
409 in practice.
410
411 The computation of I_n is based on Miller's algorithm for computing the
412 minimal function from recurrence relations.
413
414 The computation of the Gamma and Beta functions relies on the combina‐
415 torics package, whereas that of the error functions relies on the sta‐
416 tistics package.
417
418 The computation of the complete elliptic integrals uses the AGM algo‐
419 rithm.
420
421 Much information about these functions can be found in:
422
423 Abramowitz and Stegun: Handbook of Mathematical Functions (Dover, ISBN
424 486-61272-4)
425
427 This document, and the package it describes, will undoubtedly contain
428 bugs and other problems. Please report such in the category math ::
429 special of the Tcllib SF Trackers [http://source‐
430 forge.net/tracker/?group_id=12883]. Please also report any ideas for
431 enhancements you may have for either package and/or documentation.
432
434 Bessel functions, error function, math, special functions
435
437 Copyright (c) 2004 Arjen Markus <arjenmarkus@users.sourceforge.net>
438
439
440
441
442math 0.2 math::special(n)