$$ \rho = \begin{bmatrix} .7738 & -.0556 \\ -.0556 & .0040 \end{bmatrix} , \sigma = \begin{bmatrix} .9454 & -.2273 \\ -.2273 & .0546 \end{bmatrix} \\$$

As you can see $\rho$ is an operator of mixed states and $\sigma$ is a density operator from a pure state. I can calculate entropy of them individually. But can I calculate the relative entropy between them? I am not sure about what it would mean. Anyways, considering the definition of relative entropy:

$$S(\rho || \sigma) = \mathrm{tr}(\rho \log (\rho)) - \mathrm{tr}(\rho \log ( \sigma))$$

I know that I can calculate the entropy of $\sigma$ from it's eigenvalues. But here I can't use the eigenvalue approach, can I? I have to take the logarithm I think. But there is no logarithm for $\sigma$ in matlab. What can I do in this sort of cases?

  • 1
    $\begingroup$ In matlab, use "logm". $\endgroup$ Sep 28, 2019 at 11:43

1 Answer 1


As @NorbertSchuch said in a comment, matlab has a function for taking the logarithm of a matrix: logm. In general, there is a standard method for calculating the function $f(\sigma)$ of a matrix $\sigma$. You first diagonalise the matrix: $$ \sigma=UDU^\dagger, $$ where $U$ is a unitary and $D$ is diagonal. We then say $$ f(\sigma)=Uf(D)U^\dagger, $$ where $f(D)$ simply involves calculating the function $f$ on just the diagonal elements of the matrix.

Note this means that in your particular case, since $\sigma=|\psi\rangle\langle\psi|$ corresponds to a pure state, one of the eigenvalues is 0, so unless $\rho$ is an identical pure state, the answer you get will be $\infty$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.