+
    i                        ^ RI Ht ^ RIHtHtHtHt ^ RIHt ^ RI	H
t
HtHt ^ RIHtHt ^ RIHtHtHtHt ^ RIHt ^ RIHt ^ R	IHtHtHt ^ R
IHtHt ^ RI H!t!H"t" ^ RI#H$t$H%t% ^ RI&H't' ^ RI(H)t)H*t*H+t+ ^ RI,H-t-H.t. ^ RI/H0t0H1t1H2t2 ^ RI3H4t4 ^ RI5H6t6H7t7 ^ RI8H9t9 R t: ! R R]
4      t; ! R R]
4      t< ! R R]
4      t= ! R R]
4      t> ! R R]
4      t? ! R R ]
4      t@ ! R! R"]
4      tA ! R# R$]
4      tBR%# )&    )prod)AddSDummyexpand_func)Expr)DefinedFunctionArgumentIndexError	PoleError)	fuzzy_and	fuzzy_not)RationalpiooI)Powzeta)erferfcEi)re
unpolarify)explog)ceilingfloor)sqrt)sincoscot)	bernoulliharmonic)	factorialrfRisingFactorial)as_int)mpworkprec)prec_to_dpsc                 F     \        V R R7       R#   \         d     R # i ; i)F)strictT)r'   
ValueErrorns   &e/var/www/html/photoedit/myenv/lib/python3.14/site-packages/sympy/functions/special/gamma_functions.pyintliker1      s&    q s      c                      a a ] tR t^"t oRtRt]P                  3tRR lt	]
R 4       tR tR tR tR tRR	 ltR
 tRV 3R lltR tRtVtV ;t# )gammaa  
The gamma function

.. math::
    \Gamma(x) := \int^{\infty}_{0} t^{x-1} e^{-t} \mathrm{d}t.

Explanation
===========

The ``gamma`` function implements the function which passes through the
values of the factorial function (i.e., $\Gamma(n) = (n - 1)!$ when n is
an integer). More generally, $\Gamma(z)$ is defined in the whole complex
plane except at the negative integers where there are simple poles.

Examples
========

>>> from sympy import S, I, pi, gamma
>>> from sympy.abc import x

Several special values are known:

>>> gamma(1)
1
>>> gamma(4)
6
>>> gamma(S(3)/2)
sqrt(pi)/2

The ``gamma`` function obeys the mirror symmetry:

>>> from sympy import conjugate
>>> conjugate(gamma(x))
gamma(conjugate(x))

Differentiation with respect to $x$ is supported:

>>> from sympy import diff
>>> diff(gamma(x), x)
gamma(x)*polygamma(0, x)

Series expansion is also supported:

>>> from sympy import series
>>> series(gamma(x), x, 0, 3)
1/x - EulerGamma + x*(EulerGamma**2/2 + pi**2/12) + x**2*(-EulerGamma*pi**2/12 - zeta(3)/3 - EulerGamma**3/6) + O(x**3)

We can numerically evaluate the ``gamma`` function to arbitrary precision
on the whole complex plane:

>>> gamma(pi).evalf(40)
2.288037795340032417959588909060233922890
>>> gamma(1+I).evalf(20)
0.49801566811835604271 - 0.15494982830181068512*I

See Also
========

lowergamma: Lower incomplete gamma function.
uppergamma: Upper incomplete gamma function.
polygamma: Polygamma function.
loggamma: Log Gamma function.
digamma: Digamma function.
trigamma: Trigamma function.
sympy.functions.special.beta_functions.beta: Euler Beta function.

References
==========

.. [1] https://en.wikipedia.org/wiki/Gamma_function
.. [2] https://dlmf.nist.gov/5
.. [3] https://mathworld.wolfram.com/GammaFunction.html
.. [4] https://functions.wolfram.com/GammaBetaErf/Gamma/

Tc                    V^8X  dE   V P                  V P                  ^ ,          4      \        ^ V P                  ^ ,          4      ,          # \        W4      h   )funcargs	polygammar
   selfargindexs   &&r0   fdiffgamma.fdiffr   s?    q=99TYYq\*9Q		!+EEE$T44    c                r   VP                   '       Ed   V\        P                  J d   \        P                  # V\        J d   \        # \	        V4      '       d5   VP
                  '       d   \        V^,
          4      # \        P                  # VP                  '       Ed   VP                  ^8X  Ed   \        VP                  4      VP                  ,          pVP
                  '       d   T\        P                  rCM9V^,           ;r#V^,          ^ 8X  d   \        P                  pM\        P                  pV\        \        ^^V,          ^4      4      ,          pVP
                  '       d%   V\!        \"        4      ,          ^V,          ,          # ^V,          \!        \"        4      ,          V,          # R# R# R# r6   N)	is_Numberr   NaNr   r1   is_positiver$   ComplexInfinityis_RationalqabspOneNegativeOner   ranger   r   )clsargr/   kcoeffs   &&   r0   eval
gamma.evalx   s    ===aee|uu	???$S1W--,,,55A:CEE
cee+A#$aee5 !Aq5A:$%EEE$%MMET%1Q3"233E$T"X~144 !tDH}u44%  ! r?   c                   V P                   ^ ,          pVP                  '       d   \        VP                  4      VP                  8  d   \        R4      pVP                  VP                  ,          pVP                  WBP                  ,          ,
          pV P                  W4,           4      P                  4       P                  V\        WRP                  4      4      # VP                  '       d|   VP                  4       w  rgV'       d/   VP                  ^8w  d   \        V4      pWh,
          3V,           pTpVP                  ! VRR/ pV P                  V4      \        Wv4      ,          # V P                  ! V P                   !  # )r   xreevalF)r8   rF   rH   rI   rG   r   r7   _eval_expand_funcsubsr   is_Addas_coeff_addr   _new_rawargsr&   )	r;   hintsrN   rT   r/   rI   rP   tailintparts	   &,       r0   rV   gamma._eval_expand_func   s   iil???355zCEE!#JEESUUNEEAeeGOyy'99;@@HQPUPUDVWW:::**,KEA,)D0##T8%8D99T??4#???yy$))$$r?   c                b    V P                  V P                  ^ ,          P                  4       4      # r   )r7   r8   	conjugater;   s   &r0   _eval_conjugategamma._eval_conjugate   s"    yy1//122r?   c                    V P                   ^ ,          pVP                  '       d   VP                  '       d   R# \        V4      '       d
   V^ 8:  d   R# VP                  '       g   VP
                  '       d   R# R# )r   FTN)r8   is_nonpositive
is_integerr1   rD   is_nonintegerr;   rT   s   & r0   _eval_is_realgamma._eval_is_real   sQ    IIaL1::!q&===AOOO ,r?   c                    V P                   ^ ,          pVP                  '       d   R# VP                  '       d   \        V4      P                  # R# r   TN)r8   rD   rh   r   is_evenri   s   & r0   _eval_is_positivegamma._eval_is_positive   s9    IIaL===___8### r?   c                *    \        \        V4      4      # N)r   loggamma)r;   zlimitvarkwargss   &&&,r0   _eval_rewrite_as_tractable gamma._eval_rewrite_as_tractable   s    8A;r?   c                &    \        V^,
          4      # r5   )r$   r;   rt   rv   s   &&,r0   _eval_rewrite_as_factorial gamma._eval_rewrite_as_factorial   s    Qr?   c                t  < V P                   ^ ,          P                  V^ 4      pVP                  '       d   V^ 8:  g   \        SV `  WV4      # V P                   ^ ,          V,
          pV P                  V^,           4      \        V P                   ^ ,          V) ^,           4      ,          P	                  WV4      # r`   )r8   limit
is_Integersuper_eval_nseriesr7   r%   )r;   rT   r/   logxcdirx0t	__class__s   &&&&&  r0   r   gamma._eval_nseries   s    YYq\1%"'7(t44IIaL2		!a% DIIaL2#'!::II!PTUUr?   c                   V P                   ^ ,          pVP                  V^ 4      pVP                  '       dh   VP                  '       dV   V) p\        P
                  V,          V P                  V^,           4      ,          pWtV,           P                  V4      ,          # VP                  '       g   V P                  V4      # \        4       hr`   )
r8   rW   rg   rf   r   rK   r7   as_leading_termis_infiniter   )r;   rT   r   r   rN   r   r/   ress   &&&&    r0   _eval_as_leading_termgamma._eval_as_leading_term   s    iilXXa^===R...A--"499QU#33Ca0033399R= kr?    r5   rr   r`   )__name__
__module____qualname____firstlineno____doc__
unbranchedr   rE   _singularitiesr=   classmethodrQ   rV   rc   rj   ro   rw   r{   r   r   __static_attributes____classdictcell____classcell__r   __classdict__s   @@r0   r3   r3   "   si     JX J'')N5 5 5@%(3$  V
 
r?   r3   c                   t   a a ] tR t^t oRtRR lt]R 4       tR tR t	R t
V 3R ltR tR	 tR
 tRtVtV ;t# )
lowergammaaU  
The lower incomplete gamma function.

Explanation
===========

It can be defined as the meromorphic continuation of

.. math::
    \gamma(s, x) := \int_0^x t^{s-1} e^{-t} \mathrm{d}t = \Gamma(s) - \Gamma(s, x).

This can be shown to be the same as

.. math::
    \gamma(s, x) = \frac{x^s}{s} {}_1F_1\left({s \atop s+1} \middle| -x\right),

where ${}_1F_1$ is the (confluent) hypergeometric function.

Examples
========

>>> from sympy import lowergamma, S
>>> from sympy.abc import s, x
>>> lowergamma(s, x)
lowergamma(s, x)
>>> lowergamma(3, x)
-2*(x**2/2 + x + 1)*exp(-x) + 2
>>> lowergamma(-S(1)/2, x)
-2*sqrt(pi)*erf(sqrt(x)) - 2*exp(-x)/sqrt(x)

See Also
========

gamma: Gamma function.
uppergamma: Upper incomplete gamma function.
polygamma: Polygamma function.
loggamma: Log Gamma function.
digamma: Digamma function.
trigamma: Trigamma function.
sympy.functions.special.beta_functions.beta: Euler Beta function.

References
==========

.. [1] https://en.wikipedia.org/wiki/Incomplete_gamma_function#Lower_incomplete_gamma_function
.. [2] Abramowitz, Milton; Stegun, Irene A., eds. (1965), Chapter 6,
       Section 5, Handbook of Mathematical Functions with Formulas, Graphs,
       and Mathematical Tables
.. [3] https://dlmf.nist.gov/8
.. [4] https://functions.wolfram.com/GammaBetaErf/Gamma2/
.. [5] https://functions.wolfram.com/GammaBetaErf/Gamma3/

c                l   ^ RI Hp V^8X  d8   V P                  w  r4\        \	        V4      ) 4      WC^,
          ,          ,          # V^8X  d`   V P                  w  r4\        V4      \        V4      ,          \        V4      \        W44      ,          ,
          V! . ^^.^ ^ V.. V4      ,
          # \        W4      hr   )meijerg)
sympy.functions.special.hyperr   r8   r   r   r3   digammar   
uppergammar
   r;   r<   r   art   s   &&   r0   r=   lowergamma.fdiff  s    9q=99DA
1~&qq5z11]99DA8GAJ&Q
10@)@@"q!fq!QiQ78 8 %T44r?   c                	   V\         P                  J d   \         P                  # VP                  4       w  r4VP                  '       d0   VP                  '       d   \        V4      pW28w  d   \        W4      # MVP                  '       dx   VP                  '       df   V^ 8w  d^   ^\        ,          \        ,          V,          \         P                  V) ,          ,          \        V) 4      ,          \        W4      ,           # MFV^ 8w  d@   \        ^\        ,          \        ,          V,          V,          4      \        W4      ,          # VP                  '       Ed   V\         P                  J d"   \         P                  \        V) 4      ,
          # V\         P                  J d)   \!        \        4      \#        \!        V4      4      ,          # VP$                  '       g   ^V,          P$                  '       Ed`   V^,
          pVP                  '       EdH   VP                  '       dj   \        V4      \        V) 4      \        V4      ,          \'        \)        V4       Uu. uF  qbV,          \        V4      ,          NK  	  up!  ,          ,
          # \+        V4      \        \         P                  V4      \!        \        4      ,          \        V) 4      \'        \)        ^V\         P                  ,           4       Uu. uFE  qbV\         P                  ,
          ,          \+        \         P                  V,           4      ,          NKG  	  up!  ,          ,
          ,          # VP$                  '       g   \         P                  \         P                  V,
          ,          \        ,          \#        \!        V4      4      ,          \+        ^V,
          4      ,          \        V) 4      \'        \)        ^\-        ^^4      V,
          4       Uu. uF>  qbWa,           ^,
          ,          \+        V4      ,          \+        W,           4      ,          NK@  	  up!  ,          ,           # VP.                  '       d   \         P                  # R# u upi u upi u upi r   N)r   Zeroextract_branch_factorrg   rD   r   r   rf   r   r   rK   r$   r   rB   rJ   Halfr   r   r   r   rL   r3   r   is_zero)rM   r   rT   nxr/   brO   s   &&&    r0   rQ   lowergamma.eval#  s   " ;66M'')<<<AMMMABw!!(( \\\a...AvtAvax 33IqbMAJqDUUU !VqtAvaxz?:a#444 ;;;AEEzuusA2w&affBxDG,,!A#!1!1!1E===|||(|c1"g	!.DslqrsltLultghRSVV_`aVbMbMbltLuGv.vvv$QxAFFA)>tBx)G#qb'RU  DI  JK  MN  QR  QW  QW  MW  DX  XY  DX~\]`a`f`f\fXghmnontntwxnxhyXyXy  DX  XY  SZ  KZ  *Z   [  [|||==166A:6r9#d1g,FuQQRU|SVY[\Z\V]^a  SX  YZ  \d  ef  hi  \j  mn  \n  So  dp  So  NOhihmpqhqdrsxyzs{d{  }B  CD  CH  }I  eI  eI  So  dp  _q  Wq  q  q99966M  Mv XY dps   !Q:8AQ?ARc                   \         ;QJ d&    R  V P                   4       F  '       d   K   RM	  RM! R  V P                   4       4      '       d   V P                  ^ ,          P                  V4      pV P                  ^,          P                  V4      p\        V4      ;_uu_ 4        \        P
                  ! V^ V4      pRRR4       \        P                  ! XV4      # V #   + '       g   i     L); i)c              3   8   "   T F  qP                   x  K  	  R # 5irr   	is_number.0rT   s   & r0   	<genexpr>)lowergamma._eval_evalf.<locals>.<genexpr>V       .Iq{{I   FTN)allr8   
_to_mpmathr)   r(   gammaincr   _from_mpmathr;   precr   rt   r   s   &&   r0   _eval_evalflowergamma._eval_evalfU  s    3.DII.333.DII...		!''-A		!''-A$kk!Q*  $$S$//K	  s   &C  C0	c                    V P                   ^,          pV\        P                  \        P                  39  d@   V P	                  V P                   ^ ,          P                  4       VP                  4       4      # R# rA   r8   r   r   NegativeInfinityr7   ra   ri   s   & r0   rc   lowergamma._eval_conjugate_  S    IIaLQVVQ//0099TYYq\335q{{}EE 1r?   c                   V P                   w  r4\        VP                  W4      VP                  W4      .4      pV'       g   V# VP                  W4      pVP                  '       d"   \        VP
                  VP                  .4      # VP                  W4      p\        VP                  VP                  \        VP                  4      .4      # rr   )	r8   r   _eval_is_meromorphicrW   rg   rD   	is_finiter   r   )r;   rT   r   srt   
args_meromz0s0s   &&&     r0   r   lowergamma._eval_is_meromorphicd  s     yy 6 6q <""1( * +
VVA\<<<ammR\\:;;VVA\",,i

6KLMMr?   c                |  <a	a
 ^ RI Hp V P                  w  o	o
V^ ,          \        J d   S
P	                  V4      '       gn   S
S	,          \        S
) 4      ,          p\        V	V
3R l\        V^,
          4       4       4      pV! S
S	,          S	V) ,          ,          4      pWg,          V,           # \        SV `%  WW44      # )r   )Oc              3   f   <"   T F&  pSV,          \        SV^,           4      ,          x  K(  	  R# 5irA   )r%   )r   rO   r   rt   s   & r0   r   +lowergamma._eval_aseries.<locals>.<genexpr>z  s'     Cl1a41a!e,,ls   .1)
sympy.series.orderr   r8   r   hasr   sumrL   r   _eval_aseries)r;   r/   args0rT   r   r   rP   sum_expror   rt   r   s   &&&&&    @@r0   r   lowergamma._eval_aseriesu  s    (yy18r>!%%((qDaRLECeAElCCH!Q$qA2w,A>A%%w$Qq77r?   c                8    \        V4      \        W4      ,
          # rr   )r3   r   r;   r   rT   rv   s   &&&,r0   _eval_rewrite_as_uppergamma&lowergamma._eval_rewrite_as_uppergamma      Qx*Q***r?   c                    ^ RI Hp VP                  '       d   VP                  '       d   V # V P	                  \
        4      P	                  V4      # r   expint)'sympy.functions.special.error_functionsr   rg   rf   rewriter   r;   r   rT   rv   r   s   &&&, r0   _eval_rewrite_as_expint"lowergamma._eval_rewrite_as_expint  s8    B<<<A,,,K||J'//77r?   c                T    V P                   ^,          pVP                  '       d   R# R# )r6   TN)r8   r   ri   s   & r0   _eval_is_zerolowergamma._eval_is_zero  s     IIaL999 r?   r      )r   r   r   r   r   r=   r   rQ   r   rc   r   r   r   r   r   r   r   r   r   s   @@r0   r   r      sO     4n5 / /bF
N"8+8 r?   r   c                   b   a  ] tR tRt o RtRR ltR t]R 4       tR t	R t
R tR	 tR
 tRtV tR# )r   i  a  
The upper incomplete gamma function.

Explanation
===========

It can be defined as the meromorphic continuation of

.. math::
    \Gamma(s, x) := \int_x^\infty t^{s-1} e^{-t} \mathrm{d}t = \Gamma(s) - \gamma(s, x).

where $\gamma(s, x)$ is the lower incomplete gamma function,
:class:`lowergamma`. This can be shown to be the same as

.. math::
    \Gamma(s, x) = \Gamma(s) - \frac{x^s}{s} {}_1F_1\left({s \atop s+1} \middle| -x\right),

where ${}_1F_1$ is the (confluent) hypergeometric function.

The upper incomplete gamma function is also essentially equivalent to the
generalized exponential integral:

.. math::
    \operatorname{E}_{n}(x) = \int_{1}^{\infty}{\frac{e^{-xt}}{t^n} \, dt} = x^{n-1}\Gamma(1-n,x).

Examples
========

>>> from sympy import uppergamma, S
>>> from sympy.abc import s, x
>>> uppergamma(s, x)
uppergamma(s, x)
>>> uppergamma(3, x)
2*(x**2/2 + x + 1)*exp(-x)
>>> uppergamma(-S(1)/2, x)
-2*sqrt(pi)*erfc(sqrt(x)) + 2*exp(-x)/sqrt(x)
>>> uppergamma(-2, x)
expint(3, x)/x**2

See Also
========

gamma: Gamma function.
lowergamma: Lower incomplete gamma function.
polygamma: Polygamma function.
loggamma: Log Gamma function.
digamma: Digamma function.
trigamma: Trigamma function.
sympy.functions.special.beta_functions.beta: Euler Beta function.

References
==========

.. [1] https://en.wikipedia.org/wiki/Incomplete_gamma_function#Upper_incomplete_gamma_function
.. [2] Abramowitz, Milton; Stegun, Irene A., eds. (1965), Chapter 6,
       Section 5, Handbook of Mathematical Functions with Formulas, Graphs,
       and Mathematical Tables
.. [3] https://dlmf.nist.gov/8
.. [4] https://functions.wolfram.com/GammaBetaErf/Gamma2/
.. [5] https://functions.wolfram.com/GammaBetaErf/Gamma3/
.. [6] https://en.wikipedia.org/wiki/Exponential_integral#Relation_with_other_functions

c                .   ^ RI Hp V^8X  d9   V P                  w  r4\        \	        V4      ) 4      ) WC^,
          ,          ,          # V^8X  d@   V P                  w  r4\        W44      \        V4      ,          V! . ^^.^ ^ V.. V4      ,           # \        W4      hr   )r   r   r8   r   r   r   r   r
   r   s   &&   r0   r=   uppergamma.fdiff  s    9q=99DAA''E
22]99DAa#CF*WR!Q!QBPQ-RRR$T44r?   c                    \         ;QJ d&    R  V P                   4       F  '       d   K   RM	  RM! R  V P                   4       4      '       d   V P                  ^ ,          P                  V4      pV P                  ^,          P                  V4      p\        V4      ;_uu_ 4        \        P
                  ! W#\        P                  4      pRRR4       \        P                  ! XV4      # V #   + '       g   i     L); i)c              3   8   "   T F  qP                   x  K  	  R # 5irr   r   r   s   & r0   r   )uppergamma._eval_evalf.<locals>.<genexpr>  r   r   FTN)	r   r8   r   r)   r(   r   infr   r   r   s   &&   r0   r   uppergamma._eval_evalf  s    3.DII.333.DII...		!''-A		!''-A$kk!/  $$S$//  s   &&C--C=	c                   ^ RI Hp VP                  '       dw   V\        P                  J d   \        P                  # V\
        J d   \        P                  # VP                  '       d'   \        V4      P                  '       d   \        V4      # VP                  4       w  rEVP                  '       d1   VP                  '       d   \        V4      pW$8w  d   \        W4      # EMVP                  '       dx   VP                  '       df   V^ 8w  d^   R\         ,          \"        ,          V,          \        P$                  V) ,          ,          \'        V) 4      ,          \        W4      ,           # MV^ 8w  d   \        V4      ^\)        ^\         ,          \"        ,          V,          V,          4      ,
          ,          \)        ^\         ,          \"        ,          V,          V,          4      \        W4      ,          ,           # VP                  '       Ed|   V\        P                  J d    VP                  '       d   \+        V) 4      ) # V\        P,                  J d   \)        V) 4      # V\        P.                  J d)   \1        \         4      \3        \1        V4      4      ,          # VP4                  '       g   ^V,          P4                  '       Ed   V^,
          pVP                  '       Ede   VP                  '       dZ   \)        V) 4      \'        V4      ,          \7        \9        V4       Uu. uF  pW',          \'        V4      ,          NK  	  up!  ,          # \        V4      \3        \1        V4      4      ,          \        P$                  V\        ^4      ^,          ,
          ,          \)        V) 4      ,          \1        V4      ,          \7        \9        V\        P.                  ,
          4       Uu. uFJ  p\        \        P.                  ) V,
          4      V) V,          ,          \        ^V,
          4      ,          NKL  	  up!  ,          ,           # VP4                  '       d)   V! V) V4      \        V4      V^,           ,          ,          # VP4                  '       g   \        P$                  \        P.                  V,
          ,          \         ,          \3        \1        V4      4      ,          \        ^V,
          4      ,          W!,          \)        V) 4      ,          \7        \9        \        P.                  V,
          4       Uu. uF8  pW',          \        V4      ,          \        W,           ^,           4      ,          NK:  	  up!  ,          ,
          # VP                  '       d    VP                  '       d   \+        V) 4      ) # VP                  '       d)   \        V4      P                  '       d   \        V4      # R# R# u upi u upi u upi )r   r   N)r   r   rB   r   rC   r   r   r   r   rD   r3   r   rg   r   r   rf   r   r   rK   r$   r   r   rJ   r   r   r   r   r   rL   )rM   r   rt   r   r   r/   r   rO   s   &&&     r0   rQ   uppergamma.eval  s   B;;;AEEzuubvva5$$$ 8O '')<<<AMMMABw!!(( \\\a...Av"uQwqy!!44Yr]BZPQEVVV !V8QQrT!VAXaZ01C"Qq
OJqDU4UUU ;;;AFF{q}}}A2waeeA2waffBxT!W--!A#!1!1!1E===|||"A2w15GLQx>QGO! ?@dYq\>Q>QGO>Q 9R  R R !&a4Q= 8 !AaDF
 ;c1"g EQ O"%16q166z1B(D1BA ).qvvgk(:qb1W(DuQqSz(Q(Q1B(D #E!E!E F \\\!1"a=AQ)???|||MMAFFQJ7"<T$q']J5QRSTQT:UdS!Wns>CAFFQJ>O5Q>O 67TE!H_uQSQRU|5S5S>O5Q 0R RR S 999rF7N999A***8O +9%>Q
(D5Qs   &!W8
*AW=<>Xc                    V P                   ^,          pV\        P                  \        P                  39  d@   V P	                  V P                   ^ ,          P                  4       VP                  4       4      # R# rA   r   r;   rt   s   & r0   rc   uppergamma._eval_conjugate  r   r?   c                .    \         P                  WV4      # rr   )r   r   )r;   rT   r   s   &&&r0   r   uppergamma._eval_is_meromorphic"  s    ..t::r?   c                8    \        V4      \        W4      ,
          # rr   )r3   r   r   s   &&&,r0   _eval_rewrite_as_lowergamma&uppergamma._eval_rewrite_as_lowergamma%  r   r?   c                J    \        \        V4      4      \        W4      ,
          # rr   )r   rs   r   r   s   &&&,r0   rw   %uppergamma._eval_rewrite_as_tractable(  s    8A;*Q"222r?   c                H    ^ RI Hp V! ^V,
          V4      W!,          ,          # r   )r   r   r   s   &&&, r0   r   "uppergamma._eval_rewrite_as_expint+  s    Ba!eQ$$r?   r   Nr   )r   r   r   r   r   r=   r   r   rQ   rc   r   r   rw   r   r   r   r   s   @r0   r   r     sI     >B	5 6 6pF
;+3% %r?   r   c                      a a ] tR tRt oRt]R 4       tR tR tR t	R t
R tR	 tR
 tR tRR ltV 3R ltR tRtVtV ;t# )r9   i4  a[
  
The function ``polygamma(n, z)`` returns ``log(gamma(z)).diff(n + 1)``.

Explanation
===========

It is a meromorphic function on $\mathbb{C}$ and defined as the $(n+1)$-th
derivative of the logarithm of the gamma function:

.. math::
    \psi^{(n)} (z) := \frac{\mathrm{d}^{n+1}}{\mathrm{d} z^{n+1}} \log\Gamma(z).

For `n` not a nonnegative integer the generalization by Espinosa and Moll [5]_
is used:

.. math:: \psi(s,z) = \frac{\zeta'(s+1, z) + (\gamma + \psi(-s)) \zeta(s+1, z)}
    {\Gamma(-s)}

Examples
========

Several special values are known:

>>> from sympy import S, polygamma
>>> polygamma(0, 1)
-EulerGamma
>>> polygamma(0, 1/S(2))
-2*log(2) - EulerGamma
>>> polygamma(0, 1/S(3))
-log(3) - sqrt(3)*pi/6 - EulerGamma - log(sqrt(3))
>>> polygamma(0, 1/S(4))
-pi/2 - log(4) - log(2) - EulerGamma
>>> polygamma(0, 2)
1 - EulerGamma
>>> polygamma(0, 23)
19093197/5173168 - EulerGamma

>>> from sympy import oo, I
>>> polygamma(0, oo)
oo
>>> polygamma(0, -oo)
oo
>>> polygamma(0, I*oo)
oo
>>> polygamma(0, -I*oo)
oo

Differentiation with respect to $x$ is supported:

>>> from sympy import Symbol, diff
>>> x = Symbol("x")
>>> diff(polygamma(0, x), x)
polygamma(1, x)
>>> diff(polygamma(0, x), x, 2)
polygamma(2, x)
>>> diff(polygamma(0, x), x, 3)
polygamma(3, x)
>>> diff(polygamma(1, x), x)
polygamma(2, x)
>>> diff(polygamma(1, x), x, 2)
polygamma(3, x)
>>> diff(polygamma(2, x), x)
polygamma(3, x)
>>> diff(polygamma(2, x), x, 2)
polygamma(4, x)

>>> n = Symbol("n")
>>> diff(polygamma(n, x), x)
polygamma(n + 1, x)
>>> diff(polygamma(n, x), x, 2)
polygamma(n + 2, x)

We can rewrite ``polygamma`` functions in terms of harmonic numbers:

>>> from sympy import harmonic
>>> polygamma(0, x).rewrite(harmonic)
harmonic(x - 1) - EulerGamma
>>> polygamma(2, x).rewrite(harmonic)
2*harmonic(x - 1, 3) - 2*zeta(3)
>>> ni = Symbol("n", integer=True)
>>> polygamma(ni, x).rewrite(harmonic)
(-1)**(n + 1)*(-harmonic(x - 1, n + 1) + zeta(n + 1))*factorial(n)

See Also
========

gamma: Gamma function.
lowergamma: Lower incomplete gamma function.
uppergamma: Upper incomplete gamma function.
loggamma: Log Gamma function.
digamma: Digamma function.
trigamma: Trigamma function.
sympy.functions.special.beta_functions.beta: Euler Beta function.

References
==========

.. [1] https://en.wikipedia.org/wiki/Polygamma_function
.. [2] https://mathworld.wolfram.com/PolygammaFunction.html
.. [3] https://functions.wolfram.com/GammaBetaErf/PolyGamma/
.. [4] https://functions.wolfram.com/GammaBetaErf/PolyGamma2/
.. [5] O. Espinosa and V. Moll, "A generalized polygamma function",
       *Integral Transforms and Special Functions* (2004), 101-115.

c                   V\         P                  J g   V\         P                  J d   \         P                  # V\        J d)   VP                  '       d   \        # \         P                  # VP
                  '       d#   VP                  '       d   \         P                  # V\         P                  J d.   \        V4      \        ^\        ,          4      ^,          ,
          # VP                  '       d   V\        ) J g&   VP                  \        4      \        \        ) 39   d   \        # VP
                  '       d(   \        V^,
          4      \         P                  ,
          # VP                   '       dA   VP#                  4       w  r4V^8:  d&   \%        \'        \         P                  VRR7      4      # R# R# VP(                  '       Ed    VP*                  '       d   \-        V4      pW%8w  d   \'        W4      # VP
                  '       dG   \         P                  V^,           ,          \/        V4      ,          \1        V^,           V4      ,          # V\         P2                  J db   \         P                  V^,           ,          \/        V4      ,          ^V^,           ,          ^,
          ,          \1        V^,           4      ,          # R# R# R# )r   F)evaluateN)r   rC   r   r   r   r   rf   rE   rK   rs   r   r   extract_multiplicativelyr   r#   
EulerGammarF   as_numer_denomr   r9   rg   is_nonnegativer   r$   r   r   )rM   r/   rt   rI   rG   nzs   &&&   r0   rQ   polygamma.eval  s   :aee55L"W2..\\\a...$$$!--A;QrTQ..YYYRCx155a8R"IE	!}q||33'')6&yU'KLL 	  \\\a...ABw ''|||}}qs+il:T!A#q\IIaff}}qs+il:a!A#hqjIDQRSTQTIUU  /\r?   c                    V P                   ^ ,          P                  '       d(   V P                   ^,          P                  '       d   R# R# R# rm   )r8   rD   rb   s   &r0   rj   polygamma._eval_is_real  s5    99Q<###		!(@(@(@ )A#r?   c                    V P                   ^,          p\        VP                  VP                  .4      p\        VP                  \        V4      .4      # r5   )r8   r   is_negativerg   
is_complexr   )r;   rt   is_negative_integers   &  r0   _eval_is_complexpolygamma._eval_is_complex  sA    IIaL'(EF!,,	2E(FGHHr?   c                    V P                   w  rVP                  '       dQ   VP                  '       d   VP                  '       d   R # VP                  '       d   VP                  '       d   R# R# R# R# TFN)r8   rD   is_oddis_realrn   r;   r/   rt   s   &  r0   ro   polygamma._eval_is_positive  sJ    yy===xxxAIIIyyyQ]]] +y r?   c                    V P                   w  rVP                  '       dQ   VP                  '       d   VP                  '       d   R # VP                  '       d   VP                  '       d   R# R# R# R# r  )r8   rD   rn   r  r  r  s   &  r0   _eval_is_negativepolygamma._eval_is_negative  sJ    yy===yyyQ]]]xxxAIII &x r?   c                	   V P                   w  r#VP                  '       Ed   VP                  '       Ed   VP                  '       d   VP                   ^ ,          pVP                  '       d   V^,           ) pV^ 8  dE   \	        \        ^\        V4      ^,           4       Uu. uF  p\        W6,
          V4      NK  	  up!  pM=\	        \        \        V) 4      4       Uu. uF  p\        W6,           V4      NK  	  up!  ) p\        W#V,
          4      \        P                  V,          \        V4      ,          V,          ,           # MVP                  '       d   VP                  4       w  rCVP                  '       d   VP                  '       d   \        \        V4      4       Uu. uF  p\        W#\        Wd4      ,           4      NK   	  ppV^ 8X  d!   \	        V!  V,          \!        V4      ,           # \	        V!  WB^,           ,          ,          # W4,          pV^ 8X  Ed   VP"                  '       Ed   VP%                  4       w  r\        P&                  ) \(        \+        V\(        ,          V	,          4      ,          ^,          ,
          \!        V	4      ,
          \	        \        ^V	4       U
u. uF`  p
\-        ^V
,          \(        ,          V,          V	,          4      \!        ^\/        V
\(        ,          V	,          4      ,          4      ,          NKb  	  up
!  ,           pV^ 8  dJ   \1        V4      pW2,
          pT\	        \        V4       U
u. uF  p
^W,           ,          NK  	  up
!  ,           # V^ 8  dY   \1        ^V,
          4      pW2,           pT\	        \        V4       U
u. uF  p
^V^,
          V
,
          ,          NK  	  up
!  ,
          # VR8X  d.   \3        V4      \!        ^\(        ,          4      ^,          ,
          # VP4                  RJ g   VP                  RJ d   \7        R4      p\9        W4      P;                  V4      P=                  W^,           4      pV\        P&                  \?        V) 4      ,           \9        V^,           V4      ,          ,           \A        V) 4      ,          # \        W#4      # u upi u upi u upi u up
i u up
i u up
i )r   Fr   )!r8   r   r  rX   r   rL   intr   r9   r   rK   r$   is_Mulas_two_termsrD   r   r   rF   r  r
  r   r!   r    r   r   rs   rg   r   r   diffrW   r   r3   )r;   r[   r/   rt   rP   eir\   rI   rG   rO   part_1r   r   dzts   &,             r0   rV   polygamma._eval_expand_func  s   yy<<<A,,,xxxq	###a%Aqy"/4QE
Q/G%I/G! &)E1&&/G%I  J !$/4S%[/A&C/A! '*E1'&/A&C !D  D$QE	2Q]]A5EiPQl5RSW5WWW $ >>+###(9(9(9,1#e*,=?,=q &aX." *" #,=  ?Av"Dz%/#e*<<"Dz%a%.88
6ammm##%DA ll]R#a"fqj/%9A%==AFNSTUWXkZk#a!ebj1nq()CCB
O0C,DDDkZJ\ \F 1u!HUE!H%EHqa26llH%E FFFQ!a%LUa%I1a26A:&6&6%I JJJ7A;QrTQ..<<5 A$4$4$=c
Aq*//!$))!qS1C1<<'1"+5ac1EEPQrRRU%I&C? [
 &F &Js%    R3R8"$R=(A&S
S
 S
c                    VP                   '       d[   VP                  '       dG   \        P                  V^,           ,          \	        V4      ,          \        V^,           V4      ,          # R# R# rA   )rg   rD   r   rK   r$   r   r;   r/   rt   rv   s   &&&,r0   _eval_rewrite_as_zetapolygamma._eval_rewrite_as_zeta  sE    <<<AMMM==1q5))A,6tAE1~EE *<r?   c                d   VP                   '       d   VP                  '       d(   \        V^,
          4      \        P                  ,
          # \        P
                  V^,           ,          \        V4      ,          \        V^,           4      \        V^,
          V^,           4      ,
          ,          # R# rA   )rg   r   r#   r   r
  rK   r$   r   r,  s   &&&,r0   _eval_rewrite_as_harmonic#polygamma._eval_rewrite_as_harmonic  ss    <<<yyyA55}}qs+il:d1Q3i(STUVSVXYZ[X[J\>\]]	 r?   c                <   ^ RI Hp V P                   Uu. uF  qUP                  V4      NK  	  upw  rgV! Wq4      pV^ 8X  dG   VP	                  ^V,          4      '       d)   Vf   \        V4      MTpVP                  4       V,          # V P                  Wg4      # u upi )r   Order)r   r4  r8   r   containsr   getnr7   )	r;   rT   r   r   r4  r   r/   rt   r   s	   &&&&     r0   r   polygamma._eval_as_leading_term  sz    ,.2ii8i!!!$i8!K6ajj1oo!\3q6tD668d?"99Q?" 9s   Bc                v    V^8X  d)   V P                   R,          w  r#\        V^,           V4      # \        W4      h)r   :Nr   N)r8   r9   r
   )r;   r<   r/   rt   s   &&  r0   r=   polygamma.fdiff   s4    q=99R=DAQUA&&$T44r?   c                  < ^ RI Hp V^,          \        8w  gG   V P                  ^ ,          P                  '       d$   V P                  ^ ,          P
                  '       g   \        SV `  WW44      # V P                  ^,          pV P                  ^ ,          pV^ 8X  d   \        V4      ^^V,          ,          ,
          pRp	V^8  d   V! ^V,          V4      p	M\        V^,           ^,          4      p
\        ^V
4       Uu. uF8  p\        ^V,          4      ^V,          V^V,          ,          ,          ,          NK:  	  ppV\        V!  ,          pV! ^Wa,          ,          V4      p	VP                  W1V4      V	,           # \        V4      pWV,          ^V,          ,          ,           p\        V^,           ^,          4      p
\        ^V
4       F  pV^V,          V,           ^,
          ,          ^V,          V,           ^,
          ,          ^V,          ^V,          ^,
          ,          ,          pV\        ^V,          4      V,          V^V,          ,          ,          ,          pK  	  V! ^V^V
,          ,          ,          V4      p	V^ 8X  d   V! ^V,          V4      p	MV^8X  d   V! ^V^,          ,          V4      p	VP                  WaV4      V	,           pRRV,          V,          ,          V,          P                  W1V4      # u upi )r   r3  Nr!  )r   r4  r   r8   r   r  r   r   r   r   rL   r"   r   r   r3   )r;   r/   r   rT   r   r4  rt   Nrr   mrO   lface0r   s   &&&&&          r0   r   polygamma._eval_aseries'  sL   ,8r>1(((TYYq\-H-H-H7(1;;IIaLIIaL6 AAaC AA1u!A#qMQUQJ'>CAqkJkYqs^qs1qs8|44kJS!W!AD&!$??1.22 (Cuac{"BQ
#A1a[1Q37Q;'1q15!A#!aIi!nS(QqS11 ! aAaCj!$AAv!A#qMa!AqD&!$  t,q0A"Q$NQ&55aDAA- Ks   >>K>c                   \         ;QJ d&    R  V P                   4       F  '       d   K   RM	  RM! R  V P                   4       4      '       g   R# V P                  ^ ,          P                  V^,           4      pV P                  ^,          P                  V^,           4      p\        P                  ! V4      '       d   V^ 8:  d   \
        P                  # \        V^,           4      ;_uu_ 4        \        P                  ! V4      '       d   V^ 8  d   \        P                  ! W#4      pM\        P                  ! V^,           V4      p\        P                  ! V^,           V^4      pV\        P                  \        P                  ! V) 4      ,           V,          ,           \        P                  ! V) 4      ,          pRRR4       \        P                  ! XV4      #   + '       g   i     L'; i)c              3   8   "   T F  qP                   x  K  	  R # 5irr   r   )r   r'  s   & r0   r   (polygamma._eval_evalf.<locals>.<genexpr>Q  s     2	1;;	r   FTN)r   r8   r   r(   isintr   rE   r)   r9   r   eulerr   rgammar   r   )r;   r   r   rt   r   ztr)  s   &&     r0   r   polygamma._eval_evalfP  s2   s2		2sss2		222IIaL##DG,IIaL##DG,88A;;16$$$d2gxx{{qAvll1(WWQqS!_ggac1a(bhhQB72==A2N    d++ s   0CGG-	r   r   )r   r   r   r   r   r   rQ   rj   r  ro   r  rV   r-  r0  r   r=   r   r   r   r   r   r   s   @@r0   r9   r9   4  sd     hT V V:I
3jF^#5'BR, ,r?   r9   c                   x   a a ] tR tRt oRt]R 4       tR tRV 3R lltV 3R lt	R t
R tR	 tRR
 ltRtVtV ;t# )rs   ia  a	  
The ``loggamma`` function implements the logarithm of the
gamma function (i.e., $\log\Gamma(x)$).

Examples
========

Several special values are known. For numerical integral
arguments we have:

>>> from sympy import loggamma
>>> loggamma(-2)
oo
>>> loggamma(0)
oo
>>> loggamma(1)
0
>>> loggamma(2)
0
>>> loggamma(3)
log(2)

And for symbolic values:

>>> from sympy import Symbol
>>> n = Symbol("n", integer=True, positive=True)
>>> loggamma(n)
log(gamma(n))
>>> loggamma(-n)
oo

For half-integral values:

>>> from sympy import S
>>> loggamma(S(5)/2)
log(3*sqrt(pi)/4)
>>> loggamma(n/2)
log(2**(1 - n)*sqrt(pi)*gamma(n)/gamma(n/2 + 1/2))

And general rational arguments:

>>> from sympy import expand_func
>>> L = loggamma(S(16)/3)
>>> expand_func(L).doit()
-5*log(3) + loggamma(1/3) + log(4) + log(7) + log(10) + log(13)
>>> L = loggamma(S(19)/4)
>>> expand_func(L).doit()
-4*log(4) + loggamma(3/4) + log(3) + log(7) + log(11) + log(15)
>>> L = loggamma(S(23)/7)
>>> expand_func(L).doit()
-3*log(7) + log(2) + loggamma(2/7) + log(9) + log(16)

The ``loggamma`` function has the following limits towards infinity:

>>> from sympy import oo
>>> loggamma(oo)
oo
>>> loggamma(-oo)
zoo

The ``loggamma`` function obeys the mirror symmetry
if $x \in \mathbb{C} \setminus \{-\infty, 0\}$:

>>> from sympy.abc import x
>>> from sympy import conjugate
>>> conjugate(loggamma(x))
loggamma(conjugate(x))

Differentiation with respect to $x$ is supported:

>>> from sympy import diff
>>> diff(loggamma(x), x)
polygamma(0, x)

Series expansion is also supported:

>>> from sympy import series
>>> series(loggamma(x), x, 0, 4).cancel()
-log(x) - EulerGamma*x + pi**2*x**2/12 - x**3*zeta(3)/3 + O(x**4)

We can numerically evaluate the ``loggamma`` function
to arbitrary precision on the whole complex plane:

>>> from sympy import I
>>> loggamma(5).evalf(30)
3.17805383034794561964694160130
>>> loggamma(I).evalf(20)
-0.65092319930185633889 - 1.8724366472624298171*I

See Also
========

gamma: Gamma function.
lowergamma: Lower incomplete gamma function.
uppergamma: Upper incomplete gamma function.
polygamma: Polygamma function.
digamma: Digamma function.
trigamma: Trigamma function.
sympy.functions.special.beta_functions.beta: Euler Beta function.

References
==========

.. [1] https://en.wikipedia.org/wiki/Gamma_function
.. [2] https://dlmf.nist.gov/5
.. [3] https://mathworld.wolfram.com/LogGammaFunction.html
.. [4] https://functions.wolfram.com/GammaBetaErf/LogGamma/

c                   VP                   '       d@   VP                  '       d   \        # VP                  '       d   \	        \        V4      4      # MVP                  '       d   VP                  4       w  r#VP                  '       dq   V^8X  dj   \	        \        \        4      ^^V,
          ,          ,          \        V4      ,          \        V^,           \        P                  ,          4      ,          4      # V\        J d   \        # \        V4      \        J d   \        P                  # V\        P                  J d   \        P                  # R# )r   N)rg   rf   r   rD   r   r3   is_rationalr  r   r   r   r   rH   rE   rC   )rM   rt   rI   rG   s   &&  r0   rQ   loggamma.eval  s    <<<	58}$ ]]]##%DA}}}a48a!a%j058;eQUAFFN>SSTT7IVr\$$$:55L r?   c                6   ^ RI Hp V P                  ^ ,          pVP                  '       Edm   VP	                  4       w  rEWE,          pWFV,          ,
          pVP
                  '       Ed1   VP
                  '       Ed   WE8  Ed   \        R4      pVP
                  '       dX   \        WE,          4      V\        V4      ,          ,
          V! \        V^,
          V,          V,           4      V^V34      ,           # VP                  '       dn   \        WE,          4      V\        V4      ,          ,
          \        \        ,          V,          ,           V! \        Wu,          V,
          4      V^V) 34      ,
          # VP                  '       d   \        WE,          4      # V # r   )SumrO   )sympy.concrete.summationsrP  r8   rF   r  rD   r   rs   r   r  r   r   r   )r;   r[   rP  rt   rI   rG   r/   rO   s   &,      r0   rV   loggamma._eval_expand_func  s   1IIaL===##%DA AaCA}}}15#J===#AE?Qs1vX5CQ	A<NQRTUWXPY8ZZZ]]]#AE?Qs1vX51Q>Sq\TUWX[\Z\S]A^^^YYY#AE?*r?   c                   < V P                   ^ ,          P                  V^ 4      pVP                  '       d-   V P                  ! V P                   !  pVP	                  WV4      # \
        SV `  WV4      # r`   )r8   r~   r   _eval_rewrite_as_intractabler   r   )r;   rT   r/   r   r   r   fr   s   &&&&&  r0   r   loggamma._eval_nseries  s]    YYq\1%:::11499=A??1..w$Q400r?   c                  < ^ RI Hp V^ ,          \        8w  d   \        SV `  WW44      # V P
                  ^ ,          p\        V4      V\        P                  ,
          ,          V,
          \        ^\        ,          4      ^,          ,           p\        ^V4       Uu. uFT  p\        ^V,          4      ^V,          ^V,          ^,
          ,          V^V,          ^,
          ,          ,          ,          NKV  	  p	pRp
V^ 8X  d   V! ^V4      p
MV! ^Wa,          ,          V4      p
V\        V	!  ,           P                  W1V4      V
,           # u upi )r   r3  N)r   r4  r   r   r   r8   r   r   r   r   rL   r"   r   r   )r;   r/   r   rT   r   r4  rt   r<  rO   r>  r   r   s   &&&&&      r0   r   loggamma._eval_aseries  s    ,8r>7(1;;IIaLFAJ!#c!B$ik1DI!QKPKqYqs^qsAaC!G}Q1q\9::KP6aAafa ACG**16:: Qs   AEc                *    \        \        V4      4      # rr   )r   r3   rz   s   &&,r0   rT  %loggamma._eval_rewrite_as_intractable  s    58}r?   c                |    V P                   ^ ,          pVP                  '       d   R# VP                  '       d   R# R# )r   TFN)r8   rD   rf   r   s   & r0   rj   loggamma._eval_is_real  s/    IIaL=== r?   c                    V P                   ^ ,          pV\        P                  \        P                  39  d    V P	                  VP                  4       4      # R# r   r   r   s   & r0   rc   loggamma._eval_conjugate  s@    IIaLQVVQ//0099Q[[]++ 1r?   c                `    V^8X  d   \        ^ V P                  ^ ,          4      # \        W4      hr5   )r9   r8   r
   r:   s   &&r0   r=   loggamma.fdiff  s)    q=Q		!--$T44r?   r   )Nr   r5   )r   r   r   r   r   r   rQ   rV   r   r   rT  rj   rc   r=   r   r   r   r   s   @@r0   rs   rs   a  sH     lZ  &*1;,
5 5r?   rs   c                   t   a  ] tR tRt o RtR tRR ltR tR tR t	R t
]R	 4       tR
 tR tR tR tRtV tR# )r   i$  a  
The ``digamma`` function is the first derivative of the ``loggamma``
function

.. math::
    \psi(x) := \frac{\mathrm{d}}{\mathrm{d} z} \log\Gamma(z)
            = \frac{\Gamma'(z)}{\Gamma(z) }.

In this case, ``digamma(z) = polygamma(0, z)``.

Examples
========

>>> from sympy import digamma
>>> digamma(0)
zoo
>>> from sympy import Symbol
>>> z = Symbol('z')
>>> digamma(z)
polygamma(0, z)

To retain ``digamma`` as it is:

>>> digamma(0, evaluate=False)
digamma(0)
>>> digamma(z, evaluate=False)
digamma(z)

See Also
========

gamma: Gamma function.
lowergamma: Lower incomplete gamma function.
uppergamma: Upper incomplete gamma function.
polygamma: Polygamma function.
loggamma: Log Gamma function.
trigamma: Trigamma function.
sympy.functions.special.beta_functions.beta: Euler Beta function.

References
==========

.. [1] https://en.wikipedia.org/wiki/Digamma_function
.. [2] https://mathworld.wolfram.com/DigammaFunction.html
.. [3] https://functions.wolfram.com/GammaBetaErf/PolyGamma2/

c                v    V P                   ^ ,          p\        V4      p\        ^ V4      P                  VR7      # r   r.   r8   r*   r9   evalfr;   r   rt   nprecs   &&  r0   r   digamma._eval_evalfT  3    IIaLD!A$$u$--r?   c                \    V P                   ^ ,          p\        ^ V4      P                  4       # r`   r8   r9   r=   r;   r<   rt   s   && r0   r=   digamma.fdiffY  $    IIaLA$$&&r?   c                T    V P                   ^ ,          p\        ^ V4      P                  # r`   r8   r9   r  r   s   & r0   rj   digamma._eval_is_real]  !    IIaLA&&&r?   c                T    V P                   ^ ,          p\        ^ V4      P                  # r`   r8   r9   rD   r   s   & r0   ro   digamma._eval_is_positivea  !    IIaLA***r?   c                T    V P                   ^ ,          p\        ^ V4      P                  # r`   r8   r9   r  r   s   & r0   r  digamma._eval_is_negativee  rv  r?   c                    V P                  \        4      p\        P                  .V,           pVP	                  WW44      # rr   )r   r9   r   r   r   r;   r/   r   rT   r   as_polygammas   &&&&& r0   r   digamma._eval_aseriesi  s3    ||I.	E!))!A<<r?   c                    \        ^ V4      # r`   r9   rM   rt   s   &&r0   rQ   digamma.evaln      Ar?   c                `    V P                   ^ ,          p\        ^ V4      P                  RR7      # r   T)r7   r8   r9   expandr;   r[   rt   s   &, r0   rV   digamma._eval_expand_funcr  )    IIaLA%%4%00r?   c                P    \        V^,
          4      \        P                  ,
          # r5   )r#   r   r
  rz   s   &&,r0   r0  !digamma._eval_rewrite_as_harmonicv  s    A--r?   c                    \        ^ V4      # r`   r  rz   s   &&,r0   _eval_rewrite_as_polygamma"digamma._eval_rewrite_as_polygammay      Ar?   c                ^    V P                   ^ ,          p\        ^ V4      P                  V4      # r`   r8   r9   r   r;   rT   r   r   rt   s   &&&& r0   r   digamma._eval_as_leading_term|  &    IIaLA..q11r?   r   Nr5   )r   r   r   r   r   r   r=   rj   ro   r  r   r   rQ   rV   r0  r  r   r   r   r  s   @r0   r   r   $  sV     .^.
''++=
  1.2 2r?   r   c                   z   a  ] tR tRt o RtR tRR ltR tR tR t	R t
]R	 4       tR
 tR tR tR tR tRtV tR# )trigammai  a  
The ``trigamma`` function is the second derivative of the ``loggamma``
function

.. math::
    \psi^{(1)}(z) := \frac{\mathrm{d}^{2}}{\mathrm{d} z^{2}} \log\Gamma(z).

In this case, ``trigamma(z) = polygamma(1, z)``.

Examples
========

>>> from sympy import trigamma
>>> trigamma(0)
zoo
>>> from sympy import Symbol
>>> z = Symbol('z')
>>> trigamma(z)
polygamma(1, z)

To retain ``trigamma`` as it is:

>>> trigamma(0, evaluate=False)
trigamma(0)
>>> trigamma(z, evaluate=False)
trigamma(z)


See Also
========

gamma: Gamma function.
lowergamma: Lower incomplete gamma function.
uppergamma: Upper incomplete gamma function.
polygamma: Polygamma function.
loggamma: Log Gamma function.
digamma: Digamma function.
sympy.functions.special.beta_functions.beta: Euler Beta function.

References
==========

.. [1] https://en.wikipedia.org/wiki/Trigamma_function
.. [2] https://mathworld.wolfram.com/TrigammaFunction.html
.. [3] https://functions.wolfram.com/GammaBetaErf/PolyGamma2/

c                v    V P                   ^ ,          p\        V4      p\        ^V4      P                  VR7      # rc  rd  rf  s   &&  r0   r   trigamma._eval_evalf  ri  r?   c                \    V P                   ^ ,          p\        ^V4      P                  4       # r`   rk  rl  s   && r0   r=   trigamma.fdiff  rn  r?   c                T    V P                   ^ ,          p\        ^V4      P                  # r`   rp  r   s   & r0   rj   trigamma._eval_is_real  rr  r?   c                T    V P                   ^ ,          p\        ^V4      P                  # r`   rt  r   s   & r0   ro   trigamma._eval_is_positive  rv  r?   c                T    V P                   ^ ,          p\        ^V4      P                  # r`   rx  r   s   & r0   r  trigamma._eval_is_negative  rv  r?   c                    V P                  \        4      p\        P                  .V,           pVP	                  WW44      # rr   )r   r9   r   rJ   r   r{  s   &&&&& r0   r   trigamma._eval_aseries  s3    ||I.5 ))!A<<r?   c                    \        ^V4      # r5   r  r  s   &&r0   rQ   trigamma.eval  r  r?   c                `    V P                   ^ ,          p\        ^V4      P                  RR7      # r  r  r  s   &, r0   rV   trigamma._eval_expand_func  r  r?   c                    \        ^V4      # r   r   rz   s   &&,r0   r-  trigamma._eval_rewrite_as_zeta  s    Aqzr?   c                    \        ^V4      # r5   r  rz   s   &&,r0   r  #trigamma._eval_rewrite_as_polygamma  r  r?   c                \    \        V^,
          ^4      ) \        ^,          ^,          ,           # r5   )r#   r   rz   s   &&,r0   r0  "trigamma._eval_rewrite_as_harmonic  s#    Q""RUQY..r?   c                ^    V P                   ^ ,          p\        ^V4      P                  V4      # r`   r  r  s   &&&& r0   r   trigamma._eval_as_leading_term  r  r?   r   Nr5   )r   r   r   r   r   r   r=   rj   ro   r  r   r   rQ   rV   r-  r  r0  r   r   r   r  s   @r0   r  r    s[     .^.
''++=
  1/2 2r?   r  c                   N   a  ] tR tRt o RtRtR
R lt]R 4       tR t	R t
RtV tR	# )
multigammai  a?  
The multivariate gamma function is a generalization of the gamma function

.. math::
    \Gamma_p(z) = \pi^{p(p-1)/4}\prod_{k=1}^p \Gamma[z + (1 - k)/2].

In a special case, ``multigamma(x, 1) = gamma(x)``.

Examples
========

>>> from sympy import S, multigamma
>>> from sympy import Symbol
>>> x = Symbol('x')
>>> p = Symbol('p', positive=True, integer=True)

>>> multigamma(x, p)
pi**(p*(p - 1)/4)*Product(gamma(-_k/2 + x + 1/2), (_k, 1, p))

Several special values are known:

>>> multigamma(1, 1)
1
>>> multigamma(4, 1)
6
>>> multigamma(S(3)/2, 1)
sqrt(pi)/2

Writing ``multigamma`` in terms of the ``gamma`` function:

>>> multigamma(x, 1)
gamma(x)

>>> multigamma(x, 2)
sqrt(pi)*gamma(x)*gamma(x - 1/2)

>>> multigamma(x, 3)
pi**(3/2)*gamma(x)*gamma(x - 1)*gamma(x - 1/2)

Parameters
==========

p : order or dimension of the multivariate gamma function

See Also
========

gamma, lowergamma, uppergamma, polygamma, loggamma, digamma, trigamma,
sympy.functions.special.beta_functions.beta

References
==========

.. [1] https://en.wikipedia.org/wiki/Multivariate_gamma_function

Tc           	         ^ RI Hp V^8X  d[   V P                  w  r4\        R4      pV P	                  W44      V! \        ^ V^V,
          ^,          ,           4      V^V34      ,          # \        W4      hrO  )rQ  rP  r8   r   r7   r9   r
   )r;   r<   rP  rT   rI   rO   s   &&    r0   r=   multigamma.fdiff"  s^    1q=99DAc
A99Q?3yAQ	M'BQ1I#NNN$T44r?   c                6   ^ RI Hp VP                  RJ g   VP                  RJ d   \	        R4      h\        R4      p\        W"^,
          ,          ^,          ,          V! \        V^V,
          ^,          ,           4      V^V34      ,          P                  4       # )r   )ProductFz+Order parameter p must be positive integer.rO   )	sympy.concrete.productsr  rD   rg   r-   r   r   r3   doit)rM   rT   rI   r  rO   s   &&&  r0   rQ   multigamma.eval+  sw    3==E!Q\\U%:JKK#JQAYq[!'%QUAI*>+,a)#5 56:df	=r?   c                ^    V P                   w  rV P                  VP                  4       V4      # rr   )r8   r7   ra   )r;   rT   rI   s   &  r0   rc   multigamma._eval_conjugate4  s$    yyyy**r?   c                    V P                   w  r^V,          pVP                  '       d   W2^,
          8*  RJ d   R# \        V4      '       d   W2^,
          8:  d   R# W2^,
          8  g   VP                  '       d   R# R# )r   TFN)r8   rg   r1   rh   )r;   rT   rI   ys   &   r0   rj   multigamma._eval_is_real8  s\    yyaC<<<Qq5\d21::1Q<A;!/// *r?   r   Nr   )r   r   r   r   r   r   r=   r   rQ   rc   rj   r   r   r  s   @r0   r  r    s:     7p J5 = =+ r?   r  N)Cmathr   
sympy.corer   r   r   r   sympy.core.exprr   sympy.core.functionr	   r
   r   sympy.core.logicr   r   sympy.core.numbersr   r   r   r   sympy.core.powerr   &sympy.functions.special.zeta_functionsr   r   r   r   r   $sympy.functions.elementary.complexesr   r   &sympy.functions.elementary.exponentialr   r   #sympy.functions.elementary.integersr   r   (sympy.functions.elementary.miscellaneousr   (sympy.functions.elementary.trigonometricr   r    r!   %sympy.functions.combinatorial.numbersr"   r#   (sympy.functions.combinatorial.factorialsr$   r%   r&   sympy.utilities.miscr'   mpmathr(   r)   mpmath.libmp.libmpfr*   r1   r3   r   r   r9   rs   r   r  r  r   r?   r0   <module>r     s     1 1   N N 1 2 2   7 A A ? ; > 9 B B E S S '  +uO uxm m`_% _%Lj, j,Z	@5 @5FZ2o Z2|]2 ]2JY Yr?   