15,558,870 members
Articles / Quantum Computing
Article
Posted 24 Jun 2019

35.3K views
26 bookmarked

# Quantum Computation Primer - Part 1

Rate me:
5.00/5 (27 votes)
24 Jun 2019CPOL26 min read
Learn the fundamentals of quantum computation. Understand Dirac notation and design and build quantum circuits.
In this article, we explore the differences between qubits and classical bits. We see how to describe quantum state using Dirac notation. We observe that qubits can be placed into superposition, and see how to calculate the probability of observable states. We also see how entangled qubits can determine each other's state. Finally we take a ride around the Block sphere, and see how a qubit's state can be visualized in 3 dimensions.

## Introduction

Quantum computing may be on the cusp of disrupting modern computing. Gartner predicts that "by 2023, 20% of organizations will be budgeting for quantum computing projects."

The major cloud providers: Microsoft, Amazon, Google, IBM, and Oracle are racing to bring quantum computing as a service to their offerings. In addition, companies, universities, and even nation states are investing heavily.

Why all the buzz?

Quantum computers offer the potential to bring parallelism to calculations on a scale that cannot be matched by classical computers. They may enable us to model the quantum world, bringing breakthroughs in material science, medicine, you name it.

There already exists actual multi-qubit quantum computers, such as IBM's, that allow you to create and run quantum algorithms in the cloud.

Despite the general optimism though, there are those who argue that larger multi-qubit systems are not feasible and will never happen. However, the physics underpinning quantum computing has been widely validated experimentally and researches continue to make advances in improving the accuracy of multi-qubit systems.

For software engineers, it's a field, ripe for exploration.

### My Journey into the Quantum Realm

In all likelihood, like me, you're a software engineer looking to cut your teeth with the latest quantum tech. Unfortunately, nearly all of the resources online on the topic of quantum computing come from a mathematics or physics bent; much of the time written by physicists for physicists.

When I began learning quantum theory several months ago, my first step was to dive head first into what, according to some, is the authoritative text on the subject: Quantum Computation and Quantum Information, by Nielsen and Chuang. Apparently this is the book used in many physics schools. I soon found myself struggling with the linear algebra and I knew I was going to need to take a step back and read up on that. Fortunately I had an old (8th) edition of Elementary Linear Algebra, by Anton sitting on my bookshelf; left over from my undergraduate days, nearly two decades ago. I worked my way through that, and thoroughly enjoyed it. Towards the end, after a few weeks of study, I had another crack at a quantum text. This time I chose Quantum Computing for Computer Scientists by Yanofsky and Mannucci. More and more came into focus now. The only thing noticeably missing from the linear algebra book was tensors. I turned to the web for that, and tensor products turned out to be dead simple.

So, armed with my newly acquired linear algebra, I pushed through the quantum computing book; turning to the web to increase clarity here and there. Eventually I found myself where I wanted to be from the beginning, understanding and constructing quantum circuits.

While the mathematics and notation underpinning quantum theory seems daunting at first, on my journey, I've been taken with the elegance by which it all fits together. I wrote this series of articles to provide you with a grounding in the fundamentals of quantum computation without spending a lot of time on quantum mechanics, which is a branch of physics heavy in theory that, while broadening comprehension, may deter a beginner. This series doesn't spend much time on covering the relevant mathematics up front either, but rather introduces critical mathematics along the way. While there's quite a bit of math and formulas littered throughout these articles, we work through them together.

Let's dive in.

## Bits to Qubits

In quantum computing, a qubit is analogous to a bit in classical computing. I'm guessing you knew that already. We also have qubytes, which are analogous to classical bytes. As with classical computing, a qubit has two measurable states but there's a little more to it.

When you measure a qubit, its quantum state is said to collapse; to a value that is either 0 or 1. Before you measure it, however, the two observable states have a certain probability. As quantum engineers, we can modify the probabilities of a quantum state, and what's more, we can employ multiple qubits that affect one another.

A qubit is represented as a vector. The zero qubit state is represented by the single column matrix [1, 0]T. The one qubit state is represented by [0, 1]T. These are known as its basis states. The 'T' superscript denotes the transpose of the matrix, and allows the matrix to be presented horizontally. It's used occasionally to save space.

These two basis states are orthonormal, which means they are orthogonal and normalized. Together they are called the computational basis. Let me explain these terms.

Orthogonal means that the inner product of the matrices is 0. To calculate the inner product (a.k.a. the dot product), we multiply each item in the first matrix with its counterpart in the second matrix and sum them all together, like so:

$\mzero \cdot \mone = 1 \times 0 + 0 \times 1 = 0$

Normalized means that the probabilities of the observable states add up to 1.

Determining the probability of quantum states is fundamental to quantum information theory, and we delve further into that later in the article. Firstly, however, we need to cover some basic math, including complex numbers and matrix multiplication, then familiarize ourselves with Dirac notation.

## Some Preliminary Mathematics

Though it may appear otherwise skimming over this article, I've tried to keep the math simple. There are, however, just a couple operations you need under your belt to be able to follow along. In particular, you need to know how to multiply complex numbers and matrices. We look at those operations now.

### Multiplying Complex Numbers

In quantum computation, qubits are represented as vectors in 3 dimensional space. In quantum circuits, we rotate and combine them to perform computations. The vectors representing qubits' state contain complex numbers, and complex numbers are also used to rotate qubits in this space.

A complex number consists of a real part (x) and an imaginary part (y), as shown:

$x + yi$

where $i$ equals $\sqrt{-1}$, and $i^2$ equals $-1$.

When multiplying two complex numbers, you add together the products of the real and imaginary parts of both numbers. See Figure 1.

Multiplying this out gives us:

$(x_1 + y_1i)(x_2 + y_2i) = x_1x_2 + x_1y_2i + y_1x_2i + y_1y_2(i)^2$

Since $i^2 = -1$, this simplifies to:

$x_1x_2 - y_1y_2 + x_1y_2i + y_1x_2i$

The following is an example:

\begin{align} (3 + 2i)(4 + 3i) &= 12 + 9i + 8i + 6i^2 \\ &= 12 + 17i - 6 \\ &= 6 + 17i \end{align}

### Multiplying Two Matrices

When working with quantum states, there are three matrix by matrix multiplication operations that are commonly performed: matrix product, inner product, and tensor product (a.k.a. outer product). We look at the matrix product now and cover the inner and tensor products in later sections, as we need them.

The first thing to note is that calculation of the matrix product is only valid if the number of columns in the first matrix is equal to the number of rows in the second matrix. See Figure 2.

Also notice that the row count for the result equals the row count of the first matrix, and the column count of the result, equals the column count of the second matrix.

The matrix product is generally written without an operator as AB, where A and B are two matrices.

Let's work through an example, where matrix A and B are presented below.

To calculate AB, we multiply each item in the first row of A, by the item in the first column of B with the same index, and sum the products. The result is 1×2 + 3×3 + 2×1 = 13. The value 13 is placed into the first cell of the result matrix.

We then stay on the first row of A, but we shift to the next column of B; repeating the process until we get to the end of the columns in B.

We then shift down to the second row of A, and back to the first column in B. After we complete the last row in A, we're done.

### Identifying an Element in a Matrix

By convention, a matrix is often given a capital letter as an identifier. An element within the matrix is specified using the name of the matrix in lowercase, with its row then column (in that order) shown as subscript. See the following example:

$A = \begin{bmatrix} a_{00} & a_{01} \\ a_{10} & a_{11} \end{bmatrix}$

### Multiplying a Matrix by a Scalar

The process of multiplying a matrix by a scalar is a simple one: multiply every item in the matrix by the scalar.

If A is the matrix:

$A = \begin{bmatrix} a_{00} & a_{01} & a_{02} \\ a_{10} & a_{11} & a_{12} \\ a_{20} & a_{21} & a_{22} \end{bmatrix}$

Then multiplying the matrix by a scalar produces:

$\lambda A = \begin{bmatrix} \lambda a_{00} & \lambda a_{01} & \lambda a_{02} \\ \lambda a_{10} & \lambda a_{11} & \lambda a_{12} \\ \lambda a_{20} & \lambda a_{21} & \lambda a_{22} \end{bmatrix}$

For example, if the scalar multiplier is 2 and A's values are:

$A = \begin{bmatrix} 1 & 3 \\ 5 & 2 \end{bmatrix}$

Then the result is as follows:

$\lambda A = 2\begin{bmatrix} 1 & 3 \\ 5 & 2 \end{bmatrix} = \begin{bmatrix} 2 & 6 \\ 10 & 4 \end{bmatrix}$

If the scalar is a complex number and/or the matrix contains complex numbers, the procedure does not change. You calculate the products using the rules of complex number multiplication, which we looked at earlier.

Okay, so we've gone over some basic math operations that you need to know to follow along. Let's move on to something more fun.

## Describing Quantum State with Dirac Notation

Dirac notation (also known as bra-ket notation) is everywhere in quantum theory. It's used to describe quantum states. You can think of it as matrix shorthand.

A single qubit with the zero basis state can be written as a ket in Dirac notation, like so:

$\vert 0 \rangle$

This reads as "ket zero."

Conversely, a qubit with a one basis state, can be written as:

$\vert 1 \rangle$

NOTE: In some texts, |0⟩ and |1⟩ are presented as |↑⟩ (spin-up) and |↓⟩ (spin-down), respectively. When you visualize a qubit on a three dimensional sphere, |0⟩ is up at the north pole and |1⟩ is down at the south pole. I use |0⟩ and |1⟩ exclusively in this series.

Recall that |0⟩ represents the column vector [1, 0]T, and 1 represent [0, 1]T.

In Dirac notation, the values within the ket—between the vertical line character '|' and the angled bracket '⟩'—are tensor products.

The symbol '⊗' is used to denote the tensor product of two matrices. It is calculated by multiplying each item in the first matrix by all items in the second matrix, as illustrated:

$\begin{bmatrix} a_1 \\ a_2 \end{bmatrix} \otimes \begin{bmatrix} b_1 \\ b_2 \end{bmatrix} = \begin{bmatrix} a_1 \begin{bmatrix} b_1 \\ b_2 \end{bmatrix} \\ a_2 \begin{bmatrix} b_1 \\ b_2 \end{bmatrix} \end{bmatrix} = \begin{bmatrix} a_1b_1 \\ a_1b_2 \\ a_2b_1 \\ a_2b_2 \end{bmatrix}$

Tensor products are condensed within Dirac notation, like so:

$\vert 1 \rangle \otimes \vert 0 \rangle = \vert 10 \rangle$

For qubits, the Dirac notation lends itself beautifully to a binary representation. Notice below how entries in the matrix correspond to the binary. In addition, take note of how the first entry in the matrix corresponds to 0 and not 1.

NOTE: In some texts, the leading 0's within a ket are omitted and replaced with a subscript indicating the length. So that |0010⟩ becomes |104⟩. I don't use that notation in this series, but you may see it elsewhere.

You can now see how |1⟩ ⊗ |0⟩ are combined by calculating the tensor product of the matrices, like so:

$\left| 0 \right> \otimes \left| 1 \right> = \begin{bmatrix} 1 \\ 0 \end{bmatrix} \otimes \begin{bmatrix} 0 \\ 1 \end{bmatrix} = \begin{bmatrix} 0 \\ 1 \\ 0 \\ 0 \end{bmatrix} = \left| 01 \right>$

In a quantum circuit, the inputs of the circuit are combined as tensor products. We explore this later in the series.

If the Dirac notation points to the left rather than the right, as in: ⟨0|, it's called a bra. Together they form a bra-ket.

### Deriving a Bra from a Ket (and Vice Versa)

The bra is the conjugate transpose of the ket. The conjugate transpose is also known as the adjoint matrix, and yet another name is the Hermitian transpose.

To obtain the conjugate transpose, the matrix is rotated and each entry is complex conjugated. For a single column matrix, it just means we turn it horizontally and then take the complex conjugate of each entry. See Figure 3.

The complex conjugate simply means changing the sign of the imaginary part. For example, if $z = 2 + 3i$, then the complex conjugate is $\bar{z} = 2 - 3i$.

Why Complex Numbers? You may wonder why quantum theory relies so heavily on complex numbers. As Yanofsky et al (2008 p.88-89) point out, if you add two positive real numbers, the result will always increase. That's not the case with Complex numbers. You can add two Complex numbers and produce a smaller result. In fact, they may even cancel each other out. This is referred to as interference, and it's sometimes employed deliberately to eliminate unwanted states in quantum algorithms.

In the following examples we use the variables a and b, such that a,b ∈ Cd. In other words, a and b denote single column matrices of complex numbers with the number of rows equal to d. Most of the time we are working with qubits, where the dimension count is 2.

The following illustrates obtaining a bra from a ket:

$\left< a | = | a \right>^\dagger = \begin{bmatrix} \overline{a_1} \\ \overline{a_2} \\ \vdots \\ \overline{a_d} \\ \end{bmatrix}^T = \begin{bmatrix} \overline{a_1} & \overline{a_2} & \ldots & \overline{a_d} \end{bmatrix}$

This process is reversible. To obtain a ket from a bra, do the same thing again: calculate the conjugate transpose.

When combined, a bra-ket ⟨b|a⟩ represents the inner product of b and a. It's sometimes written as ⟨b,a⟩. The inner product is the sum of the products of corresponding items. This results in a complex scalar value (with or without an imaginary part). Scalar means that it's not a vector; it's a magnitude without direction.

$\left< b | a \right> = b \cdot a = a_1b_1 + a_2b_2 + \ldots + a_db_d$

All quantum states are normalized. That is ⟨a|a⟩ = 1. This has important implications for the probability of states. We return to it in a later section.

We've seen that quantum theory relies on complex numbers and vectors to describe quantum states. This algebraic structure is termed a complex vector space and is also known as Hilbert Space.

Another combination of the Dirac notation, which I include for completeness, is the ket-bra. It's written like this |a⟩⟨b| or sometimes |aXb|. A ket-bra is the tensor (or outer) product and is represented by a d × d matrix:

$\vert a \rangle \langle b \vert = \begin{bmatrix} a_1b_1 & a_1b_2 & \cdots & a_1b_d \\ a_2b_1 & a_2b_2 & \cdots & a_2b_d \\ \vdots & \vdots & \ddots & \vdots \\ a_db_1 & a_db_2 & \cdots & a_db_d \end{bmatrix}$

TIP: In quantum theory, it's common to see the Greek characters φ (phi) and ψ (psi) used as variable names in bras and kets. For example, you often see a quantum state expressed as |ψ⟩ = ... . Don't be put off by the Greek characters, foreign notation, and seemingly complex algebra. It all appears far more complex than it actually is.

## Exploring Quantum Superposition

We learned in an earlier section that when you measure a qubit, its quantum state collapses to either 0 or 1. To which value it collapses depends on the way the qubit has been configured. You can change the probability of a qubit collapsing to a particular value. By doing so, you place the qubit into a superposition.

Now, for a qubit that is in a pure basis state, either |0⟩ or |1⟩, the result is predetermined. It has a 100% chance of collapsing to its respective value. In other words, if you measure a qubit that was placed in the |0⟩ state, for example, you always get 0 because the probability of collapsing to 0, is 1; and the probability of collapsing to 1, is 0.

But, if you employ a certain quantum gate in your quantum circuit, you can split the probability of the qubit collapsing to 0 or 1, to a 50/50 chance either way. In which case, it is said to be in a superposition of both states.

When a qubit is in a superposition, its value is undetermined until it's measured. In fact, a qubit is said to be simultaneously 0 and 1 until then. It's both!

This is such an unusual phenomenon, physicists have been unable to explain it using classical physics. The double slit experiment demonstrates the phenomenon. A photon seemingly goes everywhere, interfering with itself, before landing on a spot. So to does our qubit exist in all states until it is measured.

Disambiguating the Term "State" When one or more qubits make up a quantum system, this system has an overall quantum state at any one time. However, the system also has a set of distinct states that it may collapse to when measured. We'll call these states: observable states.

The quantum state of one or more qubits can be described using Dirac notation and simple algebra. Observable states and associated probabilities comprise the qubit's superposition.

A single qubit can be described by a linear combination of |0⟩ and |1⟩, such that:

$\ket{\psi} = \alpha \ket{0} + \beta \ket{1}$

The α (alpha) and β (beta) coefficients are known as complex amplitudes or probability amplitudes. As Yanofsky and Mannucci (2008, p.106) point out, the name 'amplitude' comes from the fact that a quantum state is a wave, and a wave is characterized by its amplitudes.

NOTE: Probability amplitudes are not measurable. When a qubit is measured it collapses to one of its observable states. We can manipulate the probability amplitudes, but not observe their values directly.

## Calculating the Probability of Observable States

To calculate the probability of a qubit collapsing to a particular state, we take the square of the modulus of its coefficient. This is known as the Born rule.

So, for the |ψ⟩ example shown above, the probability of |0⟩ is |α|2.

The modulus of a complex number is calculated like so:

$\lvert x + iy \rvert = \sqrt{x^2 + y^2}$

To calculate the probability we square that number. All together this can be written succinctly as shown:

$P(x_i) = \lvert \left \langle x_i \vert \psi \right \rangle \rvert^2$

This is saying that to calculate the probability of the observable state Xi (which is either going to be 0 or 1 for a qubit), you square the modulus of the dot product. In other words, you project the state your interested in onto the superposition.

Don't worry if the algebra doesn't make sense yet. Next we look at an example, and then further illustrate it using matrices.

Say our qubit superposition is given by the following:

$\left \vert \psi \right \rangle = \frac{1}{\sqrt 3} \lvert 0 \rangle + \sqrt{\frac{2}{3}} \lvert 1 \rangle$

Then the probability of collapsing to 0 is given by:

$P(0) = \left \vert \bk{0}{\left( \frac{1}{\sqrt 3} \ket{0} + \sqrt{\frac{2}{3}} \ket{1} \right)} \right \vert^2 = \left \vert \frac{1}{\sqrt 3} \bk{0}{0} + \sqrt{\frac{2}{3}} \bk{0}{1} \right \vert^2$

Now, we can reduce ⟨0|0⟩ to 1 by calculating the dot product, as shown:

$\bk{0}{0} = \mzero \cdot \mzero = 1 \times 1 + 0 \times 0 = 1$

and because ⟨0| and |1⟩ are orthogonal, their inner product is 0, as shown:

$\bk{0}{1} = \mzero \cdot \mone = 1 \times 0 + 0 \times 1 = 0$

So, if we replace those bra-kets in our probability formula, we see that:

$P(0) = \left \vert \frac{1}{\sqrt 3} \times 1 + \sqrt{\frac{2}{3}} \times 0 \right \vert^2 = \frac{1}{3}$

Alternatively, we can look at the same problem, but substitute matrices for our states and calculate the probability that way.

\begin{align} P(0) &= \left \vert \mzero \cdot \left( \frac{1}{\sqrt 3} \mzero + \sqrt{\frac{2}{3}} \mone \right) \right \vert^2 \\ &= \left \vert \mzero \cdot \left( \begin{bmatrix} \frac{1}{\sqrt 3} \\ \sqrt{\frac{2}{3}} \end{bmatrix} \right) \right \vert^2 = \left \vert 1 \times \frac{1}{\sqrt 3} \right \vert^2 = \frac{1}{3} \end{align}

Hopefully the Dirac notation version makes a bit more sense now.

### Leveraging the Probability Distribution of Quantum States

We know that the sum of the probabilities in a probability distribution is always 1. We also learned earlier that all quantum states are normalized, i.e., ⟨a|a⟩ = 1. For orthonormal bases, such as [0, 1]T and [1, 0]T, the observable states are in a probability distribution. If you sum the probabilities of all observable states, they come to 1, as described by the formula:

$\sum_{i} P(x_i) = 1$

Therefore, we can calculate the probability of the qubit collapsing to 1, by calculating the complement of P(0), like so:

$P(1) = 1 - P(0) = \frac{2}{3}$

## Creating Multi-Qubit States

So far we've looked at the quantum states of single qubits. We can, of course, create quantum states with multiple qubits. These are known as multi-partite quantum states.

To do so, we combine states using tensor products. For example, if qubit A is in state |ψ⟩A = |0⟩ and qubit B is in state |ψ⟩B = |1⟩, then the total state is given by:

$\ket{\psi}_{AB} = \ket{0}_A \otimes \ket{1}_B = \ket{01}_{AB}$

In this case, we can measure the state of qubit A without collapsing the state of qubit B. The individual states are said to be uncorrelated.

We can, however, place qubits into a state, where measuring one affects another. This is known as entanglement.

### Entangling Qubits

For instance, take a well known state (one of the Bell states, which we discuss later), this state describes two qubits in superposition:

$\ket{\phi} = \frac{\ket{00} + \ket{11}}{\sqrt{2}}$

The state of the qubits when measured will have a 50% chance of being either 00 or 11.

If we were to measure just one of the qubits, it would cause the other's state to collapse to the same value. The qubits are said to be entangled. Even if the entangled qubits are far away from each other, possibly light years. This is what Einstein described as "spooky action at a distance."

### Determining if Qubits are Entangled

When we look at the mathematics governing entanglement, we can use the matrix representation to tell us if the qubits are entangled.

As Yanofsky et al (2008 p.89) point out, a vector that can be written as the tensor product of two vectors is called separable.

In contrast, if the tensor product state of two qubits cannot be factored, they are said to be entangled. This is pointed out in Andrew Helwer's introductory video on quantum computing.

For example, if we take the state |01⟩ and derive its matrix representation; forgetting for a moment that we know what the tensor product representation is already.

We can see that ac = 0, ad = 1, bc = 0, and bd = 0. If we solve for a, b, c, and d; we get a = 1, b = 0, c = 0, and d = 1. We can factor it, therefore we know |01⟩ is separable and not entangled.

$\ket{01} = \begin{bmatrix} 0 \\ 1 \\ 0 \\ 0 \end{bmatrix} = \mzero \otimes \mone$

In contrast, if we look at the Bell state |φ+⟩, we see that it is a two qubit state in equal superposition. The matrix representation is calculated below:

\begin{align} \frac{\ket{00} + \ket{11}}{\sqrt{2}} &= \frac{1}{\sqrt{2}} \left( \mzero \otimes \mzero \right) + \frac{1}{\sqrt{2}} \left( \mone \otimes \mone \right) \\ &= \frac{1}{\sqrt{2}} \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix} + \frac{1}{\sqrt{2}} \begin{bmatrix} 0 \\ 0 \\ 0 \\ 1 \end{bmatrix} = \begin{bmatrix} \frac{1}{\sqrt{2}} \\ 0 \\ 0 \\ \frac{1}{\sqrt{2}} \end{bmatrix} \end{align}

In this case, the matrix is not factorable. We have ac = 1/√2, ad = 0, bc = 0, and bd = 1/√2. There is no solution to a, b, c, and d. Therefore, the matrix is not separable and so the qubits are entangled. In fact, because of the equal probability of the two states |00⟩ and |11⟩, the Bell state is said to be maximally entangled. They're as entangled as you can get.

But, how do we create a Bell state? We explore that in Part 2 of the series. Next, we look at visualizing single qubit states.

To recap, as quantum engineers, we have the opportunity to manipulate the probabilities using quantum gates in our quantum circuits. We can also combine qubits in such a way that they correlate with one another. We can even leverage quantum entanglement to instantly affect the shared state of multiple qubits, even if the qubits are far away from one another.

## Visualizing a Qubit on the Bloch Sphere

Many operations on single qubits can be neatly visualized on a 3 dimensional unit sphere, known as the Bloch sphere. See figure 4.

A qubit can be represented as a line of length 1 from the center of the sphere to the sphere's surface.

At the north pole sits basis state |0⟩; at the south, |1⟩.

Before collapsing into a basis state, a qubit's superposition may be located anywhere on the Bloch sphere. You can think of θ (theta) as latitude and φ (phi) as longitude. As we move vertically, north or south, the latitude changes (θ), and as we move horizontally the longitude (φ) changes.

While the latitude affects the probability of the qubit collapsing to a particular basis state, the longitude does not. The longitude is referred to as the qubit's phase.

We saw earlier that a qubit's superposition can be written

$\ket{\psi} = \alpha \ket{0} + \beta \ket{1}$

where α and β are its probability amplitudes, which are complex numbers.

### Converting between Cartesian and Polar Coordinates

Recall that a complex number consists of a real part, x, and an imaginary multiplier, y.

$z = x + iy$

A complex number can be represented by just x and y. The pair (x, y) is called its Cartesian representation. It can be graphed on a two dimensional Cartesian plane. Such a graph is called an Argand diagram. See figure 5.

The arg function can be used to calculate θ. In this case, arg is equivalent to atan2, which is also equivalent to tan-1, as shown:

$Arg(x + iy) = atan2(y, x) = tan^{-1}(\frac{y}{x})$

Later in this section you see how to use the Arg function to calculate angles (θ, φ) on the Bloch sphere.

We can convert the Cartesian coordinates to polar representation. The polar coordinates consist of the modulus ρ (rho) and the angle θ. Recall that to calculate the modulus we use:

$\rho = \lvert x + yi \rvert = \sqrt{x^2 + y^2}$

To calculate the angle, we use:

$\theta = tan^{-1}(\frac{y}{x})$

To convert back from polar to Cartesian representation, use:

\begin{align} x &= \rho \cos{\theta} \\ y &= \rho \sin{\theta} \end{align}

### Locating the Qubit on the Bloch Sphere

Feel free to merely skim through this section. While its useful to understand how states are translated to the Bloch sphere, you can always return to this at a later stage.

α and β can be visualized on the Bloch sphere as a point corresponding to the two angles (θ, φ).

It turns out that because |α|2 + |β|2 = 1 we can calculate a qubit's position on the Bloch sphere using the following:

$\ket{\psi} = \cos{\frac{\theta}{2}} \ket{0} + e^{i \varphi} \sin{\frac{\theta}{2}} \ket{1}$

where $0 \leq \theta \leq \pi$ and $0 \leq \varphi \leq 2 \pi$.

That gives us $\alpha = \cos{\frac{\theta}{2}}$ and $\beta = e^{i \varphi} \sin{\frac{\theta}{2}}$.

To find the angles use

\begin{align} \theta &= 2 \cos^{-1}{\lvert \alpha \rvert} \\ \varphi &= arg( \beta ) - arg( \alpha ) \end{align}

NOTE: You can also find these values via the state's density matrix, which is calculated by its ket-bra: ρ = |ψ⟩⟨ψ|. But that's outside the scope of this article.

## Conclusion

In this article, we explored the differences between qubits and classical bits. We looked at the computation basis for qubits. We saw how to describe quantum state using Dirac notation. We observed that qubits can be placed into superposition, and saw how to calculate the probability of observable states. We also saw how an entangled qubit can affect the quantum state of the pair. Finally we took a ride around the Block sphere, and saw how a qubit's state can be visualized in 3 dimensions.

In the next part, we explore how quantum gates are used to build quantum circuits, which ultimately puts us on the road to materializing quantum algorithms. I hope you'll join me.

Thanks for reading and I hope you found this article useful. If so, then I'd appreciate it if you would please rate it and/or leave feedback below.

• 24 June 2019
• Published

## License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Engineer Microsoft
United States
Daniel is a senior engineer in Technology and Research at the Office of the CTO at Microsoft, working on next generation systems.

Previously Daniel was a nine-time Microsoft MVP and co-founder of Outcoder, a Swiss software and consulting company.

Daniel is the author of Windows Phone 8 Unleashed and Windows Phone 7.5 Unleashed, both published by SAMS.

Daniel is the developer behind several acclaimed mobile apps including Surfy Browser for Android and Windows Phone. Daniel is the creator of a number of popular open-source projects, most notably Codon.

Would you like Daniel to bring value to your organisation? Please contact

Blog | Twitter

Xamarin Experts
Windows 10 Experts

## Comments and Discussions

 First Prev Next
 Great introduction Emilio Silva3-Aug-21 5:30 Emilio Silva 3-Aug-21 5:30
 Re: Great introduction Daniel Vaughan3-Aug-21 6:34 Daniel Vaughan 3-Aug-21 6:34
 Confuse about Figure 4. Member 1486309014-Jun-20 19:29 Member 14863090 14-Jun-20 19:29
 I suppose "at the north poll" is a typo haha Traffic Tse6-Jun-20 0:18 Traffic Tse 6-Jun-20 0:18
 Re: I suppose "at the north poll" is a typo haha Daniel Vaughan6-Jun-20 7:59 Daniel Vaughan 6-Jun-20 7:59
 Excellent! Kevin McFarlane4-May-20 4:10 Kevin McFarlane 4-May-20 4:10
 Re: Excellent! Daniel Vaughan4-May-20 8:56 Daniel Vaughan 4-May-20 8:56
 Small error dchabaud15-Jan-20 0:18 dchabaud 15-Jan-20 0:18
 Re: Small error Daniel Vaughan15-Jan-20 7:40 Daniel Vaughan 15-Jan-20 7:40
 My vote of 5 reticulocity17-Oct-19 6:36 reticulocity 17-Oct-19 6:36
 Re: My vote of 5 Daniel Vaughan17-Oct-19 8:24 Daniel Vaughan 17-Oct-19 8:24
 Image 8 King-----Kong15-Jul-19 18:01 King-----Kong 15-Jul-19 18:01
 Re: Image 8 Daniel Vaughan18-Jul-19 10:53 Daniel Vaughan 18-Jul-19 10:53
 Frontend Serge Desmedt5-Jul-19 0:36 Serge Desmedt 5-Jul-19 0:36
 Re: Frontend Daniel Vaughan5-Jul-19 0:54 Daniel Vaughan 5-Jul-19 0:54
 Complex Luc Pattyn28-Jun-19 11:48 Luc Pattyn 28-Jun-19 11:48
 Re: Complex Daniel Vaughan28-Jun-19 12:16 Daniel Vaughan 28-Jun-19 12:16
 Would you mind correcting a perhaps confusing typo hopf28-Jun-19 0:13 hopf 28-Jun-19 0:13
 Re: Would you mind correcting a perhaps confusing typo Daniel Vaughan28-Jun-19 5:39 Daniel Vaughan 28-Jun-19 5:39
 what is a factorable matrix? Pete Lomax Member 1066450526-Jun-19 3:12 Pete Lomax Member 10664505 26-Jun-19 3:12
 Re: what is a factorable matrix? Daniel Vaughan26-Jun-19 23:42 Daniel Vaughan 26-Jun-19 23:42
 Re: what is a factorable matrix? Pete Lomax Member 1066450515-Aug-19 12:45 Pete Lomax Member 10664505 15-Aug-19 12:45
 A small detail User 1106097924-Jun-19 9:14 User 11060979 24-Jun-19 9:14
 Re: A small detail Daniel Vaughan24-Jun-19 11:03 Daniel Vaughan 24-Jun-19 11:03
 Last Visit: 31-Dec-99 19:00     Last Update: 27-Jan-23 22:03 Refresh 1

General    News    Suggestion    Question    Bug    Answer    Joke    Praise    Rant    Admin

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.