In Matlab, I would like to minimize the function
$$f(S)=\mathrm{trace}(S)+\mathrm{trace}(S^{-2})$$
where $S \in \mathcal{M}_{m,m}$ is symmetric and positive definite, which is definitely a convex function.
I tried the following code:
cvx_solver sdpt3
cvx_begin quiet
variable S(m,m) symmetric;
S == semidefinite(m);
minimize (trace(S)+trace_inv(square(S)));
cvx_end
After running this, I got the following error:
??? Error using ==> cvx.trace_inv at 9
Input must be affine.
Actually this means that what is written in the code is equivalent to have a quadratic equality in the constraint. That is, if we replace in the code $S^2$ by another $Q$ matrix, we have to add as constraint $Q=S^2$ which is convex equality since it's quadratic whereas in order to have a convex optimization problem we must have as constraints affine equalities and/or a convex inequalities. However, in reality, this is not true since my function is convex and I'm not imposing any constraint but cvx is making its own reformulation of the problem.
I even tried to solve the problem in different manner as follow:
cvx_solver sdpt3
cvx_begin quiet
variable Q(m,m) symmetric;
Q == semidefinite(m);
minimize (trace_sqrtm(Q) + trace_inv(Q));
cvx_end
S=sqrtm(Q);
but I got the following error:
??? Error using ==> cvx.plus at 83
Disciplined convex programming error:
Illegal operation: {concave} + {convex}
which means that the function $\mathrm{trace}(S^{1/2})$ is a concave function.
So I'm wondering how can I write my problem in a different manner in order to be accepted by cvx given that my function $f(S)=\mathrm{trace}(S)+\mathrm{trace}(S^{-2})$ is convex. If there is another option rather than cvx that would work too for me.