Lesson 7 of 15

Two-Qubit States

Combining Qubits

To build quantum systems, we combine multiple qubits using the tensor product (otimesotimes). Two qubits [alpha, eta] and [gamma,delta][gamma, delta] combine into a 4-element state:

[alpha, eta] otimes [gamma, delta] = [alphagamma, alphadelta, etagamma, etadelta]

The four elements represent amplitudes for the four basis states:

  • Index 0: 00angle|00 angle (first=0, second=0)
  • Index 1: 01angle|01 angle (first=0, second=1)
  • Index 2: 10angle|10 angle (first=1, second=0)
  • Index 3: 11angle|11 angle (first=1, second=1)
def tensor_product(q1, q2):
    return [
        q1[0] * q2[0],   # |00⟩
        q1[0] * q2[1],   # |01⟩
        q1[1] * q2[0],   # |10⟩
        q1[1] * q2[1],   # |11⟩
    ]

zero = [1.0, 0.0]
one  = [0.0, 1.0]

print(tensor_product(zero, zero))  # [1.0, 0.0, 0.0, 0.0] — |00⟩
print(tensor_product(one,  one))   # [0.0, 0.0, 0.0, 1.0] — |11⟩

Your Task

Implement tensor_product(q1, q2) that combines two single-qubit states.

Python runtime loading...
Loading...
Click "Run" to execute your code.