trace(X'*A*X) = trace(X'*sqrtm(A)*sqrtm(A)*X) = norm(sqrtm(A)*X,'fro')^2
So use square_pos(norm(sqrtm(A)*X,'fro'))
If it appears by itself in the objective function, there is no need to square, and it is numerically better to use norm(sqrtm(A)*X,'fro')
, which has the same argmin.
If A
is strictly positive definite, then its Colesky factorization can be used instead of sqrtm(A)
,resulting in square_pos(norm(chol(A)*X,'fro'))
. However, the formulation with sqrtm
can always be used.