Definition of Dirichlet distribution:
$$\operatorname{Dir}(\vec{x}\mid\vec{a})=\frac{\Gamma(a_0)} {\Gamma(a_1)\Gamma(a_2)\cdots\Gamma(a_M)}\prod_{k=1}^{M}x^{a_k - 1}$$ where: $$\vec{x}=(x_1, x_2, \ldots, x_M)^T$$ $$\vec{a}=(a_1, a_2, \ldots, a_M)^T$$ $$a_0 = \sum_{i=1}^{M}a_i$$
Now I need to find the expectation of $x_1^2$ for the Dirichlet distribution:
$$E(x_1^2) = \int x_1^2 \operatorname{Dir}(\vec{x}\mid\vec{a})~dx_1$$
$$E(x_1^2) = \int x_1^2 \frac{\Gamma(a_0)}{\Gamma(a_1)\cdots\Gamma(a_M)}\prod_{k=1}^M x^{a_k - 1}~dx_1$$
$$E(x_1^2) = \int x_1^2 \frac{\Gamma(a_0)}{\Gamma(a_1)\cdots\Gamma(a_M)} x^{a_1 - 1} \prod_{k=2}^M x^{a_k - 1}~dx_1$$
$$E(x_1^2) = \int \frac{\Gamma(a_0)}{\Gamma(a_1)\cdots\Gamma(a_M)} x^{a_1 +1} \prod_{k=2}^M x^{a_k - 1}~dx_1 \tag 1$$
Now I perform a variable substitution replacing vector $\vec{a}$ with vector $\vec{b}$, such that
$$\vec{b} = (a_1 + 2, a_2, a_3, \ldots, a_M)^T$$
Thus:
$$a_1 = b_1 - 2$$ $$a_0 = a_1 - 2$$ $$\Gamma(b_1) = \Gamma(a_1 - 2) \Longrightarrow \Gamma(a_1)=\frac{\Gamma(b_1)}{(a_1)(a_1+1)}$$ $$\Gamma(b_0) = \Gamma(a_0 - 2) \Longrightarrow \Gamma(a_0)=\frac{\Gamma(b_0)}{(a_0)(a_0+1)}$$
Substituting all this into (1):
$$E[x_1^2] = \frac{(a_1)(a_1-1)}{(a_0)(a_0-1)} \int_{-1}^1 \frac{\Gamma(b_0)}{\Gamma(b_1)...\Gamma(b_M)}\prod_{k=1}^{M}x^{b_k - 1}~dx_1$$
However, The Textbook says the answer should be:
$$E[x_1^2] = \frac{a_1(a_0-a_1)}{(a_0^2)(a_0+1)}$$
What am I missing?
I think, the easiest way to handle this problem is to represent Dirichlet distribution in terms of exponential family: https://en.wikipedia.org/wiki/Exponential_family