I've encountered a problem that needs to be solved by solving the following algebraic equation
$$\mathbf{Y}^\mathsf{T}\mathbf{Q}\mathbf{Y}=\mathbf{X}^\mathsf{T}\mathbf{Q}^\mathsf{-1}\mathbf{X}$$
where $Q$ is a $4 \times 4$ symmetric matrix to be solved. $X$ and $Y$ are both known $4 \times 1$ vectors. There are enough $X$ and $Y$ inputs so that I think a nonlinear least-squares solution must be existed. However, I can not figure it out by myself. Hope you could provide me with some clues.
I think you can use $\operatorname{vec}$ operator for constructing a least squares problem. But I'm not sure it would produce a consistent answer.
$$\begin{align*} \operatorname{vec}(y^TQy) &= \operatorname{vec}(x^TQ^{-1}x) \\ (y^T \otimes y^T) \operatorname{vec}(Q) &= (x^T \otimes x^T) \operatorname{vec}(Q^{-1}) \end{align*}$$
So, you can write this as
$$ \begin{bmatrix}(y_1^T \otimes y_1^T) & -(x_1^T \otimes x_1^T) \\ \vdots & \vdots \\ (y_N^T \otimes y_N^T) & -(x_N^T \otimes x_N^T) \end{bmatrix} \begin{bmatrix} \operatorname{vec}(Q) \\ \operatorname{vec}(Q^{-1}) \end{bmatrix} = 0$$
for $N$ data you have. From this point the problem becomes finding the null space of the known matrix and selecting the set of vectors such that $Q Q^{-1} \approx I$.