Given a pos. def. matrix X, I thought that det_rootn(X) = det(X)^(1/n) . Am I wrong about this as it does not seem to work.

Can you show a reproducible example (along with output of `cvx_version`

) or other evidence of `det_rootn`

not complying with the documentation?

Note that there are two versions of `det_rootn`

, one for numerical arguments and one for cvx_expression arguments.

Here is the documentation:

help det_rootn

det_rootn nth-root of the determinant of an SPD matrix.

For a square matrix X, det_rootn(X) returns

POW(DET(X),1/(size(X,1))

if X is symmetric (real) or Hermitian (complex) and positive semidefinite,

and -Inf otherwise.`This function can be used in many convex optimization problems that call for LOG(DET(X)) instead. For example, if the objective function contains nothing but LOG(DET(X)), it can be replaced with det_rootn(X), and the same optimal point will be produced. Disciplined convex programming information: det_rootn is concave and nonmonotonic; therefore, when used in CVX specifications, its argument must be affine.`

n=10;

r = 5;

d = rand(n,1)+.1;

V = randn(n,4);

n = length(V);

VdV = V’*diag(d)*V;

VdV = (VdV+VdV’)/2;

detVdV = det_rootn(VdV);

eigsvdv = eig(VdV);

detVdVprod = prod(eigsvdv.^(1/n));

deterror = abs(detVdV-detVdVprod);

if deterror > 1e-12

fprintf(‘detVdV??? %g \n’,deterror)

end

whenever I run this I get errors of e.g. order 2-3 i.e. VERY large errors. Am I missing something?

X = VdV here. I am using the product (eig.^(1/n))

there was a typo there i think … this is what i cut-n-paste and get

n=10;

r = 5;

d = rand(n,1)+.1;

V = randn(n,r);

n = length(V);

VdV = V’*diag(d)*V;

VdV = (VdV+VdV’)/2;

detVdV = det_rootn(VdV);

eigsvdv = eig(VdV);

detVdVprod = prod(eigsvdv.^(1/n));

deterror = abs(detVdV-detVdVprod);

if deterror > 1e-12

fprintf(‘detVdV??? %g \n’,deterror)

end

detVdV??? 1.91185

p.s. You say there are two versions of det_rootn ? Do they do different things? What is the algorithm for the calculation? Note that (det(X)^(1/n)) will give terrible results as det(X) is too large for even moderate size X and so the round-off makes the result meaningless. But using the product of eigs rooted does not suffer frmo this problem.

`VdV`

is r by r, not n by n.

If you change to `detVdVprod = prod(eigsvdv.^(1/r));`

everything agrees.

As can be seen by examining the source code, if `chol(X)`

exists, det_rootn is calculated as the square of `geo_mean`

applied to the diagonal of the Cholesky factor; otherwise it’s calulated as `geo_mean(eig(X))`

.

Numerical argument version is at

`CVX/functions/det_rootn.m`

CXV expression version is at

`CVX/functions/@cvx/det_rootn.m`