Lesson 10 of 15
Detecting Entanglement
Separable vs. Entangled States
A 2-qubit state is separable if it can be written as a tensor product of two single-qubit states:
This requires:
If this equality does not hold, the state is entangled — it cannot be factored into independent parts.
def is_entangled(state):
return abs(state[0] * state[3] - state[1] * state[2]) > 1e-9
import math
s = 1 / math.sqrt(2)
ket_00 = [1.0, 0.0, 0.0, 0.0] # Separable: |0⟩⊗|0⟩
phi_plus = [s, 0.0, 0.0, s ] # Entangled: Bell state
print(is_entangled(ket_00)) # False
print(is_entangled(phi_plus)) # True
Entangled states exhibit quantum correlations: measuring one qubit instantly determines the outcome of measuring the other, regardless of the distance between them. This is what Einstein called "spooky action at a distance."
Your Task
Implement is_entangled(state) that checks whether a 2-qubit state is entangled.
Python runtime loading...
Loading...
Click "Run" to execute your code.