<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.13"> <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"> <a name="Special-Functions"></a> <p> Next: <a rel="next" accesskey="n" href="Coordinate-Transformations.html#Coordinate-Transformations">Coordinate Transformations</a>, Previous: <a rel="previous" accesskey="p" href="Utility-Functions.html#Utility-Functions">Utility Functions</a>, Up: <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"> — 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—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"> — 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> — 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> — 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> — 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> — 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—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"> — 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"> — 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"> — 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"> — 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"> — 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"> — 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"> — 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"> — 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"> — 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"> — 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"> — 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"> — Function File: <var>l</var> = <b>legendre</b> (<var>n, x</var>)<var><a name="index-legendre-1499"></a></var><br> — 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"> — Mapping Function: <b>lgamma</b> (<var>x</var>)<var><a name="index-lgamma-1501"></a></var><br> — 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>