Show that $(\sum_{k=1}^{n}x_{k}\cos{k})^2+(\sum_{k=1}^{n}x_{k}\sin{k})^2\le (2+\frac{n}{4})\sum_{k=1}^{n}x^2_{k}$ 
Let $x_{1},x_{2},\cdots,x_{n}>0$, show that
$$\left(\sum_{k=1}^{n}x_{k}\cos{k}\right)^2+\left(\sum_{k=1}^{n}x_{k}\sin{k}\right)^2\le \left(2+\dfrac{n}{4}\right)\sum_{k=1}^{n}x^2_{k}$$

This question was posted some time ago at MSE. A bounty was placed on it, but no complete solution was received.
The only solution there claims to solve the problem when $n \le 10^9$.
It's easy to see that the inequality can be proved when $(2+n/4)$ is replaced by $n$ (in fact, this follows directly from Cauchy-Schwarz inequality).
Also the LHS is equal to: $\sum_{k=1}^n x_k^2 + 2\sum_{i < j} x_ix_j\cos(i - j)$.
I'm looking for a proof or any reference of this result.
Any help would be appreciated.
 A: It is a bit long for a comment. 
Your question is about the matrix $A=(\cos((i-j)))_{i,j=1\ldots n}$, specifically, the maximum of the quadratic form $q(x)=(Ax,x)$ on  the subset $M_+$ of the unit sphere $(x,x)=1$ consisting of the vectors with positive coordinates.
Since the sphere is compact, the maximum is attained, but in general it would be attained in the closure of the set $M_+$. So in fact, we have some subset $I\subset\{1,\ldots,n\}$ where the desired point has zero coordinates, and its complement where the coordinates are positive, and the correct Lagrange multiplier problem involves the function
 $$
(Ax,x)-\lambda((x,x)-1)-\sum_{i\in I}\mu_i x_i .
 $$
Taking derivatives gives us conditions
 $$
Ax-\lambda x-\frac12\sum_i \mu_i e_i=0,\quad (x,x)=1, \quad x_i=0 \text{ for } i\in I,
 $$
or in plain language, $x$ is a unit vector that is a combination of vectors $e_i$ for $i\notin I$, and such that $Ax$, up to a vector proportional to $x$, is a combination of vectors $e_i$ for $i\in I$. 
I did not follow it through fully, but I convinced myself that the maximum is indeed contained in a nontrivial boundary point of $M_+$. In fact, it is possible to describe eigenvalues and eigenvectors of $A$ in a very cute way. Consider the matrix 
$$
A(t)=(\cos((i-j)t))_{i,j=1\ldots n}
$$
Suppose that $t$ is not a rational multiple of $\pi$. First, I claim that this matrix has $n-2$ zero eigenvalues. To show that, I shall exhibit $n-2$ linearly independent elements in the kernel (here $e_i$ are standard unit vectors of $\mathbb{R}^n$):
 $$
v_i=\sin(t)e_i-\sin((n-i)t)e_{n-1}+\sin((n-1-i)t)e_n,\quad i=1,\ldots,n-2 .
 $$
Next, I claim that two remaining eigenvalues are 
 $$
\frac{n}{2}\pm\sum_{j=1}^k\cos((2j-1)t)
 $$
for even $n=2k$ and
 $$
\frac{n-1}{2}+\sum_{j=1}^{k-1}\cos(2jt),\quad 
\frac{n+1}{2}-\sum_{j=1}^{k-1}\cos(2jt)
 $$
for odd $n=2k+1$. 
Moreover, the corresponding eigenvectors are as follows
 $$
\sum_{j=1}^n \cos((k-j)t)e_j,\quad
\sum_{j=1}^n \sin((k-j)t)e_j
 $$
for even $n=2k$
$$
\sum_{j=1}^n (\sin((k-j)t-\sin((k-1-j)t))e_j,\quad
\sum_{j=1}^n (\sin((k-j)t+\sin((k-1-j)t))e_j
 $$
for odd $n=2k+1$. All these claims are checked by a rather direct calculation. 
Now, if the maximum of $(Ax,x)$ were attained at an interior point, we would need to look at eigenvectors, and the maximum would be given by the respective eigenvalue. Vectors of the kernel do not interest us, clearly. From the explicit formulas above, the other two eigenvectors almost immediately start having negative coordinates too (some silly exceptions for small $n$ exist).  
Not sure if it is easy to finish this, I might revisit it later.
A: Too long for a comment. Let us consider for $X\in \mathbb S^{n-1}$,
$
\langle X,(e^{i \alpha k})_{1\le k\le n}\rangle_{\mathbb C^n}.
$
The question at hand is
$$
\max_{X\in \mathbb S^{n-1}}\vert\langle X,(e^{i \alpha k})_{1\le k\le n}\rangle_{\mathbb C^n}\vert\le \sqrt{2+\frac n4}, 
\tag{$\ast$}$$
for $\alpha =1$.
Of course, the above inequality does not hold when $\alpha =π$ since in that case ($\ast$) means
$$
\max_{X\in \mathbb S^{n-1}}\vert\langle X,((-1)^k)_{1\le k\le n}\rangle_{\mathbb C^n}\vert\le \sqrt{2+\frac n4}
$$
and choosing
$
X_{2l+1}=0, X_{2l}>0,
$
the lhs is $\sqrt{n/2}$. 
The question for a given $\alpha$ is related to the closedness in $\mathbb C^n$ of the vector $(e^{i \alpha k})_{1\le k\le n}$ to a real-valued unit vector (i.e. in $\mathbb S^{n-1}$). In fact one may write
$$
\langle X,\underbrace{(e^{i \alpha k})_{1\le k\le n}}_{\mathbf e_\alpha \sqrt n}\rangle_{\mathbb C^n}=\frac14\Vert X+\mathbf e_\alpha\sqrt n\Vert^2_{\mathbb C^n}-\frac14
\Vert X-\mathbf e_\alpha\sqrt n\Vert^2_{\mathbb C^n},
$$
so that $(\ast)$ means that for $X\in \mathbb S^{n-1}$
$$
\vert\langle X,\mathbf e_\alpha \rangle_{\mathbb C^n}\vert\le\sqrt{\frac 2n+\frac 14,}\quad \text{i.e.}\quad \cos(\mathbb S^{n-1}, \mathbf e_\alpha )
\le\sqrt{\frac 2n+\frac 14}.
$$
Passing to the limit when $n\rightarrow+\infty$ we would get 
$
\text{angle}(\mathbb S^{n-1}, \mathbf e_\alpha )\ge π/3.
$
Going back to the case $\alpha =1$ the subgroup $\{e^{ik}\}_{k\in \mathbb Z}$ is dense in the unit circle (it cannot be discreet), which implies that for a given $\epsilon >0$, you can find infinitely many $k\in \mathbb Z$ such that 
$
\vert e^{ik}-1\vert <\epsilon.
$
This is probably not enough to violate your property, since what would be needed is a fixed proportion (more that $1/4$) of integers  like this, but the property at hand seems related to diophantine properties of the above subgroup.
