Tensor product
A single qubit does little. The power appears when we put several together, and the operation that joins quantum systems is the tensor product.
Joining two qubits
If one qubit is in and another in , the pair is in , which we shorten to or . In components:
In this course, the qubit on the left is the first one, and the order of the basis is .
The general state of two qubits is
with the sum of the equal to 1.
What is the amplitude of in ?
Mini-challenge
Exponential growth
With qubits, there are amplitudes. This is why simulating many qubits on an ordinary computer becomes infeasible.
How many amplitudes does the state of 10 qubits have?
Mini-challenge
Careful: having amplitudes does not mean being able to read numbers. When we measure, we get only bits.
Gates in parallel
Applying to the first qubit and to the second means applying the matrix , of size :
If only one qubit gets a gate, the other gets the identity: acts only on the first.
To which state does the gate take ? (Write only the two digits.)
Mini-challenge
In Python
Write the tensor product of two vectors of any size. Try it first with loops; then compare with np.kron, which does this in NumPy.
Mini-challenge Β· Python
Input
u, vnp.ndarrayformat: two vectors, shapes (n,) and (m,)
example:
np.array([1, 2]), np.array([3, 4])
Output
tensornp.ndarrayformat: vector of shape (nΒ·m,)
example:
np.array([3, 4, 6, 8])
Tests
Test 1 Example Not run yet
Call:
tensor(np.array([1, 2]), np.array([3, 4]))Expected output:
np.array([3, 4, 6, 8])Test 2 Hidden Not run yet
Test 3 Hidden Not run yet
To go deeper: T. G. Wong, Introduction to Classical and Quantum Computing, ch. 4.
Solve this mini-lesson's mini-challenge to continue.