File: Special-Functions.html

package info (click to toggle)
octave3.2 3.2.4-8
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 62,936 kB
  • ctags: 37,353
  • sloc: cpp: 219,497; fortran: 116,336; ansic: 10,264; sh: 5,508; makefile: 4,245; lex: 3,573; yacc: 3,062; objc: 2,042; lisp: 1,692; awk: 860; perl: 844
file content (416 lines) | stat: -rw-r--r-- 18,691 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
<html lang="en">
<head>
<title>Special Functions - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.11">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Arithmetic.html#Arithmetic" title="Arithmetic">
<link rel="prev" href="Utility-Functions.html#Utility-Functions" title="Utility Functions">
<link rel="next" href="Coordinate-Transformations.html#Coordinate-Transformations" title="Coordinate Transformations">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<p>
<a name="Special-Functions"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="Coordinate-Transformations.html#Coordinate-Transformations">Coordinate Transformations</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Utility-Functions.html#Utility-Functions">Utility Functions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Arithmetic.html#Arithmetic">Arithmetic</a>
<hr>
</div>

<h3 class="section">17.6 Special Functions</h3>

<!-- ./DLD-FUNCTIONS/besselj.cc -->
<p><a name="doc_002dairy"></a>

<div class="defun">
&mdash; Loadable Function: [<var>a</var>, <var>ierr</var>] = <b>airy</b> (<var>k, z, opt</var>)<var><a name="index-airy-1482"></a></var><br>
<blockquote><p>Compute Airy functions of the first and second kind, and their
derivatives.

     <pre class="example">           K   Function   Scale factor (if 'opt' is supplied)
          ---  --------   ---------------------------------------
           0   Ai (Z)     exp ((2/3) * Z * sqrt (Z))
           1   dAi(Z)/dZ  exp ((2/3) * Z * sqrt (Z))
           2   Bi (Z)     exp (-abs (real ((2/3) * Z *sqrt (Z))))
           3   dBi(Z)/dZ  exp (-abs (real ((2/3) * Z *sqrt (Z))))
</pre>
        <p>The function call <code>airy (</code><var>z</var><code>)</code> is equivalent to
<code>airy (0, </code><var>z</var><code>)</code>.

        <p>The result is the same size as <var>z</var>.

        <p>If requested, <var>ierr</var> contains the following status information and
is the same size as the result.

          <ol type=1 start=0>
<li>Normal return. 
<li>Input error, return <code>NaN</code>. 
<li>Overflow, return <code>Inf</code>. 
<li>Loss of significance by argument reduction results in less than half
 of machine accuracy. 
<li>Complete loss of significance by argument reduction, return <code>NaN</code>. 
<li>Error&mdash;no computation, algorithm termination condition not met,
return <code>NaN</code>.
             </ol>
</p></blockquote></div>

<!-- ./DLD-FUNCTIONS/besselj.cc -->
   <p><a name="doc_002dbesselj"></a>

<div class="defun">
&mdash; Loadable Function: [<var>j</var>, <var>ierr</var>] = <b>besselj</b> (<var>alpha, x, opt</var>)<var><a name="index-besselj-1483"></a></var><br>
&mdash; Loadable Function: [<var>y</var>, <var>ierr</var>] = <b>bessely</b> (<var>alpha, x, opt</var>)<var><a name="index-bessely-1484"></a></var><br>
&mdash; Loadable Function: [<var>i</var>, <var>ierr</var>] = <b>besseli</b> (<var>alpha, x, opt</var>)<var><a name="index-besseli-1485"></a></var><br>
&mdash; Loadable Function: [<var>k</var>, <var>ierr</var>] = <b>besselk</b> (<var>alpha, x, opt</var>)<var><a name="index-besselk-1486"></a></var><br>
&mdash; Loadable Function: [<var>h</var>, <var>ierr</var>] = <b>besselh</b> (<var>alpha, k, x, opt</var>)<var><a name="index-besselh-1487"></a></var><br>
<blockquote><p>Compute Bessel or Hankel functions of various kinds:

          <dl>
<dt><code>besselj</code><dd>Bessel functions of the first kind.  If the argument <var>opt</var> is supplied,
the result is multiplied by <code>exp(-abs(imag(x)))</code>. 
<br><dt><code>bessely</code><dd>Bessel functions of the second kind.  If the argument <var>opt</var> is supplied,
the result is multiplied by <code>exp(-abs(imag(x)))</code>. 
<br><dt><code>besseli</code><dd>Modified Bessel functions of the first kind.  If the argument <var>opt</var> is supplied,
the result is multiplied by <code>exp(-abs(real(x)))</code>. 
<br><dt><code>besselk</code><dd>Modified Bessel functions of the second kind.  If the argument <var>opt</var> is supplied,
the result is multiplied by <code>exp(x)</code>. 
<br><dt><code>besselh</code><dd>Compute Hankel functions of the first (<var>k</var> = 1) or second (<var>k</var>
= 2) kind.  If the argument <var>opt</var> is supplied, the result is multiplied by
<code>exp (-I*</code><var>x</var><code>)</code> for <var>k</var> = 1 or <code>exp (I*</code><var>x</var><code>)</code> for
<var>k</var> = 2. 
</dl>

        <p>If <var>alpha</var> is a scalar, the result is the same size as <var>x</var>. 
If <var>x</var> is a scalar, the result is the same size as <var>alpha</var>. 
If <var>alpha</var> is a row vector and <var>x</var> is a column vector, the
result is a matrix with <code>length (</code><var>x</var><code>)</code> rows and
<code>length (</code><var>alpha</var><code>)</code> columns.  Otherwise, <var>alpha</var> and
<var>x</var> must conform and the result will be the same size.

        <p>The value of <var>alpha</var> must be real.  The value of <var>x</var> may be
complex.

        <p>If requested, <var>ierr</var> contains the following status information
and is the same size as the result.

          <ol type=1 start=0>
<li>Normal return. 
<li>Input error, return <code>NaN</code>. 
<li>Overflow, return <code>Inf</code>. 
<li>Loss of significance by argument reduction results in less than
half of machine accuracy. 
<li>Complete loss of significance by argument reduction, return <code>NaN</code>. 
<li>Error&mdash;no computation, algorithm termination condition not met,
return <code>NaN</code>.
             </ol>
</p></blockquote></div>

<!-- ./specfun/beta.m -->
   <p><a name="doc_002dbeta"></a>

<div class="defun">
&mdash; Mapping Function:  <b>beta</b> (<var>a, b</var>)<var><a name="index-beta-1488"></a></var><br>
<blockquote><p>For real inputs, return the Beta function,

     <pre class="example">          beta (a, b) = gamma (a) * gamma (b) / gamma (a + b).
</pre>
        </blockquote></div>

<!-- ./DLD-FUNCTIONS/betainc.cc -->
   <p><a name="doc_002dbetainc"></a>

<div class="defun">
&mdash; Mapping Function:  <b>betainc</b> (<var>x, a, b</var>)<var><a name="index-betainc-1489"></a></var><br>
<blockquote><p>Return the incomplete Beta function,

     <!-- Set example in small font to prevent overfull line -->
     <pre class="smallexample">                                                x
                                               /
          betainc (x, a, b) = beta (a, b)^(-1) | t^(a-1) (1-t)^(b-1) dt.
                                               /
                                            t=0
</pre>
        <p>If x has more than one component, both <var>a</var> and <var>b</var> must be
scalars.  If <var>x</var> is a scalar, <var>a</var> and <var>b</var> must be of
compatible dimensions. 
</p></blockquote></div>

<!-- ./specfun/betaln.m -->
   <p><a name="doc_002dbetaln"></a>

<div class="defun">
&mdash; Mapping Function:  <b>betaln</b> (<var>a, b</var>)<var><a name="index-betaln-1490"></a></var><br>
<blockquote><p>Return the log of the Beta function,

     <pre class="example">          betaln (a, b) = gammaln (a) + gammaln (b) - gammaln (a + b)
</pre>
        <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
     <!-- A simple blank line produces the correct behavior. -->
     <!-- @sp 1 -->
     <p class="noindent"><strong>See also:</strong> <a href="doc_002dbeta.html#doc_002dbeta">beta</a>, <a href="doc_002dbetainc.html#doc_002dbetainc">betainc</a>, <a href="doc_002dgammaln.html#doc_002dgammaln">gammaln</a>. 
</p></blockquote></div>

<!-- ./miscellaneous/bincoeff.m -->
   <p><a name="doc_002dbincoeff"></a>

<div class="defun">
&mdash; Mapping Function:  <b>bincoeff</b> (<var>n, k</var>)<var><a name="index-bincoeff-1491"></a></var><br>
<blockquote><p>Return the binomial coefficient of <var>n</var> and <var>k</var>, defined as

     <pre class="example">           /   \
           | n |    n (n-1) (n-2) ... (n-k+1)
           |   |  = -------------------------
           | k |               k!
           \   /
</pre>
        <p>For example,

     <pre class="example">          bincoeff (5, 2)
                10
</pre>
        <p>In most cases, the <code>nchoosek</code> function is faster for small
scalar integer arguments.  It also warns about loss of precision for
big arguments.

     <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
     <!-- A simple blank line produces the correct behavior. -->
     <!-- @sp 1 -->
     <p class="noindent"><strong>See also:</strong> <a href="doc_002dnchoosek.html#doc_002dnchoosek">nchoosek</a>. 
</p></blockquote></div>

<!-- ./linear-algebra/commutation_matrix.m -->
   <p><a name="doc_002dcommutation_005fmatrix"></a>

<div class="defun">
&mdash; Function File:  <b>commutation_matrix</b> (<var>m, n</var>)<var><a name="index-commutation_005fmatrix-1492"></a></var><br>
<blockquote><p>Return the commutation matrix
 K(m,n)
 which is the unique
<var>m</var>*<var>n</var> by <var>m</var>*<var>n</var>
 matrix such that
K(m,n) * vec(A) = vec(A')
 for all
m by n
 matrices
A.

        <p>If only one argument <var>m</var> is given,
K(m,m)
 is returned.

        <p>See Magnus and Neudecker (1988), Matrix differential calculus with
applications in statistics and econometrics. 
</p></blockquote></div>

<!-- ./linear-algebra/duplication_matrix.m -->
   <p><a name="doc_002dduplication_005fmatrix"></a>

<div class="defun">
&mdash; Function File:  <b>duplication_matrix</b> (<var>n</var>)<var><a name="index-duplication_005fmatrix-1493"></a></var><br>
<blockquote><p>Return the duplication matrix
Dn
 which is the unique
n^2 by n*(n+1)/2
 matrix such that
Dn vech (A) = vec (A)
 for all symmetric
n by n
 matrices
A.

        <p>See Magnus and Neudecker (1988), Matrix differential calculus with
applications in statistics and econometrics. 
</p></blockquote></div>

<!-- mappers.cc -->
   <p><a name="doc_002derf"></a>

<div class="defun">
&mdash; Mapping Function:  <b>erf</b> (<var>z</var>)<var><a name="index-erf-1494"></a></var><br>
<blockquote><p>Computes the error function,

     <pre class="example">                                   z
                                  /
          erf (z) = (2/sqrt (pi)) | e^(-t^2) dt
                                  /
                               t=0
</pre>
        <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
     <!-- A simple blank line produces the correct behavior. -->
     <!-- @sp 1 -->
     <p class="noindent"><strong>See also:</strong> <a href="doc_002derfc.html#doc_002derfc">erfc</a>, <a href="doc_002derfinv.html#doc_002derfinv">erfinv</a>. 
</p></blockquote></div>

<!-- mappers.cc -->
   <p><a name="doc_002derfc"></a>

<div class="defun">
&mdash; Mapping Function:  <b>erfc</b> (<var>z</var>)<var><a name="index-erfc-1495"></a></var><br>
<blockquote><p>Computes the complementary error function,
<code>1 - erf (</code><var>z</var><code>)</code>. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002derf.html#doc_002derf">erf</a>, <a href="doc_002derfinv.html#doc_002derfinv">erfinv</a>. 
</p></blockquote></div>

<!-- ./specfun/erfinv.m -->
   <p><a name="doc_002derfinv"></a>

<div class="defun">
&mdash; Mapping Function:  <b>erfinv</b> (<var>z</var>)<var><a name="index-erfinv-1496"></a></var><br>
<blockquote><p>Computes the inverse of the error function. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002derf.html#doc_002derf">erf</a>, <a href="doc_002derfc.html#doc_002derfc">erfc</a>. 
</p></blockquote></div>

<!-- mappers.cc -->
   <p><a name="doc_002dgamma"></a>

<div class="defun">
&mdash; Mapping Function:  <b>gamma</b> (<var>z</var>)<var><a name="index-gamma-1497"></a></var><br>
<blockquote><p>Computes the Gamma function,

     <pre class="example">                      infinity
                      /
          gamma (z) = | t^(z-1) exp (-t) dt.
                      /
                   t=0
</pre>
        <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
     <!-- A simple blank line produces the correct behavior. -->
     <!-- @sp 1 -->
     <p class="noindent"><strong>See also:</strong> <a href="doc_002dgammainc.html#doc_002dgammainc">gammainc</a>, <a href="doc_002dlgamma.html#doc_002dlgamma">lgamma</a>. 
</p></blockquote></div>

<!-- ./DLD-FUNCTIONS/gammainc.cc -->
   <p><a name="doc_002dgammainc"></a>

<div class="defun">
&mdash; Mapping Function:  <b>gammainc</b> (<var>x, a</var>)<var><a name="index-gammainc-1498"></a></var><br>
<blockquote><p>Compute the normalized incomplete gamma function,

     <pre class="smallexample">                                          x
                                1        /
          gammainc (x, a) = ---------    | exp (-t) t^(a-1) dt
                            gamma (a)    /
                                      t=0
</pre>
        <p>with the limiting value of 1 as <var>x</var> approaches infinity. 
The standard notation is P(a,x), e.g., Abramowitz and Stegun (6.5.1).

        <p>If <var>a</var> is scalar, then <code>gammainc (</code><var>x</var><code>, </code><var>a</var><code>)</code> is returned
for each element of <var>x</var> and vice versa.

        <p>If neither <var>x</var> nor <var>a</var> is scalar, the sizes of <var>x</var> and
<var>a</var> must agree, and <var>gammainc</var> is applied element-by-element. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dgamma.html#doc_002dgamma">gamma</a>, <a href="doc_002dlgamma.html#doc_002dlgamma">lgamma</a>. 
</p></blockquote></div>

<!-- ./specfun/legendre.m -->
   <p><a name="doc_002dlegendre"></a>

<div class="defun">
&mdash; Function File: <var>l</var> = <b>legendre</b> (<var>n, x</var>)<var><a name="index-legendre-1499"></a></var><br>
&mdash; Function File: <var>l</var> = <b>legendre</b> (<var>n, x, normalization</var>)<var><a name="index-legendre-1500"></a></var><br>
<blockquote><p>Compute the Legendre function of degree <var>n</var> and order
<var>m</var> = 0 <small class="dots">...</small> N.  The optional argument, <var>normalization</var>,
may be one of <code>"unnorm"</code>, <code>"sch"</code>, or <code>"norm"</code>. 
The default is <code>"unnorm"</code>.  The value of <var>n</var> must be a
non-negative scalar integer.

        <p>If the optional argument <var>normalization</var> is missing or is
<code>"unnorm"</code>, compute the Legendre function of degree <var>n</var> and
order <var>m</var> and return all values for <var>m</var> = 0 <small class="dots">...</small> <var>n</var>. 
The return value has one dimension more than <var>x</var>.

        <p>The Legendre Function of degree <var>n</var> and order <var>m</var>:

     <pre class="example">           m        m       2  m/2   d^m
          P(x) = (-1) * (1-x  )    * ----  P (x)
           n                         dx^m   n
</pre>
        <p class="noindent">with Legendre polynomial of degree <var>n</var>:

     <pre class="example">                    1     d^n   2    n
          P (x) = ------ [----(x - 1)  ]
           n      2^n n!  dx^n
</pre>
        <p class="noindent"><code>legendre (3, [-1.0, -0.9, -0.8])</code> returns the matrix:

     <pre class="example">           x  |   -1.0   |   -0.9   |  -0.8
          ------------------------------------
          m=0 | -1.00000 | -0.47250 | -0.08000
          m=1 |  0.00000 | -1.99420 | -1.98000
          m=2 |  0.00000 | -2.56500 | -4.32000
          m=3 |  0.00000 | -1.24229 | -3.24000
</pre>
        <p>If the optional argument <code>normalization</code> is <code>"sch"</code>,
compute the Schmidt semi-normalized associated Legendre function. 
The Schmidt semi-normalized associated Legendre function is related
to the unnormalized Legendre functions by the following:

        <p>For Legendre functions of degree n and order 0:

     <pre class="example">            0       0
          SP (x) = P (x)
            n       n
</pre>
        <p>For Legendre functions of degree n and order m:

     <pre class="example">            m       m          m    2(n-m)! 0.5
          SP (x) = P (x) * (-1)  * [-------]
            n       n               (n+m)!
</pre>
        <p>If the optional argument <var>normalization</var> is <code>"norm"</code>,
compute the fully normalized associated Legendre function. 
The fully normalized associated Legendre function is related
to the unnormalized Legendre functions by the following:

        <p>For Legendre functions of degree <var>n</var> and order <var>m</var>

     <pre class="example">            m       m          m    (n+0.5)(n-m)! 0.5
          NP (x) = P (x) * (-1)  * [-------------]
            n       n                   (n+m)!
</pre>
        </blockquote></div>

   <p><a name="doc_002dgammaln"></a><!-- mappers.cc -->
<a name="doc_002dlgamma"></a>

<div class="defun">
&mdash; Mapping Function:  <b>lgamma</b> (<var>x</var>)<var><a name="index-lgamma-1501"></a></var><br>
&mdash; Mapping Function:  <b>gammaln</b> (<var>x</var>)<var><a name="index-gammaln-1502"></a></var><br>
<blockquote><p>Return the natural logarithm of the gamma function of <var>x</var>. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dgamma.html#doc_002dgamma">gamma</a>, <a href="doc_002dgammainc.html#doc_002dgammainc">gammainc</a>. 
</p></blockquote></div>

   </body></html>