Evaluating an integral without using the Digamma function or complex analysis. Suppose that $n$ is a positive integer, and let $k$ be a positive integer less than $n$.
How can one show that $\displaystyle\int_0^1 \frac{x^{k-1} - x^{n-k-1}}{1 - x^n} \; dx= \frac{\pi}{n} \cot{\frac{\pi k}{n}}$ without using the digamma (psi) function or complex analysis? I am pretty sure that I have seen such an approach (using basic calculus) at one point, but I can not quite recall how the argument worked. Thanks!
 A: Begin by Taylor expanding the denominator:
$$\int_0^1 dx \; \frac{x^{k-1} - x^{n-k-1}}{1 - x^n} = \int_0^1 dx \; (x^{k-1} - x^{n-k-1}) \sum_{m=0}^{\infty} x^{m n} $$
Reverse the order of the sum and the integral:
$$ \begin{align} &= \sum_{m=0}^{\infty} \int_0^1 dx \; (x^{m n + k-1} - x^{(m+1) n-k-1}) \\ &= \sum_{m=0}^{\infty} \left ( \frac{1}{m n + k} - \frac{1}{(m+1) n - k} \right ) \\ &= \frac{1}{n} \sum_{m=0}^{\infty} \left ( \frac{1}{m + k/n} - \frac{1}{m+1 - k/n} \right )   \\&= \frac{1}{n} \sum_{m=-\infty}^{\infty} \frac{1}{m + k/n} \\ \end{align}$$
Write $k/n = z/\pi$ and rewrite the sum below:
$$ \begin{align} &= \frac{\pi}{n}  \left ( \frac{1}{z} + 2 z \sum_{m=1}^{\infty} \frac{1}{z^2-\pi^2 m^2} \right ) \\ \end{align} $$
The expression in parenthesis is a well-known representation of $\cot(z)$ .  This result was derived by Euler, and may be derived by considering Euler's product representation of $\sin{\pi z}/(\pi z)$ and differentiating $\log{\sin{\pi z}}$.
Using the definition of $z$, we find that 
$$\int_0^1 dx \; \frac{x^{k-1} - x^{n-k-1}}{1 - x^n} = \frac{\pi}{n} \cot{\frac{\pi k}{n}} $$
EDIT
Simple proof that 
$$\cot{z} = \frac{1}{z} + 2 z \sum_{m=1}^{\infty} \frac{1}{z^2-\pi^2 m^2}  $$
Consider the relation
$$\cot{y} = \frac{1}{2} (\cot{\frac{y}{2}} - \tan{\frac{y}{2}}) $$
We may rewrite this as
$$\pi x \cot{\pi x} = \frac{\pi x}{2} \left (\cot{\frac{\pi x}{2}} + \cot{\frac{\pi (x \pm 1)}{2}} \right ) $$
Note that this forms a sort of recurrence.  That is, we can apply the above relation to each term inside the parenthesis.  We use the minus sign for the first term, and the plus sign for the second term.  The result of a first pass is
$$\pi x \cot{\pi x} = \frac{\pi x}{2^2} \left (\cot{\frac{\pi x}{2^2}} + \cot{\frac{\pi (x - 1)}{2^2}} + \cot{\frac{\pi (x + 1)}{2^2}} + \cot{\frac{\pi (x + 2)}{2^2}} \right ) $$
We can repeat this as much as we like; after $r$ rounds of this, we get
$$\pi x \cot{\pi x} = \frac{\pi x}{2^r} \left (\cot{\frac{\pi x}{2^r}} + \sum_{m=1}^{2^{r-1}-1} \left [\cot{\frac{\pi (x - m)}{2^r}} + \cot{\frac{\pi (x + m)}{2^r}} \right ] + \cot{\frac{\pi (x + 2^{r-1})}{2^r}} \right ) $$
Now take the limit as $r \rightarrow \infty$.  Use the facts that
$$\lim_{r \rightarrow \infty} \frac{\pi x}{2^r} \cot{\frac{\pi x}{2^r}} = 1 $$
$$\lim_{r \rightarrow \infty} \frac{1}{2^r} \cot{\frac{a}{2^r}} = \frac{1}{a} $$
$$\lim_{r \rightarrow \infty} \frac{1}{2^r} \cot{\frac{\pi(x+2^{r-1})}{2^r}} = 0$$
$\forall \, a \ne 0$.  and we get the expansion
$$\pi x \cot{\pi x} = 1 + x \sum_{m=1}^{\infty} \left ( \frac{1}{x+m} + \frac{1}{x-m} \right ) $$
from which the cited result follows.
