I am trying to understand a solution to a problem and stuck at the step where it mentions

$$ \sum^n_{k=1} x^T_ky_iy^T_ix_k = tr(x^Ty_iy^T_ix)$$ , $$ x_k,y_i \in \mathbb{R^d}$$

I understand that the centre term $$ y_iy^T_i$$ will give an outer product with square terms at the diagonal. But how to then include the other terms on the left and right?

Can someone help me visualise this, as a product of matrix and vectors and then relate it with the trace?

  • $\begingroup$ What is the definition of $x$? $\endgroup$
    – Zhanxiong
    Feb 8, 2023 at 21:09
  • 1
    $\begingroup$ This doesn’t make much sense unless $x$ is a matrix whose column vectors are the $x_k$. (Otherwise, the RHS is a trace over scalar quantities.) $\endgroup$ Feb 8, 2023 at 22:33

1 Answer 1


$y y^t$ is a positive semi-definite matrix, so you can change bases (orthogonally) to make $y = e_1$ (this does not affect the trace). The computation then becomes easy.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .