mirror of
https://github.com/quantumjim/Quantum-Computation-course-Basel.git
synced 2026-10-06 02:58:33 +02:00
2.1 KiB
2.1 KiB
In [ ]:
"""
LOCC cannot create entanglement. Simulate LOCC-like maps (local unitaries + classical randomness) on product states.
Exercises:
- Add classical mixing over different local unitaries and show separability persists for mixed states.
"""In [1]:
import numpy as np
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
def entangled(psi):
s = np.linalg.svd(psi.data.reshape(2,2), compute_uv=False)
return abs(s[0]*s[1])>1e-12 # Basically 0 if separable, i.e. not entangled.
psi = Statevector.from_label("00")
local = QuantumCircuit(2) # A separable state.
for q in range(2): local.rx(0.7,q); local.ry(0.3,q); local.rz(0.2,q) # Example local unitaries. Change as desired.
psi_local = psi.evolve(local)
print("Entangled after local?", entangled(psi_local)) #Whateve separable state, whatever local unitaries, should be False.
ent = QuantumCircuit(2); ent.rxx(0.6,0,1) # An entangling operation.
psi_ent = psi_local.evolve(ent)
print("Entangled after RXX?", entangled(psi_ent)) #Whatever entagnled state, whatever locc, should be True.Entangled after local? False Entangled after RXX? True