Expected value of $\ln X$ if $X$ is $\Gamma(a,b)$ distributed. I'm new here and hope you can help.
It's really late here in South Africa, maybe my mind just doesn't want to function now!  But I need to figure out how to get a closed form expression hopefully for $E(\ln X)$  and even $E(\ln (X^2))$  if $X$ is $\Gamma(a,b)$ distributed.
Any help would be greatly appreciated!!
Scrofungulus
 A: The exponential generating function for expectations of the powers of $\log(X)$ is 
$$\begin{eqnarray}
    \sum_{r=0}^\infty \frac{t^r}{r!} \mathbb{E}(\log^r(X)) &=&  \mathbb{E}(\sum_{r=0}^\infty \frac{t^r}{r!} \log^r(X))  = \mathbb{E}\left(X^t\right) = \int_0^\infty x^t \frac{b^{-a}}{\Gamma(a)} x^{a-1} \mathrm{e}^{-\frac{x}{b}} \mathrm{d} x 
   = b^{t} \frac{\Gamma(t+a)}{\Gamma(a)}
\end{eqnarray}
$$
Hence:
$$
  \mathbb{E}\left(\log(X)\right) = \left. \frac{\mathrm{d}}{\mathrm{d} t} b^{t} \frac{\Gamma(t+a)}{\Gamma(a)} \right|_{t=0} = \log(b) + \psi(a)
$$
$$
  \mathbb{E}\left(\log^2(X)\right) = \left. \frac{\mathrm{d}^2}{\mathrm{d} t^2} b^{t} \frac{\Gamma(t+a)}{\Gamma(a)} \right|_{t=0} = \log^2(b) + 2 \log(b) \psi(a) + \psi(a)^2 + \psi^{(1)}(a)
$$
where $\psi(a)$ denotes the digamma function, and $\psi^{(1)}(a)$ denotes the trigamma function.
A: The probability density function for the gamma distribution is 
$$f(x;a,b) = \frac{1}{b^a\Gamma(a)} x^{a-1}e^{-x/b},$$
so the integral we must consider is 
$$\mathbb{E}(\ln (X^n)) = \frac{1}{b^a \Gamma(a)} 
\int_0^\infty dx\, x^{a-1} e^{-x/b} \ln x^n.$$
Let $z=x/b$. 
We find 
$$\begin{eqnarray*}
\mathbb{E}(\ln (X^n)) 
&=& \frac{n}{\Gamma(a)} \int_0^\infty dz\, z^{a-1} e^{-z}\ln (b z) \\
&=& n\ln b + \frac{n}{\Gamma(a)} \int_0^\infty dz\, z^{a-1} e^{-z}\ln z \\
&=& n\ln b + \frac{n}{\Gamma(a)} 
\frac{d}{d a} \int_0^\infty dz\, z^{a-1} e^{-z} \\
&=& n\left(\ln b + \frac{\Gamma'(a)}{\Gamma(a)}\right) \\
&=& n\left(\ln b + \psi(a)\right),
\end{eqnarray*}$$
where we have used the definition of the gamma function, 
$\Gamma(a) = \int_0^\infty d x \, x^{a-1} e^{-x}$, 
and the digamma function, $\psi(z) = \Gamma'(z)/\Gamma(z)$. 
Addendum 1: It is possible to show (using the fact that $\ln x\leq z^s/s$ for all $s>0$) that 
$\int_0^\infty dz\, z^{a-1} e^{-z}\ln z$
converges uniformly for $1< a < \infty$. 
This justifies the trick of differentiating $\Gamma(a)$. 
Addendum 2: 
There is a possibility that the OP is interested in $\mathbb{E}((\ln X)^n)$.
@Sasha dealt with this below. 
It can also be handled with the derivative trick, 
$$\begin{eqnarray*}
\mathbb{E}((\ln X)^n)
&=& \frac{1}{\Gamma(a)} \int_0^\infty dz\, z^{a-1} e^{-z}(\ln (b z))^n \\
&=& \frac{1}{\Gamma(a)} \int_0^\infty dz\, z^{a-1} e^{-z}(\ln b + \ln z)^n \\
&=& \frac{1}{\Gamma(a)} \int_0^\infty dz\, z^{a-1} e^{-z}
\sum_{k=0}^n {n \choose k} (\ln b)^{n-k} (\ln z)^k \\
&=& \frac{1}{\Gamma(a)} \sum_{k=0}^n {n \choose k} (\ln b)^{n-k}
\int_0^\infty dz\, z^{a-1} e^{-z} (\ln z)^k \\
&=& \frac{1}{\Gamma(a)} \sum_{k=0}^n {n \choose k} (\ln b)^{n-k}
\frac{d^k}{d a^k} \int_0^\infty dz\, z^{a-1} e^{-z}  \\
&=& \frac{1}{\Gamma(a)} \sum_{k=0}^n {n \choose k} (\ln b)^{n-k}
\Gamma^{(k)}(a). 
\end{eqnarray*}$$
This is equivalent to the solution given by @Sasha.
For $n=2$ we arrive at 
$$\mathbb{E}((\ln X)^2) = (\ln b + \psi(x))^2 + \psi^{(1)}(a),$$ 
where $\psi^{(m)}(z) = d^{m+1}(\ln \Gamma(z))/d z^{m+1}$ is the polygamma function. 
