
\chapter{A note on a particular integral}
\label{app:dilog}
In this note I want to take a look at the calculation of an integral
that comes up in the evaluation of transport integrals over
tetrahedral volumes.  The integral in question is the following:
\begin{equation}
J(p,q,r) = \int^{1}_{0}{\log(p+qx) \over x-r}dx
\end{equation}
Here $p$ and $q$ are such that both $p$ and $p+q$ are in the same
half-plane and $r$ is a complex number and we note that the integral
defines an analytic function of $r$ with a branch cut on the real axis
between 0 and 1.  The analytic solution to this integral can be
written down explicitly in terms of the dilogarithm function,
$\dilog(x)$ and logarithms and is (ostensibly) given by:
\begin{eqnarray}
J(p,q,r) &=& 
\dilog\left({p+q \over p+qr}\right)+
\log(p+q)\log\left(1-{p+q \over p+qr}\right)
\nonumber\\ &-&
\dilog\left({p \over p+qr}\right)
\log(p)\log\left(1-{p \over p+qr}\right)
\end{eqnarray}
The $\dilog$ is defined in the following way:
\begin{equation}
\dilog(z) = \sum_{k = 1}^{\infty}{z^k \over k^2} = 
-\int^{z}_{0}{\log(1-w)dw \over w} = 
-\int^{1}_{0}{\log(1-zx)dx \over x}.
\end{equation}
We note that the sum converges only for $|z|<1$ but the integrals
provide an analytic extension to the whole complex plane with a branch
cut on the real axis from 1 to $\infty$.  There are numerous
identities and relations that exist between dilogarithms of different
arguments \cite{Lewin,Osacar:1995} but the one that we need to use
here is:
\begin{equation}
\dilog(z) = -\dilog(1-z)-\log(z)\log(1-z)+{\pi^2 \over 6}.
\end{equation}
Let us now look more closely at the solution to the integral.  Using
the definition of the dilogarithm we see by direct differentiation
that
\begin{equation}
J(z;p,q,r) = \int^{z}{\log(p+qx) \over x-r}dx
= 
\dilog\left({p+qz \over p+qr}\right)+
\log(p+qz)\log\left(1-{p+qz \over p+qr}\right).
\end{equation}
Now if line segment from ${p \over p+qr}$ to ${p+q \over p+qr}$ does
not cut the real axis above 1 we see that we have indeed:
\begin{equation}
J(p,q,r) = J(1,p,q,r)-J(0,p,q,r).
\end{equation}
However, if that happens, we have to take the branch cut into account
and make sure that we stay on the right branch, i.e. the branch that 
we start out on.  Thus let us write:
\begin{eqnarray}
\int_{0}^{z}{\log(p+qx) \over x-r}dx &=&
\dilog\left({p+qz \over p+qr}\right)+
\log(p+qz)\log\left(1-{p+qz \over p+qr}\right)-
J(0,p,q,r) 
\nonumber \\ &=&
{\pi^2 \over 6}-\dilog\left(1-{p+qz \over p+qr}\right)-J(0,p,q,r) 
\nonumber \\ &+&
\left[\log(p+qz)-\log\left({p+qz \over p+qr}\right)\right]
\log\left(1-{p+qz \over p+qr}\right)
\end{eqnarray}
Here we have used the identity above and now we see that we don't have
any problems with the dilogarithms and we need to consider the branch
cut only for the term:
\begin{equation}
\log\left(1-{p+qz \over p+qr}\right)
\end{equation}
which is easy because we know exactly how it behaves at the branch
cut.  Thus we come to the conclusion that there are three cases that
need to be considered depending on the position of the line segment:
\begin{equation}
l = \{z | z = z_{0}+t(z_{f}-z_{0}), t\in [0,1] \}
\end{equation}
where we have defined
\begin{equation}
z_{0} = 1-{p \over p+qr}
\qquad\mbox{and}\qquad
z_{f} = 1-{p+q \over p+qr}
\end{equation}
\begin{enumerate}
\item $l$ does not cut the negative real axis:
\begin{equation}
J(p,q,r) = 
\dilog(1-z_f)+
\log(p+q)\log(z_f)-
\dilog(1-z_0)-
\log(p)\log(z_0)
\end{equation}
\item $l$ does cut the negative real axis and $Im(z_0)>0$
\begin{eqnarray}
J(p,q,r) &=& 
{\pi^2 \over 6}-\dilog(z_f)+
\left[\log(p+q)-\log(1-z_f)\right]
\left[\log(z_f)+2\pi i\right]
\nonumber\\ &-&
\dilog(1-z_0)-
\log(p)\log(z_0)
\end{eqnarray}
\item $l$ does cut the negative real axis and $Im(z_0)<0$
\begin{eqnarray}
J(p,q,r) &=& 
{\pi^2 \over 6}-\dilog(z_f)+
\left[\log(p+q)-\log(1-z_f)\right]
\left[\log(z_f)-2\pi i\right]
\nonumber\\ &-&
\dilog(1-z_0)-
\log(p)\log(z_0)
\end{eqnarray}
\end{enumerate}
We can now use the identity again on case 2 and 3 and we get:
\begin{eqnarray}
J(p,q,r) &=& 
\dilog(1-z_f)+
\log(p+q)\log(z_f)-
\dilog(1-z_0)-
\log(p)\log(z_0)
\nonumber\\ &+&
2\pi i Sign[Im(z_0)](\log(p+q)-\log(1-z_f))
\end{eqnarray}


