Quantumic Math

Get introduced to the concept of quantumic math.

We'll cover the following...

“You take the blue pill—the story ends, you wake up in your bed and believe whatever you want to believe. You take the red pill—you stay in Wonderland, and I show you how deep the rabbit-hole goes.”

The Matrix

After this chapter, we’ll have a better understanding of the concept called the Hadamard gate.

A qubit resembles the idea of the spin of an electron. It is in a state of superposition. While the electron’s superposition consists of the states up and down, the qubit’s superposition consists of the states 0|0\rangle and 1|1\rangle.

A popular notion of superposition is that the system is in different states concurrently unless it is measured. However, when you look at the electron, we find it either up or down. When we look at the qubit, it is either 0 or 1. Another notion is that the system is truly random and not just sensitive dependent on initial conditions (see Exploring the Quantum States). But superposition does not mean and, and it does not mean or. It’s a combination of states that does not map onto classical concepts.

“This is your last chance. After this, there is no turning back.”

—The Matrix

A vector space gives the basic model of superposition. A vector space is a collection of all valid qubit state vectors along with the operations you can perform on them. We found the qubit state vector using the following equation:

ψ=α0+β1=[αβ]|\psi\rangle = \alpha|0\rangle + \beta|1\rangle = \begin{bmatrix}\alpha\\\beta\end{bmatrix}, with α2+β2=1\alpha^2 + \beta^2 = 1. In Python, the array [alpha, beta] denotes this vector.

α\alpha and β\beta are the probability amplitudes. They are not probabilities. They can be positive or negative. Their squares α2\alpha^2 and β2\beta^2 denote the probabilities.

When we measure a qubit, it will collapse to either one of the possible measurements. The number of possible measurements determines the dimension of this underlying vector space. There are two possible measurements of a qubit, 0 or 1. Thus, the vector space is two-dimensional. All vectors in this vector space consist of two numbers. These are the probability amplitudes α\alpha and β\beta, as in the vector [αβ]\begin{bmatrix}\alpha\\\beta\end{bmatrix}.

When we measure a qubit, we observe it as either 0 or 1. We know that the state 0|0\rangle says our qubit will result in the value 0 when observed. 1|1\rangle says our qubit will result in the value 1 when observed. In general, ψ=α0+β1|\psi\rangle = \alpha|0\rangle + \beta|1\rangle says our qubit will result in the value 0 with the probability of α2\alpha^2 and 1 with the probability of β2\beta^2.

The probability is a single number, called a scalar. How can we obtain this scalar from a qubit state? There’s one way of vector multiplication that produces a scalar, called the inner product. This results from multiplying a column vector such as [10]\begin{bmatrix}1\\0\end{bmatrix} with a row vector, such as [10]\begin{bmatrix}1 & 0\end{bmatrix}.

In the lesson Exploring the Quantum States, we introduced the Dirac notation and its “ket”-construct that denotes a column vector, for instance, 0=[10]|0\rangle=\begin{bmatrix}1\\0\end{bmatrix}. Now, we introduce the “bra”-construct (0\langle0|). The bra is a row vector, such as 0=[10]\langle0|=\begin{bmatrix}1 & 0\end{bmatrix}

The inner product is defined as:

ab=[a0a1...an].[b0b1bn]=a0b0+a1.b1+.an.bn\langle a|b\rangle=\begin{bmatrix}a_0 & a_1 & ... & a_n\end{bmatrix}.\begin{bmatrix}b_0\\b_1\\\vdots\\b_n\end{bmatrix}=a_0\cdot b_0+a_1. b_1 + . a_n. b_n

We can use the inner product to obtain the probability of measuring a particular value from a qubit state. Its square denotes the probability.

So, what’s the probability of measuring 1 from the state 0|0\rangle? Let’s build the inner product to find out:

(10)2=([01][10])2=(01+10)2=02=0\left(\langle1|0\rangle\right)^2=\left(\begin{bmatrix}0 & 1\end{bmatrix}\cdot\begin{bmatrix}1\\0\end{bmatrix}\right)^2=\left(0\cdot 1 + 1\cdot 0\right)^2=0^2=0 ...