# Computing $\int_a^b \frac{x^p}{\sqrt{(x-a)(b-x)}} \mathrm dx$

I would like to compute the integral:

$$\int_a^b \frac{x^p}{\sqrt{(x-a)(b-x)}} \mathrm dx$$

where $$a<b$$ and $$p\in\mathbb{N}$$

$$\int_a^b \frac{x^p}{\sqrt{(x-a)(b-x)}} \mathrm dx=\frac{2}{b-a} \int_a^b \frac{x^p \mathrm dx}{\sqrt{1-\left(\frac{2x-(a+b)}{b-a}\right)^2}}$$

The substitution $x\rightarrow \frac{2x-(a+b)}{b-a}$ gives:

$$\frac{1}{2^p} \int_{-1}^{1} \frac{((b-a)x+a+b)^p}{\sqrt{1-x^2}} \mathrm dx$$

I tried to make an integration by parts:

$$\frac{1}{2^p}\left(2^{p-1}\pi(a^p+b^p)-p(b-a) \int_{-1}^1 \arcsin(x)((b-a)x+a+b)^{p-1} \mathrm dx \right)$$

What about the integral $$\int_{-1}^1 \arcsin(x)((b-a)x+a+b)^{p-1} \mathrm dx$$?

-

Let $x = a + (b-a)t$. Then $$I(p) = \int_0^1 \dfrac{(a+(b-a)t)^p}{\sqrt{t(1-t)}} dt$$ We have that $$\int_0^1 \dfrac{t^k dt}{\sqrt{t(1-t)}} = \sqrt{\pi} \dfrac{\Gamma(k+1/2)}{\Gamma(k+1)}$$ The above simplification is possible due to the following reason. Recall that the $\beta$ function is defined as $$\beta(x,y) = \int_0^1 t^{x-1} (1-t)^{y-1} dt$$ The $\beta$-function is closely related to the $\Gamma$ function through the relation $$\beta(x,y) = \dfrac{\Gamma(x) \Gamma(y)}{\Gamma(x+y)}.$$ The proof for the above claim can be seen here.

Hence, we get that $$\int_0^1 \dfrac{t^k dt}{\sqrt{t(1-t)}} = \int_0^1 t^{k-1/2} (1-t)^{-1/2} dt = \int_0^1 t^{(k+1/2)-1} (1-t)^{1/2-1} dt\\ = \beta(k+1/2,1/2) = \dfrac{\Gamma(k+1/2) \Gamma(1/2)}{\Gamma(k+1)} = \sqrt{\pi} \dfrac{\Gamma(k+1/2)}{\Gamma(k+1)}$$ Further, $$\Gamma(1/2) = \sqrt{\pi}$$ You can look up here for some particular values of the $\Gamma$ function. $$\Gamma(k+1/2) = \dfrac{(2k-1)(2k-3)\cdots 1}{2^k} \sqrt{\pi} \text{ where } k \in \mathbb{Z}^+$$ The above is so since $\Gamma(z+1) = z \Gamma(z)$ and $\Gamma(1/2) = \sqrt{\pi}$. $$\Gamma(k+1) = k! \text{ where } k \in \mathbb{Z}^+$$ $$\dfrac{\Gamma(k+1/2)}{\Gamma(k+1)} = \dfrac{(2k-1)(2k-3)\cdots 1}{2^k k!} \sqrt{\pi} = \dfrac1{4^k} \binom{2k}{k} \sqrt{\pi}$$

Hence, $$I(p) = \int_0^1 \sum_{k=0}^{p} \binom{p}{k} a^{p-k}(b-a)^{k} \dfrac{t^{k}}{\sqrt{t(1-t)}} dt\\ = \displaystyle \sum_{k=0}^{p} \left(\binom{p}{k} a^{p-k}(b-a)^{k} \int_0^1 \dfrac{t^{k}}{\sqrt{t(1-t)}} dt \right)\\ = \pi \times \left( \sum_{k=0}^{p} \left( \binom{p}{k}\binom{2k}{k} \dfrac{a^{p-k}(b-a)^{k}}{4^k} \right) \right)$$

We have that $$I(0) = \pi$$ $$I(1) = \dfrac{a+b}{2} \pi$$ $$I(2) = \dfrac{3a^2+2ab+3b^2}{8} \pi$$ $$I(3) = \dfrac{5a^3+3a^2b+3ab^2+5b^3}{16} \pi$$

I am not sure if you can simplify this further in terms of elementary functions.

-
I don't understand the equalities: $$\int_0^1 \dfrac{t^k dt}{\sqrt{t(1-t)}} = \sqrt{\pi} \dfrac{\Gamma(k+1/2)}{\Gamma(k+1)}, \Gamma(k+1/2) = \dfrac{(2k-1)(2k-3)\cdots 1}{2^k}$$ Is it possible to explain them? –  Chon Jun 2 '12 at 21:08
@Chon I have added some details. Hope it is clear now. It might be possible to simplify the final solution. –  user17762 Jun 2 '12 at 21:16
@Marvis Please check your normalization. It should be $I(0) = \pi$ and $I(1) = \frac{a+b}{2}$. –  Sasha Jun 2 '12 at 22:11
@Sasha Oops... you are right :). Also, can this answer be simplified? –  user17762 Jun 2 '12 at 22:16
What does $\beta$ represent? –  Chon Jun 3 '12 at 19:29

I would probably find it easiest to reduce the given integral to Euler's integral for Gauss's hypergeometric function: $$\int_a^b \frac{ x^p \mathrm{d} x}{\sqrt{(b-x)(x-a)}} \stackrel{x = a+(b-a) u}{=} \int_0^1 \frac{(a+(b-a)u)^p }{\sqrt{u(1-u)}} \mathrm{d} u = \\ a^p \int_0^1 u^{-\frac{1}{2}} \left(1-u\right)^{-\frac{1}{2}} \left( 1- \left(1-\frac{b}{a}\right) u \right)^p \mathrm{d} u$$ This is the case of the Euler integral representation of the Gauss's hypergeometric function with parameters $\alpha = \frac{1}{2}$, $\gamma=1$ and $\beta = -p$ and $z=1-\frac{b}{a}$, hence $$\int_a^b \frac{ x^p \mathrm{d} x}{\sqrt{(b-x)(x-a)}} = a^p \cdot \underbrace{\mathrm{B}\left(\frac{1}{2}, \frac{1}{2}\right)}_{\pi} \cdot {}_2 F_1\left(\frac{1}{2}, -p ; 1; 1 - \frac{b}{a}\right)$$ The hypergeometric series terminates for $p\in \mathbb{N}$, and the result coincides with that of @Marvis, but the above result extends to all the complex values of $p$:

In[29]:= With[{a = 2.4, b = 3.6, p = 3.4},
a^p \[Pi] Hypergeometric2F1[1/2, -p, 1, 1 - b/a]]

Out[29]= 142.388

In[30]:= With[{a = 2.4, b = 3.6, p = 3.4},
NIntegrate[x^p/Sqrt[(b - x) (x - a)], {x, a, b}]]

Out[30]= 142.388

-

I would proceed by complex integration. I will give a sketchy proof as the detailed discussion would take pages, but involves many standard moves. Consider the contour consisting of the upper edge of $[a,b]$ ($\arg z=0$) a small circle around $z=a$, then the lower edge of $[a,b]$ ($\arg z$ decreases by $\pi i$ due to factor $\left(z-a\right)^{-1/2}$, the other factors make no contribution) and a small circle around $z=b$. Integrating along this contour amounts to integrating along a large circle surrounding the infinity. It should be relatively easy to show that the integrals along the small circles tend to 0 as the radii tend to 0 hence, by the residue theorem: $$-I+e^{-\pi i}I=2\pi i R_{\infty}$$ $$-Ie^{-\frac{\pi i}{2}}\left(e^{\frac{\pi i}{2}}-e^{-\frac{\pi i}{2}}\right)=2\pi i R_{\infty}$$ $$I=-\frac{e^{\frac{\pi i}{2}}}{\sin\frac{\pi}{2}}R_\infty=-\pi e^{\frac{\pi i}{2}}R_{\infty}$$

Now it remains to find $R_{\infty}$ which is the coefficient at $z^{-1}$ taken with the opposite sign. Expanding: $$\frac{z^{p}}{\sqrt{\left(z-a\right)\left(b-z\right)}}=e^{-\frac{\pi i}{2}}z^{p-1}\left(1-\frac{a}{z}\right)^{-\frac{1}{2}}\left(1-\frac{b}{z}\right)^{-\frac{1}{2}}=e^{-\frac{\pi i}{2}}z^{p-1}\sum_{k=0}^{\infty}\left(\begin{array}{c} k-\frac{1}{2}\\ k \end{array}\right)\left(\frac{a}{z}\right)^{k}\times \sum_{k=0}^{\infty}\left(\begin{array}{c} k-\frac{1}{2}\\ k \end{array}\right)\left(\frac{b}{z}\right)^{k}$$ So we need to take the coefficient at $z^{-p}$ in the expansion. Finally, as the exponents cancel out we obtain: $$I=\pi \sum_{k=0}^{p}\left(\begin{array}{c} k-\frac{1}{2}\\ k \end{array}\right)\left(\begin{array}{c} p-k+\frac{1}{2}\\ p-k \end{array}\right)a^{k}b^{p-k}$$ which should be equivalent to the form stated in the previous answer.

-
Well, for one $${-1/2 \choose k}=1/2^k{2k \choose k}$$ or something of the sort. –  Pedro Tamaroff Jun 2 '12 at 22:45
in fact i should have used this $$\frac{1}{\left(1-z\right)^{\beta+1}}=\left(\begin{array}{c} k+\beta\\ k \end{array}\right)z^k$$ to get the signs in order –  Valentin Jun 2 '12 at 23:08
You're missing a sum sign over there! But I get it. –  Pedro Tamaroff Jun 2 '12 at 23:12
take it this is Einstein sum :D –  Valentin Jun 2 '12 at 23:15

Let $x = \sin(\theta)$ in your second to last integral. Then your integral reduces to $${1 \over 2^p}\int_{-{\pi \over 2}}^{\pi \over 2} ((b - a)\sin(\theta) + (a + b))^p\,d\theta$$ If you expand the integrand you get terms of the form $Const \times \int_{-{\pi \over 2}}^{\pi \over 2}\sin^k(\theta)\,d\theta$ which there are well known formulas for.

-