Multiple angle identity for cotangent

The previous post discusses generalized replicative functions, functions that satisfy

a_n f(nx) + b_n = \sum_{i=0}^{n-1} f\left(x + \frac{i}{n} \right )

Donald Knuth says in Exercise 40 of Section 1.2.4 of TAOCP that the functions cot πx and csc² πx fall into this class of functions.

If this is true of cot πx then it follows by differentiation that it is true of csc² πx as well, so we will focus on the former.

I believe that for f(x) = cot(πx) we have an = n and bn = 0, but I don’t have a proof. If this is correct then

n \cot (n \pi x) = \sum_{i=0}^{n-1} \cot\left(\pi\left(x + \frac{i}{n} \right ) \right )

Here’s a Python script that draws values of n and x at random and verifies that the left and right sides above are equal to at least 10 decimal places. It’s not a proof, but it’s good evidence.

    import numpy as np

    def cot(x): return 1/np.tan(x)

    def f1(n, x): return n*cot(n*np.pi*x)

    def f2(n, x): return sum(cot(np.pi*(x + k/n)) for k in range(n))

    np.random.seed(20211011)
    for _ in range(1000):
        n = np.random.randint(1, 50)
        x = np.random.random()
        a, b = f1(n,x), f2(n, x)
        assert( abs(a - b) <= abs(a)*1e-10 )

Note that NumPy doesn’t have a cotangent function. See this post for quirks of how trig functions are supported in various environments.

An actual proof is left as an exercise for the reader. Knuth left it as an exercise too, but he didn’t say what the a‘s are, so I’m being nicer than he was. :)

If you come up with a proof, please share it in the comments.

Update

Here’s a proof combining the first two comments below. Start with the identity

\sin(nx) = 2^{n-1}\prod_{k=1}^{n-1}\sin\left(x+\frac{k\pi}{n}\right)

and substitute πx for x. Take the logarithm and then the derivative of both sides, divide by π, and you get the identity we’re trying to prove.

4 thoughts on “Multiple angle identity for cotangent

  1. I think the product expansion which Jesse McKeown mentions is sin(nx) = 2ⁿ⁻¹∏ sin(x+kπ/n) [1].
    An alternative derivation seems to be contained in the paper “A Simple Proof of 1+1/2²+1/3²+…=π²/6 and Related Identities” by Josef Hofbauer the csc result appears in section 3 and the cot result more or less implicitly in section 4, the reference appears as citation 6 in [2]

    [1]https://en.wikipedia.org/wiki/List_of_trigonometric_identities#Finite_products_of_trigonometric_functions
    [2]https://en.wikipedia.org/wiki/List_of_mathematical_series

  2. Diethard Michaelis

    Typos only.
    Title: Identify -> Identity
    Last sentence before script: bit -> but
    Script is somehow incomplete, no assignment to x, dangling ).

  3. Without using infinite products/sums – the Cotangent is more or less the discrete Fourier transformation of the fractional part function {.} on IQ, i.e. essentially B_1 (the first periodic Bernoulli polynomial):

    1/2*i*cot(Pi*a/q)=sum(k=1..(q-1), B_1(k/q)*exp(-2*Pi*i*a*k/q)

    Or the inverse transformation:
    {n/p}-1/2 = B_1(n/p) = i/(2*p)*sum(k=1..(p-1), cot(Pi*k/p)*exp(2*Pi*i*k*n/p))

Leave a Reply

Your email address will not be published.