# How to simulate quantum entanglement variation in different quantum gates?

I'm trying to study quantum entanglement variation during quantum computation with 4 qubit systems comprising a variety of quantum gates. How can I simulate this variation on MATLAB? Is there any other alternatives?

Step 1: Choose a measure for the entanglement. There are a lot of entanglement measures, some of them are easier to calculate in MATLAB than others.

Step 2: Initialize your 4-qubit system's density matrix. It will be a 16x16 matrix since $$2^4 = 16$$. This means all calculations will be very fast in MATLAB and you will have no problem working with the density matrix rather than wavefunction. You could also work with the wavefunction, but a lot of entanglement measures are defined in terms of the density matrix so it's better to work with the density matrix for this type of thing.

Step 3: Apply your various gates. They will be unitaries, so this will just be some matrix multiplications like: $$\rho_{t} = U\rho_{t-1} U^\dagger$$, where $$\rho_{t-1}$$ is the density matrix before the gate is applied, and $$\rho_{t}$$ is the density matrix after the gate is applied.

Step 4: Calculate the your entanglement measure, which can be a function of the density matrix: $$f(\rho_t)$$.

Step 5: Now you have $$f(\rho_1)$$, $$f(\rho_2)$$, $$f(\rho_3) \ldots$$
You now have the entanglement measure at each point in time, and you can plot this and see how your measure of etanglement varies over the course of applying all your gates.

• As long as the total state is pure (which seems to be tacitly assumed), there are clearly preferred entanglement measures, most importantly the entropy of entanglement. Many entanglement measures only really make sense once one looks at mixed states. Also, it is most easily computed from the pure state vector directly. – Norbert Schuch Oct 23 '18 at 22:18
• @NorbertSchuch, the author of the question said nothing about there being an environment interacting with the 4 qubits. Just that there would be various gates applied. I guess you could still have a mixed state if you start in a mixed state, but my answer uses the density matrix anyway so it works for both pure and mixed. What are the referred entanglement measures for a pure state of 4 qubits? – user1271772 Oct 23 '18 at 22:22
• Entropy of entanglement. Specifically, one desirable property of good entanglement measures is that for pure states, they are equal to the entropy of entanglement, with negativity being the one popular exception (really for its computability - but for pure states, entropy of entanglement is in fact easier to compute than negativity). – Norbert Schuch Oct 23 '18 at 22:24
• von Neumann or Renyi ? And aren't there other measures apart from entropy of entanglement and negativity? – user1271772 Oct 23 '18 at 22:27
• Sure there are, but the nice ones usually collapse to the entropy of entanglement for pure states. Von Neumann, by the way, because it is operationally well defined and pretty much the only way to put one number on the entanglement of a pure state. – Norbert Schuch Oct 23 '18 at 22:28