Spectral decomposition of $A_{ij}=x_i+x_j$ Suppose we have a vector of real numbers $x_1,\ldots,x_n$, does anyone see an easy way to obtain the spectral decomposition of $n$-by-$n$ matrix $A$ defined below?
$$A_{ij}=x_i+x_j$$
It seems to be rank-2 with eigenvector matrix being mostly zeros.
 A: Let $x$ denote the column vector $(x_1,x_2,\ldots,x_n)$.  We also write $e$ for the column vector $(1,1,\ldots,1)$.  Note that $A=xe^\top+ex^\top$.  Therefore, $\text{rank}(A)\leq 2$.  If $x=0$, then $A=0$ and you know what to do with it.  If $x$ is a nonzero multiple of $e$, then $A$ is a nonzero multiple of $ee^\top$, and you should probably know what to do with it.  We assume now that $x$ is not a multiple of $e$. 
Let $V$ denote the subspace spanned by $x$ and $e$. Observe that $V$ is $2$-dimensional.  Now, we see that
$$Ax=(e^\top x)\,x+(x^\top x)\,e\text{ and }Ae=n\,x+(x^\top e)\,e\,.$$
Therefore, $A|_V:V\to V$.  The matrix of $A|_V$ with respect to the ordered basis $(x,e)$ of $V$ is
$$T:=\begin{bmatrix}e^\top x&n\\ x^\top x&x^\top e\end{bmatrix}\,.$$
The remaining two eigenvalues of $A$ are precisely the eigenvalues of $T$: $e^\top x\pm\sqrt{n\,x^{\top^\vphantom{a^\vphantom{a}}} x}$.  Note that $n\,x^\top x>(e^\top x)^2$ by the Cauchy-Schwarz Inequality, so both eigenvalues are nonzero and distinct.  Hence, $\text{rank}(A)=2$ in this case.
A: Indeed, $A$ is a symmetric that has rank at most 2 (rank at most 1 in the case that $x_1 = \cdots = x_n$).  We can write $A$ as
$$
A = xv^T + vx^T
$$
where $x = (x_1,\dots,x_n)$ $v = (1,\dots,1)$ are column-vectors.  Notably, we can write
$$
A = \pmatrix{x&v}\pmatrix{0&1\\1&0}\pmatrix{x&v}^T
$$
which informs one approach to the spectral decomposition (i.e. applying a QR decomposition to $[x,v]^T$).
Another approach is as follows: to compute the non-zero eigenvalues (assuming the $x_i$ are not all equal), we find that
$$
\operatorname{tr}(A) = 2x^Tv = 2\sum_{i=1}^n x_i\\
\operatorname{tr}(A^2) = 2(v^Tv)(x^Tx) + 2(v^Tx)^2 = 2n\sum_{i=1}^n x_i^2 + 2\left(\sum_{i=1}^n x_i\right).
$$
Let $M_1 = \sum_{i=1}^n x_i$ and $M_2 = \sum_{i=1}^n x_i^2$.  If $\lambda_1,\lambda_2$ are the non-zero eigenvalues, then we have
$$
\lambda_1 + \lambda_2 = 2M_1\\
\lambda_1^2 + \lambda_2^2 = 2nM_2 + 2M_1^2.
$$
Solving these equations yields
$$
\lambda_1 = M_1 - \sqrt{nM_2}, \lambda_2 = M_1 + \sqrt{nM_2}.
$$
