\chapter{The gamma function}
\label{gamma}
\index{gamma function}

This chapter studies a special function called the \emph{gamma
function.}

% ---------------------------------------------------------------------

\section{Special functions}
\index{special function}
\index{function!special}
\label{gamma:040}

\index{function!elementary or nonelementary}
\index{elementary function}
\index{nonelementary function}
The gamma function being a special function, the chapter might begin by
telling what a \emph{special function} is.  However, a definition of the
term is hard to find.  N.~N.\ Lebedev begins
chapter~1 of his book on special functions,
\begin{quote}
  One of the simplest and most important special functions is the
  \emph{gamma function.}\footnote{Emphasis in the
  original.}~\cite{Lebedev}
\end{quote}
The gamma is a special function and is simple and important,
reveals Lebedev; but what a special function is, or why the gamma
should be one, is not stated.  Larry~C.\ Andrews begins the preface of
\emph{his} book on special functions,
\begin{quote}
  Modern engineering and physics applications demand a \ldots\ thorough
  knowledge of \ldots\ the basic properties of \emph{special
  functions.}\footnote{Emphasis in the original.}
\end{quote}
The italics suggest that Andrews might next define the term, but
instead he continues,
\begin{quote}
  These functions commonly arise in such areas of application as heat
  conduction, communications systems,
  electro-optics\mbox{,\:.\:.\:.~\cite{Andrews}}
\end{quote}
In~\cite{A-S}, Abramowitz and Stegun deliver two early chapters named
``Elementary analytical methods'' and ``Elementary transcendental
functions'' before launching into a series of nineteen chapters on special
functions (exponential integral, gamma, error/Fresnel, Legendre,
Bessel-integer, Bessel-fractional, Bessel integral, Struve, confluent
hypergeometric, Coulomb, hypergeometric, Jacobian elliptic/theta,
elliptic integral, Weierstrass elliptic, parabolic cylinder, Mathieu,
spheroidal wave, orthogonal polynomial and Bernoulli/
% bad break
Euler/Riemann\footnote{The book you are reading will treat only a few
of the topics of Abramowitz's and Stegun's nineteen chapters.}), by
which one may infer that special functions are \emph{nonelementary;}
but even Abramowitz and Stegun never quite seem to say what a special
function is. Gradshteyn and Ryzhik agree with Abramowitz and Stegun
that special functions are nonelementary:
\begin{quote}
  First, we have the elementary functions:
  the function $f(x)=x$;
  the exponential function;
  the hyperbolic functions;
  the trigonometric functions;
  the logarithmic function;
  the inverse hyperbolic functions \ldots;
  the inverse trigonometric functions.

  Then follow the special functions:
  elliptic integrals;
  elliptic functions;
  the logarithm \ldots, exponential \ldots, sine \ldots\
    and \ldots\ cosine integral functions;
  probability integrals and Fresnel's integrals;
  the gamma function and related functions;
  Bessel functions;
  Mathieu functions;
  Legendre functions;
  orthogonal polynomials;
  hypergeometric functions;
  degenerate hypergeometric functions;
  parabolic cylinder functions;
  {M}{e}{\ij}{e}{r}'s and Mac-
    \linebreak
    % bad break (the name is "MacRobert's", the sole hyphenation in
    % which TeX finds at the point shown.  Unfortunately, even this
    % break must be forced onto TeX!
    Robert's functions;
  Riemann's zeta function.~\cite{G-R}
\end{quote}
No actual definition is seen here, either, though.  And W.~W.\ Bell?
Bell too has written a book on special functions. In his book Bell
begins chapter~1,
\begin{quote}
  Many special functions arise in the consideration of solutions of
  equations of the form
  $P(x)\,d^2y/dx^2+Q(x)\,dy/dx+
  \linebreak % bad break
  R(x)y=0$.~\cite{WWBell}
\end{quote}
And so on.  The desultory collection of quotations this paragraph
has assembled is no exhaustive survey, of course, but \emph{special
function} nevertheless appears to be a term specialists\footnote{Neat
word.  Take ``specialist'' either way.} were reluctant to define.

Eric~W.\ Weisstein, like your author a nonspecialist, does define the
term:
\begin{quote}
  A special function is a function (usually named after an early
  investigator of its properties) having a particular use in
  mathematical physics or some other branch of mathematics. Prominent
  examples include the gamma function, hypergeometric function,
  Whittaker function, and {M}{e}{\ij}{e}{r} G-function.~\cite{EWW-web}
\end{quote}
Such a nonspecialist's definition however, presenting itself
chiefly in terms of examples, differs from the \emph{specialists'
nondefinitions} less than one might like.

If specialists like Lebedev, Andrews, Abramowitz, Stegun, Gradshteyn,
Ryzhik and Bell cannot or will not define the term \emph{special function}
more precisely than they have, then perhaps the book you are reading
should leave the question in the form in which the specialists have
left it.  Apparently, an applied mathematician is to recognize a
special function when he meets it!  The gamma function is one at any
rate, by common consent.

Besides the gamma, we have already met two other special functions in
this book: the sine integral of \S~\ref{fours:160}; and the cumulative
normal distribution of \S\S~\ref{prob:100.40} and~\ref{prob:750}.
Furthermore, \S~\ref{prob:750} and~\ref{prob:760} have introduced
asymptotic series, chiefly a special-functions topic.

Special functions tend to have in common that they
\begin{itemize}
  \item solve differential equations, definite integrals or integral
    equations
    \linebreak % bad break
    (\S~\ref{gamma:960})
    of applicationary interest; but
  \item cannot readily be expressed in terms of polynomials of finite
    numbers of terms, nor in terms of combinations of such polynomials
    with ratios, exponentials, trigonometrics, logarithms and/or
    inverse trigonometrics; and
  \item may want asymptotic series to calculate their values;
\end{itemize}
but otherwise special functions are various.

The fascination of special functions to the scientist and engineer lies
in how gracefully they analyze otherwise intractable physical models; in
how reluctantly they yield their mathematical secrets; in how readily
they conform to unexpected applications; in how often they connect
seemingly unrelated phenomena; and in that, the more intrepidly one
explores their realm, the more disquietly one feels that one had barely
penetrated the realm's frontier.  The topic of special functions seems
inexhaustible.  We surely will not begin to exhaust the topic in this
book; yet, even so, useful results will start to flow from our study
almost at once.

The chapter you are reading mainly regards the gamma function.

% ---------------------------------------------------------------------

% diagn: reconsider whether the next line needs definite-integral
% hyphenated?  (The author *thinks* not, but unsure.)
\section{The definite integral representation}
\index{definite integral!to represent the gamma function}
\index{integral!to represent the gamma function}
\index{gamma function!definite integral representation of}
\label{gamma:100}

%This section develops a definite integral to represent the gamma function.

\index{divergence}
\index{$Gamma$}
Consider the definite integral
\[
  \int_{t_1}^{t_2} \tau^{a-1}\,d\tau,
\]
slightly perplexing in that it diverges if $t_1\ra 0^{+}$ and $a\le 0$, yet
also diverges if $t_2\ra \infty$ and $a\ge 0$; and more perplexing
in that it diverges regardless of the value of~$a$ if both $t_1\ra
0^{+}$ and $t_2\ra \infty$, a frequent case even in applied work.
To co\"erce convergence, various tactics might be tried, among which is
to damp the integrand%
\footnote{%
  Damping the integrand is a practical technique to force a
  nonconvergent integral to
  converge~\cite{Brown-conversation}.  Whether this section's
  integral is the right kind of integral to damp can be debated (the
  book prints the damping attempt because the attempt incidentally
  discovers the gamma function) but one might damp other integrals by
  \[
    \lim_{\ep\ra 0^{+}} \int_{0}^\infty e^{-\ep^n\alpha \tau}
    f(\tau)\,d\tau
  \]
  or
  \[
    \lim_{\ep\ra 0^{+}} \int_{-\infty}^\infty
      e^{-\ep^n\alpha \tau^2/2} f(\tau)\,d\tau
  \]
  or the like, the~$n$ being a small nonnegative integer
  (typically~$0$, $1$ or~$2$) and the~$\alpha$ being a positive real
  number.  The present section tries damping by $e^{-\ep^n\alpha \tau}$
  with $n=0$ and $\alpha=1$.  (If unsure what the~$n$ is for, then see
  for example \S~\ref{lapl:260} in which $n=2$ is used.)
}
by
\[
  \int_{t_1}^{t_2} e^{-\tau}\tau^{a-1}\,d\tau.
\]
The damped integral converges even if $t_1\ra 0^{+}$ and $t_2\ra
\infty$ as long as~$a$ is positive.
When $z\la a$ is changed to support complex exponents, the
definite integral%
\footnote{%
  \cite[eqn.~1.1.1]{Lebedev}%
  \cite[eqn.~2.5]{Andrews}%
  \cite[eqn.~6.1.1]{A-S}%
  \cite[eqn.~2]{Sebah-Gourdon}%
}
that results,
\bq{gamma:def-int}
  \Gamma(z) \equiv \int_0^\infty e^{-\tau}\tau^{z-1}\,d\tau,
  \ \ \Re(z) > 0,
\eq
has been found to be sufficiently interesting to merit a name.
Its name is the \emph{gamma function.}  It is this chapter's
chief subject.

% ---------------------------------------------------------------------

\section{Relationship to the factorial}
\label{gamma:110}
\index{factorial!as related to the gamma function}
\index{gamma function!as related to the factorial}

Expressing $\Gamma(z+1$) according to~(\ref{gamma:def-int}) and
using~(\ref{inttx:parts}) to integrate by
parts\footnote{\cite[\S~1.2]{Lebedev}},
\[
  \begin{split}
    \Gamma(z+1) &=
      \int_0^\infty e^{-\tau}\tau^{z} \,d\tau
    \\&=
      -\int_0^\infty \tau^{z}\,d[e^{-\tau}]
    \\&=
      \left.-e^{-\tau}\tau^{z}\right|_{\tau=0}^\infty
      + \int_0^\infty e^{-\tau}\,d[\tau^{z}]
    \\&=
      0 + z\int_0^\infty e^{-\tau}\tau^{z-1}\,d\tau.
  \end{split}
\]
That is,%
\footnote{%
  \cite[eqn.~1.2.1]{Lebedev}%
  \cite[eqn.~2.3]{Andrews}%
  \cite[eqn.~6.1.15]{A-S}%
}
\bq{gamma:110:00}
    \Gamma(z+1) = z\Gamma(z).
\eq
According to~(\ref{gamma:def-int}),%
\footnote{%
  \cite[eqn.~2.2]{Andrews}%
}
\bq{gamma:110:01}
    \Gamma(1) = 1,
\eq
so by induction on~(\ref{gamma:110:00}) we conclude that%
\footnote{%
  \cite[eqn.~2.4]{Andrews}%
  \cite[eqn.~6.1.6]{A-S}%
}
\bq{gamma:110:05}
    n! = \Gamma(n+1).
\eq

The recursion~(\ref{gamma:110:00}) incidentally affords a means
to calculate $\Gamma(z)$ for $\Re(z) \le 0$---although,
according to~(\ref{gamma:110:00}) or~(\ref{gamma:110:05}), $\Gamma(z)$
diverges\footnote{Section~\ref{gamma:230} will address the gamma
function's analyticity and poles.}
%\footnote{%
%  It can be shown that the gamma function is analytic over the complex
%  plane except at negative real integral values of~$z$, where the
%  function has single poles~\cite[\S~1.1]{Lebedev}.  However, this book
%  does not use that theorem and does not develop it.
%}
for $z < 0$ if $z \in \mathbb Z$.

% ---------------------------------------------------------------------

\section{Half-integral arguments}
\label{gamma:120}
\index{half!gamma function of}
\index{gamma function!of a half-integral argument}

Using technique\footnote{\cite[\S~2.2.1]{Andrews}} like that of
\S~\ref{fouri:130}, changing $u^2 \la \tau$ and $x \la z$
in~(\ref{gamma:def-int}),
\[
  \Gamma(x) = 2\int_0^\infty e^{-u^2}u^{2x-1}\,du.
\]
Similarly,
\[
  \Gamma(y) = 2\int_0^\infty e^{-v^2}v^{2y-1}\,dv.
\]
The product of the last two equations has that
\splx{
  \Gamma(x)\Gamma(y) &= 4\int_0^\infty \int_0^\infty e^{-(u^2+v^2)}u^{2x-1}v^{2y-1}\,du\,dv
  \\&= 4\int_0^{2\pi/4} \int_0^\infty e^{-\rho^2}(\rho\cos\phi)^{2x-1}(\rho\sin\phi)^{2y-1}\rho\,d\rho\,d\phi
  \\&= 4\int_0^{2\pi/4} \int_0^\infty
  e^{-\rho^2}\rho^{2(x+y)-1}\cos^{2x-1}\phi\sin^{2y-1}\phi\,d\rho\,d\phi.
}
Evaluating at $x=1/2$ and $y=1/2$,
\[
  \Gamma^2\left(\frac 1 2\right) =
    4\int_0^{2\pi/4} \int_0^\infty
    e^{-\rho^2}\rho \,d\rho\,d\phi
  =
    2\pi
    \int_0^\infty e^{-\rho^2}\rho\,d\rho
  =
    \left.
      -\pi e^{-\rho^2}
    \right|_0^\infty
  =
      \pi.
\]
That is,%
\footnote{%
  \cite[eqn.~1.2.5]{Lebedev}%
  \cite[eqn.~2.23]{Andrews}%
  \cite[eqn.~6.1.8]{A-S}%
}
insofar as~(\ref{gamma:def-int})
makes~$\Gamma(z)$ to be positive for all real, positive~$z$,
\bq{gamma:half}
  \Gamma\left(\frac 1 2\right) = \sqrt{\pi}.
\eq

Equations~(\ref{gamma:110:00}) and~(\ref{gamma:half}) together
determine $\Gamma(z)$ for all half-integral $z=n+1/2$, $n\in\mathbb Z$.
For example, $\Gamma(3/2) = (1/2)\Gamma(1/2) = (\sqrt{\pi})/2$ and
$\Gamma(-1/2) = \Gamma(1/2)/(-1/2) = -2\sqrt{\pi}$.

% ---------------------------------------------------------------------

\section{Numerical evaluation}
\label{gamma:200}
\index{gamma function!numerical evaluation of}

Not every method used to expand elementary functions works on a special
function like the gamma but one method that almost works is to
expand the exponential in~(\ref{gamma:def-int}) via
Table~\ref{taylor:315:tbl}, obtaining the form
\[
  \Gamma(z) = \int_0^\infty \sum_{k=0}^\infty \frac{(-)^k\tau^{k+z-1}}{k!}\,d\tau.
\]
Here, one would like to swap the~$\int$ integration
and~$\sum$ summation
signs to integrate each term but, unfortunately, the
term-by-term integrals diverge.

Better is to split (\ref{gamma:def-int})'s integral at~$\tau=T$ into
two domains as
\bq{gamma:200:20}
  \Gamma(z) = \int_0^{T} e^{-\tau}\tau^{z-1}\,d\tau
  + \int_T^\infty e^{-\tau}\tau^{z-1}\,d\tau, \ \ \Im(T)=0,\ \Re(T) > 0,
\eq
the~$T$ being a nonnegative real number one can choose at
discretion---the larger, the numerically harder (a computer needing
wider registers with more bits) but the more accurate the calculation.

The leftward integral now supports the $\int$-$\sum$ swap we had wanted earlier:
\bqa
  \Gamma(z) &=&
  \sum_{k=0}^\infty \int_0^T \frac{(-)^k\tau^{k+z-1}}{k!}\,d\tau
  + \int_T^\infty e^{-\tau}\tau^{z-1}\,d\tau
  \xn\\&=&
  \sum_{k=0}^\infty \frac{(-)^kT^{k+z}}{k!(k+z)}
  + \int_T^\infty e^{-\tau}\tau^{z-1}\,d\tau.
  \label{gamma:200:25}
\eqa

The rightward integral is
\bq{gamma:200:30}
  I = \int_T^\infty e^{-\tau}\tau^{z-1}\,d\tau.
\eq
If $0 < \Re(z) < 1$,
\[
  |I| < \left|T^{z-1}\right|\int_T^\infty e^{-\tau}\,d\tau.
\]
Evaluating,
\bq{gamma:200:35}
  |I| < \left|T^{z-1}\right| e^{-T}\ \text{for}\ 0 < \Re(z) < 1.
\eq

If $\Im(z) = 0$ and $0 < z < 1$ then~(\ref{gamma:200:35}) implies that
\[
  0 < I < T^{z-1} e^{-T},
\]
since the integrand in~(\ref{gamma:200:30}) is never negative in the
real-valued case.  Indeed, a yet tighter bound can be established
in the real-valued case by observing the factor~$\tau^{z-1}$
in~(\ref{gamma:200:30}) and estimating, for~$\tau$ in the neighborhood
of~$T$, that
\[
  \tau^{z-1} \approx T^{z-1}e^{(\alpha)(T-\tau)}
\]
the estimate evidently being
exact at $\tau = T$ regardless of the value of~$\alpha$, the~$\alpha$
being an arbitrary parameter with a value to be chosen momentarily.
Differentiating the estimate with respect to~$\tau$,
\[
  (z-1)\tau^{z-2} \approx -\alpha T^{z-1}e^{(\alpha)(T-\tau)}.
\]
Preferring the last to be exact at $\tau = T$, we require that
\[
  (z-1)T^{z-2} = -\alpha T^{z-1}e^{(\alpha)(T-T)}
\]
or, solving, that
\[
  \alpha = -\frac{z-1}{T},
\]
which lets us express the estimate---and here we refer to the original
estimate rather than to its derivative---as
\[
  \tau^{z-1} \approx T^{z-1}e^{(z-1)(\tau/T-1)}.
\]
For a reason that will soon grow clear, it would be convenient in view
of the last line if%
{
  \setlength\arraycolsep{0.30\arraycolsep}
  \settowidth\tla{$\tau,$}
  \settowidth\tlb{$T$}
  \settowidth\tld{for}
  \bqa
    \tau^{z-1} &>& T^{z-1}e^{(z-1)(\tau/T-1)} > 0%
    \label{gamma:200:40}
    \\&&\quad
    \text{for}\
    0 < T < \tau,\
    \Im(T) = 0,\
    \Im(\tau) = 0,\ \xn
    \\&&\quad
    \makebox[\tld][l]{}\
    0 < \makebox[\tlb][c]{$z$} < \makebox[\tla][r]{$1,$}\
    \Im(\makebox[\tlb][c]{$z$}) = 0,\xn
  \eqa
}%
or, rearranging factors, if
\[
  \left(\frac\tau T\right)^{z-1} > e^{(z-1)(\tau/T-1)} > 0
\]
or, raising both sides to the $1/(z-1)$ power (where $1/[z-1] < 0$
because $z < 1$), if
\[
  0 < \frac\tau T < e^{\tau/T-1}
\]
or, expressing both sides in terms of the exponent, if
\[
  0 < 1+\left(\frac\tau T-1\right) < e^{\tau/T-1}
\]
over the domain~(\ref{gamma:200:40}) stipulates.
The quantity $\tau/T-1$ being positive over the domain,
a Taylor expansion of the last inequality's exponential proves the
inequality to be true and, the steps leading to the last
inequality being reversible, thereby verifies~(\ref{gamma:200:40}).

Applying~(\ref{gamma:200:40}) to~(\ref{gamma:200:30}),
\[
  I > \int_T^\infty e^{-\tau}
    T^{z-1}e^{(z-1)(\tau/T-1)}
    \,d\tau
  = e^{-(z-1)}T^{z-1}\int_T^\infty e^{[(z-1)/T-1]\tau} \,d\tau.
\]
Unlike the integral of~(\ref{gamma:200:30}), the last integral is one
we know how to evaluate.  Evaluating it,
\[
  I > \left.\frac{e^{-(z-1)}T^{z-1}}{(z-1)/T-1}
    e^{[(z-1)/T-1]\tau}
  \right|_{\tau=T}^\infty
  =
  -\frac{e^{-(z-1)}T^{z-1}}{(z-1)/T-1}
    e^{[(z-1)/T-1]T}.
\]
That is,
\[
  I > \frac{T^{z-1}e^{-T}}{1-(z-1)/T}.
\]
Combining the last inequality with the unnumbered inequality
following
% bad break
(\ref{gamma:200:35}), we conclude that
{
  \setlength\arraycolsep{0.30\arraycolsep}
  \settowidth\tla{$\tau,$}
  \settowidth\tlb{$T$}
  \settowidth\tld{for}
  \bqa
    \label{gamma:200:45}
      \lefteqn{\frac{T^{z-1}e^{-T}}{1-(z-1)/T} < I < T^{z-1} e^{-T}}
    &&\\&&\qquad
    \text{for}\
    0 < T,\
    \Im(T) = 0,\
    0 < z < 1,\
    \Im(z) = 0;\xn
  \eqa
}%
and by similar reasoning%
\footnote{%
  To reach~(\ref{gamma:200:46}), require in~(\ref{gamma:200:40}) that
  $\tau^{z-1} < T^{z-1}e^{(z-1)(\tau/T-1)}$.%
}
that
{
  \setlength\arraycolsep{0.30\arraycolsep}
  \settowidth\tla{$\tau,$}
  \settowidth\tlb{$T$}
  \settowidth\tld{for}
  \bqa
    \label{gamma:200:46}
      \lefteqn{T^{z-1}e^{-T} < I < \frac{T^{z-1} e^{-T}}{1-(z-1)/T}}
    &&\\&&\qquad
    \text{for}\
    0 < T,\
    \Im(T) = 0,\
    1 < z,\
    \Im(z) = 0.\xn
  \eqa
}%

Finally, using~(\ref{gamma:200:30}) to condense the representation
of~(\ref{gamma:200:25}),
\bq{gamma:200:50}
  \Gamma(z) =
  \sum_{k=0}^\infty \frac{(-)^kT^{k+z}}{k!(k+z)}
  + I,
\eq
with either~(\ref{gamma:200:35}), in the complex case,
or~(\ref{gamma:200:45}) or~(\ref{gamma:200:46}), in the real case,
providing a bounded estimate of~$I$.  Equation~(\ref{gamma:200:25})
numerically evaluates $\Gamma(z)$.

Several other methods to evaluate $\Gamma(z)$ are known, incidentally,
as for instance in~\cite[chapter~6]{A-S}.
%\footnote{Abramowitz's and
%Stegun's book~\cite{A-S}, a public-domain classic, is unlike the
%book you are reading, for it omits derivations, referring one
%onward to other sources for those.  Abramowitz's and Stegun's book
%however reports many special-functions results the book you are reading
%does not.}

Figure~\ref{gamma:plot} plots the gamma function
per~(\ref{gamma:200:50}), with~(\ref{gamma:110:00}), over the real
domain.\footnote{Similar is \cite[Fig.~6.1]{A-S} but because that
figure predated computer plotting, the present figure is more
accurate.}
\begin{figure}
  \caption{The gamma function.}
  \label{gamma:plot}
  \bc
    \nc\fxa{-5.0} \nc\fxb{5.0}
    \nc\fya{-4.7} \nc\fyb{5.2}
    \nc\xxa{4.50} \nc\xxb{4.50}
    \nc\xxc{4.25} \nc\xxd{4.25}
    \newcommand\xxplot[4]{
      % The writer has learned a little more about the gamma
      % function since composing this figure, so he would do it
      % slightly differently if he did it now, but this works.
      \psplot[plotpoints={#1}]{#2}{#3}{
        /heightlimit 4.50 def
        /scale 1.00 def
        /integertolerance 1.0e-5 def
        /doinvert #4 def
        /e      2.718281828459045 def
        /rootpi 1.772453850905516 def
        /pi     3.141592653589793 def
        /T 8.0 def
        /N 64 def
        /z x scale div def
        /zbase 0 def
        {z 0.0 le {/zbase zbase 1 sub def /z z 1.0 add def} {exit} ifelse} loop
        {z 1.0 gt {/zbase zbase 1 add def /z z 1.0 sub def} {exit} ifelse} loop
        /isreflected false def
        z 0.5 lt {/isreflected true def /z 1.0 z sub def} if
        /ihi {
          T z 1.0 sub exp e T neg exp mul
        } def
        /ilo {
          ihi 1.0 z 1.0 sub T div sub div
        } def
        /iav {
          ihi ilo add 0.5 mul
        } def
        0.0
        /term T z exp def
        0 1 N {
          /k exch def
          term k z add div add
          /term term neg T mul k 1 add div def
        } for
        iav add
        isreflected {pi 180.0 z mul sin div exch div /z 1.0 z sub def} if
        {zbase 0 gt {z mul /zbase zbase 1 sub def /z z 1.0 add def} {exit} ifelse} loop
        {zbase 0 lt {/zbase zbase 1 add def /z z 1.0 sub def z div} {exit} ifelse} loop
        z 1.0 ge {
          /zint z floor def
          z zint sub integertolerance lt {
            pop 1.0 1 1 zint 1 sub {mul} for
          } if
        } if
        doinvert {1.0 exch div} if
        scale mul
        /myscaledgamma exch def
        myscaledgamma abs heightlimit gt {
            heightlimit myscaledgamma 0.0 lt {neg} if
        } {myscaledgamma} ifelse
      }
    }
    \begin{pspicture}(\fxa,\fya)(\fxb,\fyb)
      %\psframe[linewidth=0.5pt,dimen=outer](\fxa,\fya)(\fxb,\fyb)
      %\localscalebox{1.0}{1.0}
      {
        \small
        \psset{dimen=middle}
        {
          \psset{linewidth=0.5pt}
          %\psframe[linecolor=orange](-\xxa,-\xxb)(\xxa,\xxb)
          {
            \psset{linecolor=lightgray}
            \psline(-\xxc,1)(-0.90,1)\psline(-0.70,1)(\xxc,1)
            \psline(-\xxc,2)(\xxc,2)
            \psline(-\xxc,3)(\xxc,3)
            \psline(-\xxc,4)(\xxc,4)
            \psline(-\xxc,-1)(\xxc,-1)
            \psline(-\xxc,-2)(\xxc,-2)
            \psline(-\xxc,-3)(\xxc,-3)
            \psline(-\xxc,-4)(\xxc,-4)
            \psline(1,-\xxd)(1,\xxd)
            \psline(2,-\xxd)(2,\xxd)
            \psline(3,-\xxd)(3,\xxd)
            \psline(4,-\xxd)(4,\xxd)
            \psline(-1,-\xxd)(-1,0.40)\psline(-1,1.52)(-1,\xxd)\psline(-1,0.83)(-1,1.00)
            \psline(-2,-\xxd)(-2,\xxd)
            \psline(-3,-\xxd)(-3,\xxd)
            \psline(-4,-\xxd)(-4,\xxd)
          }
          \psline(-\xxa,0)(\xxa,0)
          \psline(0,-\xxb)(0,\xxb)
          \uput[u](0,\xxb){$\Gamma(t)$}
          \uput[r](\xxa,0){$t$}
          \rput(-1.45,1.25){$1/\Gamma(t)$}
          \psline[linewidth=0.5pt](-0.92,1.25)(-0.80,1.25)(-0.80,0.90)(-1.195,0.32)
          {\psset{linewidth=2.0pt}
            \xxplot{500}{ 0.204}{ 3.763}{false}
            \xxplot{150}{-0.723}{-0.283}{false}
            \xxplot{150}{-1.872}{-1.216}{false}
            \xxplot{150}{-2.962}{-2.102}{false}
            \xxplot{150}{-3.991}{-3.035}{false}
            \xxplot {80}{-4.347}{-4.009}{false}
          }
          {\psset{linestyle=dashed}\psset{linewidth=1.0pt}\xxplot{300}{-4.154}{4.347}{true}}
        }
      }
    \end{pspicture}
  \ec
\end{figure}

% ---------------------------------------------------------------------

\section{Reflection}
\label{gamma:220}
\index{reflection!of the gamma function}
\index{gamma function!reflection of}

If evaluating the gamma function at a certain value of~$z$ is
inconvenient, the gamma function's \emph{reflection
formula,}\footnote{%
  \cite[eqn.~6.1.17]{A-S}\cite[eqn.~1.2.2]{Lebedev}\cite[eqn.~2.31]{Andrews}%
}
\bq{gamma:220:00}
  \Gamma(z)\Gamma(1-z) = \frac{\pi}{\sin \pi z},
\eq
can help.  The formula is proved for $0 < \Re(z) < 1$ by writing
per~(\ref{gamma:def-int}) that\footnote{%
  \cite[\S\S~1.86 and~3.123]{Titchmarsh}\cite[\S~1.2]{Lebedev}%
}
\splx{
  \Gamma(z)\Gamma(1-z) &=
    \int_0^\infty e^{-\tau}\tau^{z-1}\,d\tau
    \int_0^\infty e^{-\sigma}\sigma^{-z}\,d\sigma
  \\&=
    \int_{0}^\infty\frac{e^{-\sigma}}{\sigma}\left[
      \int_{0}^\infty e^{-(\sigma)(\tau/\sigma)}
      \left(\frac\tau\sigma\right)^{z-1}\,d\tau
      \right] d\sigma,
}
in which the order of integration does not matter\footnote{As the book
has several times noted, justifications of convergence generally
interest the professional mathematician more than they do the
applicationist.  Nevertheless, even at the applied level, an
occasional, brief justification seems fitting as in the present
instance.  Reasoning similarly, the interested reader can justify
convergence on the book's behalf when other, related instances arise.}
because the real parts of both $z-1$ and~$-z$ lie between~$-1$ and~$0$.
Changing $v\la\tau/\sigma$ within the inner integral,
\splx{
  \Gamma(z)\Gamma(1-z) &=
    \int_{0}^\infty e^{-\sigma}\left[
      \int_{0}^\infty e^{-\sigma v}
      v^{z-1}\,dv
      \right] d\sigma
  \\&=
    \int_{0}^\infty \left[
      \int_{0}^\infty e^{-(\sigma)(1+v)}
      v^{z-1}\,dv
      \right] d\sigma.
}
Again swapping the order,
\[
  \Gamma(z)\Gamma(1-z) =
    \int_{0}^\infty v^{z-1}
    \left[
      \int_{0}^\infty e^{-(\sigma)(1+v)}
      \,d\sigma
    \right] dv.
\]
Changing $u\la(\sigma)(1+v)$ within the inner integral,
\splx{
  \Gamma(z)\Gamma(1-z) &=
    \int_{0}^\infty \frac{v^{z-1}}{1+v}
    \left[
      \int_{0}^\infty e^{-u} \,du
    \right] dv
  \\&=
    \int_{0}^\infty \frac{v^{z-1}}{1+v}
    [1] \,dv
  =
    \int_{0}^\infty \frac{v^{z-1}\,dv}{1+v}.
}
The last integral is perhaps nonobvious but, fortunately, if one has a
sharp memory regarding integrals earlier worked (and an applied
mathematician ought to cultivate such a memory to the extent to which
he can), then one may recall~(\ref{inttx:250:20}) which---after the
identity of Table~\ref{trig:228:table} that $\sin(\phi\pm\pi) = -\sin\phi$
is applied---yields~(\ref{gamma:220:00}) as sought.

The recurrence~(\ref{gamma:110:00}) extends the
reflection~(\ref{gamma:220:00}) to all~$z$ (except, naturally, to
the nonanalytic points at $z=0,-1,-2,-3,\ldots$).  For
example,\footnote{Formally to prove the point via induction is left as
an exercise to the interested reader.}
$\Gamma(\text{0xA}/3)\Gamma(-7/3)
= [\Gamma(1/3)(1/3)(4/3)(7/3)]
[\Gamma(2/3)/(-1/3)(-4/3)
\linebreak\times % bad break
(-7/3)] = -\Gamma(1/3)\Gamma(2/3) = -\pi/\sin[\pi(1/3)] =
\pi/\sin[\pi(3 + 1/3)] = \pi/\sin[\pi(\text{0xA}/3)]$.

% ---------------------------------------------------------------------

\section{Analyticity, poles and residues}
\label{gamma:230}
\index{analyticity!of the gamma function}
\index{pole!of the gamma function}
\index{gamma function!analyticity of}
\index{gamma function!pole of}
\index{residue!of the gamma function}
\index{gamma function!residue of}

Since eqn.~(\ref{gamma:def-int}) makes the gamma function analytic over
the domain $\Re(z) > 0$, eqn.~(\ref{gamma:110:00}) extends the gamma's
analyticity over the whole complex plane except at the isolated points
$z=0,-1,-2, -3,\mbox{\mdots}$ Why?  Because the fact that
\[
  \Gamma(z) = \frac{\Gamma(z+1)}{z},
\]
the $\Gamma(z+1)$ being analytic over the domain $\Re(z) > -1$, implies that
\begin{itemize}
  \item
    $\Gamma(z)$ too is analytic over the domain $\Re(z) > -1$ except at $z=0$,
  \item
    at $z=0$ stands a single pole (\S~\ref{alggeo:250}), and
  \item
    the residue (\S~\ref{taylor:350}) associated with the pole is~$\Gamma(z+1)|_{z=0}=1$.
\end{itemize}
Similarly, the fact that
\[
  \Gamma(z) = \frac{\Gamma(z+2)}{(z)(z+1)},
\]
the $\Gamma(z+2)$ being analytic over the domain $\Re(z) > -2$, implies that
\begin{itemize}
  \item
    $\Gamma(z)$ is analytic over the domain $\Re(z) > -2$ except at $z=0$ and
    at $z=-1$,
  \item
    at $z=-1$ stands a single pole, and
  \item
    the residue associated with the pole is~$\Gamma(z+2)/z|_{z=-1}=-1$.
\end{itemize}
Generalizing,
\begin{itemize}
  \item
    $\Gamma(z)$ is analytic over the whole complex plane except at
    $z=0,-1,
    \linebreak % bad break
    -2,-3,\ldots$,
  \item
    at each of $z=0,-1,-2,-3,\ldots$ stands a single pole, and
  \item
    the residue at $z=-n$
    is~$\Gamma(z+n+1)/(z)(z+1)\cdots(z+n-2)(z+n-1)|_{z=-n}=(-n)(-n+1)\cdots(-2)(-1)$.
\end{itemize}
That is, the gamma function's residue at $z=-n$, $n\in\mathbb Z$, $n \ge 0$,
is $(-)^n/n!$.

One can use the residue to estimate $\Gamma(z)$ in the neighborhood of
a pole to be
\bq{gamma:230:20}
  \Gamma(-n+\ep) \approx (-)^n/n!\ep, \ \ \ |\ep| \ll 1,\ n=0,1,2,3,\ldots
\eq
For example,
\splx{
  \Gamma(-\text{0x6.FF}+i\text{0x0.02}) &=
    \Gamma(7+\text{0x0.01}+i\text{0x0.02})
  \\&\approx
    (-)^5/7!(\text{0x0.01}+i\text{0x0.02})
  \\&\approx
    (-\text{0x100}+i\text{0x200})/7!(1^2+2^2)
  \\&\approx
    (-\text{0x100}+i\text{0x200})/7!5
  \\&\approx
    -\text{0x0.02A}+i\text{0x0.053}.
}

\index{reciprocal gamma function}
\index{gamma function!reciprocal}
\index{entire function}
\index{meromorphic function}
Among the consequences of this section's findings is that the
\emph{reciprocal gamma function,} $1/\Gamma(z)$, plotted in
Fig.~\ref{gamma:plot} over the real domain, is an entire function
(see \S~\ref{taylor:330}).  The gamma function itself is not entire, for it
has poles, but it is meromorphic (see again \S~\ref{taylor:330})
because its poles are simple ones and it lacks branches and other singularities.

% ---------------------------------------------------------------------

\section{The digamma function}
\label{gamma:320}
\index{digamma function}

\index{gamma function!logarithmic derivative of}
\index{logarithmic derivative!of the gamma function}
The \emph{digamma function} is the gamma function's logarithmic
derivative
\bq{gamma:digamma}
  \psi(z) \equiv \frac{d}{dz}\ln\Gamma(z) =
  \frac{(d/dz)\Gamma(z)}{\Gamma(z)},
\eq
the logarithmic derivative as an operation having been introduced in
\S~\ref{drvtv:240.40}.
Following Lebedev~\cite[\S~1.3]{Lebedev},
differentiating~(\ref{gamma:def-int}),
\splx{
  \frac{d}{dz}\Gamma(z) &=
    \int_0^\infty e^{-\tau}\frac{d\left[\tau^{z-1}\right]}{dz}\,d\tau,
  \\&=
    \int_0^\infty e^{-\tau}\frac{d\left[e^{(\ln\tau)(z-1)}\right]}{dz}\,d\tau
  \\&=
    \int_0^\infty e^{-\tau}\tau^{z-1}\ln\tau\,d\tau
  \\&=
    \int_0^\infty e^{-\tau}\tau^{z-1}\ln\left(\frac\tau 1\right) d\tau.
}
For the next step, we shall use Frullani's
integral~(\ref{inttx:460:frullani}).
Changing $\sigma\la\tau$ in~(\ref{inttx:460:frullani}),
using~$e^{-\sigma}$ for Frullani's $f(\sigma)$, and expanding
$\ln(\tau/1)$ according to the result,
\splx{
  \frac{d}{dz}\Gamma(z) &=
    \int_0^\infty e^{-\tau}\tau^{z-1}
      \int_0^\infty \frac{e^{-1\sigma}-e^{-\tau\sigma}}{\sigma} \,d\sigma
    \,d\tau
  \\&=
    \int_0^\infty \frac{1}{\sigma} \int_0^\infty
    e^{-\tau}\tau^{z-1} \left(e^{-\sigma}-e^{-\tau\sigma}\right)
    d\tau
    \,d\sigma
  \\&=
    \int_0^\infty \left[
      e^{-\sigma}\int_0^\infty e^{-\tau}\tau^{z-1} \,d\tau
      -\int_0^\infty e^{-(\sigma+1)\tau}\tau^{z-1} \,d\tau
    \right] \frac{d\sigma}{\sigma}
  \\&=
    \int_0^\infty \left[
      e^{-\sigma}\Gamma(z)
      -\int_0^\infty e^{-(\sigma+1)\tau}\tau^{z-1} \,d\tau
    \right] \frac{d\sigma}{\sigma}.
}
Changing $t\la (\sigma+1)\tau$ within the inner integral,
\splx{
  \frac{d}{dz}\Gamma(z) &=
    \int_0^\infty \left[
      e^{-\sigma}\Gamma(z)
      - \frac{1}{(\sigma+1)^z}
      \int_0^\infty e^{-t}t^{z-1}
      \,dt
    \right] \frac{d\sigma}{\sigma}
  \\&=
    \int_0^\infty \left[
      e^{-\sigma}\Gamma(z)
      - \frac{1}{(\sigma+1)^z}\Gamma(z)
    \right] \frac{d\sigma}{\sigma}
  \\&=
    \Gamma(z)\int_0^\infty \left[
      e^{-\sigma} - \frac{1}{(\sigma+1)^z}
    \right] \frac{d\sigma}{\sigma}.
}
Changing $\tau\la\sigma$, dividing both sides by $\Gamma(z)$, and
applying~(\ref{gamma:digamma}),
\bq{gamma:digamma-int}
  \psi(z) =
    \int_0^\infty \left[
      e^{-\tau} - \frac{1}{(\tau+1)^z}
    \right] \frac{d\tau}{\tau},\ \ \ \Re(z) > 0.
\eq
Equation~(\ref{gamma:digamma-int}) affords the digamma function an
integral representation as eqn.~(\ref{gamma:def-int}) has afforded the
gamma function one.

% ---------------------------------------------------------------------

\section{Integral equations (overview)}
\index{integral equation}
\label{gamma:960}

Section~\ref{gamma:040} has mentioned that special functions solve
solve differential equations, definite integrals and integral equations.
Differential equations and definite integrals are familiar from earlier
chapters, but what is an integral equation?

An \emph{integral equation}\footnote{\cite{colofred}} is an equation
for example like
\bq{gamma:050:10}
  f(z) = g(z) + \int_{-\infty}^\infty K(z,w) f(w) \,dw,
\eq
in which the unknown is a function $f(z)$ integrated over a definite
domain such that one cannot convert the equation to a differential
equation by the expedient of differentiating it.

Integral equations are typically less tractable than differential
equations.  To solve them wants different techniques.

Actually, we have already met integral equations in disguise, in
discretized form, in matrix notation (chapters~\ref{matrix}
through~\ref{eigen}) resembling
\[
  \ve f = \ve g + K\ve f,
\]
which means no more than it seems to mean; so maybe integral equations
are not so strange as they look.  The integral
equation~(\ref{gamma:050:10}) is merely the matrix equation with%
{
  \settowidth\tla{$w$}
  \nc\wz{\makebox[\tla][l]{$z$}}
  \[
    \begin{split}
      f(i\,\Delta z) \,\Delta \wz &\la \ve f\ \text{[without the integral]},\\
      g(i\,\Delta z) \,\Delta \wz &\la \ve g,\\
      K(i\,\Delta z,j\,\Delta w) \,\Delta \wz &\la K,\\
      f(j\,\Delta w) \,\Delta w &\la \ve f\ \text{[within the integral]}\\
    \end{split}
  \]
}%
(the letter~$i$ representing here not the imaginary unit but rather an index
as in chapter~\ref{matrix}) and with $\Delta w=\Delta z$.

