Simplify using the Tangent Difference identity I solved a problem to the point that I know the answer is 
$$\frac{2nr}{\tan\left( \frac{(n-2)\pi}{2n} \right)}$$
The question tells me that the answer is going to be 
$$2rn\tan\left(\frac{\pi}{n}\right)$$
Wolfram Alpha tells me the two are equal, so at least I'm on the right track. [link]
I was able to simplify 
$$\frac{2nr}{\tan\left( \frac{(n-2)\pi}{2n} \right)}$$ to $$\frac{2nr}{\tan\left( \frac{\pi}{2} - \frac{\pi}{n} \right)}$$
and then attempted to use the tangent difference identify, 
$$\tan(\alpha \pm \beta) = \frac{\tan\alpha \pm \tan\beta}{1 \mp \tan\alpha\tan\beta}$$
to simplify further.
But I am unable to find $\tan\alpha$ due to the fact that $\tan\left(\frac{\pi}{2}\right)$ is undefined. How do I work around this?
(Sorry if I went overboard with my LaTeX, I was really excited to be able to use it.)
 A: The two expressions are indeed the same. To go from your answer to the official one, use the identities $$\frac{1}{\tan \theta} = \cot \theta$$ and $$\cot(\frac{\pi}{2} - \theta) = \tan \theta.$$ 
The first one is just the definition of cotangent function, and the second is one of the properties of complementary angles. To see this second identity, just draw a right triangle with acute angles $\theta$ and $\pi/2-\theta$ and use the definitions of $\tan$ and $\cot$.
Another approach. If you want to arrive at the complementary angle formula, using the  tangent-difference formula, then you can proceed as follows. From
$$
\tan(A - B) = \frac{\tan A - \tan B}{1 + \tan A \tan B},
$$
derive
$$
\tan(A - B) = \frac{\cot B - \cot A}{\cot A \cot B + 1}.
$$
Now, since $\cot (\pi/2) = 0$, you can safely apply this formula to get:
$$
\tan(\frac{\pi}{2} - \theta) = \frac{\cot \theta - 0}{0 \cdot \cot \theta + 1} = \cot \theta.
$$
This is a nice trick worth knowing, but keep in mind that it may not be all that legitimate, since the right hand side of the starting identity is not even defined, and we divided by $\tan A \tan B$ (which is zero) to go to the second nicer form involving $\cot$.  Such manipulations (multiplying and dividing by $0$) are technically incorrect, and can eve lead to false statements (like $1=2$). 
A: First, as you note: 
$$\tan\left(\frac{(n-2)\pi}{2n}\right) = \tan\left(\frac{\pi}{2}-\frac{\pi}{n}\right) =- \tan\left(\frac{\pi}{n}-\frac{\pi}{2}\right).$$
Now remember that $\sin\left(a - \frac{\pi}{2}\right) = -\cos(a)$ and $\cos\left(a - \frac{\pi}{2}\right) = \sin(a)$. So:
$$\begin{align*}
\tan\left(\frac{(n-2)\pi}{2n}\right) &= -\tan\left(\frac{\pi}{n}-\frac{\pi}{2}\right)\\
&= -\frac{\sin\left(\frac{\pi}{n}-\frac{\pi}{2}\right)}{\cos\left(\frac{\pi}{n}-\frac{\pi}{2}\right)}\\
&= -\frac{-\cos\frac{\pi}{n}}{\sin\frac{\pi}{n}}\\
&= \cot\frac{\pi}{n}.
\end{align*}$$
Therefore,
$$\frac{2nr}{\tan\left(\frac{(n-2)\pi}{2n}\right)} = \frac{2nr}{\cot\frac{\pi}{n}} = 2nr\tan\frac{\pi}{n}.$$
