So, I was trying to calculate the integral
$$\ I(n) = \int_0^{\frac{\pi}{2}} \tan^n x dx$$
I used the substitution $\sin^2x = t$. Rearranging, I got the expression:
$$\ I(n) = \frac{1}{2} \cdot \int_0^1 t^{\frac{n-1}{2}} \cdot (1-t)^{\frac{-1-n}{2}} dt = \frac{1}{2}\cdot \beta(\frac{n+1}{2}, \frac{1-n}{2}) = \frac{\pi}{2\cos\frac{n\pi}{2}}$$
This works pretty nicely for $\ n < 1$, complying with the known results of $\ I(\frac{1}{2}) = \frac{\pi}{\sqrt2}$ and $\ I(\frac{1}{3}) = \frac{\pi}{\sqrt3}$
Also notice that the formula is invalid for odd natural $\ n$, which is to be expected since $\ I(1), I(3), I(5)....$ etc. diverge.
My question is : Why am I getting finite real values if I use the above formula for even natural $\ n$, despite the fact that $\ I(2), I(4), I(6)....$ etc. ought to (and do indeed) diverge?
Any help is appreciated. Thank you for reading!