# A weighted mean of roots of unity

In my research, I have come across the following problem:

Let $$n \in \mathbb{N}$$ and $$r \geq 0$$ be given. For $$\theta \in [0,2 \pi)$$, define $$f(\theta) = \biggl| \frac{\sum_{j=0}^{n-1} e^{2 \pi ij/n} e^{r \Re (e^{2 \pi i j/n + i\theta})}}{\sum_{j=0}^{n-1} e^{r \Re (e^{2 \pi i j/n + i\theta})}}\biggr|.$$ Is it then the case that $$f(\theta)$$ is maximal at $$\theta = 0$$?

Mathematica suggests that this is at least true for small $$n$$. Also, it is easy to check that $$f(\theta)$$ is $$2 \pi/n$$-periodic, and that $$f(2\pi/n-\theta) = f(\theta)$$.

With some work, one can verify that for any $$\theta_0 \in [0,2\pi)$$, one has $$f(\theta)^2 = \biggl( \frac{\sum_{j} \cos \bigl( 2 \pi j/n+\theta_0 \bigr) e^{r \cos (2 \pi j/n + \theta) }}{\sum_{j} e^{r \cos (2 \pi j/n + \theta) }} \biggr)^2 + \biggl( \frac{\sum_{j} \sin \bigl( 2 \pi j/n+\theta_0\bigr) e^{r \cos (2 \pi j/n + \theta) }}{\sum_{j} e^{r \cos (2 \pi j/n + \theta) }} \biggr)^2.$$ Putting $$\theta_0 = \theta$$ makes the expression look nice and symmetric, while choosing $$\theta_0 = 0$$ makes it easier to differentiate. Differentiating the expression, one finds local extrema at $$\theta = 0, \pi/n, 2 \pi/n, 3\pi/n, \ldots$$, but it is not clear to me neither that these are all local extreme points(?) not which of these are local maxima(?).