1math::special(n)               Tcl Math Library               math::special(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       math::special - Special mathematical functions
9

SYNOPSIS

11       package require Tcl  ?8.3?
12
13       package require math::special  ?0.3?
14
15       ::math::special::Beta x y
16
17       ::math::special::Gamma x
18
19       ::math::special::erf x
20
21       ::math::special::erfc x
22
23       ::math::special::invnorm p
24
25       ::math::special::J0 x
26
27       ::math::special::J1 x
28
29       ::math::special::Jn n x
30
31       ::math::special::J1/2 x
32
33       ::math::special::J-1/2 x
34
35       ::math::special::I_n x
36
37       ::math::special::cn u k
38
39       ::math::special::dn u k
40
41       ::math::special::sn u k
42
43       ::math::special::elliptic_K k
44
45       ::math::special::elliptic_E k
46
47       ::math::special::exponential_Ei x
48
49       ::math::special::exponential_En n x
50
51       ::math::special::exponential_li x
52
53       ::math::special::exponential_Ci x
54
55       ::math::special::exponential_Si x
56
57       ::math::special::exponential_Chi x
58
59       ::math::special::exponential_Shi x
60
61       ::math::special::fresnel_C x
62
63       ::math::special::fresnel_S x
64
65       ::math::special::sinc x
66
67       ::math::special::legendre n
68
69       ::math::special::chebyshev n
70
71       ::math::special::laguerre alpha n
72
73       ::math::special::hermite n
74
75______________________________________________________________________________
76

DESCRIPTION

78       This  package  implements several so-called special functions, like the
79       Gamma function, the Bessel functions and such.
80
81       Each function is implemented by a procedure that bears its name  (well,
82       in close approximation):
83
84       ·      J0 for the zeroth-order Bessel function of the first kind
85
86       ·      J1 for the first-order Bessel function of the first kind
87
88       ·      Jn for the nth-order Bessel function of the first kind
89
90       ·      J1/2 for the half-order Bessel function of the first kind
91
92       ·      J-1/2 for the minus-half-order Bessel function of the first kind
93
94       ·      I_n  for the modified Bessel function of the first kind of order
95              n
96
97       ·      Gamma for the Gamma function, erf and erfc for the  error  func‐
98              tion and the complementary error function
99
100       ·      fresnel_C and fresnel_S for the Fresnel integrals
101
102       ·      elliptic_K and elliptic_E (complete elliptic integrals)
103
104       ·      exponent_Ei  and  other functions related to the so-called expo‐
105              nential integrals
106
107       ·      legendre, hermite: some of the classical orthogonal polynomials.
108

OVERVIEW

110       In the following table several characteristics of the functions in this
111       package are summarized: the domain for the argument, the values for the
112       parameters and error bounds.
113
114
115              Family       | Function    | Domain x    | Parameter   | Error bound
116              -------------+-------------+-------------+-------------+--------------
117              Bessel       | J0, J1,     | all of R    | n = integer |   < 1.0e-8
118                           | Jn          |             |             |  (|x|<20, n<20)
119              Bessel       | J1/2, J-1/2,|  x > 0      | n = integer |   exact
120              Bessel       | I_n         | all of R    | n = integer |   < 1.0e-6
121                           |             |             |             |
122              Elliptic     | cn          | 0 <= x <= 1 |     --      |   < 1.0e-10
123              functions    | dn          | 0 <= x <= 1 |     --      |   < 1.0e-10
124                           | sn          | 0 <= x <= 1 |     --      |   < 1.0e-10
125              Elliptic     | K           | 0 <= x < 1  |     --      |   < 1.0e-6
126              integrals    | E           | 0 <= x < 1  |     --      |   < 1.0e-6
127                           |             |             |             |
128              Error        | erf         |             |     --      |
129              functions    | erfc        |             |             |
130                           |             |             |             |
131              Inverse      | invnorm     | 0 < x < 1   |     --      |   < 1.2e-9
132              normal       |             |             |             |
133              distribution |             |             |             |
134                           |             |             |             |
135              Exponential  | Ei          |  x != 0     |     --      |   < 1.0e-10 (relative)
136              integrals    | En          |  x >  0     |     --      |   as Ei
137                           | li          |  x > 0      |     --      |   as Ei
138                           | Chi         |  x > 0      |     --      |   < 1.0e-8
139                           | Shi         |  x > 0      |     --      |   < 1.0e-8
140                           | Ci          |  x > 0      |     --      |   < 2.0e-4
141                           | Si          |  x > 0      |     --      |   < 2.0e-4
142                           |             |             |             |
143              Fresnel      | C           |  all of R   |     --      |   < 2.0e-3
144              integrals    | S           |  all of R   |     --      |   < 2.0e-3
145                           |             |             |             |
146              general      | Beta        | (see Gamma) |     --      |   < 1.0e-9
147                           | Gamma       |  x != 0,-1, |     --      |   < 1.0e-9
148                           |             |  -2, ...    |             |
149                           | sinc        |  all of R   |     --      |   exact
150                           |             |             |             |
151              orthogonal   | Legendre    |  all of R   | n = 0,1,... |   exact
152              polynomials  | Chebyshev   |  all of R   | n = 0,1,... |   exact
153                           | Laguerre    |  all of R   | n = 0,1,... |   exact
154                           |             |             | alpha el. R |
155                           | Hermite     |  all of R   | n = 0,1,... |   exact
156
157       Note: Some of the error bounds are estimated,  as  no  "formal"  bounds
158       were  available  with the implemented approximation method, others hold
159       for the auxiliary functions used for estimating the primary functions.
160
161       The following well-known functions are currently missing from the pack‐
162       age:
163
164       ·      Bessel functions of the second kind (Y_n, K_n)
165
166       ·      Bessel  functions  of  arbitrary order (and hence the Airy func‐
167              tions)
168
169       ·      Chebyshev polynomials of the second kind (U_n)
170
171       ·      The digamma function (psi)
172
173       ·      The incomplete gamma and beta functions
174

PROCEDURES

176       The package defines the following public procedures:
177
178       ::math::special::Beta x y
179              Compute the Beta function for arguments "x" and "y"
180
181              float x
182                     First argument for the Beta function
183
184              float y
185                     Second argument for the Beta function
186
187
188       ::math::special::Gamma x
189              Compute the Gamma function for argument "x"
190
191              float x
192                     Argument for the Gamma function
193
194
195       ::math::special::erf x
196              Compute the error function for argument "x"
197
198              float x
199                     Argument for the error function
200
201
202       ::math::special::erfc x
203              Compute the complementary error function for argument "x"
204
205              float x
206                     Argument for the complementary error function
207
208
209       ::math::special::invnorm p
210              Compute the inverse of  the  normal  distribution  function  for
211              argument "p"
212
213              float p
214                     Argument  for the inverse normal distribution function (p
215                     must be greater than 0 and lower than 1)
216
217
218       ::math::special::J0 x
219              Compute the zeroth-order Bessel function of the first  kind  for
220              the argument "x"
221
222              float x
223                     Argument for the Bessel function
224
225       ::math::special::J1 x
226              Compute  the  first-order  Bessel function of the first kind for
227              the argument "x"
228
229              float x
230                     Argument for the Bessel function
231
232       ::math::special::Jn n x
233              Compute the nth-order Bessel function of the first kind for  the
234              argument "x"
235
236              integer n
237                     Order of the Bessel function
238
239              float x
240                     Argument for the Bessel function
241
242       ::math::special::J1/2 x
243              Compute the half-order Bessel function of the first kind for the
244              argument "x"
245
246              float x
247                     Argument for the Bessel function
248
249       ::math::special::J-1/2 x
250              Compute the minus-half-order Bessel function of the  first  kind
251              for the argument "x"
252
253              float x
254                     Argument for the Bessel function
255
256       ::math::special::I_n x
257              Compute  the modified Bessel function of the first kind of order
258              n for the argument "x"
259
260              int x  Positive integer order of the function
261
262              float x
263                     Argument for the function
264
265       ::math::special::cn u k
266              Compute the elliptic function cn for the argument "u" and param‐
267              eter "k".
268
269              float u
270                     Argument for the function
271
272              float k
273                     Parameter
274
275       ::math::special::dn u k
276              Compute the elliptic function dn for the argument "u" and param‐
277              eter "k".
278
279              float u
280                     Argument for the function
281
282              float k
283                     Parameter
284
285       ::math::special::sn u k
286              Compute the elliptic function sn for the argument "u" and param‐
287              eter "k".
288
289              float u
290                     Argument for the function
291
292              float k
293                     Parameter
294
295       ::math::special::elliptic_K k
296              Compute the complete elliptic integral of the first kind for the
297              argument "k"
298
299              float k
300                     Argument for the function
301
302       ::math::special::elliptic_E k
303              Compute the complete elliptic integral of the  second  kind  for
304              the argument "k"
305
306              float k
307                     Argument for the function
308
309       ::math::special::exponential_Ei x
310              Compute  the  exponential  integral  of  the second kind for the
311              argument "x"
312
313              float x
314                     Argument for the function (x != 0)
315
316       ::math::special::exponential_En n x
317              Compute the exponential integral of the first kind for the argu‐
318              ment "x" and order n
319
320              int n  Order of the integral (n >= 0)
321
322              float x
323                     Argument for the function (x >= 0)
324
325       ::math::special::exponential_li x
326              Compute the logarithmic integral for the argument "x"
327
328              float x
329                     Argument for the function (x > 0)
330
331       ::math::special::exponential_Ci x
332              Compute the cosine integral for the argument "x"
333
334              float x
335                     Argument for the function (x > 0)
336
337       ::math::special::exponential_Si x
338              Compute the sine integral for the argument "x"
339
340              float x
341                     Argument for the function (x > 0)
342
343       ::math::special::exponential_Chi x
344              Compute the hyperbolic cosine integral for the argument "x"
345
346              float x
347                     Argument for the function (x > 0)
348
349       ::math::special::exponential_Shi x
350              Compute the hyperbolic sine integral for the argument "x"
351
352              float x
353                     Argument for the function (x > 0)
354
355       ::math::special::fresnel_C x
356              Compute the Fresnel cosine integral for real argument x
357
358              float x
359                     Argument for the function
360
361       ::math::special::fresnel_S x
362              Compute the Fresnel sine integral for real argument x
363
364              float x
365                     Argument for the function
366
367       ::math::special::sinc x
368              Compute the sinc function for real argument x
369
370              float x
371                     Argument for the function
372
373       ::math::special::legendre n
374              Return  the  Legendre polynomial of degree n (see THE ORTHOGONAL
375              POLYNOMIALS)
376
377              int n  Degree of the polynomial
378
379
380       ::math::special::chebyshev n
381              Return the Chebyshev polynomial of degree n (of the first kind)
382
383              int n  Degree of the polynomial
384
385
386       ::math::special::laguerre alpha n
387              Return the Laguerre polynomial of degree n with parameter alpha
388
389              float alpha
390                     Parameter of the Laguerre polynomial
391
392              int n  Degree of the polynomial
393
394
395       ::math::special::hermite n
396              Return the Hermite polynomial of degree n
397
398              int n  Degree of the polynomial
399
400

THE ORTHOGONAL POLYNOMIALS

402       For dealing with the classical families of orthogonal polynomials,  the
403       package  relies on the math::polynomials package. To evaluate the poly‐
404       nomial at some coordinate, use the evalPolyn command:
405
406
407                 set leg2 [::math::special::legendre 2]
408                 puts "Value at x=$x: [::math::polynomials::evalPolyn $leg2 $x]"
409
410
411       The return value from the legendre and other commands is  actually  the
412       definition of the corresponding polynomial as used in that package.
413

REMARKS ON THE IMPLEMENTATION

415       It should be noted, that the actual implementation of J0 and J1 depends
416       on straightforward Gaussian quadrature formulas. The  (absolute)  accu‐
417       racy  of  the results is of the order 1.0e-4 or better. The main reason
418       to implement them like that was that it was fast to  do  (the  formulas
419       are simple) and the computations are fast too.
420
421       The implementation of J1/2 does not suffer from this: this function can
422       be expressed exactly in terms of elementary functions.
423
424       The functions J0 and J1 are the ones you will encounter most frequently
425       in practice.
426
427       The computation of I_n is based on Miller's algorithm for computing the
428       minimal function from recurrence relations.
429
430       The computation of the Gamma and Beta functions relies on the  combina‐
431       torics  package, whereas that of the error functions relies on the sta‐
432       tistics package.
433
434       The computation of the complete elliptic integrals uses the  AGM  algo‐
435       rithm.
436
437       Much information about these functions can be found in:
438
439       Abramowitz  and Stegun: Handbook of Mathematical Functions (Dover, ISBN
440       486-61272-4)
441

BUGS, IDEAS, FEEDBACK

443       This document, and the package it describes, will  undoubtedly  contain
444       bugs  and  other  problems.  Please report such in the category math ::
445       special of the Tcllib Trackers  [http://core.tcl.tk/tcllib/reportlist].
446       Please  also  report any ideas for enhancements you may have for either
447       package and/or documentation.
448
449       When proposing code changes, please provide unified diffs, i.e the out‐
450       put of diff -u.
451
452       Note  further  that  attachments  are  strongly  preferred over inlined
453       patches. Attachments can be made by going  to  the  Edit  form  of  the
454       ticket  immediately  after  its  creation, and then using the left-most
455       button in the secondary navigation bar.
456

KEYWORDS

458       Bessel functions, error function, math, special functions
459

CATEGORY

461       Mathematics
462
464       Copyright (c) 2004 Arjen Markus <arjenmarkus@users.sourceforge.net>
465
466
467
468
469tcllib                                0.3                     math::special(n)
Impressum