TITLE: To compute $\tan1-\tan3+\tan5-\cdots+\tan89$, $\tan1+\tan3+\tan5+\cdots+\tan89$
QUESTION [7 upvotes]: How do we compute :
$$i)\  S_1 = \tan1-\tan3+\tan5-\cdots+\tan89$$
and
$$ii)\  S_2 = \tan1+\tan3+\tan5+\cdots+\tan89$$ 
all the angles are in degrees.
Thanks

REPLY [6 votes]: Numerically, $S_1$ is very close to 45, this suggest it might have a simple derivation. Indeed, it does have one. For $S_2$, I have no idea.
For $S_1$, notice
$$\begin{array}{rrrrr}
\tan 1^\circ = \cot 89^\circ,& \tan 5^\circ = \cot 84^\circ,& \ldots,& \tan k^\circ = \cot (90-k)^\circ,& \ldots\\
-\tan 3^\circ = \cot 93^\circ,& -\tan 7^\circ = \cot 97^\circ,&\ldots,& -\tan k^\circ = \cot(90+k)^\circ,&\ldots
\end{array}$$
We can rewrite $S_1$ as
$$S_1 = \sum_{k=0}^{44}\cot(4k+1)^\circ = \sum_{k=0}^{44}\cot\left(\frac{\pi k}{45} + \frac{\pi}{180}\right)$$
Using following product formula for sine:
$$\sin(Nx) = 2^{N-1}\prod_{k=0}^{N-1} \sin\left(\frac{\pi k}{N} + x\right)$$
take logarithm and differentiate with respect to $x$ gives us
$$N\cot(Nx) = \sum_{k=0}^{N-1} \cot\left(\frac{\pi k}{N} + x\right)$$
and hence
$$S_1 = 45\cot\left(45\times\frac{\pi}{180}\right) = 45\cot\left(\frac{\pi}{4}\right) = 45.$$

REPLY [4 votes]: The value of i) is 45.
Mathematica computed the value numerically, and that suggested I look for a solution involving products and a derivative. Here's a derivation.
According to this post, the following is a trigonometric identity. 
$$2\,\sin \left( n\theta \right) =\prod _{k=0}^{n-1}2\,\sin \left(  \theta+{\frac {k\pi }{n}} \right)$$
Let $n=45$ to get the following identity.
$$2\,\sin \left( 45\theta \right) =\prod _{k=0}^{44}2\,\sin \left(  \theta+k4^\circ \right)$$
Differentiate both sides with respect to $\theta$ and use the original identity to get the following identity.
$$90\,\cos\left( 45\theta \right)=\left(\prod _{k=0}^{44}2\,\sin \left(  \theta+k4^\circ \right)\right)\sum_{k=0}^{44}\cot\left(  \theta+k4^\circ \right) =2\sin(45\theta)\sum_{k=0}^{44}\cot\left(  \theta+k4^\circ \right)$$
Let $\theta=1^\circ$ to get the following.
$$45\,\cot\left( 45^\circ \right)=\cot(1^\circ)+\cot(5^\circ)+\cdots+\cot(177^\circ)$$
Using basic trig identities,
$$45=\tan(89^\circ)+\tan(85^\circ)+\cdots+\tan(1^\circ)+\cot(177^\circ)+\cot(173^\circ)+\cdots\cot(93^\circ),$$
which with a little rearrangement is the desired result.