TITLE: How to prove this inequality $\frac{a_{1}a_{2}+a_{2}a_{3}+\cdots+a_{n-1}a_{n}}{a^2_{1}+a^2_{2}+\cdots+a^2_{n}}\le\cos{\frac{\pi}{n+1}}$
QUESTION [20 upvotes]: Let $a_{1},a_{2},\cdots,a_{n},n\ge 2$ be real numbers,show that
  $$\dfrac{a_{1}a_{2}+a_{2}a_{3}+\cdots+a_{n-1}a_{n}}{a^2_{1}+a^2_{2}+\cdots+a^2_{n}}\le\cos{\dfrac{\pi}{n+1}}$$

I think this result is interesting.
When $n=2$, clearly
$$\dfrac{a_{1}a_{2}}{a^2_{1}+a^2_{2}}\le\dfrac{1}{2}=\cos{\dfrac{\pi}{3}}=\dfrac{1}{2}$$
When $n=3$,
$$\dfrac{a_{1}a_{2}+a_{2}a_{3}}{a^2_{1}+a^2_{2}+a^2_{3}}\le\dfrac{\sqrt{2}}{2}.$$
This is true, because
$$a^2_{1}+\dfrac{1}{2}a^2_{2}\ge \sqrt{2}a_{1}a_{2},$$
$$\dfrac{1}{2}a^2_{2}+a^2_{3}\ge\sqrt{2}a_{2}a_{3}.$$
But for general $n$ I cannot prove it.

REPLY [12 votes]: Here is a derivation using the calculus of variations.
Given that
$$
\sum_{k=1}^na_k^2=1\tag{1}
$$
we want to find the maximum of
$$
\sum_{k=1}^na_ka_{k-1}\tag{2}
$$
where $a_0=a_{n+1}=0$.
We want to find $a_k$ so that $(2)$ is stationary, that is,
$$
\begin{align}
0
&=\sum_{k=1}^na_k\,\delta a_{k-1}+a_{k-1}\,\delta a_k\\
&=\sum_{k=1}^n(a_{k-1}+a_{k+1})\,\delta a_k\tag{3}
\end{align}
$$
for all $\delta a_k$ so that $(1)$ is constant:
$$
0=\sum_{k=1}^na_k\,\delta a_k\tag{4}
$$
For both the $a_{k-1}+a_{k+1}$ in $(3)$ and the $a_k$ in $(4)$ to be perpendicular to all the same $\delta a_k$, we must have some $\lambda$ so that
$$
a_{k+1}+a_{k-1}=\lambda a_k\tag{5}
$$
Solving $(5)$, so that $a_0=a_{n+1}=0$, using the standard methods for linear recurrences yields
$$
a_k=r\sin\left(\frac{\pi mk}{n+1}\right)\tag{6}
$$
for $m\in\mathbb{Z}$.
We can compute $r$ using $(1)$ and $(6)$:
$$
\begin{align}
\sum_{k=1}^na_k^2
&=\sum_{k=1}^nr^2\sin^2\left(\frac{\pi mk}{n+1}\right)\\
&=-\frac{r^2}{4}\sum_{k=1}^n\left[\exp\left(\frac{2\pi imk}{n+1}\right)+\exp\left(\frac{-2\pi imk}{n+1}\right)-2\right]\\
&=-\frac{r^2}{4}(-2n-2)\ \Big[m\not\equiv0\bmod{(n+1)}\Big]\\
&=r^2\frac{n+1}{2}\ \Big[m\not\equiv0\bmod{(n+1)}\Big]\tag{7}
\end{align}
$$
We cannot satisfy $(1)$ when $m\equiv0\bmod{(n+1)}$; therefore, we require $m\not\equiv0\bmod{(n+1)}$, in which case,
$$
r=\sqrt{\dfrac2{n+1}}\tag{8}
$$
Finally, we need to compute $(2)$ for each $m\not\equiv0\bmod{(n+1)}$:
$$
\begin{align}
&\frac2{n+1}\sum_{k=1}^n\sin\left(\frac{\pi mk\vphantom{()}}{n+1}\right)\sin\left(\frac{\pi m(k-1)}{n+1}\right)\\
&=\frac1{n+1}\sum_{k=1}^n\left[\cos\left(\frac{\pi\vphantom{()}m}{n+1}\right)-\cos\left(\frac{\pi m(2k-1)}{n+1}\right)\right]\\
&=\frac{n}{n+1}\cos\left(\frac{\pi m}{n+1}\right)+\frac1{n+1}\cos\left(\frac{\pi m}{n+1}\right)\\
&=\cos\left(\frac{\pi m}{n+1}\right)\tag{9}
\end{align}
$$
The largest that $(9)$ can be if $m\not\equiv0\bmod{(n+1)}$ is $\cos\left(\frac\pi{n+1}\right)$.
Therefore, by homogeneity,
$$
\frac{\displaystyle\sum_{k=1}^na_ka_{k-1}}{\displaystyle\sum_{k=1}^na_k^2}\le\cos\left(\frac\pi{n+1}\right)\tag{10}
$$