I have an optimization problem of the following form


$$\text{minimize} \,\|Qa-b\|\_2 \quad \text{ subject to } Q \succeq 0$$ 


where $a,b \in \mathbb{R}^n$ are given and the $n \times n$ square matrix $Q$ is the variable. 


* It is most probably a semidefinite programming problem. Is there a standard answer to this problem?
* If not, which algorithm is best suited to solve this problem?



Standard solution to semidefinite program
I will assume throughout that the definition of positive semidefiniteness includes symmetry. The problem is to find the Euclidean projection of $b$ onto the convex set $R = \{Qa \mid Q\succeq 0\}$. Let $S = \{c \mid c^Ta \geq 0\}$, which is closed. We first show that $S$ is the closure of $R$. If $c\in R$ then $c=Qa$ for some $Q\succeq 0$ so $c^Ta = a^TQa \geq 0$ and $c\in S$. Conversely if $c$ is in the interior of $S$, so $c^Ta > 0$, then let $Q = bb^T$ for $b = \frac{c}{\sqrt{c^Ta}}$, so $Q$ is positive semidefinite and $Qa = c\frac{c^Ta}{c^Ta} = c\in R$. Therefore $\overline{R}=S$.


Projecting $b$ onto the closed set $S$ is easy: if $b^Ta \geq 0$ then the projection is $b$, otherwise the projection is $b - \frac{b^Ta}{a^Ta}a$.


This leaves the question of whether this infimum is actually achieved by some $Q$, i.e. whether the projection is in $R$. In general it may not be: for example take $a = \begin{bmatrix}1 \\ 0\end{bmatrix}$ and $b = \begin{bmatrix}0 \\ 1\end{bmatrix}$. Then $b^Ta = 0$, so the projection of $b$ onto $S$ is $b$. But now suppose there is some positive semidefinite $Q$ with $Qa = b$. By symmetry this means $Q = \begin{bmatrix}0 & 1 \\ 1 & q\end{bmatrix}$ for some $q\geq 0$. But then $\det Q = -1$, contradicting positive semidefiniteness.


