# Computing von Neumann entropy of pure state in density matrix

Let's say I have a pure state of the form: $$\psi = \sqrt{\frac{3}{9}} \lvert 0 \rangle + \sqrt{\frac{6}{9}} \lvert 1 \rangle$$

Then the density matrix representation would be: $$\rho = \psi \otimes \psi' = \begin{bmatrix}.3333&.4714\\4714&.6667\end{bmatrix}$$

Now, what would be the Von Neumann entropy of this matrix? I saw that the equation is:

$$S(\rho) = -\text{trace}(\rho \log \rho) = 1.3455.$$ But it's supposed to be 0, isn't it?

• Did you make sure to do log as a matrix not element-wise? If you did it with a program, it often assumes you mean element-wise. – AHusain Mar 18 '19 at 2:45
• Thanks AHusain, that was the issue I see. – Hasan Iqbal Mar 18 '19 at 3:46
• @HasanIqbal If you've found your mistake, you could answer your own question too. :) – Sanchayan Dutta Mar 18 '19 at 18:53

It turns out to be a novice mistake. I was using matlab and this log is elementwise, as @Ahusain pointed out. We must take the matrix logarithm in Matlab which is denoted by $$logm$$. Then the calculation becomes: $$-\text{trace}(\rho \log m (\rho)) = \text{NaN}.$$ The reason is, we have to define $$0 \times \log (0)$$ as $$0$$ instead of $$\text{NaN}$$ which is the default behavior of Matlab. Another way to calculate it is the following:
$$\rho = \sum_{j} \lambda_j \lvert \phi_j \rangle \langle \phi_j \lvert$$
Where, $$\lambda_j$$ are it's eigenvalues and $$\lvert \phi_j \rangle$$ are it's distinct eigenvectors. In which case, the von Neumann entropy is simply the shannon entropy of it's eigenvalues:
$$S(\rho) = H(\lambda_1, \lambda_2) = -0 \times \log(0) - 1 \times \log(1) = 0$$Using the above definition of $$\log(0) = 0$$.
• You may use \times for the $\times$ multiplication symbol rather than $*$. Alternatively, use a $.$ dot. – Sanchayan Dutta Mar 19 '19 at 16:48