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:

[alpha00,alpha01,alpha10,alpha11]=[a,b]otimes[c,d][alpha_{00}, alpha_{01}, alpha_{10}, alpha_{11}] = [a, b] otimes [c, d]

This requires: alpha00cdotalpha11=alpha01cdotalpha10alpha_{00} cdot alpha_{11} = alpha_{01} cdot alpha_{10}

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.