TITLE: Matrix consisting of cosines of differences
QUESTION [5 upvotes]: Consider the following matrix:
$$\left[\begin{array}{cccc} \cos(x_1-y_1) & \cos(x_1-y_2) & \ldots & \cos(x_1-y_n)  \\
\cos(x_2-y_1) & \cos(x_2-y_2) & \ldots & \cos(x_2-y_n) \\
\cos(x_3-y_1) & \cos(x_3-y_2) & \ldots & \cos(x_3-y_n) \\
\vdots & \vdots & \ddots & \vdots\\
\cos(x_n-y_1) & \cos(x_n-y_2) & \ldots & \cos(x_n-y_n) \\
\end{array}  \right]$$
with $x_k, y_k$ being real numbers. I cannot really apply any kind of functional calculus, I believe, to get a closed form formula for the determinant of this matrix. Any hints or ideas how to proceed?

REPLY [9 votes]: Let us denote by $M$ the given matrix. The answer is: 

If $n \geq 3$, $\det(M)=0$ .

Proof $\sharp 1$ (using complex numbers):
Using Euler formulas, one can write 
$$M=\dfrac{1}{2}(M_1+\overline{M_1})$$
with rank 1 matrix $M_1$ defined by:
$$M_1=\begin{bmatrix}e^{ix_1}\\e^{ix_2}\\\vdots\\e^{ix_n}\end{bmatrix}\begin{bmatrix}e^{-iy_1}&e^{-iy_2}&\cdots&e^{-iy_n}\end{bmatrix}$$
Thus rank$(M)\leq 2$, as sum of two rank 1 matrices  (see this.) 
Thus, for $n \geq 3$, by rank-nullity theorem, $dim(Ker(M))\geq 1$, and the answer follows.

Proof $\sharp 2$ (very similar proof, but using a geometrical interpretation, without complex numbers):
Let us define, in $\mathbb{R}^2$ unit vectors $U_i$ (resp. $V_{j}$) with polar angle $x_i, \ i=1,2,\cdots n $ (resp $y_j , \ j=1,2,\cdots n $). 
Then $M_{i,j}=U_i \cdot V_j$ (dot-product).
Let $A$ (resp. $B$) be the $2 \times n$ matrix whose columns are the cartesian coordinates of vectors $U_i$ (resp. $V_j$).
Then $M=A^TB$, whose rank is clearly at most $2$.
Remarks: 
1) If $n=1$ or $n=2$, one has in general $\det(M)\neq 0$. 
2) In the case $n=2$, I don't think there is a special "closed form formula".