Qiskit implementation
Die Siite isch nonig ibersetzt worre. Ihr luege d englischi Originalversion aa.
In the previous lesson, we took a first look at the Statevector and Operator classes in Qiskit, and used them to simulate operations and measurements on single qubits.
In this section, we'll use these classes to explore the behavior of multiple qubits.
# Added by doQumentation — required packages for this notebook
!pip install -q numpy qiskit
from qiskit import __version__
print(__version__)
2.1.1
We'll start by importing the Statevector and Operator classes, as well as the square root function from NumPy.
Hereafter, generally speaking, we'll take care of all of our required imports first within each lesson.
from qiskit.quantum_info import Statevector, Operator
from numpy import sqrt
Tensor products
The Statevector class has a tensor method, which returns the tensor product of that Statevector with another, given as an argument.
The argument is interpreted as the tensor factor on the right.
For example, below we create two state vectors representing and and use the tensor method to create a new vector,
Notice here that we're using the from_label method to define the states and rather than defining them ourselves.
zero = Statevector.from_label("0")
one = Statevector.from_label("1")
psi = zero.tensor(one)
display(psi.draw("latex"))
Other allowed labels include "+" and "-" for the plus and minus states, as well as "r" and "l" (short for "right" and "left") for the states