On the Wolfram Research Reference page for the cotangent function (https://functions.wolfram.com/ElementaryFunctions/Cot/23/01/), I saw the following partial sum formula

$$\sum_{k=0}^{n-1}(-1)^k\cot\Big(\frac{\pi}{4n}(2k+1)\Big)=n.$$ I was unable to find a reference for it but eventually proved it as described below.

My Question

  1. A reference for the equation above?
  2. Naturally, I wondered what was known about the regular sum of the cotangents above, not the alternating sums. I found no related equation but instead was able to empirically derive the following limit

\begin{align*} \lim_{n\to\infty}\Big[\sum_{k=0}^{n-1}\frac{1}{2k+1}-\sum_{k=0}^{n-1}\frac{\pi}{4n}\cot\Big(\frac{\pi}{4n}(2k+1)\Big)\Big]&=\lim_{n\to\infty}\Big[\Big(H_{2n}-\frac{1}{2}H_{n}\Big)-\sum_{k=0}^{n-1}\frac{\pi}{4n}\cot\Big(\frac{\pi}{4n}(2k+1)\Big)\Big]\\ &=\ln(\sqrt{\pi/2}). \end{align*}

Yet, I am stuck on proving this limit and would appreciate any advice on where to begin.

My Proof for the Equation in the Beginning:

Consider the well-known partial fraction expansion for the cotangent function,

$$\pi\cot(\pi x)=\frac{1}{x}+\sum_{k=1}^{\infty}\frac{1}{x-k}+\frac{1}{x+k}$$

excluding integral $x$. Rather unconventionally, let us expand the summation of the RHS and reindex it, getting \begin{align*} \frac{1}{x}+\frac{1}{x-1}+\frac{1}{x+1}+\frac{1}{x-2}+\frac{1}{x+2}+\cdots&=\frac{1}{x}-\frac{1}{1-x}+\frac{1}{x+1}-\frac{1}{2-x}+\frac{1}{x+2}-\cdots\\ &=\sum_{k=0}^{\infty}\frac{1}{k+x}-\frac{1}{k+1-x}. \end{align*} By letting $x=b/a$ for positive integers $a,b$ such that $a>b\geq1,$ we get


Consider the equation for $a=4n$ and $b$ from $1$ to $2n-1$. Then, $$\frac{\pi}{4n}\cot\Big(\pi\cdot\frac{1}{4n}\Big)=\sum_{k=0}^{\infty}\frac{1}{(4n)k+1}-\frac{1}{(4n)k+4n-1},$$ $$\frac{\pi}{4n}\cot\Big(\pi\cdot\frac{3}{4n}\Big)=\sum_{k=0}^{\infty}\frac{1}{(4n)k+3}-\frac{1}{(4n)k+4n-3},$$ $$\cdots$$ $$\frac{\pi}{4n}\cot\Big(\pi\cdot\frac{2n-1}{4n}\Big)=\sum_{k=0}^{\infty}\frac{1}{(4n)k+2n-1}-\frac{1}{(4n)k+2n+1}.$$

By summing up the equations in an alternating fashion (adding the first, subtracting the second, and so on,) the summed $LHS$ equals $$\frac{\pi}{4n}\sum_{k=0}^{n-1}(-1)^k\cot\Big(\frac{\pi}{4n}(2k+1)\Big)$$ while the summed RHS is simply the alternating series of the reciprocals of odd numbers, which is well-known by Leibniz to be $\frac{\pi}{4}.$ Hence, we get the initial formula.

  • 2
    $\begingroup$ These kind of identities are well-known (folklore). For example, one of the homework problems in my introductory complex analysis course is the following. Let $n=2m+1$ be an odd positive integer. Then $\sum_{k=-m}^m\tan(z+k\pi/n)=n\tan(nz)$. (Specialize this to $z=\pi/(4n)$.) $\endgroup$
    – GH from MO
    Commented Aug 10, 2020 at 13:49
  • 2
    $\begingroup$ I googled "alternating sum odd cotangent", and found this, by Bruce Berndt and Boon Pin Yeap, which has a good set of references for identities like this: sciencedirect.com/science/article/pii/S0196885802000209 $\endgroup$
    – user44143
    Commented Aug 10, 2020 at 14:01

1 Answer 1


The expression under the limit sign in question is just a Riemann sum for $$\int_0^{\pi/2} \frac12\,\Big(\frac1x-\cot x\Big)\,dx=\frac12\,\ln\frac\pi2,$$ which therefore is the value of the limit.

  • $\begingroup$ Just to make sure, the definite integral on the left gives $-\ln(\sin(1))$? $\endgroup$
    – bryanjaeho
    Commented Aug 10, 2020 at 15:41
  • 1
    $\begingroup$ I believe the integral should be over $\frac{1}{2}\Big(\frac{1}{x}-\frac{\pi}{2}\cdot \cot(\pi/2\cdot x)\Big)$ ranging from $0$ to $1$. Thank you for the approach! $\endgroup$
    – bryanjaeho
    Commented Aug 10, 2020 at 16:00
  • 1
    $\begingroup$ @bryanjaeho : Oops! The integral is of course from$0$ to $\pi/2$, not to $1$. This typo is now corrected $\endgroup$ Commented Aug 10, 2020 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.