$$\begin{array}{ll} \text{minimize} & \| \mathrm X \mathrm a - \mathrm b \|_2 \\ \text{subject to} & \mathrm X \succeq \mathrm O_n\end{array}$$ where $\mathrm a, \mathrm b \in \mathbb R^n \setminus \{0_n\}$ are given. If $\color{blue}{\mathrm a^{\top} \mathrm b \geq 0}$, a solution would be $$\boxed{\bar{\mathrm X} := \frac{ \,\,\, \mathrm b \mathrm a^{\top} }{ \mathrm a^{\top} \mathrm a}}$$ as $$\bar{\mathrm X} \mathrm a - \mathrm b = \left(\frac{ \,\,\, \mathrm b \mathrm a^{\top} }{ \mathrm a^{\top} \mathrm a}\right) \mathrm a - \mathrm b = \mathrm b \left(\frac{ \mathrm a^{\top} \mathrm a }{ \mathrm a^{\top} \mathrm a}\right) - \mathrm b = \mathrm b - \mathrm b = 0_n$$ and $\bar{\mathrm X} \succeq \mathrm O_n$. Note that $\bar{\mathrm X}$ is a rank-$1$ matrix and, thus, its *nonzero* eigenvalue is equal to its trace $$\mbox{tr} (\bar{\mathrm X}) = \frac{1}{\| \mathrm a \|_2^2} \, \mbox{tr} ( \, \mathrm b \mathrm a^{\top}) = \frac{1}{\| \mathrm a \|_2^2} \, \mbox{tr} ( \mathrm a^{\top} \mathrm b ) = \frac{\mathrm a^{\top} \mathrm b}{\| \mathrm a \|_2^2} \geq 0$$ ---------- ###SDP formulation The general case can be formulated as a semidefinite program (SDP). Minimizing the squared $2$-norm of $\mathrm X \mathrm a - \mathrm b$, and writing in epigraph form, we obtain a minimization problem in $\rm X$ and $t$ $$\begin{array}{ll} \text{minimize} & t\\ \text{subject to} & \| \mathrm X \mathrm a - \mathrm b \|_2^2 - t \leq 0 \\ & \mathrm X \succeq \mathrm O_n\end{array}$$ Using the Schur complement, the inequality $$\| \mathrm X \mathrm a - \mathrm b \|_2^2 - t = (\mathrm X \mathrm a - \mathrm b)^{\top} (\mathrm X \mathrm a - \mathrm b) - t \leq 0$$ can be written as the following linear matrix inequality (LMI) $$\begin{bmatrix} \mathrm I_n & \mathrm X \mathrm a - \mathrm b\\ (\mathrm X \mathrm a - \mathrm b)^{\top} & t\end{bmatrix} \succeq \mathrm O_{n+1}$$ Thus, we have the following **semidefinite program** (SDP) in $\rm X$ and $t$ $$\begin{array}{ll} \text{minimize} & t\\ \text{subject to} & \begin{bmatrix} \mathrm I_n & \mathrm X \mathrm a - \mathrm b & \mathrm O_n\\ (\mathrm X \mathrm a - \mathrm b)^{\top} & t & 0_n^{\top}\\ \mathrm O_n & 0_n & \mathrm X\end{bmatrix} \succeq \mathrm O_{2n+1}\end{array}$$