I have this function:
$$\pi(\theta|\vec{x}) = \frac{2^{-n/2-2}\theta^{-n/2-3}\left(\sum_\limits{i = 1}^{n} x_i^2+4\right)^{n/2+2}\exp\left({-{\left(\sum_\limits{i = 1}^{n} x_i^2 + 4\right)}/{2\theta}}\right)}{\Gamma(n/2 +2)} $$
and I am trying to take the mean of it with respect to $\theta$.
Here is what I did:
$$E(\theta|\vec{x}) = \int_{0}^{\infty} \theta \, \frac{2^{-n/2-2}\theta^{-n/2-3}\left(\sum_\limits{i = 1}^{n} x_i^2+4\right)^{n/2+2}\exp\left({-{\left(\sum_\limits{i = 1}^{n} x_i^2 + 4\right)}/{2\theta}}\right)}{\Gamma(n/2 +2)} d\theta$$ Using wolfram alpha, the answer came out to be $$=\frac{n (\sum_{i = 1}^{n} x_i^2 + 4)\Gamma(n/2)}{4 \Gamma(n/2+2)}$$
When I simplified this by hand, I got:
$$ = \frac{n (\sum_{i = 1}^{n} x_i^2 + 4)\Gamma(n/2)}{4 (n/2+2)(n/2+1)\Gamma(n/2)} = \frac{n (\sum_{i = 1}^{n} x_i^2 + 4)}{(n+4)(n+2)}$$
However, wolfram showed that the simplification was: $$= \frac{(\sum_{i = 1}^{n} x_i^2 + 4)}{(n+2)}$$ which is not equivalent to the original answer to the integral when plugging numbers in.
Any suggestion on where things might be going wrong would be much appreciated. The answer I obtained from the integral and the hand simplification apparently are not correct.
Recall that $$\Gamma\left(x+1\right)=x\Gamma\left(x\right)$$