# How to write log(det(I+X)/det(X)) in cvx?

log(det(I+X)/det(X)) is a convex function of matrix X, however, I do not know how to represent it in cvx. Please help.

This is not convex. Consider the 1-D case. The 2nd derivative of log((1+x)/x) w.r.t. x is positive for x > -0.5, but is negative for x < -0.5.

Sorry, forget to mention that X is a diagonal matrix with positive entries. Then, can it be expressed this in cvx?

I don’t know how to do it and am not optimistic. You’ll have to wait to see whether mcg or someone else chimes in.

Can you provide your convexity proof?

By taking the second-order derivative, it can be shown that the second-order derivative is larger than 0 in the 1-D case when x>0. Thus, the function is convex when x>0. This can be extended to the matrix case.

O.k., I guess I hadn’t quite processed that X is now presumed to be diagonal, so the det is just the product of the constituent (diagonal) components, and the function reduces to the sum of 1-D functions.

Nevertheless, I don’t see how to do this in CVX even in 1-D. As before, I remain unoptimistic it can be done. When the function is only convex when restricted to a portion of its domain, I think it’s going to take some reformulaton, maybe a change of variables, to get it into CVX even on the convex portion of the domain, it it can be done at all.

I have solved it. By substitute Y = (I+X)^-1, and employing the Schur’s Complement, this can be transformed from an implicit convex constraints to an explicit convex constraints. Thank you very much for your help.

For the benefit of board readers going forward, it might be nice to show your “complete” CVX implementation.

You can try the cvx function “log_det(X)” for log(det(X)), and it can be formulated as log_det(I+X) -log_det(X).

@ yinshiheiyu, your approach is not going to work, because your expression is a concave minus a concave, which will not be accepted by CVX.

Yes，you are right. I’m wrong with the expression rule. However, I haven’t undertood @zmmblack 's method. I guess Y = (I+X)^-1 is going to change the primal problem to -logdetY - logdetX, a convex problem for X,Y are both positive diagonal matrix. But I didn’t know how to use Schur’s Complement to transform the problem Y-(I+X)^{-1}=0.