# interesting integral involving powers of tan in the denominator

I ran across this integration problem that has an interesting pattern.

$$\int_{0}^{(n-1)\pi}\frac{1}{\tan^{n}(x)+1}dx=\frac{(n-1)\pi}{2}$$

I evaluated increasing values of n up to n=10, and the result is always one half the upper limit of integration.

Why is this?. That is, how could we show it. I graphed it and as n gets larger, the graph resembles rectangles of equal size stacked up along the x-axis.

Thanks.

-
You are aware that the integrand diverges at each $3\pi/4+k\pi$ for every odd $n$, aren't you? – Did Apr 4 '11 at 17:19
How do you define the integral for $n=3$? It seems to have a pole at $x= 3\pi/4$... – Fabian Apr 4 '11 at 17:19
@Cody Don't forget to accept helpful answers to questions you've asked. Notice your "0% accept rate". – Matthew Conroy Apr 4 '11 at 17:21
I am sorry, I appreciate and thank everyone who helps. No, I did not notice a 0% accept rate. Yes, I see what you mean about the divergence. I just noticed a pattern and thought it was interesting. At n=3, I get a result of $pi$. Which would be one half the upper limit of integration. Anyway, thanks. I did not mean to annoy anyone. I was unaware of "accepting" helpful answers. – Cody Apr 4 '11 at 17:24
... not to mention that the integrand is undefined at odd multiples of $\frac{\pi}{2}$. – Arturo Magidin Apr 4 '11 at 17:26
show 1 more comment

If $n$ is even,

then $\dfrac{1}{\tan^n x + 1} = \dfrac{\cos^n x}{\sin^n x + \cos^n x}$ is periodic with period $\pi$.

Also for $x \in [0, \pi/2]$ we have that for $t = x + \pi/2$ that $\dfrac{\cos^n t}{\sin^n t + \cos^n t} = \dfrac{\sin^n x}{\sin^n x + \cos^n x}$

And so

$\int_{0}^{\pi} \dfrac{1}{\tan^n x + 1} = \int_{0}^{\pi/2} \dfrac{\cos^n x}{\sin^n x + \cos^n x} + \int_{0}^{\pi/2} \dfrac{\sin^n x}{\sin^n x + \cos^n x} = \pi/2$.

-
 Thanks very much. I should have seen this. – Cody Apr 4 '11 at 17:39

For every odd $n$, the integral is not defined. For every even $n$, the integral equals what you say. To show this, first note that since the function you integrate has period $\pi$, it is enough to show that $I_k=\pi/2$, where $$I_k=\int_0^\pi\frac{\mathrm{d}x}{\tan(x)^{2k}+1}.$$ To compute $I_k$, use the change of variable $t=\tan(x)$, hence $\mathrm{d}t=(1+t^2)\mathrm{d}x$ and $$I_k=\int_{-\infty}^{+\infty}\frac{\mathrm{d}t}{(t^{2k}+1)(t^2+1)}=2\int_0^{+\infty}\frac{\mathrm{d}t}{(t^{2k}+1)(t^2+1)}.$$ Decompose the last integral into an integral from $0$ to $1$ and an integral from $1$ to $+\infty$, to which one can apply the change of variable $s=1/t$. This yields $$I_k=2\int_0^{1}\frac{\mathrm{d}t}{(t^{2k}+1)(t^2+1)}+2\int_0^{1}\frac{s^{2k}\mathrm{d}s}{(1+s^{2k})(1+s^2)}.$$ Finally, $$I_k=2\int_0^{1}\frac{\mathrm{d}t}{t^2+1}=2[\arctan(t)]_0^1=\pi/2.$$

-
Yes, I did notice it was undefined at odd n. I should have stated that and written 2n instead of n as the power of tan. Thank you very much. May I ask what Matthew meant by 'accepting a helpful answer"?. Is there a link where one rates an answer?. – Cody Apr 4 '11 at 17:38
As the OP, in front of each answer to your post you should see a small v below the up and down arrows that one uses to rate an answer. If you click on the v, this will "accept" the answer it corresponds to (meaning you consider it is the best and you are not interested in more answers). – Did Apr 4 '11 at 17:43
@Cody: and in principle you can still do this for all questions which you have posted so far... – Fabian Apr 4 '11 at 17:50
@Fabian Yes, and even in practice... :-) – Did Apr 4 '11 at 17:53