Function: lngamma
Section: transcendental
C-Name: glngamma
Prototype: Gp
Help: lngamma(x): logarithm of the gamma function of x.
Doc: principal branch of the logarithm of the gamma function of $x$. This
 function is analytic on the complex plane with nonpositive integers
 removed, and can have much larger arguments than \kbd{gamma} itself.

 For $x$ a power series such that $x(0)$ is not a pole of \kbd{gamma},
 compute the Taylor expansion. (PARI only knows about regular power series
 and can't include logarithmic terms.)
 \bprog
 ? lngamma(1+x+O(x^2))
 %1 = -0.57721566490153286060651209008240243104*x + O(x^2)
 ? lngamma(x+O(x^2))
  ***   at top-level: lngamma(x+O(x^2))
  ***                 ^-----------------
  *** lngamma: domain error in lngamma: valuation != 0
 ? lngamma(-1+x+O(x^2))
  *** lngamma: Warning: normalizing a series with 0 leading term.
  ***   at top-level: lngamma(-1+x+O(x^2))
  ***                 ^--------------------
  *** lngamma: domain error in intformal: residue(series, pole) != 0
 @eprog
 For $x$ a \typ{PADIC}, return the $p$-adic $\log\Gamma_{p}$ function, which
 is the $p$-adic logarithm of Morita's gamma function for $x \in \Z_{p}$,
 and Diamond's function if $|x| > 1$.
 \bprog
 ? lngamma(5+O(5^7))
 %2 = 4*5^2 + 4*5^3 + 5^4 + 2*5^5 + O(5^6)
 ? log(gamma(5+O(5^7)))
 %3 = 4*5^2 + 4*5^3 + 5^4 + 2*5^5 + O(5^6)
 ? lngamma(1/5+O(5^4))
 %4 = 4*5^-1 + 4 + 2*5 + 5^2 + 5^3 + O(5^4)
 ? gamma(1/5+O(5^4))
  ***   at top-level: gamma(1/5+O(5^4))
  ***                 ^-----------------
  *** gamma: domain error in gamma: v_p(x) < 0
 @eprog
