The nuclear norm is defined by this [from wikipedia]:
$$\|A\|_* = \text{trace} \left( \sqrt{A^*A} \right) = \sum_{i=i}^{\min\{m,n\}}\sigma_i(A)$$
I get the derivation of this equation. However, I wanted to test it in MATLAB. So used this script:
clc; clear; close all; P = rand([3,4]); PTP = P'*P; %compute trace(P'*P) B = sqrt(P'*P); S1 = trace(B) %Compute sum of sigma_i(P) E = svd(P); S2 = sum(E) %Do the same for eigenvalues E3 = sqrt(eig(P*P')); S3 = sum(E3) But for some reason, the values inside S1 and S2 does not match. I do not understand where I did wrong. Could anybody help?
$\endgroup$11 Answer
$\begingroup$On the line
B = sqrt(P'*P); "sqrt" in Matlab calculates element-wise square root.
You probably want to use "sqrtm" : matrix square root instead.
$\endgroup$2