1 @c -*- mode: texinfo -*-
3 * Introduction to Special Functions::
6 * Gamma and Factorial Functions::
7 * Exponential Integrals::
10 * Hypergeometric Functions::
11 * Parabolic Cylinder Functions::
12 * Functions and Variables for Special Functions::
15 @c -----------------------------------------------------------------------------
16 @node Introduction to Special Functions, Bessel Functions, , Special Functions
17 @section Introduction to Special Functions
18 @c -----------------------------------------------------------------------------
20 Special function notation follows:
23 bessel_j (index, expr) Bessel function, 1st kind
24 bessel_y (index, expr) Bessel function, 2nd kind
25 bessel_i (index, expr) Modified Bessel function, 1st kind
26 bessel_k (index, expr) Modified Bessel function, 2nd kind
28 hankel_1 (v,z) Hankel function of the 1st kind
29 hankel_2 (v,z) Hankel function of the 2nd kind
30 struve_h (v,z) Struve H function
31 struve_l (v,z) Struve L function
33 assoc_legendre_p[v,u] (z) Legendre function of degree v and order u
34 assoc_legendre_q[v,u] (z) Legendre function, 2nd kind
36 %f[p,q] ([], [], expr) Generalized Hypergeometric function
37 gamma (z) Gamma function
38 gamma_incomplete_lower (a,z) Lower incomplete gamma function
39 gamma_incomplete (a,z) Tail of incomplete gamma function
40 hypergeometric (l1, l2, z) Hypergeometric function
41 %s[u,v] (z) Lommel "small" s function
42 slommel[u,v] (z) Lommel "big" S function
43 %m[u,k] (z) Whittaker function, 1st kind
44 %w[u,k] (z) Whittaker function, 2nd kind
45 erfc (z) Complement of the erf function
47 expintegral_e (v,z) Exponential integral E
48 expintegral_e1 (z) Exponential integral E1
49 expintegral_ei (z) Exponential integral Ei
50 expintegral_li (z) Logarithmic integral Li
51 expintegral_si (z) Exponential integral Si
52 expintegral_ci (z) Exponential integral Ci
53 expintegral_shi (z) Exponential integral Shi
54 expintegral_chi (z) Exponential integral Chi
56 kelliptic (z) Complete elliptic integral of the first
58 parabolic_cylinder_d (v,z) Parabolic cylinder D function
61 @opencatbox{Categories:}
62 @category{Bessel functions}
63 @category{Airy functions}
64 @category{Special functions}
67 @c -----------------------------------------------------------------------------
68 @node Bessel Functions, Airy Functions, Introduction to Special Functions, Special Functions
69 @section Bessel Functions
70 @c -----------------------------------------------------------------------------
72 @c -----------------------------------------------------------------------------
74 @deffn {Function} bessel_j (@var{v}, @var{z})
76 The Bessel function of the first kind of order @math{v} and argument @math{z}.
77 See @urlaands{eqn 9.1.10, 360} and @urldlmf{10.2.E2}.
79 @code{bessel_j} is defined as
82 <<<J_v(z) = \sum_{k=0}^{\infty }{{{\left(-1\right)^{k}\,\left(z\over 2\right)^{v+2\,k}
83 }\over{k!\,\Gamma\left(v+k+1\right)}}}>>>,
86 ==== k - v - 2 k v + 2 k
88 > --------------------------
95 although the infinite series is not used for computations.
97 When @code{besselexpand} is @code{true}, @code{bessel_j} is expanded in terms
98 of elementary functions when the order @math{v} is half of an odd integer.
99 See @mrefdot{besselexpand}
101 @opencatbox{Categories:}
102 @category{Bessel functions}
103 @category{Special functions}
107 @c -----------------------------------------------------------------------------
109 @deffn {Function} bessel_y (@var{v}, @var{z})
111 The Bessel function of the second kind of order @math{v} and argument @math{z}.
112 See @urlaands{eqn 9.1.2, 358} and @urldlmf{10.2.E3}.
114 @code{bessel_y} is defined as
116 <<<Y_v(z) = {{\cos(\pi v)\, J_v(z) - J_{-v}(z)}\over{\sin{\pi v}}}>>>,
118 cos(%pi v) bessel_j(v, z) - bessel_j(-v, z)
119 -------------------------------------------
124 when @math{v} is not an integer. When @math{v} is an integer @math{n},
125 the limit as @math{v} approaches @math{n} is taken.
127 When @code{besselexpand} is @code{true}, @code{bessel_y} is expanded in terms
128 of elementary functions when the order @math{v} is half of an odd integer.
129 See @mrefdot{besselexpand}
131 @opencatbox{Categories:}
132 @category{Bessel functions}
133 @category{Special functions}
137 @c -----------------------------------------------------------------------------
139 @deffn {Function} bessel_i (@var{v}, @var{z})
141 The modified Bessel function of the first kind of order @math{v} and argument
142 @math{z}. See @urlaands{eqn 9.6.10, 375} and @urldlmf{10.25.E2}.
144 @code{bessel_i} is defined as
146 <<<I_v(z) = \sum_{k=0}^{\infty } {{1\over{k!\,\Gamma
147 \left(v+k+1\right)}} {\left(z\over 2\right)^{v+2\,k}}}>>>,
150 ==== - v - 2 k v + 2 k
152 > -------------------
153 / k! gamma(v + k + 1)
159 although the infinite series is not used for computations.
161 When @code{besselexpand} is @code{true}, @code{bessel_i} is expanded in terms
162 of elementary functions when the order @math{v} is half of an odd integer.
163 See @mrefdot{besselexpand}
166 @opencatbox{Categories:}
167 @category{Bessel functions}
168 @category{Special functions}
172 @c -----------------------------------------------------------------------------
174 @deffn {Function} bessel_k (@var{v}, @var{z})
176 The modified Bessel function of the second kind of order @math{v} and argument
177 @math{z}. See @urlaands{eqn 9.6.2, 375} and @urldlmf{10.27.E4}.
179 @code{bessel_k} is defined as
181 <<<K_v(z) = {1\over 2} \pi\, {I_{-v}(z)-I_{v}(z) \over \sin v\pi}>>>,
183 %pi (bessel_i(- v, z) - bessel_i(v, z))
184 ---------------------------------------
189 when @math{v} is not an integer. If @math{v} is an integer @math{n},
190 then the limit as @math{v} approaches @math{n} is taken.
192 When @code{besselexpand} is @code{true}, @code{bessel_k} is expanded in terms
193 of elementary functions when the order @math{v} is half of an odd integer.
194 See @mrefdot{besselexpand}
197 @opencatbox{Categories:}
198 @category{Bessel functions}
199 @category{Special functions}
203 @c -----------------------------------------------------------------------------
205 @deffn {Function} hankel_1 (@var{v}, @var{z})
207 The Hankel function of the first kind of order @math{v} and argument @math{z}.
208 See @urlaands{eqn 9.1.3, 358} and @urldlmf{10.4.E3}.
210 @code{hankel_1} is defined as
213 <<<H^{(1)}_v(z) = J_v(z) + i Y_v(z)>>>,
215 bessel_j(v,z) + %i * bessel_y(v,z)
219 Maxima evaluates @code{hankel_1} numerically for a complex order @math{v} and
220 complex argument @math{z} in float precision. The numerical evaluation in
221 bigfloat precision is not supported.
223 When @code{besselexpand} is @code{true}, @code{hankel_1} is expanded in terms
224 of elementary functions when the order @math{v} is half of an odd integer.
225 See @mrefdot{besselexpand}
227 Maxima knows the derivative of @code{hankel_1} wrt the argument @math{z}.
231 Numerical evaluation:
235 @c hankel_1(1,0.5+%i);
239 (%i1) hankel_1(1,0.5);
240 (%o1) 0.24226845767487 - 1.471472392670243 %i
243 (%i2) hankel_1(1,0.5+%i);
244 (%o2) - 0.25582879948621 %i - 0.23957560188301
248 Expansion of @code{hankel_1} when @code{besselexpand} is @code{true}:
251 @c hankel_1(1/2,z),besselexpand:true;
255 (%i1) hankel_1(1/2,z),besselexpand:true;
256 sqrt(2) sin(z) - sqrt(2) %i cos(z)
257 (%o1) ----------------------------------
262 Derivative of @code{hankel_1} wrt the argument @math{z}. The derivative wrt the
263 order @math{v} is not supported. Maxima returns a noun form:
266 @c diff(hankel_1(v,z),z);
267 @c diff(hankel_1(v,z),v);
271 (%i1) diff(hankel_1(v,z),z);
272 hankel_1(v - 1, z) - hankel_1(v + 1, z)
273 (%o1) ---------------------------------------
277 (%i2) diff(hankel_1(v,z),v);
279 (%o2) -- (hankel_1(v, z))
284 @opencatbox{Categories:}
285 @category{Bessel functions}
286 @category{Special functions}
290 @c -----------------------------------------------------------------------------
292 @deffn {Function} hankel_2 (@var{v}, @var{z})
294 The Hankel function of the second kind of order @math{v} and argument @math{z}.
295 See @urlaands{eqn 9.1.4, 358} and @urldlmf{10.4.E3}.
297 @code{hankel_2} is defined as
300 <<<H^{(2)}_v(z) = J_v(z) - i Y_v(z)>>>,
303 bessel_j(v,z) - %i * bessel_y(v,z)
307 Maxima evaluates @code{hankel_2} numerically for a complex order @math{v} and
308 complex argument @math{z} in float precision. The numerical evaluation in
309 bigfloat precision is not supported.
311 When @code{besselexpand} is @code{true}, @code{hankel_2} is expanded in terms
312 of elementary functions when the order @math{v} is half of an odd integer.
313 See @mrefdot{besselexpand}
315 Maxima knows the derivative of @code{hankel_2} wrt the argument @math{z}.
317 For examples see @code{hankel_1}.
319 @opencatbox{Categories:}
320 @category{Bessel functions}
321 @category{Special functions}
325 @c -----------------------------------------------------------------------------
326 @anchor{besselexpand}
327 @defvr {Option variable} besselexpand
328 Default value: @code{false}
331 Controls expansion of the Bessel, Hankel and Struve functions
332 when the order is half of
333 an odd integer. In this case, the functions can be expanded
334 in terms of other elementary functions. When @code{besselexpand} is @code{true},
335 the Bessel function is expanded.
338 (%i1) besselexpand: false$
339 (%i2) bessel_j (3/2, z);
343 (%i3) besselexpand: true$
344 (%i4) bessel_j (3/2, z);
346 sqrt(2) sqrt(z) (------ - ------)
349 (%o4) ---------------------------------
351 (%i5) bessel_y(3/2,z);
353 sqrt(2) sqrt(z) ((- ------) - ------)
356 (%o5) -------------------------------------
358 (%i6) bessel_i(3/2,z);
360 sqrt(2) sqrt(z) (------- - -------)
363 (%o6) -----------------------------------
365 (%i7) bessel_k(3/2,z);
369 (%o7) -----------------------
374 @opencatbox{Categories:}
375 @category{Bessel functions}
376 @category{Simplification flags and variables}
377 @category{Special functions}
381 @c -----------------------------------------------------------------------------
382 @anchor{scaled_bessel_i}
383 @deffn {Function} scaled_bessel_i (@var{v}, @var{z})
385 The scaled modified Bessel function of the first kind of order
386 @math{v} and argument @math{z}. That is,
389 <<<{\rm scaled\_bessel\_i}(v,z) = e^{-|z|} I_v(z).>>>,
390 <<<scaled_bessel_i(v,z) = exp(-abs(z)) * bessel_i(v,z).>>>)
392 This function is particularly useful
394 m4_math(<<<I_v(z)>>>,<<<bessel_i>>>)
395 for large @math{z}, which is large.
396 However, maxima does not otherwise know much about this function. For
397 symbolic work, it is probably preferable to work with the expression
398 @code{exp(-abs(z))*bessel_i(v, z)}.
400 @opencatbox{Categories:}
401 @category{Bessel functions}
405 @anchor{scaled_bessel_i0}
406 @deffn {Function} scaled_bessel_i0 (@var{z})
408 Identical to @code{scaled_bessel_i(0,z)}.
410 @opencatbox{Categories:}
411 @category{Bessel functions}
412 @category{Special functions}
416 @c -----------------------------------------------------------------------------
417 @anchor{scaled_bessel_i1}
418 @deffn {Function} scaled_bessel_i1 (@var{z})
420 Identical to @code{scaled_bessel_i(1,z)}.
421 @opencatbox{Categories:}
422 @category{Bessel functions}
423 @category{Special functions}
427 @c -----------------------------------------------------------------------------
429 @deffn {Function} %s [@var{u},@var{v}] (@var{z})
431 m4_math(<<<s_{\mu,\nu}(z)>>>, <<<s[u,v](z)>>>)
433 (@urldlmf{11.9.E3})(G&R 8.570.1).
435 This Lommel function is the particular solution of the inhomogeneous
436 Bessel differential equation:
439 <<<{d^2\over dz^2} + {1\over z}{dw\over dz} + \left(1-{\nu^2\over z^2}\right) w = z^{\mu-1}>>>,
440 <<<diff(w,z,2)+1/z*diff(w,z)+(1-v^2/z^2)*w = z^(u-1)>>>)
442 This can be defined by the series
445 <<<s_{\mu,\nu}(z) = z^{\mu+1}\sum_{k=0}^{\infty} (-1)^k {z^{2k}\over a_{k+1}(\mu, \nu)}>>>,
446 <<<%s[u,v](z) = z^(u+1)*sum((-1)^k*z^(2*k)/a[k+1](u,v)>>>)
451 <<<a_k(\mu,\nu) = \prod_{m=1}^k \left(\left(\mu + 2m-1\right)^2-\nu^2\right) = 4^k\left(\mu-\nu+1\over 2\right)_k \left(\mu+\nu+1\over 2\right)_k>>>,
452 <<<a[k](u,v) = product(((u+2*m-1)^2-v^2),m,1,k) = 4^k*pochhammer((u-v+1)/2,k)*pochhammer((u+v+1)/2,k)>>>)
454 @opencatbox{Categories:}
455 @category{Bessel functions}
456 @category{Special functions}
460 @c -----------------------------------------------------------------------------
461 @deffn {Function} slommel [@var{u},@var{v}] (@var{z})
463 m4_math(<<<S_{\mu,\nu}(z)>>>, <<<S[u,v](z)>>>)
465 (@urldlmf{11.9.E5})(G&R 8.570.2).
467 Lommels big S function is another particular solution of the
468 inhomogeneous Bessel differential equation
469 (@pxref{%s}) defined for all values
478 S_{\mu,\nu}(z) = s_{\mu,\nu}(z) + 2^{\mu-1} & \Gamma\left({\mu\over 2} + {\nu\over 2} + {1\over 2}\right) \Gamma\left({\mu\over 2} - {\nu\over 2} + {1\over 2}\right) \cr
479 & \times \left(\sin\left({(\mu-\nu)\pi\over 2}\right) J_{\nu}(z) - \cos\left({(\mu-\nu)\pi\over 2}\right) Y_{\nu}(z)\right)
481 <<<@math{slommel[u,v](z) = %s[u,v](z) + 2^(u-1)*gamma(u/2+v/2+1/2)*gamma(u/2-v/2+1/2)
482 * (sin(1/2*(u-v)*%pi)*bessel_j(v,z) - cos(1/2*(u-v)*%pi)*bessel_y(v,z))}>>>)
485 m4_math(<<<\mu\pm \nu>>>, u+/-v)
487 negative integer, the limit must be used.
489 @opencatbox{Categories:}
490 @category{Bessel functions}
491 @category{Special functions}
496 @c -----------------------------------------------------------------------------
497 @node Airy Functions, Gamma and Factorial Functions, Bessel Functions, Special Functions
498 @section Airy Functions
499 @c -----------------------------------------------------------------------------
502 m4_math(<<<{\rm Ai}(x)>>>,<<<Ai(x)>>>)
504 m4_math(<<<{\rm Bi}(x)>>>,<<<Bi(x)>>>)
505 are defined in Abramowitz and Stegun,
506 @i{Handbook of Mathematical Functions}, @urlaands{Section 10.4, 446} and @urldlmf{9}.
508 The Airy differential equation is:
511 <<<{d^2 y\over dx^2} - xy = 0>>>,
512 <<<@math{diff (y(x), x, 2) - x y(x) = 0}>>>)
514 The numerically satisfactory pair of solutions (@urldlmf{9.2#T1}) on
516 m4_math(<<<y = {\rm Ai}(x)>>>,<<<y = Ai(x)>>>)
518 m4_mathdot(<<<y = {\rm Bi}(x)>>>,<<<y = Bi(x)>>>)
519 These two solutions are oscillatory for @math{x < 0}.
520 m4_math({\rm Ai}(x), Ai(x))
522 the solution subject to the condition that
523 m4_math(y\rightarrow 0, y->0)
525 m4_math(<<<x\rightarrow +\infty,>>>, <<<x -> +inf,>>>)
527 m4_math({\rm Bi}(x), Bi(x))
529 the second solution with the
531 m4_math({\rm Ai}(x),Ai(x))
533 m4_math(x\rightarrow-\infty,x->minf)
534 which differs in phase
536 m4_mathdot(\pi/2,%pi/2)
538 m4_math({\rm Bi}(x),Bi(x))
541 m4_mathdot(x\rightarrow +\infty, x->+inf)
544 If the argument @math{x} is a real or complex floating point
545 number, the numerical value of the function is returned.
548 @deffn {Function} airy_ai (@var{x})
550 m4_mathdot(<<<{\rm Ai}(x)>>>, <<<Ai(x)>>>)
551 See @urlaands{eqn 10.4.2, 446} and @urldlmf{9}.
553 See also @mrefcomma{airy_bi} @mrefcomma{airy_dai} and @mrefdot{airy_dbi}
555 @opencatbox{Categories:}
556 @category{Airy functions}
557 @category{Special functions}
561 @c -----------------------------------------------------------------------------
563 @deffn {Function} airy_dai (@var{x})
564 The derivative of the Airy function
565 m4_mathpunc(<<<:>>>,<<<{\rm Ai}(x)>>>,<<<Ai(x)>>>)
569 <<<{\rm airy\_dai}(x) = {d\over dx}{\rm Ai}(x)>>>,
570 <<<@math{airy_dai(x) = diff(airy_ai(x),x)>>>})
572 See @mrefdot{airy_ai}
574 @opencatbox{Categories:}
575 @category{Airy functions}
576 @category{Special functions}
580 @c -----------------------------------------------------------------------------
582 @deffn {Function} airy_bi (@var{x})
584 m4_mathdot(<<<{\rm Bi}(x)>>>, Bi(x))
585 See @urlaands{eqn 10.4.3, 446} and @urldlmf{9}.
587 See @mrefcomma{airy_ai} and @mrefdot{airy_dbi}
589 @opencatbox{Categories:}
590 @category{Airy functions}
591 @category{Special functions}
595 @c -----------------------------------------------------------------------------
597 @deffn {Function} airy_dbi (@var{x})
598 The derivative of the Airy function
599 m4_mathpunc(<<<:>>>,<<<{\rm Bi}(x)>>>, <<<Bi(x)>>>)
603 <<<{\rm airy\_dbi}(x) = {d\over dx}{\rm Bi}(x)>>>,
604 <<<@math{airy_dbi(x) = diff(airy_bi(x),x)}>>>)
606 See @mrefcomma{airy_ai} and @mrefdot{airy_bi}
608 @opencatbox{Categories:}
609 @category{Airy functions}
610 @category{Special functions}
614 @c -----------------------------------------------------------------------------
615 @node Gamma and Factorial Functions, Exponential Integrals, Airy Functions, Special Functions
616 @section Gamma and Factorial Functions
617 @c -----------------------------------------------------------------------------
619 The gamma function and the related beta, psi and incomplete gamma
620 functions are defined in Abramowitz and Stegun,
621 @i{Handbook of Mathematical Functions}, Chapter 6.
623 @c FOLLOWING FUNCTIONS IN bffac.mac ARE NOT DESCRIBED IN .texi FILES: !!!
624 @c obfac, azetb, vonschtoonk, divrlst, obzeta, bfhzeta, bfpsi0 !!!
625 @c DON'T KNOW WHICH ONES ARE INTENDED FOR GENERAL USE !!!
627 @c FOLLOWING FUNCTIONS IN bffac.mac ARE DESCRIBED IN Number.texi: !!!
628 @c burn, bzeta, bfzeta !!!
630 @c FOLLOWING FUNCTIONS IN bffac.mac ARE DESCRIBED HERE: !!!
631 @c bfpsi, bffac, cbffac !!!
633 @c -----------------------------------------------------------------------------
635 @deffn {Function} bffac (@var{expr}, @var{n})
637 Bigfloat version of the factorial (shifted gamma)
638 function. The second argument is how many digits to retain and return,
639 it's a good idea to request a couple of extra.
643 (%o1) 8.862269254527584b-1
645 (%o2) 0.886226925452758
647 (%o3) 8.862269254527580136490837416707b-1
650 @opencatbox{Categories:}
651 @category{Gamma and factorial functions}
652 @category{Numerical evaluation}
656 @c -----------------------------------------------------------------------------
658 @deffn {Function} bfpsi (@var{n}, @var{z}, @var{fpprec})
659 @deffnx {Function} bfpsi0 (@var{z}, @var{fpprec})
661 @code{bfpsi} is the polygamma function of real argument @var{z} and
662 integer order @var{n}. See @ref{polygamma, psi} for further
663 information. @code{bfpsi0} is the digamma function.
664 @code{bfpsi0(@var{z}, @var{fpprec})} is equivalent to @code{bfpsi(0,
665 @var{z}, @var{fpprec})}.
667 These functions return bigfloat values.
668 @var{fpprec} is the bigfloat precision of the return value.
670 @c psi0(1) = -%gamma IS AN INTERESTING PROPERTY BUT IN THE ABSENCE OF ANY OTHER
671 @c DISCUSSION OF THE PROPERTIES OF THIS FUNCTION, THIS STATEMENT SEEMS OUT OF PLACE.
672 @c Note @code{-bfpsi0 (1, fpprec)} provides @code{%gamma} (Euler's constant) as a bigfloat.
675 (%i1) bfpsi0(1/3, 15);
676 (%o1) - 3.13203378002081b0
677 (%i2) bfpsi0(1/3, 32);
678 (%o2) - 3.1320337800208063229964190742873b0
679 (%i3) bfpsi(0,1/3,32);
680 (%o3) - 3.1320337800208063229964190742873b0
683 (%o4) (- --------) - --------- - %gamma
686 (%o5) - 3.132033780020806
689 @opencatbox{Categories:}
690 @category{Gamma and factorial functions}
691 @category{Numerical evaluation}
695 @c -----------------------------------------------------------------------------
697 @deffn {Function} cbffac (@var{z}, @var{fpprec})
698 Complex bigfloat factorial.
700 @code{load ("bffac")} loads this function.
703 (%i1) cbffac(1+%i,16);
704 (%o1) 3.430658398165453b-1 %i + 6.529654964201666b-1
706 (%o2) 0.3430658398165453 %i + 0.6529654964201667
709 @opencatbox{Categories:}
710 @category{Gamma and factorial functions}
711 @category{Complex variables}
712 @category{Numerical evaluation}
716 @c -----------------------------------------------------------------------------
718 @deffn {Function} gamma (@var{z})
720 The basic definition of the gamma function (@urldlmf{5.2.E1} and @urlaands{eqn 6.1.1, 255}) is
723 <<<\Gamma\left(z\right)=\int_{0}^{\infty }{t^{z-1}\,e^ {- t }\;dt}>>>,
734 Maxima simplifies @code{gamma} for positive integer and positive and negative
735 rational numbers. For half integral values the result is a rational number
737 m4_mathdot(<<<\sqrt{\pi}>>>,<<<sqrt(%pi)>>>)
738 The simplification for integer values is controlled by
739 @code{factlim}. For integers greater than @code{factlim} the numerical result of
740 the factorial function, which is used to calculate @code{gamma}, will overflow.
741 The simplification for rational numbers is controlled by @code{gammalim} to
742 avoid internal overflow. See @code{factlim} and @code{gammalim}.
744 For negative integers @code{gamma} is not defined.
746 Maxima can evaluate @code{gamma} numerically for real and complex values in float
747 and bigfloat precision.
749 @code{gamma} has mirror symmetry.
751 When @mref{gamma_expand} is @code{true}, Maxima expands @code{gamma} for
752 arguments @code{z+n} and @code{z-n} where @code{n} is an integer.
754 Maxima knows the derivative of @code{gamma}.
758 Simplification for integer, half integral, and rational numbers:
761 (%i1) map('gamma,[1,2,3,4,5,6,7,8,9]);
762 (%o1) [1, 1, 2, 6, 24, 120, 720, 5040, 40320]
763 (%i2) map('gamma,[1/2,3/2,5/2,7/2]);
764 sqrt(%pi) 3 sqrt(%pi) 15 sqrt(%pi)
765 (%o2) [sqrt(%pi), ---------, -----------, ------------]
767 (%i3) map('gamma,[2/3,5/3,7/3]);
769 2 gamma(-) 4 gamma(-)
771 (%o3) [gamma(-), ----------, ----------]
775 Numerical evaluation for real and complex values:
778 (%i4) map('gamma,[2.5,2.5b0]);
779 (%o4) [1.329340388179137, 1.3293403881791370205b0]
780 (%i5) map('gamma,[1.0+%i,1.0b0+%i]);
781 (%o5) [0.498015668118356 - .1549498283018107 %i,
782 4.9801566811835604272b-1 - 1.5494982830181068513b-1 %i]
785 @code{gamma} has mirror symmetry:
788 (%i6) declare(z,complex)$
789 (%i7) conjugate(gamma(z));
790 (%o7) gamma(conjugate(z))
793 Maxima expands @code{gamma(z+n)} and @code{gamma(z-n)}, when @mref{gamma_expand}
797 (%i8) gamma_expand:true$
799 (%i9) [gamma(z+1),gamma(z-1),gamma(z+2)/gamma(z+1)];
801 (%o9) [z gamma(z), --------, z + 1]
805 The derivative of @code{gamma}:
808 (%i10) diff(gamma(z),z);
809 (%o10) psi (z) gamma(z)
813 See also @mrefdot{makegamma}
815 The Euler-Mascheroni constant is @code{%gamma}.
817 @opencatbox{Categories:}
818 @category{Gamma and factorial functions}
819 @category{Special functions}
823 @c -----------------------------------------------------------------------------
824 @deffn {Function} log_gamma (@var{z})
826 The natural logarithm of the gamma function.
833 (%i3) log_gamma(0.5);
834 (%o3) 0.5723649429247004
837 @opencatbox{Categories:}
838 @category{Gamma and factorial functions}
839 @category{Special functions}
843 @c -----------------------------------------------------------------------------
844 @deffn {Function} gamma_incomplete_lower (@var{a}, @var{z})
846 The lower incomplete gamma function (@urldlmf{8.2.E1} and @urlaands{eqn 6.5.2, 260}):
849 <<<\gamma\left(a , z\right)=\int_{0}^{z}{t^{a-1}\,e^ {- t }\;dt}>>>,
854 gamma_incomplete_lower(a, z) = I t %e dt
861 See also @mref{gamma_incomplete} (upper incomplete gamma function).
863 @opencatbox{Categories:}
864 @category{Gamma and factorial functions}
865 @category{Special functions}
869 @c -----------------------------------------------------------------------------
870 @anchor{gamma_incomplete}
871 @deffn {Function} gamma_incomplete (@var{a}, @var{z})
873 The incomplete upper gamma function (@urldlmf{8.2.E2} and @urlaands{eqn 6.5.3, 260}):
876 <<<\Gamma\left(a , z\right)=\int_{z}^{\infty }{t^{a-1}\,e^ {- t }\;dt}>>>,
881 gamma_incomplete(a, z) = I t %e dt
889 See also @mref{gamma_expand} for controlling how
890 @code{gamma_incomplete} is expressed in terms of elementary functions
893 Also see the related functions @mref{gamma_incomplete_regularized} and
894 @mref{gamma_incomplete_generalized}.
896 @opencatbox{Categories:}
897 @category{Gamma and factorial functions}
898 @category{Special functions}
902 @c -----------------------------------------------------------------------------
903 @anchor{gamma_incomplete_regularized}
904 @deffn {Function} gamma_incomplete_regularized (@var{a}, @var{z})
906 The regularized incomplete upper gamma function (@urldlmf{8.2.E4}):
909 <<<Q\left(a , z\right)={{\Gamma\left(a , z\right)}\over{\Gamma\left(a\right)}}>>>,
911 gamma_incomplete_regularized(a, z) =
912 gamma_incomplete(a, z)
913 ----------------------
918 See also @mref{gamma_expand} for controlling how
919 @mref{gamma_incomplete} is expressed in terms of elementary functions
922 Also see @mref{gamma_incomplete}.
924 @opencatbox{Categories:}
925 @category{Gamma and factorial functions}
926 @category{Special functions}
930 @c -----------------------------------------------------------------------------
931 @anchor{gamma_incomplete_generalized}
932 @deffn {Function} gamma_incomplete_generalized (@var{a}, @var{z1}, @var{z1})
934 The generalized incomplete gamma function.
937 <<<\Gamma\left(a , z_{1}, z_{2}\right)=\int_{z_{1}}^{z_{2}}{t^{a-1}\,e^ {- t }\;dt}>>>,
939 gamma_incomplete_generalized(a, z1, z2) =
950 Also see @mref{gamma_incomplete} and @mref{gamma_incomplete_regularized}.
952 @opencatbox{Categories:}
953 @category{Gamma and factorial functions}
954 @category{Special functions}
959 @c -----------------------------------------------------------------------------
960 @anchor{gamma_expand}
961 @defvr {Option variable} gamma_expand
962 Default value: @code{false}
964 @code{gamma_expand} controls expansion of @mref{gamma_incomplete}.
965 When @code{gamma_expand} is @code{true}, @code{gamma_incomplete(v,z)}
966 is expanded in terms of
967 @code{z}, @code{exp(z)}, and @mref{gamma_incomplete} or @mref{erfc} when possible.
970 (%i1) gamma_incomplete(2,z);
971 (%o1) gamma_incomplete(2, z)
972 (%i2) gamma_expand:true;
974 (%i3) gamma_incomplete(2,z);
978 (%i4) gamma_incomplete(3/2,z);
979 - z sqrt(%pi) erfc(sqrt(z))
980 (%o4) sqrt(z) %e + -----------------------
984 (%i5) gamma_incomplete(4/3,z);
986 gamma_incomplete(-, z)
988 (%o5) z %e + ----------------------
992 (%i6) gamma_incomplete(a+2,z);
994 (%o6) z (z + a + 1) %e + a (a + 1) gamma_incomplete(a, z)
995 (%i7) gamma_incomplete(a-2, z);
996 gamma_incomplete(a, z) a - 2 z 1 - z
997 (%o7) ---------------------- - z (--------------- + -----) %e
998 (1 - a) (2 - a) (a - 2) (a - 1) a - 2
1003 @opencatbox{Categories:}
1004 @category{Gamma and factorial functions}
1005 @category{Simplification flags and variables}
1009 @c -----------------------------------------------------------------------------
1011 @defvr {Option variable} gammalim
1012 Default value: 10000
1015 @code{gammalim} controls simplification of the gamma
1016 function for integral and rational number arguments. If the absolute
1017 value of the argument is not greater than @code{gammalim}, then
1018 simplification will occur. Note that the @code{factlim} switch controls
1019 simplification of the result of @code{gamma} of an integer argument as well.
1021 @opencatbox{Categories:}
1022 @category{Gamma and factorial functions}
1023 @category{Simplification flags and variables}
1028 @c NEED CROSS REFS HERE
1029 @c NEED EXAMPLES HERE
1031 @c -----------------------------------------------------------------------------
1033 @deffn {Function} makegamma (@var{expr})
1034 Transforms instances of binomial, factorial, and beta
1035 functions in @var{expr} into gamma functions.
1037 See also @mrefdot{makefact}
1040 (%i1) makegamma(binomial(n,k));
1042 (%o1) -----------------------------
1043 gamma(k + 1) gamma(n - k + 1)
1044 (%i2) makegamma(x!);
1046 (%i3) makegamma(beta(a,b));
1048 (%o3) -----------------
1052 @opencatbox{Categories:}
1053 @category{Gamma and factorial functions}
1058 @c -----------------------------------------------------------------------------
1059 @deffn {Function} beta (@var{a}, @var{b})
1060 The beta function is defined as
1062 <<<{\rm B}(a, b) = {{\Gamma(a) \Gamma(b)}\over{\Gamma(a+b)}}>>>,
1063 <<<@math{gamma(a) gamma(b)/gamma(a+b)}>>>)
1064 (@urldlmf{5.12.E1} and @urlaands{eqn 6.2.1, 258}).
1066 Maxima simplifies the beta function for positive integers and rational
1067 numbers, which sum to an integer. When @code{beta_args_sum_to_integer} is
1068 @code{true}, Maxima simplifies also general expressions which sum to an integer.
1070 For @var{a} or @var{b} equal to zero the beta function is not defined.
1072 In general the beta function is not defined for negative integers as an
1073 argument. The exception is for @var{a=-n}, @var{n} a positive integer
1074 and @var{b} a positive integer with @code{b<=n}, it is possible to define an
1075 analytic continuation. Maxima gives for this case a result.
1077 When @mref{beta_expand} is @code{true}, expressions like @code{beta(a+n,b)} and
1078 @code{beta(a-n,b)} or @code{beta(a,b+n)} and @code{beta(a,b-n)} with @code{n}
1079 an integer are simplified.
1081 Maxima can evaluate the beta function for real and complex values in float and
1082 bigfloat precision. For numerical evaluation Maxima uses @code{log_gamma}:
1085 - log_gamma(b + a) + log_gamma(b) + log_gamma(a)
1089 Maxima knows that the beta function is symmetric and has mirror symmetry.
1091 Maxima knows the derivatives of the beta function with respect to @var{a} or
1094 To express the beta function as a ratio of gamma functions see @code{makegamma}.
1098 Simplification, when one of the arguments is an integer:
1101 (%i1) [beta(2,3),beta(2,1/3),beta(2,a)];
1103 (%o1) [--, -, ---------]
1107 Simplification for two rational numbers as arguments which sum to an integer:
1110 (%i2) [beta(1/2,5/2),beta(1/3,2/3),beta(1/4,3/4)];
1112 (%o2) [-----, -------, sqrt(2) %pi]
1116 When setting @code{beta_args_sum_to_integer} to @code{true} more general
1117 expression are simplified, when the sum of the arguments is an integer:
1120 (%i3) beta_args_sum_to_integer:true$
1121 (%i4) beta(a+1,-a+2);
1123 (%o4) ------------------
1127 The possible results, when one of the arguments is a negative integer:
1130 (%i5) [beta(-3,1),beta(-3,2),beta(-3,3)];
1136 @code{beta(a+n,b)} or @code{beta(a-n,b)} with @code{n} an integer simplifies when
1137 @mref{beta_expand} is @code{true}:
1140 (%i6) beta_expand:true$
1141 (%i7) [beta(a+1,b),beta(a-1,b),beta(a+1,b)/beta(a,b+1)];
1142 a beta(a, b) beta(a, b) (b + a - 1) a
1143 (%o7) [------------, ----------------------, -]
1148 Beta is not defined, when one of the arguments is zero:
1152 beta: expected nonzero arguments; found 0, b
1153 -- an error. To debug this try debugmode(true);
1156 Numerical evaluation for real and complex arguments in float or bigfloat
1160 (%i8) beta(2.5,2.3);
1161 (%o8) .08694748611299981
1163 (%i9) beta(2.5,1.4+%i);
1164 (%o9) 0.0640144950796695 - .1502078053286415 %i
1166 (%i10) beta(2.5b0,2.3b0);
1167 (%o10) 8.694748611299969b-2
1169 (%i11) beta(2.5b0,1.4b0+%i);
1170 (%o11) 6.401449507966944b-2 - 1.502078053286415b-1 %i
1173 Beta is symmetric and has mirror symmetry:
1176 (%i14) beta(a,b)-beta(b,a);
1178 (%i15) declare(a,complex,b,complex)$
1179 (%i16) conjugate(beta(a,b));
1180 (%o16) beta(conjugate(a), conjugate(b))
1183 The derivative of the beta function wrt @code{a}:
1186 (%i17) diff(beta(a,b),a);
1187 (%o17) - beta(a, b) (psi (b + a) - psi (a))
1191 @opencatbox{Categories:}
1192 @category{Gamma and factorial functions}
1196 @c -----------------------------------------------------------------------------
1197 @deffn {Function} beta_incomplete (@var{a}, @var{b}, @var{z})
1199 The basic definition of the incomplete beta function
1200 (@urldlmf{8.17.E1} and @urlaands{eqn 6.6.1, 263}) is
1203 <<<{\rm B}_z(a,b) = \int_0^z t^{a-1}(1-t)^{b-1}\; dt>>>,
1228 This definition is possible for
1229 m4_math(<<<{\rm Re}(a) > 0>>>, <<<realpart(a)>0>>>)
1231 m4_math(<<<{\rm Re}(b) > 0>>>, <<<realpart(b)>0>>>)
1233 m4_mathdot(<<<|z| < 1>>>, <<<abs(z)<1>>>)
1234 For other values the incomplete beta function can be
1235 defined through a generalized hypergeometric function:
1238 gamma(a) hypergeometric_generalized([a, 1 - b], [a + 1], z) z
1241 (See @url{https://functions.wolfram.com/GammaBetaErf/Beta3/} for a complete definition of the incomplete beta
1244 For negative integers @math{a = -n} and positive integers @math{b=m}
1246 m4_math(<<<m \le n>>>, <<<m<=n>>>)
1247 the incomplete beta function is defined through
1250 <<<z^{n-1}\sum_{k=0}^{m-1} {{(1-m)_k z^k} \over {k! (n-k)}}>>>,
1271 Maxima uses this definition to simplify @code{beta_incomplete} for @var{a} a
1274 For @var{a} a positive integer, @code{beta_incomplete} simplifies for any
1275 argument @var{b} and @var{z} and for @var{b} a positive integer for any
1276 argument @var{a} and @var{z}, with the exception of @var{a} a negative integer.
1279 m4_mathcomma(<<<{\rm Re}(a) > 0>>>, <<<realpart(a)>0>>>)
1280 @code{beta_incomplete} has the
1281 specific value zero. For @math{z=1} and
1282 m4_mathcomma(<<<{\rm Re}(b) > 0>>>, <<<realpart(b)>0>>>)
1283 @code{beta_incomplete} simplifies to the beta function @code{beta(a,b)}.
1285 Maxima evaluates @code{beta_incomplete} numerically for real and complex values
1286 in float or bigfloat precision. For the numerical evaluation an expansion of the
1287 incomplete beta function in continued fractions is used.
1289 When the option variable @mref{beta_expand} is @code{true}, Maxima expands
1290 expressions like @code{beta_incomplete(a+n,b,z)} and
1291 @code{beta_incomplete(a-n,b,z)} where n is a positive integer.
1293 Maxima knows the derivatives of @code{beta_incomplete} with respect to the
1294 variables @var{a}, @var{b} and @var{z} and the integral with respect to the
1299 Simplification for @var{a} a positive integer:
1302 (%i1) beta_incomplete(2,b,z);
1304 1 - (1 - z) (b z + 1)
1305 (%o1) ----------------------
1309 Simplification for @var{b} a positive integer:
1312 (%i2) beta_incomplete(a,2,z);
1315 (%o2) ------------------
1319 Simplification for @var{a} and @var{b} a positive integer:
1322 (%i3) beta_incomplete(3,2,z);
1326 (%o3) ------------------
1331 @var{a} is a negative integer and @math{b<=(-a)}, Maxima simplifies:
1334 (%i4) beta_incomplete(-3,1,z);
1341 For the specific values @math{z=0} and @math{z=1}, Maxima simplifies:
1344 (%i5) assume(a>0,b>0)$
1345 (%i6) beta_incomplete(a,b,0);
1347 (%i7) beta_incomplete(a,b,1);
1351 Numerical evaluation in float or bigfloat precision:
1354 (%i8) beta_incomplete(0.25,0.50,0.9);
1355 (%o8) 4.594959440269333
1357 (%i10) beta_incomplete(0.25,0.50,0.9b0);
1358 (%o10) 4.594959440269324086971203b0
1361 For @math{abs(z)>1} @code{beta_incomplete} returns a complex result:
1364 (%i11) beta_incomplete(0.25,0.50,1.7);
1365 (%o11) 5.244115108584249 - 1.45518047787844 %i
1368 Results for more general complex arguments:
1371 (%i14) beta_incomplete(0.25+%i,1.0+%i,1.7+%i);
1372 (%o14) 2.726960675662536 - .3831175704269199 %i
1373 (%i15) beta_incomplete(1/2,5/4*%i,2.8+%i);
1374 (%o15) 13.04649635168716 %i - 5.802067956270001
1378 Expansion, when @mref{beta_expand} is @code{true}:
1381 (%i23) beta_incomplete(a+1,b,z),beta_expand:true;
1383 a beta_incomplete(a, b, z) (1 - z) z
1384 (%o23) -------------------------- - -----------
1387 (%i24) beta_incomplete(a-1,b,z),beta_expand:true;
1389 beta_incomplete(a, b, z) (- b - a + 1) (1 - z) z
1390 (%o24) -------------------------------------- - ---------------
1394 Derivative and integral for @code{beta_incomplete}:
1397 (%i34) diff(beta_incomplete(a, b, z), z);
1402 (%i35) integrate(beta_incomplete(a, b, z), z);
1405 (%o35) ----------- + beta_incomplete(a, b, z) z
1407 a beta_incomplete(a, b, z)
1408 - --------------------------
1410 (%i36) factor(diff(%, z));
1411 (%o36) beta_incomplete(a, b, z)
1414 @opencatbox{Categories:}
1415 @category{Gamma and factorial functions}
1419 @c -----------------------------------------------------------------------------
1420 @anchor{beta_incomplete_regularized}
1421 @deffn {Function} beta_incomplete_regularized (@var{a}, @var{b}, @var{z})
1423 The regularized incomplete beta function (@urldlmf{8.17.E2} and
1424 @urlaands{eqn 6.6.2, 263}), defined as
1427 <<<I_z(a,b) = {{\rm B}_z(a,b)\over {\rm B}(a,b)}>>>,
1429 beta_incomplete_regularized(a, b, z) =
1430 beta_incomplete(a, b, z)
1431 ------------------------
1436 @c beta_incomplete_regularized(a, b, z) =
1437 @c beta_incomplete(a, b, z)
1438 @c ------------------------
1442 As for @code{beta_incomplete} this definition is not complete. See
1443 @url{https://functions.wolfram.com/GammaBetaErf/BetaRegularized/} for a complete definition of
1444 @code{beta_incomplete_regularized}.
1446 @code{beta_incomplete_regularized} simplifies @var{a} or @var{b} a positive
1450 m4_mathcomma(<<<{\rm Re}(a)>0>>>, <<<realpart(a) > 0>>>)
1451 @code{beta_incomplete_regularized} has
1452 the specific value 0. For @math{z=1} and
1453 m4_mathcomma(<<<{\rm Re}(b) > 0>>>, <<<realpart(b)>0>>>)
1454 @code{beta_incomplete_regularized} simplifies to 1.
1456 Maxima can evaluate @code{beta_incomplete_regularized} for real and complex
1457 arguments in float and bigfloat precision.
1459 When @mref{beta_expand} is @code{true}, Maxima expands
1460 @code{beta_incomplete_regularized} for arguments @math{a+n} or @math{a-n},
1461 where n is an integer.
1463 Maxima knows the derivatives of @code{beta_incomplete_regularized} with respect
1464 to the variables @var{a}, @var{b}, and @var{z} and the integral with respect to
1465 the variable @var{z}.
1469 Simplification for @var{a} or @var{b} a positive integer:
1472 (%i1) beta_incomplete_regularized(2,b,z);
1474 (%o1) 1 - (1 - z) (b z + 1)
1476 (%i2) beta_incomplete_regularized(a,2,z);
1478 (%o2) (a (1 - z) + 1) z
1480 (%i3) beta_incomplete_regularized(3,2,z);
1482 (%o3) (3 (1 - z) + 1) z
1485 For the specific values @math{z=0} and @math{z=1}, Maxima simplifies:
1488 (%i4) assume(a>0,b>0)$
1489 (%i5) beta_incomplete_regularized(a,b,0);
1491 (%i6) beta_incomplete_regularized(a,b,1);
1495 Numerical evaluation for real and complex arguments in float and bigfloat
1499 (%i7) beta_incomplete_regularized(0.12,0.43,0.9);
1500 (%o7) .9114011367359802
1502 (%i9) beta_incomplete_regularized(0.12,0.43,0.9b0);
1503 (%o9) 9.1140113673598075519946998779975b-1
1504 (%i10) beta_incomplete_regularized(1+%i,3/3,1.5*%i);
1505 (%o10) .2865367499935403 %i - 0.122995963334684
1507 (%i12) beta_incomplete_regularized(1+%i,3/3,1.5b0*%i);
1508 (%o12) 2.8653674999354036142b-1 %i - 1.2299596333468400163b-1
1511 Expansion, when @mref{beta_expand} is @code{true}:
1514 (%i13) beta_incomplete_regularized(a+1,b,z);
1517 (%o13) beta_incomplete_regularized(a, b, z) - ------------
1519 (%i14) beta_incomplete_regularized(a-1,b,z);
1520 (%o14) beta_incomplete_regularized(a, b, z)
1523 - ----------------------
1524 beta(a, b) (b + a - 1)
1527 The derivative and the integral wrt @var{z}:
1530 (%i15) diff(beta_incomplete_regularized(a,b,z),z);
1533 (%o15) -------------------
1535 (%i16) integrate(beta_incomplete_regularized(a,b,z),z);
1536 (%o16) beta_incomplete_regularized(a, b, z) z
1539 a (beta_incomplete_regularized(a, b, z) - ------------)
1541 - -------------------------------------------------------
1545 @opencatbox{Categories:}
1546 @category{Gamma and factorial functions}
1550 @c -----------------------------------------------------------------------------
1551 @deffn {Function} beta_incomplete_generalized (@var{a}, @var{b}, @var{z1}, @var{z2})
1553 The basic definition of the generalized incomplete beta function is
1556 <<<\int_{z_1}^{z_2} t^{a-1}(1-t)^{b-1}\; dt>>>,
1581 Maxima simplifies @code{beta_incomplete_regularized} for @var{a} and @var{b}
1585 m4_math(<<<{\rm Re}(a) > 0>>>, <<<realpart(a)>0>>>)
1587 m4_math(z_1 = 0, z1=0)
1589 m4_mathcomma(z_2 = 0, z2=0)
1591 @code{beta_incomplete_generalized} to @code{beta_incomplete}.
1593 m4_math({\rm Re}(b) > 0, realpart(b)>0)
1595 m4_math(z_1 = 1, z1=1)
1597 m4_mathcomma(z_2 = 1, z2=1)
1598 Maxima simplifies to an
1599 expression with @code{beta} and @code{beta_incomplete}.
1601 Maxima evaluates @code{beta_incomplete_regularized} for real and complex values
1602 in float and bigfloat precision.
1604 When @mref{beta_expand} is @code{true}, Maxima expands
1605 @code{beta_incomplete_generalized} for @math{a+n} and @math{a-n}, @var{n} a
1608 Maxima knows the derivative of @code{beta_incomplete_generalized} with respect
1609 to the variables @var{a}, @var{b}, @var{z1}, and @var{z2} and the integrals with
1610 respect to the variables @var{z1} and @var{z2}.
1614 Maxima simplifies @code{beta_incomplete_generalized} for @var{a} and @var{b} a
1618 (%i1) beta_incomplete_generalized(2,b,z1,z2);
1620 (1 - z1) (b z1 + 1) - (1 - z2) (b z2 + 1)
1621 (%o1) -------------------------------------------
1623 (%i2) beta_incomplete_generalized(a,2,z1,z2);
1626 (a (1 - z2) + 1) z2 - (a (1 - z1) + 1) z1
1627 (%o2) -------------------------------------------
1630 (%i3) beta_incomplete_generalized(3,2,z1,z2);
1632 (1 - z1) (3 z1 + 2 z1 + 1) - (1 - z2) (3 z2 + 2 z2 + 1)
1633 (%o3) -----------------------------------------------------------
1637 Simplification for specific values @math{z1=0}, @math{z2=0}, @math{z1=1}, or
1641 (%i4) assume(a > 0, b > 0)$
1642 (%i5) beta_incomplete_generalized(a,b,z1,0);
1643 (%o5) - beta_incomplete(a, b, z1)
1645 (%i6) beta_incomplete_generalized(a,b,0,z2);
1646 (%o6) - beta_incomplete(a, b, z2)
1648 (%i7) beta_incomplete_generalized(a,b,z1,1);
1649 (%o7) beta(a, b) - beta_incomplete(a, b, z1)
1651 (%i8) beta_incomplete_generalized(a,b,1,z2);
1652 (%o8) beta_incomplete(a, b, z2) - beta(a, b)
1655 Numerical evaluation for real arguments in float or bigfloat precision:
1658 (%i9) beta_incomplete_generalized(1/2,3/2,0.25,0.31);
1659 (%o9) .09638178086368676
1662 (%i10) beta_incomplete_generalized(1/2,3/2,0.25,0.31b0);
1663 (%o10) 9.6381780863686935309170054689964b-2
1666 Numerical evaluation for complex arguments in float or bigfloat precision:
1669 (%i11) beta_incomplete_generalized(1/2+%i,3/2+%i,0.25,0.31);
1670 (%o11) - .09625463003205376 %i - .003323847735353769
1672 (%i13) beta_incomplete_generalized(1/2+%i,3/2+%i,0.25,0.31b0);
1673 (%o13) - 9.6254630032054178691b-2 %i - 3.3238477353543591914b-3
1676 Expansion for @math{a+n} or @math{a-n}, @var{n} a positive integer, when
1677 @mref{beta_expand} is @code{true}:
1680 (%i14) beta_expand:true$
1682 (%i15) beta_incomplete_generalized(a+1,b,z1,z2);
1685 (1 - z1) z1 - (1 - z2) z2
1686 (%o15) -----------------------------
1688 a beta_incomplete_generalized(a, b, z1, z2)
1689 + -------------------------------------------
1691 (%i16) beta_incomplete_generalized(a-1,b,z1,z2);
1693 beta_incomplete_generalized(a, b, z1, z2) (- b - a + 1)
1694 (%o16) -------------------------------------------------------
1697 (1 - z2) z2 - (1 - z1) z1
1698 - -------------------------------------
1702 Derivative wrt the variable @var{z1} and integrals wrt @var{z1} and @var{z2}:
1705 (%i17) diff(beta_incomplete_generalized(a,b,z1,z2),z1);
1707 (%o17) - (1 - z1) z1
1708 (%i18) integrate(beta_incomplete_generalized(a,b,z1,z2),z1);
1709 (%o18) beta_incomplete_generalized(a, b, z1, z2) z1
1710 + beta_incomplete(a + 1, b, z1)
1711 (%i19) integrate(beta_incomplete_generalized(a,b,z1,z2),z2);
1712 (%o19) beta_incomplete_generalized(a, b, z1, z2) z2
1713 - beta_incomplete(a + 1, b, z2)
1716 @opencatbox{Categories:}
1717 @category{Gamma and factorial functions}
1721 @anchor{beta_expand}
1722 @defvr {Option variable} beta_expand
1723 Default value: false
1725 When @code{beta_expand} is @code{true}, @code{beta(a,b)} and related
1726 functions are expanded for arguments like @math{a+n} or @math{a-n},
1727 where @math{n} is an integer.
1729 @xref{beta} for examples.
1731 @opencatbox{Categories:}
1732 @category{Gamma and factorial functions}
1733 @category{Simplification flags and variables}
1737 @defvr {Option variable} beta_args_sum_to_integer
1738 Default value: false
1740 When @code{beta_args_sum_to_integer} is @code{true}, Maxima simplifies
1741 @code{beta(a,b)}, when the arguments @var{a} and @var{b} sum to an integer.
1743 @xref{beta} for examples.
1745 @opencatbox{Categories:}
1746 @category{Gamma and factorial functions}
1747 @category{Simplification flags and variables}
1752 @c NEED INFO HERE ABOUT THE SUBSCRIPTED FORM psi[n](x)
1753 @c I (rtoy) don't think there is a plain psi(x) function anymore.
1754 @c @deffn {Function} psi (@var{x})
1755 @c @deffnx {Function} psi [@var{n}](@var{x})
1757 @deffn {Function} psi [@var{n}](@var{x})
1759 @c The derivative of @code{log (gamma (@var{x}))} of order @code{@var{n}+1}.
1760 @code{psi[n](x)} is the polygamma function (@urldlmf{5.2E2},
1761 @urldlmf{5.15}, @urlaands{eqn 6.3.1, 258} and @urlaands{eqn 6.4.1, 260}) defined by
1763 <<<\psi^{(n)}(x) = {d^{n+1}\over{dx^{n+1}}} \log\Gamma(x)>>>,
1764 <<<@math{diff(log(gamma(x)), x, n+1)}>>>)
1765 Thus, @code{psi[0](@var{x})} is the first derivative,
1766 @code{psi[1](@var{x})} is the second derivative, etc.
1768 Maxima can compute some exact values for rational args as well for
1769 float and bfloat args. Several variables control what range of
1771 m4_math(<<<\psi^{(n)}(x)>>>,<<<psi[n](x)>>>)
1773 exact value, if possible. See @mref{maxpsiposint},
1774 @mref{maxpsinegint}, @mref{maxpsifracnum}, and
1775 @mrefdot{maxpsifracdenom} That is, @math{x} must lie between
1776 @code{maxpsinegint} and @code{maxpsiposint}. If the absolute value of
1777 the fractional part of @math{x} is rational and has a numerator less
1778 than @code{maxpsifracnum} and has a denominator less than
1779 @code{maxpsifracdenom},
1780 m4_math(<<<\psi^{(0)}(x)>>>,<<<psi[0](x)>>>)
1782 return an exact value.
1784 The function @mref{bfpsi} in the @code{bffac} package can compute
1789 (%o1) - 4.227453533376265
1792 (%o2) (- 3 log(2)) - --- - %gamma
1795 (%o3) - 4.227453533376265
1797 (%o4) - 5.30263321633764
1800 (%o5) psi (-) + 4 %pi
1803 (%o6) - 5.30263321633764
1806 @opencatbox{Categories:}
1807 @category{Gamma and factorial functions}
1811 @anchor{maxpsiposint}
1812 @defvr {Option variable} maxpsiposint
1815 @code{maxpsiposint} is the largest positive integer value for
1817 m4_math(<<<\psi^{(n)}(m)>>>,<<<psi[n](x)>>>)
1818 gives an exact value for
1824 (%o1) --------- - %gamma
1830 1683118856778495358491487
1831 (%o3) 2 (------------------------- - zeta(3))
1832 1401731326612193601024000
1839 @opencatbox{Categories:}
1840 @category{Gamma and factorial functions}
1845 @anchor{maxpsinegint}
1846 @defvr {Option variable} maxpsinegint
1849 @code{maxpsinegint} is the most negative value for
1851 m4_math(<<<\psi^{(0)}(x)>>>,<<<psi[0](x)>>>)
1852 will try to compute an exact
1853 value for rational @math{x}. That is if @math{x} is less than
1854 @code{maxpsinegint},
1855 m4_math(<<<\psi^{(n)}(x)>>>,<<<psi[n](x)>>>)
1857 return simplified answer, even if it could.
1860 (%i1) psi[0](-100/9);
1864 (%i2) psi[0](-100/11);
1865 100 %pi 1 5231385863539
1866 (%o2) %pi cot(-------) + psi (--) + -------------
1867 11 0 11 381905105400
1869 (%i3) psi[2](-100/9);
1873 (%i4) psi[2](-100/11);
1874 3 100 %pi 2 100 %pi 1
1875 (%o4) 2 %pi cot(-------) csc (-------) + psi (--)
1877 74191313259470963498957651385614962459
1878 + --------------------------------------
1879 27850718060013605318710152732000000
1881 @opencatbox{Categories:}
1882 @category{Gamma and factorial functions}
1887 @anchor{maxpsifracnum}
1888 @defvr {Option variable} maxpsifracnum
1891 Let @math{x} be a rational number of the form @math{p/q}.
1892 If @math{p} is greater than @code{maxpsifracnum},
1894 m4_math(<<<\psi^{(0)}(x)>>>,<<<@code{psi[0](x)}>>>)
1896 return a simplified value.
1901 (%o1) (- 3 log(2)) + --- - %gamma
1905 (%o2) psi (-) + 4 %pi
1907 (%i3) maxpsifracnum:2;
1915 (%o5) psi (-) + 4 %pi
1919 @opencatbox{Categories:}
1920 @category{Gamma and factorial functions}
1925 @anchor{maxpsifracdenom}
1926 @defvr {Option variable} maxpsifracdenom
1929 Let @math{x} be a rational number of the form @math{p/q}.
1930 If @math{q} is greater than @code{maxpsifracdenom},
1932 m4_math(<<<\psi^{(0)}(x)>>>,<<<@code{psi[@var{0}](@var{x})}>>>)
1934 not try to return a simplified value.
1939 (%o1) (- 3 log(2)) + --- - %gamma
1943 (%o2) psi (-) + 4 %pi
1945 (%i3) maxpsifracdenom:2;
1953 (%o5) psi (-) + 4 %pi
1957 @opencatbox{Categories:}
1958 @category{Gamma and factorial functions}
1963 @c NEED CROSS REFS HERE
1964 @c NEED EXAMPLES HERE
1966 @deffn {Function} makefact (@var{expr})
1967 Transforms instances of binomial, gamma, and beta
1968 functions in @var{expr} into factorials.
1970 See also @mrefdot{makegamma}
1973 (%i1) makefact(binomial(n,k));
1977 (%i2) makefact(gamma(x));
1979 (%i3) makefact(beta(a,b));
1981 (%o3) -----------------
1985 @opencatbox{Categories:}
1986 @category{Gamma and factorial functions}
1991 @c AREN'T THERE OTHER FUNCTIONS THAT DO ESSENTIALLY THE SAME THING ??
1992 @deffn {Function} numfactor (@var{expr})
1993 Returns the numerical factor multiplying the expression
1994 @var{expr}, which should be a single term.
1996 @c WHY IS content MENTIONED IN THIS CONTEXT ??
1997 @mref{content} returns the greatest common divisor (gcd) of all terms in a sum.
2004 (%i2) numfactor (%);
2010 @opencatbox{Categories:}
2011 @category{Expressions}
2016 @node Exponential Integrals, Error Function, Gamma and Factorial Functions, Special Functions
2017 @section Exponential Integrals
2019 The Exponential Integral and related functions are defined in
2020 Abramowitz and Stegun,
2021 @i{Handbook of Mathematical Functions}, @urlaands{Chapter 5, 228}.
2023 @anchor{expintegral_e1}
2024 @deffn {Function} expintegral_e1 (@var{z})
2025 The Exponential Integral E1(z) defined as
2028 <<<E_1(z) = \int_z^\infty {e^{-t} \over t} dt>>>,
2029 <<<@math{integrate(exp(-t)/t, t, z, inf)}>>>)
2032 m4_mathdot(<<<\left| \arg z \right| < \pi>>>, <<<abs(arg z) < %pi>>>)
2033 (@urlaands{eqn 5.1.1, 228}) and (@urldlmf{6.2E2})
2035 This can be written in terms of other functions. @xref{expintrep} for examples.
2036 @opencatbox{Categories:}
2037 @category{Exponential Integrals}
2038 @category{Special functions}
2042 @deffn {Function} expintegral_ei (@var{x})
2043 The Exponential Integral Ei(x) defined as
2047 = - -\kern-10.5pt\int_{-x}^\infty {e^{-t} \over t} dt
2048 = -\kern-10.5pt\int_{-\infty}^x {e^{t} \over t} dt >>>,
2049 <<<@math{-integrate(%e^(-t)/t, t, -x, inf) = integrate(%e^(t)/t, t, -inf, x)} >>>)
2051 with @math{x} real and @math{x > 0}. (@urlaands{eqn 5.1.2, 228}) and (@urldlmf{6.2E5})
2053 This can be written in terms of other functions. @xref{expintrep} for examples.
2055 @opencatbox{Categories:}
2056 @category{Exponential Integrals}
2057 @category{Special functions}
2061 @deffn {Function} expintegral_li (@var{x})
2062 The Exponential Integral li(x) defined as
2065 <<<li(x) = -\kern-10.5pt\int_0^x {dt \over \ln t}>>>,
2066 <<<@math{integrate(1/ln(t), t, 0, x)}>>>)
2068 with @math{x} real and @math{x > 1}. (@urlaands{eqn 5.1.3, 228}) and (@urldlmf{6.2E8})
2070 This can be written in terms of other functions. @xref{expintrep} for examples.
2072 @opencatbox{Categories:}
2073 @category{Exponential Integrals}
2074 @category{Special functions}
2078 @anchor{expintegral_e}
2079 @deffn {Function} expintegral_e (@var{n},@var{z})
2080 The Exponential Integral En(z) (@urlaands{eqn 5.1.4, 228}) defined as
2083 <<<E_n(z) = \int_1^\infty {e^{-zt} \over t^n} dt>>>,
2084 <<<@math{integrate(exp(-z*t)/t^n, t, 1, inf)}>>>)
2086 m4_math(<<<{\rm Re}(z) > 1>>>,<<<realpart(z) > 1>>>)
2088 non-negative integer.
2090 For half-integral orders, this can be written in terms of @mref{erfc}
2091 or @mref{erf}. @xref{expintexpand} for examples.
2093 @opencatbox{Categories:}
2094 @category{Exponential Integrals}
2095 @category{Special functions}
2099 @anchor{expintegral_si}
2100 @deffn {Function} expintegral_si (@var{z})
2101 The Exponential Integral Si(z) (@urlaands{eqn 5.2.1, 231}
2102 and @urldlmf{6.2#E9}) defined as
2105 <<<{\rm Si}(z) = \int_0^z {\sin t \over t} dt>>>,
2106 <<<@math{integrate(sin(t)/t, t, 0, z)}>>>)
2108 This can be written in terms of other functions. @xref{expintrep} for examples.
2110 @opencatbox{Categories:}
2111 @category{Exponential Integrals}
2112 @category{Special functions}
2116 @anchor{expintegral_ci}
2117 @deffn {Function} expintegral_ci (@var{z})
2118 The Exponential Integral Ci(z) (@urlaands{eqn 5.2.2, 231}
2119 and @urldlmf{6.2#E13}) defined as
2122 <<<{\rm Ci}(z) = \gamma + \log z + \int_0^z {{\cos t - 1} \over t} dt>>>,
2123 <<<@math{%gamma + log(z) + integrate((cos(t) - 1)/t, t, 0, z)}>>>)
2126 m4_mathdot(<<<|\arg z| < \pi>>>, <<<abs(arg z) < %pi>>>)
2128 This can be written in terms of other functions. @xref{expintrep} for examples.
2130 @opencatbox{Categories:}
2131 @category{Exponential Integrals}
2132 @category{Special functions}
2136 @anchor{expintegral_shi}
2137 @deffn {Function} expintegral_shi (@var{z})
2138 The Exponential Integral Shi(z) (@urlaands{eqn 5.2.3, 231}
2139 and @urldlmf{6.2#E15}) defined as
2142 <<<{\rm Shi}(z) = \int_0^z {\sinh t \over t} dt>>>,
2143 <<<@math{integrate(sinh(t)/t, t, 0, z)}>>>)
2145 This can be written in terms of other functions. @xref{expintrep} for examples.
2147 @opencatbox{Categories:}
2148 @category{Exponential Integrals}
2149 @category{Special functions}
2153 @anchor{expintegral_chi}
2154 @deffn {Function} expintegral_chi (@var{z})
2155 The Exponential Integral Chi(z) (@urlaands{eqn 5.2.4, 231}
2156 and @urldlmf{6.2#E16}) defined as
2159 <<<{\rm Chi}(z) = \gamma + \log z + \int_0^z {{\cosh t - 1} \over t} dt>>>,
2160 <<<@math{%gamma + log(z) + integrate((cosh(t) - 1)/t, t, 0, z)}>>>)
2163 m4_mathdot(<<<|\arg z| < \pi>>>, <<<abs(arg z) < %pi>>>)
2165 This can be written in terms of other functions. @xref{expintrep} for examples.
2167 @opencatbox{Categories:}
2168 @category{Exponential Integrals}
2169 @category{Special functions}
2174 @defvr {Option variable} expintrep
2175 Default value: false
2177 Change the representation of one of the exponential integrals,
2178 @code{expintegral_e(m, z)}, @code{expintegral_e1}, or
2179 @code{expintegral_ei} to an equivalent form if possible.
2181 Possible values for @code{expintrep} are @code{false},
2182 @code{gamma_incomplete}, @code{expintegral_e1}, @code{expintegral_ei},
2183 @code{expintegral_li}, @code{expintegral_trig}, or
2184 @code{expintegral_hyp}.
2186 @code{false} means that the representation is not changed. Other
2187 values indicate the representation is to be changed to use the
2188 function specified where @code{expintegral_trig} means
2189 @mref{expintegral_si}, @mref{expintegral_ci}; and @code{expintegral_hyp}
2190 means @mref{expintegral_shi} or @mref{expintegral_chi}.
2192 Here are some examples for @code{expintrep} set to @code{gamma_incomplete}:
2194 (%i1) expintrep:'gamma_incomplete;
2195 (%o1) gamma_incomplete
2196 (%i2) expintegral_e1(z);
2197 (%o2) gamma_incomplete(0, z)
2198 (%i3) expintegral_ei(z);
2199 (%o3) log(z) - log(- z) - gamma_incomplete(0, - z)
2200 (%i4) expintegral_li(z);
2201 (%o4) log(log(z)) - log(- log(z)) - gamma_incomplete(0, - log(z))
2202 (%i5) expintegral_e(n,z);
2204 (%o5) gamma_incomplete(1 - n, z) z
2205 (%i6) expintegral_si(z);
2206 (%o6) (%i ((- log(%i z)) + log(- %i z) - gamma_incomplete(0, %i z)
2207 + gamma_incomplete(0, - %i z)))/2
2208 (%i7) expintegral_ci(z);
2209 (%o7) log(z) - (log(%i z) + log(- %i z) + gamma_incomplete(0, %i z)
2210 + gamma_incomplete(0, - %i z))/2
2211 (%i8) expintegral_shi(z);
2212 log(z) - log(- z) + gamma_incomplete(0, z) - gamma_incomplete(0, - z)
2213 (%o8) ---------------------------------------------------------------------
2215 (%i9) expintegral_chi(z);
2217 (- log(z)) + log(- z) + gamma_incomplete(0, z) + gamma_incomplete(0, - z)
2218 - -------------------------------------------------------------------------
2222 For @code{expintrep} set to @code{expintegral_e1}:
2225 (%i1) expintrep:'expintegral_e1;
2226 (%o1) expintegral_e1
2227 (%i2) expintegral_ei(z);
2228 (%o2) log(z) - log(- z) - expintegral_e1(- z)
2229 (%i3) expintegral_li(z);
2230 (%o3) log(log(z)) - log(- log(z)) - expintegral_e1(- log(z))
2231 (%i4) expintegral_e(n,z);
2232 (%o4) expintegral_e(n, z)
2233 (%i5) expintegral_si(z);
2234 (%o5) (%i ((- log(%i z)) - expintegral_e1(%i z) + log(- %i z)
2235 + expintegral_e1(- %i z)))/2
2236 (%i6) expintegral_ci(z);
2238 log(- %i z) (expintegral_e1(%i z) + expintegral_e1(- %i z)) log(%i z)
2239 - ---------------------------------------------------------------------
2241 (%i7) expintegral_shi(z);
2242 log(z) + expintegral_e1(z) - log(- z) - expintegral_e1(- z)
2243 (%o7) -----------------------------------------------------------
2245 (%i8) expintegral_chi(z);
2246 (- log(z)) + expintegral_e1(z) + log(- z) + expintegral_e1(- z)
2247 (%o8) - ---------------------------------------------------------------
2251 For @code{expintrep} set to @code{expintegral_ei}:
2254 (%i1) expintrep:'expintegral_ei;
2255 (%o1) expintegral_ei
2256 (%i2) expintegral_e1(z);
2260 (%o2) (- log(z)) + ------------------- - expintegral_ei(- z)
2262 (%i3) expintegral_ei(z);
2263 (%o3) expintegral_ei(z)
2264 (%i4) expintegral_li(z);
2265 (%o4) expintegral_ei(log(z))
2266 (%i5) expintegral_e(n,z);
2267 (%o5) expintegral_e(n, z)
2268 (%i6) expintegral_si(z);
2269 (%o6) (%i (log(%i z) + 2 (expintegral_ei(- %i z) - expintegral_ei(%i z))
2271 - log(- %i z) + log(--) - log(- --)))/4
2273 (%i7) expintegral_ci(z);
2274 (%o7) ((- log(%i z)) + 2 (expintegral_ei(%i z) + expintegral_ei(- %i z))
2276 - log(- %i z) + log(--) + log(- --))/4 + log(z)
2278 (%i8) expintegral_shi(z);
2279 (%o8) ((- 2 log(z)) + 2 (expintegral_ei(z) - expintegral_ei(- z)) + log(- z)
2283 (%i9) expintegral_chi(z);
2286 2 log(z) + 2 (expintegral_ei(z) + expintegral_ei(- z)) - log(- z) + log(- -)
2288 ----------------------------------------------------------------------------
2292 For @code{expintrep} set to @code{expintegral_li}:
2295 (%i1) expintrep:'expintegral_li;
2296 (%o1) expintegral_li
2297 (%i2) expintegral_e1(z);
2301 (%o2) (- expintegral_li(%e )) - log(z) + -------------------
2303 (%i3) expintegral_ei(z);
2305 (%o3) expintegral_li(%e )
2306 (%i4) expintegral_li(z);
2307 (%o4) expintegral_li(z)
2308 (%i5) expintegral_e(n,z);
2309 (%o5) expintegral_e(n, z)
2310 (%i6) expintegral_si(z);
2311 %i z - %e z %pi signum(z)
2312 %i (expintegral_li(%e ) - expintegral_li(%e ) - -------------)
2314 (%o6) - ----------------------------------------------------------------------
2316 (%i7) expintegral_ci(z);
2318 expintegral_li(%e ) + expintegral_li(%e )
2319 (%o7) ------------------------------------------------- - signum(z) + 1
2321 (%i8) expintegral_shi(z);
2323 expintegral_li(%e ) - expintegral_li(%e )
2324 (%o8) -------------------------------------------
2326 (%i9) expintegral_chi(z);
2328 expintegral_li(%e ) + expintegral_li(%e )
2329 (%o9) -------------------------------------------
2333 For @code{expintrep} set to @code{expintegral_trig}:
2336 (%i1) expintrep:'expintegral_trig;
2337 (%o1) expintegral_trig
2338 (%i2) expintegral_e1(z);
2339 (%o2) log(%i z) - %i expintegral_si(%i z) - expintegral_ci(%i z) - log(z)
2340 (%i3) expintegral_ei(z);
2341 (%o3) (- log(%i z)) - %i expintegral_si(%i z) + expintegral_ci(%i z) + log(z)
2342 (%i4) expintegral_li(z);
2343 (%o4) (- log(%i log(z))) - %i expintegral_si(%i log(z))
2344 + expintegral_ci(%i log(z)) + log(log(z))
2345 (%i5) expintegral_e(n,z);
2346 (%o5) expintegral_e(n, z)
2347 (%i6) expintegral_si(z);
2348 (%o6) expintegral_si(z)
2349 (%i7) expintegral_ci(z);
2350 (%o7) expintegral_ci(z)
2351 (%i8) expintegral_shi(z);
2352 (%o8) - %i expintegral_si(%i z)
2353 (%i9) expintegral_chi(z);
2354 (%o9) (- log(%i z)) + expintegral_ci(%i z) + log(z)
2357 For @code{expintrep} set to @code{expintegral_hyp}:
2360 (%i1) expintrep:'expintegral_hyp;
2361 (%o1) expintegral_hyp
2362 (%i2) expintegral_e1(z);
2363 (%o2) expintegral_shi(z) - expintegral_chi(z)
2364 (%i3) expintegral_ei(z);
2365 (%o3) expintegral_shi(z) + expintegral_chi(z)
2366 (%i4) expintegral_li(z);
2367 (%o4) expintegral_shi(log(z)) + expintegral_chi(log(z))
2368 (%i5) expintegral_e(n,z);
2369 (%o5) expintegral_e(n, z)
2370 (%i6) expintegral_si(z);
2371 (%o6) - %i expintegral_shi(%i z)
2372 (%i7) expintegral_ci(z);
2373 (%o7) (- log(%i z)) + expintegral_chi(%i z) + log(z)
2374 (%i8) expintegral_shi(z);
2375 (%o8) expintegral_shi(z)
2376 (%i9) expintegral_chi(z);
2377 (%o9) expintegral_chi(z)
2380 @opencatbox{Categories:}
2381 @category{Exponential Integrals}
2385 @anchor{expintexpand}
2386 @defvr {Option variable} expintexpand
2387 Default value: false
2389 Expand @code{expintegral_e(n,z)} for half
2390 integral values in terms of @code{erfc} or @code{erf} and
2391 for positive integers in terms of @code{expintegral_ei}.
2394 (%i1) expintegral_e(1/2,z);
2396 (%o1) expintegral_e(-, z)
2398 (%i2) expintegral_e(1,z);
2399 (%o2) expintegral_e(1, z)
2400 (%i3) expintexpand:true;
2402 (%i4) expintegral_e(1/2,z);
2403 sqrt(%pi) erfc(sqrt(z))
2404 (%o4) -----------------------
2406 (%i5) expintegral_e(1,z);
2410 (%o5) (- log(z)) - ------------------- - expintegral_ei(- z)
2414 @opencatbox{Categories:}
2415 @category{Exponential Integrals}
2419 @node Error Function, Struve Functions, Exponential Integrals, Special Functions
2420 @section Error Function
2422 The Error function and related functions are defined in
2423 Abramowitz and Stegun,
2424 @i{Handbook of Mathematical Functions}, @urlaands{Chapter 7, 297} and (@urldlmf{7})
2426 @c -----------------------------------------------------------------------------
2428 @deffn {Function} erf (@var{z})
2430 The Error Function erf(z):
2432 <<<{\rm erf}\ z = {{2\over \sqrt{\pi}}} \int_0^z e^{-t^2}\, dt>>>,
2433 <<<@math{erf(z) = 2/sqrt(%pi)*integrate(exp(-t^2), t, 0, z)}>>>)
2435 (@urlaands{eqn 7.1.1, 297}) and (@urldlmf{7.2.E1}).
2437 See also flag @mrefdot{erfflag} This can also be expressed in terms
2438 of a hypergeometric function. @xref{hypergeometric_representation}.
2439 @opencatbox{Categories:}
2440 @category{Special functions}
2445 @deffn {Function} erfc (@var{z})
2446 The Complementary Error Function erfc(z):
2448 <<<{\rm erfc}\ z = 1 - {\rm erf}\ z>>>,
2449 <<<@math{erfc(z) = 1-erf(z)}>>>)
2451 (@urlaands{eqn 7.1.2, 297}) and (@urldlmf{7.2.E2}).
2453 This can also be expressed in terms
2454 of a hypergeometric function. @xref{hypergeometric_representation}.
2455 @opencatbox{Categories:}
2456 @category{Special functions}
2461 @deffn {Function} erfi (@var{z})
2462 The Imaginary Error Function.
2464 <<<{\rm erfi}\ z = -i\, {\rm erf}(i z)>>>,
2465 <<<@math{erfi(z) = -%i*erf(%i*z)}>>>)
2467 @opencatbox{Categories:}
2468 @category{Special functions}
2472 @anchor{erf_generalized}
2473 @deffn {Function} erf_generalized (@var{z1},@var{z2})
2474 Generalized Error function Erf(z1,z2):
2476 <<<{\rm erf}(z_1, z_2) = {{2\over \sqrt{\pi}}} \int_{z_1}^{z_2} e^{-t^2}\, dt>>>,
2477 <<<@math{erf(z) = 2/sqrt(%pi)*integrate(exp(-t^2), t, z1, z2)}>>>)
2479 This can also be expressed in terms
2480 of a hypergeometric function. @xref{hypergeometric_representation}.
2481 @opencatbox{Categories:}
2482 @category{Special functions}
2487 @deffn {Function} fresnel_c (@var{z})
2488 The Fresnel Integral
2491 <<<C(z) = \int_0^z \cos\left({\pi \over 2} t^2\right)\, dt>>>,
2492 <<<@math{C(z) = integrate(cos((%pi/2)*t^2),t,0,z)}>>>)
2494 (@urlaands{eqn 7.3.1, 300}) and (@urldlmf{7.2.E7}).
2497 m4_math(<<<C(-x) = -C(x)>>>, <<<@code{fresnel_c(-x) = -fresnel_c(x)}>>>)
2499 flag @mref{trigsign} is true.
2502 m4_math(<<<C(ix) = iC(x)>>>, <<<@code{fresnel_c(%i*x) = %i*fresnel_c(x)}>>>)
2504 flag @mref{%iargs} is true.
2506 See flags @mref{erf_representation} and @mref{hypergeometric_representation}.
2507 @opencatbox{Categories:}
2508 @category{Special functions}
2513 @deffn {Function} fresnel_s (@var{z})
2514 The Fresnel Integral
2516 <<<S(z) = \int_0^z \sin\left({\pi \over 2} t^2\right)\, dt>>>,
2517 <<<@math{S(z) = integrate(sin((%pi/2)*t^2),t,0,z)}>>>)
2519 (@urlaands{eqn 7.3.2, 300}) and (@urldlmf{7.2.E8}).
2522 m4_math(<<<S(-x) = -S(x)>>>, <<<@code{fresnel_s(-x) = -fresnel_s(x)}>>>)
2524 flag @mref{trigsign} is true.
2527 m4_math(<<<S(ix) = iS(x)>>>, <<<@code{fresnel_s(%i*x) = -%i*fresnel_s(x)}>>>)
2529 flag @mref{%iargs} is true.
2531 See flags @mref{erf_representation} and @mref{hypergeometric_representation}.
2532 @opencatbox{Categories:}
2533 @category{Special functions}
2537 @anchor{erf_representation}
2538 @defvr {Option variable} erf_representation
2539 Default value: false
2541 @code{erf_representation} controls how the error functions are
2542 represented. It must be set to one of @code{false}, @code{erf},
2543 @code{erfc}, or @code{erfi}. When set to @code{false}, the error functions are not
2544 modified. When set to @code{erf}, all error functions (@mref{erfc},
2545 @mref{erfi}, @mref{erf_generalized}, @mref{fresnel_s} and
2546 @mref{fresnel_c}) are converted to @mref{erf} functions. Similary,
2547 @code{erfc} converts error functions to @mref{erfc}. Finally
2548 @code{erfi} converts the functions to @mref{erfi}.
2550 Converting to @mref{erf}:
2552 (%i1) erf_representation:erf;
2558 (%i4) erf_generalized(z1,z2);
2559 (%o4) erf(z2) - erf(z1)
2561 sqrt(%pi) (%i + 1) z sqrt(%pi) (1 - %i) z
2562 (1 - %i) (erf(--------------------) + %i erf(--------------------))
2564 (%o5) -------------------------------------------------------------------
2567 sqrt(%pi) (%i + 1) z sqrt(%pi) (1 - %i) z
2568 (%i + 1) (erf(--------------------) - %i erf(--------------------))
2570 (%o6) -------------------------------------------------------------------
2575 Converting to @mref{erfc}:
2577 (%i1) erf_representation:erfc;
2583 (%i4) erf_generalized(z1,z2);
2584 (%o4) erfc(z1) - erfc(z2)
2586 sqrt(%pi) (%i + 1) c
2587 (%o5) ((%i + 1) ((- erfc(--------------------))
2589 sqrt(%pi) (1 - %i) c
2590 - %i (1 - erfc(--------------------)) + 1))/4
2593 sqrt(%pi) (%i + 1) c
2594 (%o6) ((1 - %i) ((- erfc(--------------------))
2596 sqrt(%pi) (1 - %i) c
2597 + %i (1 - erfc(--------------------)) + 1))/4
2601 Converting to @mref{erfc}:
2604 (%i1) erf_representation:erfi;
2607 (%o2) - %i erfi(%i z)
2609 (%o3) %i erfi(%i z) + 1
2612 (%i5) erf_generalized(z1,z2);
2613 (%o5) %i erfi(%i z1) - %i erfi(%i z2)
2615 sqrt(%pi) %i (%i + 1) z
2616 (%o6) ((%i + 1) ((- %i erfi(-----------------------))
2618 sqrt(%pi) (1 - %i) %i z
2619 - erfi(-----------------------)))/4
2623 sqrt(%pi) (1 - %i) %i z sqrt(%pi) %i (%i + 1) z
2624 (1 - %i) (erfi(-----------------------) - %i erfi(-----------------------))
2626 ---------------------------------------------------------------------------
2631 @anchor{hypergeometric_representation}
2632 @defvr {Option variable} hypergeometric_representation
2633 Default value: false
2635 Enables transformation to a Hypergeometric
2636 representation for @mref{fresnel_s} and @mref{fresnel_c} and other
2640 (%i1) hypergeometric_representation:true;
2645 %pi hypergeometric([-], [-, -], - -------) z
2647 (%o2) ---------------------------------------------
2652 (%o3) hypergeometric([-], [-, -], - -------) z
2656 2 hypergeometric([-], [-], - z ) z
2658 (%o4) ----------------------------------
2662 2 hypergeometric([-], [-], z ) z
2664 (%o5) --------------------------------
2668 2 hypergeometric([-], [-], - z ) z
2670 (%o6) 1 - ----------------------------------
2672 (%i7) erf_generalized(z1,z2);
2674 2 hypergeometric([-], [-], - z2 ) z2
2676 (%o7) ------------------------------------
2679 2 hypergeometric([-], [-], - z1 ) z1
2681 - ------------------------------------
2687 @node Struve Functions, Hypergeometric Functions, Error Function, Special Functions
2688 @section Struve Functions
2690 The Struve functions are defined in Abramowitz and Stegun,
2691 @i{Handbook of Mathematical Functions}, @urlaands{Chapter 12, 496} and (@urldlmf{11}).
2693 m4_math(<<<{\bf H}_{\nu}(z)>>>,<<<H[v](z)>>>)
2694 is a particular solution
2695 of the differential equation:
2697 <<<z^2 {d^2 w \over dz^2} + z {dw \over dz} + (z^2-\nu^2)w =
2698 {{4\left({1\over 2} z\right)^{\nu+1}} \over \sqrt{\pi} \Gamma\left(\nu + {1\over 2}\right)}>>>,
2699 <<<@math{z^2*diff(w,z,2) + z*diff(w,z)+(z^2-v^2)*w = 4*(z/2)^(v+1)/(sqrt(%pi)*gamma(v+1/2))}>>>)
2701 which has the general soution
2703 <<<w = aJ_{\nu}(z) + bY_{\nu}(z) + {\bf H}_{\nu}(z)>>>,
2704 <<<@math{w = a*bessel_j(v,z) + b*bessel_y(v,z) + struve_h(v,z)}>>>)
2706 @c -----------------------------------------------------------------------------
2708 @deffn {Function} struve_h (@var{v}, @var{z})
2709 The Struve Function H of order
2710 m4_math(<<<\nu>>>, v)
2711 and argument @math{z}:
2714 <<<{\bf H}_{\nu}(z) = \left({z\over 2}\right)^{\nu+1}
2715 \sum_{k=0}^{\infty} {(-1)^k\left({z\over 2}\right)^{2k} \over \Gamma\left(k + {3\over 2}\right) \Gamma\left(k + \nu + {3\over 2}\right)}>>>,
2716 <<<@math{struve_h(v,z) = (z/2)^(v+1)*sum((-1)^k*(z/2)^(2*k)/(gamma(k+3/2)*gamma(k+v+3/2)), k, 0, inf)}>>>)
2718 (@urlaands{eqn 12.1.3, 496}) and (@urldlmf{11.2.E1}).
2720 When @code{besselexpand} is @code{true}, @code{struve_h} is expanded in terms
2721 of elementary functions when the order @math{v} is half of an odd integer.
2722 See @mrefdot{besselexpand}
2724 @opencatbox{Categories:}
2725 @category{Special functions}
2729 @c -----------------------------------------------------------------------------
2731 @deffn {Function} struve_l (@var{v}, @var{z})
2732 The Modified Struve Function L of order
2733 m4_math(<<<\nu>>>, v)
2734 and argument @math{z}:
2736 <<<{\bf L}_{\nu}(z) = -ie^{-{i\nu\pi\over 2}} {\bf H}_{\nu}(iz)>>>,
2737 <<<@math{struve_l(v,z) = %i*exp(-%i*v*%pi/2)*struve_h(v,z)}>>>)
2739 (@urlaands{eqn 12.2.1, 498}) and (@urldlmf{11.2.E2}).
2741 When @code{besselexpand} is @code{true}, @code{struve_l} is expanded in terms
2742 of elementary functions when the order @math{v} is half of an odd integer.
2743 See @mrefdot{besselexpand}
2745 @opencatbox{Categories:}
2746 @category{Special functions}
2750 @node Hypergeometric Functions, Parabolic Cylinder Functions, Struve Functions, Special Functions
2751 @section Hypergeometric Functions
2753 The Hypergeometric Functions are defined in Abramowitz and Stegun,
2754 @i{Handbook of Mathematical Functions}, @urlaands{Chapters 13, 504} and
2757 Maxima has very limited knowledge of these functions. They
2758 can be returned from function @code{hgfred}.
2760 @deffn {Function} %m [@var{k},@var{u}] (@var{z})
2761 Whittaker M function (@urlaands{eqn 13.1.32, 505}):
2764 <<<M_{\kappa,\mu}(z) = e^{-{1\over 2}z} z^{{1\over 2} + \mu} M\left({1\over 2} + \mu - \kappa, 1 + 2\mu, z\right)>>>,
2765 <<<@math{%m[k,u](z) = exp(-z/2)*z^(1/2+u)*M(1/2+u-k,1+2*u,z)}>>>)
2767 where @math{M(a,b,z)} is Kummer's solution of the confluent hypergeometric equation.
2769 This can also be expressed by the series (@urldlmf{13.14.E6}):
2771 <<<M_{\kappa,\mu}(z) = e^{-{1\over 2} z} z^{{1\over 2} + \mu}
2772 \sum_{s=0}^{\infty} {\left({1\over 2} + \mu - \kappa\right)_s \over (1 + 2\mu)_s s!} z^s>>>,
2773 <<<@math{%m[k,u](z) = %e^(-z/2)*z^(1/2+u)*sum(pochhammer(1/2+u-k,s)/(pochhammer(1+2*u,s)*s!)*z^s, s, 0, inf)}>>>)
2775 @opencatbox{Categories:}
2776 @category{Special functions}
2780 @deffn {Function} %w [@var{k},@var{u}] (@var{z})
2781 Whittaker W function (@urlaands{eqn 13.1.33, 505}):
2783 <<<W_{\kappa,\mu}(z) = e^{-{1\over 2}z} z^{{1\over 2} + \mu} U\left({1\over 2} + \mu - \kappa, 1+2\mu,z\right)>>>,
2784 <<<@math{%w[k,v](z) = exp(-z/2)*z^(1/2+u)*U(1/2+u-k, 1+2*u, z)}>>>)
2786 where @math{U(a,b,z)} is Kummer's second solution of the confluent hypergeometric equation.
2788 @opencatbox{Categories:}
2789 @category{Special functions}
2794 @deffn {Function} %f [@var{p},@var{q}] (@var{[a],[b],z})
2796 m4_math(<<<_{p}F_{q}(a_1,a_2,...,a_p;b_1,b_2,...,b_q;z)>>>,<<<pFq(a_1,a_2,...,a_p;b_1,b_2,...,b_q;z)>>>)
2797 hypergeometric function,
2798 where @var{a} a list of length @var{p} and
2799 @var{b} a list of length @var{q}.
2800 @opencatbox{Categories:}
2801 @category{Bessel functions}
2802 @category{Special functions}
2806 @deffn {Function} hypergeometric ([@var{a1}, ..., @var{ap}],[@var{b1}, ... ,@var{bq}], x)
2807 The hypergeometric function. Unlike Maxima's @code{%f} hypergeometric
2808 function, the function @code{hypergeometric} is a simplifying
2809 function; also, @code{hypergeometric} supports complex double and
2810 big floating point evaluation. For the Gauss hypergeometric function,
2811 that is @math{p = 2} and @math{q = 1}, floating point evaluation
2812 outside the unit circle is supported, but in general, it is not
2815 When the option variable @code{expand_hypergeometric} is true (default
2816 is false) and one of the arguments @code{a1} through @code{ap} is a
2817 negative integer (a polynomial case), @code{hypergeometric} returns an
2818 expanded polynomial.
2823 (%i1) hypergeometric([],[],x);
2827 Polynomial cases automatically expand when @code{expand_hypergeometric} is true:
2830 (%i2) hypergeometric([-3],[7],x);
2831 (%o2) hypergeometric([-3],[7],x)
2833 (%i3) hypergeometric([-3],[7],x), expand_hypergeometric : true;
2834 (%o3) -x^3/504+3*x^2/56-3*x/7+1
2837 Both double float and big float evaluation is supported:
2840 (%i4) hypergeometric([5.1],[7.1 + %i],0.42);
2841 (%o4) 1.346250786375334 - 0.0559061414208204 %i
2842 (%i5) hypergeometric([5,6],[8], 5.7 - %i);
2843 (%o5) .007375824009774946 - .001049813688578674 %i
2844 (%i6) hypergeometric([5,6],[8], 5.7b0 - %i), fpprec : 30;
2845 (%o6) 7.37582400977494674506442010824b-3
2846 - 1.04981368857867315858055393376b-3 %i
2850 @deffn {Function} hypergeometric_simp (@var{e})
2852 @code{hypergeometric_simp} simplifies hypergeometric functions
2853 by applying @code{hgfred}
2854 to the arguments of any hypergeometric functions in the expression @var{e}.
2856 Only instances of @code{hypergeometric} are affected;
2857 any @code{%f}, @code{%w}, and @code{%m} in the expression @var{e} are not affected.
2858 Any unsimplified hypergeometric functions are returned unchanged
2859 (instead of changing to @code{%f} as @code{hgfred} would).
2861 @code{load("hypergeometric");} loads this function.
2863 See also @mrefdot{hgfred}
2868 @c load ("hypergeometric") $
2869 @c foo : [hypergeometric([1,1], [2], z), hypergeometric([1/2], [1], z)];
2870 @c hypergeometric_simp (foo);
2871 @c bar : hypergeometric([n], [m], z + 1);
2872 @c hypergeometric_simp (bar);
2875 (%i1) load ("hypergeometric") $
2876 (%i2) foo : [hypergeometric([1,1], [2], z), hypergeometric([1/2], [1], z)];
2877 (%o2) [hypergeometric([1, 1], [2], z),
2879 hypergeometric([-], [1], z)]
2881 (%i3) hypergeometric_simp (foo);
2883 (%o3) [- ----------, bessel_i(0, -) %e ]
2885 (%i4) bar : hypergeometric([n], [m], z + 1);
2886 (%o4) hypergeometric([n], [m], z + 1)
2887 (%i5) hypergeometric_simp (bar);
2888 (%o5) hypergeometric([n], [m], z + 1)
2891 @opencatbox{Categories:}
2892 @category{Hypergeometric functions}
2893 @category{Simplification functions}
2894 @category{Special functions}
2899 @deffn {Function} hgfred (@var{a}, @var{b}, @var{t})
2901 Simplify the generalized hypergeometric function in terms of other,
2902 simpler, forms. @var{a} is a list of numerator parameters and @var{b}
2903 is a list of the denominator parameters.
2905 If @code{hgfred} cannot simplify the hypergeometric function, it returns
2906 an expression of the form @code{%f[p,q]([a], [b], x)} where @var{p} is
2907 the number of elements in @var{a}, and @var{q} is the number of elements
2908 in @var{b}. This is the usual
2909 m4_math(<<<_pF_q>>>,<<<@code{pFq}>>>)
2910 generalized hypergeometric
2914 (%i1) assume(not(equal(z,0)));
2915 (%o1) [notequal(z, 0)]
2916 (%i2) hgfred([v+1/2],[2*v+1],2*%i*z);
2919 4 bessel_j(v, z) gamma(v + 1) %e
2920 (%o2) ---------------------------------------
2923 (%i3) hgfred([1,1],[2],z);
2928 (%i4) hgfred([a,a+1/2],[3/2],z^2);
2932 (%o4) -------------------------------
2937 It can be beneficial to load orthopoly too as the following example
2938 shows. Note that @var{L} is the generalized Laguerre polynomial.
2941 (%i5) load("orthopoly")$
2942 (%i6) hgfred([-2],[a],z);
2955 (%o7) --------- - --- + 1
2961 @node Parabolic Cylinder Functions, Functions and Variables for Special Functions, Hypergeometric Functions, Special Functions
2962 @section Parabolic Cylinder Functions
2964 The Parabolic Cylinder Functions are defined in Abramowitz and Stegun,
2965 @i{Handbook of Mathematical Functions}, @urlaands{Chapter 19, 686}.
2967 Maxima has very limited knowledge of these functions. They
2968 can be returned from function @mref{specint}.
2970 @anchor{parabolic_cylinder_d}
2971 @deffn {Function} parabolic_cylinder_d (@var{v}, @var{z})
2972 The parabolic cylinder function @code{parabolic_cylinder_d(v,z)}. (@urlaands{eqn 19.3.1, 687}).
2974 @c See https://mathworld.wolfram.com/ParabolicCylinderFunction.html for more info.
2975 The solution of the Weber differential equation
2977 <<<y''(z) + \left(\nu + {1\over 2} - {1\over 4} z^2\right) y(z) = 0>>>,
2978 <<<diff(y(z), z, 2) + (v+1/2-z^2/4)*y(z) = 0>>>)
2979 has two independent solutions, one of which is
2980 m4_mathcomma(<<<D_{\nu}(z)>>>, <<<@code{parabolic_cylinder_d(v,z)}>>>)
2981 the parabolic cylinder d function.
2983 Function @mref{specint} can return expressions containing
2984 @code{parabolic_cylinder_d(v,z)} if the option variable
2985 @mref{prefer_d} is @code{true}.
2987 @opencatbox{Categories:}
2988 @category{Special functions}
2995 @node Functions and Variables for Special Functions, , Parabolic Cylinder Functions, Special Functions
2996 @section Functions and Variables for Special Functions
2999 @deffn {Function} lambert_w (@var{z})
3000 The principal branch of Lambert's W function W(z) (@urldlmf{4.13}), the solution of
3002 <<<z = W(z)e^{W(z)}>>>,
3003 @math{z = W(z) * exp(W(z))})
3004 @opencatbox{Categories:}
3005 @category{Special functions}
3009 @deffn {Function} generalized_lambert_w (@var{k}, @var{z})
3010 The @var{k}-th branch of Lambert's W function W(z) (@urldlmf{4.13}), the solution
3012 m4_mathdot(<<<z=W(z)e^{W(z)}>>>,z = W(z) * exp(W(z)))
3014 The principal branch, denoted
3015 m4_math(W_p(z),Wp(z))
3016 in DLMF, is @code{lambert_w(z) = generalized_lambert_w(0,z)}.
3018 The other branch with real values, denoted
3019 m4_math(W_m(z), Wm(z))
3020 in DLMF, is @code{generalized_lambert_w(-1,z)}.
3021 @opencatbox{Categories:}
3022 @category{Special functions}
3028 @deffn {Function} kbateman [@var{v}] (@var{x})
3029 The Bateman k function
3033 = \frac{2}{\pi} \int_0^{\frac{\pi}{2}} \cos(x \tan\theta-v\theta)d\theta>>>,
3034 <<<@math{kbateman[v](x) = (2/%pi) integrate(cos(x*tan(t)-v*t),t,0,%pi/2)}>>>)
3036 It is a special case of the confluent hypergeometric function. Maxima can
3037 calculate the Laplace transform of @code{kbateman} using @mref{laplace}
3038 or @mrefcomma{specint} but has no other knowledge of this function.
3040 @opencatbox{Categories:}
3041 @category{Special functions}
3047 @deffn {Function} nzeta (@var{z})
3048 The Plasma Dispersion Function
3050 <<<{\rm nzeta}(z) = i\sqrt{\pi}e^{-z^2}(1-{\rm erf}(-iz))>>>,
3051 <<<@math{nzeta(z) = %i*sqrt(%pi)*exp(-z^2)*(1-erf(-%i*z))}>>>)
3053 @opencatbox{Categories:}
3054 @category{Special functions}
3058 @deffn {Function} nzetar (@var{z})
3059 Returns @code{realpart(nzeta(z))}.
3060 @opencatbox{Categories:}
3061 @category{Special functions}
3065 @deffn {Function} nzetai (@var{z})
3066 Returns @code{imagpart(nzeta(z))}.
3067 @opencatbox{Categories:}
3068 @category{Special functions}