Quantum Tinkering

Qubit states

The elementary units of information in classical computing are bits . As their name suggests, bits represent one single bit of information , which means they can take on either of two values - 0{0} and 1{1} - at a time.

Qubits are the quantum computing equivalent of bits. They differ from classical bits - among other things - in that they can take on a multitude of values instead of just 0{0} and 1,{1,} until that value is measured , at which point they behave just like classical bits. To explain what this means exactly, we'll need to introduce some further concepts.

Let 0{|0\rangle} and 1{|1\rangle} denote the so called basis states of a qubit that are the quantum-equivalent of classical bit states. If you look at a qubit directly to learn it's value, you'll see one of these basis states. But while you're not looking - due to it's quantum nature - the state of a qubit may be something more intricate. Generally, it can be expressed as the linear combination of the two basis states: α0+β1.{\alpha |0\rangle + \beta |1\rangle.} Here, α{\alpha} and β{\beta} are complex numbers that indicate the relative weight, with which the two basis states are present in this combination. More precisely, if we now look at the qubit, we'll see the basis state 0{|0\rangle} with a probability of α2,{\Vert{\alpha}\Vert^2,} and the basis state 1{|1\rangle} with a probability of β2.{\Vert{\beta}\Vert^2.} Because these probabilities must add up to one - as 0{|0\rangle} and 1{|1\rangle} are the only possible outcomes - the equation α2+β2=1{\Vert{\alpha}\Vert^2 + \Vert{\beta}\Vert^2 = 1} must hold for all valid qubit states. Let's call α2{\Vert{\alpha}\Vert^2} and β2{\Vert{\beta}\Vert^2} the measurement probabilities of the basis states.

Important properties of complex numbers

Play around with 2 representations of a single qubit. You adjust the view of the 3D Bloch sphere by clicking on the image and dragging.

ϕα{\phi_\alpha} ϕβ{\phi_\beta} rα{r_\alpha} Display Bloch sphere
(0.87+0.23i)0+(0.28+0.33i)1{\textcolor{#4682B4}{(0.87 + 0.23i) \cdot | 0 \rangle} + \textcolor{#FA8072}{(0.28 + -0.33i) \cdot | 1 \rangle}} 1 −1 i −i

The Bloch-sphere

As the coefficients α{\alpha} and β{\beta} are complex numbers, they can be expressed in the form α=αeiϕα{\alpha = \Vert{\alpha}\Vert \cdot e^{i \phi_{\alpha}}} and β=βeiϕβ.{\beta = \Vert{\beta}\Vert \cdot e^{i \phi_{\beta}}.} Thus, the state of the qubit can be rewritten as αeiϕα0+βeiϕβ1.{\Vert{\alpha}\Vert \cdot e^{i \phi_{\alpha}} |0\rangle + \Vert{\beta}\Vert \cdot e^{i \phi_{\beta}} |1\rangle.}

Remember that eiϕα{e^{i \phi_{\alpha}}} is a unit vector rotated around the origin, and therefore the square of its norm eiϕα2{\Vert{e^{i \phi_{\alpha}}}\Vert^2} also equals 1.{1.} This means that we can modify the angles ϕα{\phi_{\alpha}} and ϕβ{\phi_{\beta}} freely without affecting the measurement probabilities. Therefore, we can do an algebraic trick to simplify the expression above. Namely, let's divide the state by eiϕα{e^{i \phi_{\alpha}}} to obtain α0+βeiϕβeiϕα1.{\Vert{\alpha}\Vert \cdot |0\rangle + \Vert{\beta}\Vert \cdot \frac{e^{i \phi_{\beta}}}{e^{i \phi_{\alpha}}} |1\rangle.} By the rules of exponentiation, eiϕβeiϕα=ei(ϕβϕα).{\frac{e^{i \phi_{\beta}}}{e^{i \phi_{\alpha}}} = e^{i (\phi_{\beta} - \phi_{\alpha})}.} Next, let's introduce a new variable ϕ=ϕβϕα,{\phi = \phi_{\beta} - \phi_{\alpha},} with the help of which the state can be further simplified to α0+βeiϕ1.{\Vert{\alpha}\Vert \cdot |0\rangle + \Vert{\beta}\Vert \cdot e^{i \phi} |1\rangle.}

We know that α2+β2=1.{\Vert{\alpha}\Vert^2 + \Vert{\beta}\Vert^2 = 1.} Consequently, these two numbers can also be represented geometrically as a vector of unit length, the x{x}- and y{y}-coordinates of which correspond to α2{\Vert{\alpha}\Vert^2} and β2{\Vert{\beta}\Vert^2}, respectively. (Note that here, we don't need to use the complex plane, only a regular real plane, as both α2{\Vert{\alpha}\Vert^2} and β2{\Vert{\beta}\Vert^2} are real numbers.) Let's define a new variable θ{\theta} as twice the angle between this vector and the x{x}-axis. Using trigonometry, we find that α2=cos(θ2){\Vert{\alpha}\Vert^2 = \cos{(\frac{\theta}{2})}} and β2=sin(θ2){\Vert{\beta}\Vert^2 = \sin{(\frac{\theta}{2})}}, which allows us to rewrite the state as cos(θ2)0+sin(θ2)eiϕ1{\cos{(\frac{\theta}{2})} \cdot |0 \rangle + \sin{(\frac{\theta}{2})} \cdot e^{i \phi} |1 \rangle}. Notice that we now only need two variables to express the state of the qubit: the angles θ{\theta} and ϕ.{\phi.} Geometrically, this can be represented as another vector pointing to the surface of 3-dimensional sphere with unit radius, where θ{\theta} is the angle of the vector and the z{z} axis, and ϕ{\phi} is the angle of the vertical projection of the vector on the xy{x-y} plane. This representation of qubit states is called the Bloch sphere .

It's important to note that of the two degrees of freedom on the Bloch sphere, only the angle θ{\theta} is related to measurement probabilities. ϕ{\phi} is an inherently quantum property called the phase that does not have any physical manifestation directly observable to us. Because of this, it's hard to find any intuitive analogy from everyday life that could help us understand what exactly the phase is. The most useful approach in this context is to look at the phase as a matematical property of quantum objects that we can leverage to design clever algorithms.

Quantum gates

Quantum operators are functions that act on the state of a quantum system. Quantum algorithms are sequences of specific quantum operators that modify the state of single or multiple qubits. The physical device that implements quantum algorithms is called a quantum circuit , the building blocks of which are quantum logic gates that correspond to the individual operators in the sequence.

For each quantum operator, there's a corresponding matrix and the state of the qubit can be written as a vector ψ=[αβ],{|\psi\rangle = \begin{bmatrix}\alpha\\\beta\end{bmatrix},} so the algebraic representation of an operator U{U} acting on the state ψ{|\psi\rangle} is essentially the matrix multiplication Uψ{U|\psi\rangle}. For example, the Hadamard gate is represented by the H=12[1111]{\displaystyle H = \frac{1}{\sqrt{2}} \cdot \begin{bmatrix}1&1 \\ 1&-1\end{bmatrix}} matrix, which means it can transform a qubit from a state of [1+0i0+0i]{\begin{bmatrix}1+0i\\0+0i\end{bmatrix}} to [12+0i12+0i]{\begin{bmatrix}\frac{1}{\sqrt{2}}+0i\\\frac{1}{\sqrt{2}}+0i\end{bmatrix}}. This is a slightly more complicated case of thinking of matrices as linear transformations - as complex numbers are involved - but the basic principles remain the same, and hopefully one can gather a decent understanding by tinkering with the Bloch sphere and its transformations below.

Look at the how a quantum gate - expressed as a unitary matrix - transforms a Bloch sphere

θ{\theta} ϕ{\phi} Select quantum gate
{}
Toggle Bloch/vectors
θ:0.17π,ϕ:0.142π{\textcolor{red}{\theta: 0.17 \cdot \pi}, \textcolor{purple}{\phi: 0.14 \cdot 2\pi}} ∣1⟩∣0⟩
θ:0.17π,ϕ:0.142π{\textcolor{red}{\theta: 0.17 \cdot \pi}, \textcolor{purple}{\phi: 0.14 \cdot 2\pi}} ∣1⟩∣0⟩