<s>[INST] Integrating $\int_a^b\left[ \left(1 - \frac{a}{x} \right)\left(\frac{b}{x}-1 \right) \right]^\frac{1}{2}dx$ We are interested in the following integration:
$$ \int_a^b \left[ \left(1 - \frac{a}{x} \right)\left(\frac{b}{x}-1 \right) \right]^{1/2} dx. $$
I try to use substitution with:
$$u = \left(1-\tfrac{a}{x}\right)\left(\tfrac{b}{x} -1\right) = (a+b)x^{-1} - 1 - (ab)x^{-2}.$$
$$ du = \left( (-a-b)x^{-2} + (2ab)(x^{-3}) \right)dx $$ 
or
$$  dx = du \left( \left( (-a-b)x^{-2} + (2ab)(x^{-3}) \right)^{-1} \right)$$
Now the integration becomes something ugly. I try integration by parts on the ugly part, and it becomes even uglier. Obviously, I don't see some easier ways. I would appreciate some advices or the solution!
Edit: It may be easier to see the problem as
$$ \int_a^b \left[ (a-x)(x-b)x^{-2}  \right]^{1/2} dx .$$
 [/INST] Rescale the integration range with the following variable change and the shorthand $q$
$$u = \frac{x-a}{b-a}, \>\>\>\>\>\>q=\frac{b}{a}-1$$
to simplify the original integral
$$ I = \int_a^b \left[ \left(1 - \frac{a}{x} \right)\left(\frac{b}{x}-1 \right) \right]^{1/2} dx=aq^2\int_0^1 \frac{\sqrt{u(1-u)}}{1+qu} du\tag{1}$$
Then, let $u=\sin^2 t$ to rewrite (1) as
$$ I = 2a\int_0^{\pi/2} \frac{q^2\sin^2 t\cos^2 t}{1+q\sin^2 t}dt$$
Decompose the integrand,
$$I = 2a\int_0^{\pi/2}\left( 1+q\cos^2 t-\frac{1+q}{1+q\sin^2 t}\right) dt$$
Carry out the two integrals,
$$I_1=\int_0^{\pi/2}\left( 1+q\cos^2 t\right) dt=\frac{\pi}{2}\left(1+\frac{q}{2}\right)$$
$$I_2=\int_0^{\pi/2} \frac{1+q}{1+q\sin^2 t}dt=\int_0^{\infty} \frac{(1+q)ds}{1+(1+q)s^2 }=\frac{\pi}{2}\sqrt{1+q}$$
where $s=\tan t$ is used in evaluating $I_2$. Thus,
$$I= 2a(I_1- I_2)= \frac{\pi}{2}(b+a-2\sqrt{ab})$$
</s>