Skip to main content

Section 5.1 Introductino to Quantum Computing with Qiskit

Note ID: 202604120001 | Tags: <tensor products>, <Qiskit>, <state vectors>

Exercises Problem Set 1

Imports.

from quiskit.quantum_info import Statevector, Operator
import numpy as np
from numpy import sqrt
from IPython.display import display, Latex, Math

from qiskit import __version__
print(f"Qiskit version: {__version__}")

Tensor Products.

1.
Use Qiskit to compute the tensor product \(\ket{-} \otimes \ket{i}\text{.}\) Your solution must construct the state and print out the amplitudes in the computational basis.
Hint.
Use
  • Statevector.from_label("-") for \(\ket{-}\)
  • Statevector.from_label("r") for \(\ket{i}\)
Answer.
\(\frac{1}{2} \ket{00} + \frac{i}{2} \ket{01} - \frac{1}{2} \ket{10} - \frac{i}{2} \ket{11}\)
Solution.
# Declare state vectors
minus = Statevector.from_label("-")
plus_i = Statevector.from_label("r")

# Compute the tensor product and display the result
display(minus.tensor(plus_i).draw("latex"))
2.
Given the state \(\ket{0} \otimes \ket{1} \otimes \ket{+}\) write the state vector ordering explicitly.
Hint.
πŸŽ—οΈ Quiskit starts its indexing (qubit 0) from the right-hand side.
Answer.
\(\frac{\sqrt{2}}{2}\ket{010} + \frac{\sqrt{2}}{2}\ket{011}\)
Solution.
zero = Statevector([1, 0])
one = Statevector([0, 1])
plus = Statevector.from_label("+")

display((zero ^ one ^ plus).draw("latex"))