\n", "

\n",
" ## Reminder: Matrix Addition and Multiplication by Scalars (Click here to expand)

\n",
"

\n",
"\n",
"To add two vectors, we add their elements together:\n", " $$|a\\rangle = \\begin{bmatrix}a_0 \\\\ a_1 \\\\ \\vdots \\\\ a_n \\end{bmatrix}, \\quad\n", " |b\\rangle = \\begin{bmatrix}b_0 \\\\ b_1 \\\\ \\vdots \\\\ b_n \\end{bmatrix}$$\n", " $$|a\\rangle + |b\\rangle = \\begin{bmatrix}a_0 + b_0 \\\\ a_1 + b_1 \\\\ \\vdots \\\\ a_n + b_n \\end{bmatrix} $$\n", "

\n", "And to multiply a vector by a scalar, we multiply each element by the scalar:\n", " $$x|a\\rangle = \\begin{bmatrix}x \\times a_0 \\\\ x \\times a_1 \\\\ \\vdots \\\\ x \\times a_n \\end{bmatrix}$$\n", "

\n", "These two rules are used to rewrite the vector $|q_0\\rangle$ (as shown above):\n", " $$\n", " \\begin{aligned} \n", " |q_0\\rangle & = \\tfrac{1}{\\sqrt{2}}|0\\rangle + \\tfrac{i}{\\sqrt{2}}|1\\rangle \\\\\n", " & = \\tfrac{1}{\\sqrt{2}}\\begin{bmatrix}1\\\\0\\end{bmatrix} + \\tfrac{i}{\\sqrt{2}}\\begin{bmatrix}0\\\\1\\end{bmatrix}\\\\\n", " & = \\begin{bmatrix}\\tfrac{1}{\\sqrt{2}}\\\\0\\end{bmatrix} + \\begin{bmatrix}0\\\\\\tfrac{i}{\\sqrt{2}}\\end{bmatrix}\\\\\n", " & = \\begin{bmatrix}\\tfrac{1}{\\sqrt{2}} \\\\ \\tfrac{i}{\\sqrt{2}} \\end{bmatrix}\\\\\n", " \\end{aligned}\n", " $$\n", "

\n", "

\n",
" ## Reminder: Orthonormal Bases (Click here to expand)

\n",
"

\n",
"\n",
"\n",
"Since the states $|0\\rangle$ and $|1\\rangle$ form an orthonormal basis, we can represent any 2D vector with a combination of these two states. This allows us to write the state of our qubit in the alternative form:\n",
"\n",
"$$ |q_0\\rangle = \\tfrac{1}{\\sqrt{2}}|0\\rangle + \\tfrac{i}{\\sqrt{2}}|1\\rangle $$\n",
"\n",
"This vector, $|q_0\\rangle$ is called the qubit's _statevector,_ it tells us everything we could possibly know about this qubit. For now, we are only able to draw a few simple conclusions about this particular example of a statevector: it is not entirely $|0\\rangle$ and not entirely $|1\\rangle$. Instead, it is described by a linear combination of the two. In quantum mechanics, we typically describe linear combinations such as this using the word 'superposition'.\n",
"\n",
"Though our example state $|q_0\\rangle$ can be expressed as a superposition of $|0\\rangle$ and $|1\\rangle$, it is no less a definite and well-defined qubit state than they are. To see this, we can begin to explore how a qubit can be manipulated.\n",
"\n",
"### 1.3 Exploring Qubits with Qiskit \n",
"\n",
"First, we need to import all the tools we will need:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": [
"thebelab-init"
]
},
"outputs": [],
"source": [
"from qiskit import QuantumCircuit, assemble, Aer\n",
"from qiskit.visualization import plot_histogram, plot_bloch_vector\n",
"from math import sqrt, pi"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In Qiskit, we use the `QuantumCircuit` object to store our circuits, this is essentially a list of the quantum operations on our circuit and the qubits they are applied to."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"qc = QuantumCircuit(1) # Create a quantum circuit with one qubit"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In our quantum circuits, our qubits always start out in the state $|0\\rangle$. We can use the `initialize()` method to transform this into any state. We give `initialize()` the vector we want in the form of a list, and tell it which qubit(s) we want to initialise in this state:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
"\n",
" It was stated before that the two vectors $|0\\rangle$ and $|1\\rangle$ are orthonormal, this means they are both *orthogonal* and *normalised*. Orthogonal means the vectors are at right angles:\n",
"

And normalised means their magnitudes (length of the arrow) is equal to 1. The two vectors $|0\\rangle$ and $|1\\rangle$ are *linearly independent*, which means we cannot describe $|0\\rangle$ in terms of $|1\\rangle$, and vice versa. However, using both the vectors $|0\\rangle$ and $|1\\rangle$, and our rules of addition and multiplication by scalars, we can describe all possible vectors in 2D space:\n",
"

Because the vectors $|0\\rangle$ and $|1\\rangle$ are linearly independent, and can be used to describe any vector in 2D space using vector addition and scalar multiplication, we say the vectors $|0\\rangle$ and $|1\\rangle$ form a *basis*. In this case, since they are both orthogonal and normalised, we call it an *orthonormal basis*.\n",
"