**Problem definition:** Let $x_i \in \mathbb{R}^d$ and $a_i \in [0,1]$, for all $i = 1,\dots, k$ (with $k\geq d$). Define $M(a) = \sum_{i = 1}^k a_i x_ix_i^T,$ and assume $M(a) \succ 0.$

**Question:** Is there any closed-form solution (for $a$) to this set of equations? If not, there is at least an efficient way to solve it?

$$\begin{cases}\text{trace}\left(M(a)^{-1}x_jx_j^T\right) = \text{trace}\left(M(a)^{-1}x_lx_l^T\right), \forall j \neq l,\\ \sum_{i =1}^k a_i= 1.\end{cases}$$

*Related question:* here.

**Attempted solution**: Note that, since $\text{trace}(Ayx^T) = \text{trace}(x^TAy) = x^TAy$, the first equation can be rewritten as

$$ x_j^T M(a)^{-1}x_j =x_l^T M(a)^{-1}x_l, $$

with $M(a) = X^TAX$, where $X: \text{col}(X) = \{x_i\}_{i\in[k]}$, and $A = \text{diag}(a)$.

Hence we have $$ (x_j^TX^{-T})A^{-1}(X^{-1}x_j) = (x_l^TX^{-T})A^{-1}(X^{-1}x_l) $$

By denoting $\tilde{x}_i = x_i^TX^{-T}$, for all $i\in[k]$, and for a vector $x$, its $n$-th component $x(n)$, we can write

$$ \sum_{i = 1}^k \frac{\tilde{x_j}(i)^2}{a_i} = \sum_{i = 1}^k \frac{\tilde{x_l}(i)^2}{a_i}. $$

*Any suggestion on the correctness of this solution would be appreciated.*