The set of matrices whose range is the span of a given set Given a set $S \subset \mathbb{R}^n$, consider two sets of matrices:
$$ X = \{ A \in \mathbb{R}^{n\times n} \text{ s.t. } A \text { is positive semidefinite, } \operatorname{range}(A) \subseteq \operatorname{span}(S) \}\\
Y =  \{ A \in \mathbb{R}^{n\times n} \text{ s.t. } A = \sum_i x x^T, x \in \operatorname{span}(S) \}$$
Are the two sets the same?
And by the way, is there a shorthand notation or a term for the set of matrices $A$ such that $\operatorname{range}(A) \subseteq \operatorname{span}(S)$? I feel like there should be a way to describe it better and I'm being stupid.
 A: Yes.  If $A$ is positive semidefinite, there is an orthonormal basis of eigenvectors $v_i$ corresponding to eigenvalues $\lambda_i \ge 0$, and thus
$A = \sum_i x_i x_i^T$ where $x_i = \sqrt{\lambda_i} v_i$.  Moreover, each $x_i \in \text{range}(A)$ (note that if $\lambda_i = 0$, $x_i = 0$).
Conversely, matrices of the form $x x^T$ are positive semidefinite, a sum of 
positive semidefinite matrices is positive semidefinite, and 
$\text{range}(\sum_i x_i x_i^T) \subseteq \text{span}(\{x_i\})$.
A: $Y \subseteq X$ can be verified directly, as follows. If $A \in Y$, then from the definition of $Y$, it follows that $v^\top A v \ge 0$ for any $v$. Moreover, by the definition of $Y$, each column of $A$ is a linear combination of elements from $\text{span}(S)$, so $\text{range}(A) \subseteq \text{span}(S)$.
For $X \subseteq Y$, use the spectral theorem. If $A \in X$, then there exists an eigendecomposition $A = \sum_{i=1}^n \lambda_i u_i u_i^\top$, where $\lambda_i \ge 0$ and the $u_i$ are an orthonormal basis. For the $i$ such that $\lambda_i = 0$, we can simply remove them from the sum, so that we can write $A$ as $A = \sum_{i=1}^{n'} \lambda_i u_i u_i^\top$, the $u_i$ are orthogonal with unit norm, and where $\lambda_i > 0$, and $n' \le n$.
Finally, we may write $A = \sum_{i=1}^{n'} x_i x_i^\top$, where $x_i = \sqrt{\lambda_i} u_i$.
Finally, the vectors $u_i$ are in $\text{span}(S)$ by definition of $X$, so the $x_i$ are in $\text{span}(S)$ as well.
