# Quantum computing

## Mats Tage Axelsson introduces you to quantum computing, the coolest tech around. Learn how it works and how you can get started.

Locked in his super-cooled computing basement Mats Tage Axelsson explains how mere mortals can get working with literally the coolest tech around…

Quantum computing has caught the attention of large companies, academics and hobbyists. This article will cover the history, the different ways to make a quantum computer and the logic behind programming. You’ll also learn about some programming toolkits that you can use to get started.

To run a quantum computer, the physics has to be understood so programmers can then manipulate and measure the final results. Scientists have observed quantum effects in photons, electrons and isotopes of many materials. This means engineers use superconducting materials such as niobium and aluminium to construct workable quantum computing systems.

The logic gates are made of silicon wafers and are controlled using microwave emitters. These solutions may not be the best in the long run, but they’re the ones that are running now. To use quantum computers, you need logic that takes advantage of the two core concepts: superposition and entanglement. When you start exploring these concepts, the Bloch sphere will help visualise what to do with different gates. Programmers can use classical bit gates together with quantum gates to create the algorithms needed.

The mainstream media hails quantum computers as significantly faster than current models. It turns out they’re only fast in specific areas: cryptography, optimisation, simulation and database searches. In cryptography, many algorithms are safe because factorising large prime numbers with classical computers will take far too long for practical use. Shor’s quantum algorithm can do it in minutes. Optimisation and simulations can benefit from a quantum computer’s ability to test many solutions at once.

Database searches are faster by a factor of four. And with faster database searches, machine learning also becomes much faster.

The history of quantum computers begins with quantum physics. In 1900 Max Planck first proposed that light comes in discrete packets called quanta. This discovery later led Einstein to show that Planck was right. When measuring the photoelectric effect scientists could observe packet behaviour. These two discoveries later led to quantum physics. Yet the deeper scientists dove into the quantum nature of things, the harder it got to explain how it works. For quantum computing, the most interesting developments are entanglement and superposition.

Superposition is the phenomenon where a particle exists in many positions at the same time. Considering this, scientists concluded that a quantum computer should be possible to build. A quantum computer is one that can do many calculations per operation. The cat in the box The famous physicist Schrödinger created a thought experiment. In it, he describes a cat and a gas container inside a box. The gas will poison the cat after the radioactive decay of an atom that releases the gas. The process is random so observers won’t know if the cat is dead or alive until they open the box. In quantum physics, this means that the cat is both alive and dead before anyone observes it. In the case of the cat, this is absurd but in quantum physics it’s normal. What Schrödinger was saying was that there must be another explanation – one as yet undiscovered.

Another phenomenon is entanglement, where two particles can have intertwined states. This means that the state of one particle will always be opposite of the other even when they are apart. In quantum computers the software creates entanglement, a CNOT gate creates this state.

To make use of all the phenomena demonstrated in quantum physics, scientists needed a way to describe what happens on a small scale. To program a computer, it needs logical operations, described as logical gates. Quantum gates and classical logic gates are the same only up to a point. Quantum gates add features for changing states and entanglement.

It took until the 1970s for the first attempt at a theory to use quantum effects for computers. Shannon information theory describes classical gates and other aspects of data processing. For quantum computers, this is insufficient because it doesn’t specifically describe quantum effects.

Quantum information theory was first attempted in 1976. During the 1980s scientists made more progress, in part thanks to quantum computing conferences organised by MIT and IBM. Other interesting developments included quantum cryptography and the first universal quantum computer.

To make use of all the states of the particle you measure, programmers need a formal language. Quantum information theory needed to improve. The different gates are the foundation for such a scheme.

Keeping track of what the different quantum states are is confusing. First of all, the way it works is counterintuitive at best. Second, there are many different spin axles to keep track of. The system isn’t complicated, but it involves atypical approaches that are tricky to grasp. To make sense of all the state transitions, physicist created the Bloch sphere.

Peter Shor discovered Shor’s Algorithm in 1994. This algorithm solves the problem of finding the prime factors of large numbers. The basis of all encryption is that you can’t, in a reasonable time, solve this problem. Quantum

Schrödinger was a cat person “The process is random so observers won’t know if the cat is dead or alive until they open the box. In quantum physics, the cat is both alive and dead”

computers may solve this problem in minutes. Interest in quantum computers subsequently sky-rocketed.

Shortly after Shor’s discovery, Lov Grover invented the Grover algorithm. This is best known as the database search algorithm, but it’s also useful for other tasks.

Through the coming decades, scientists invented new features. Quantum error correction and faulttolerant quantum computers were among the major ones. The first demonstration of a quantum computer took place in 1998. After this, development accelerated.

Bose, Einstein and Joseph walk into a bar

To date there are a range of quantum computers in use. Researchers are using ion traps, light-based and microwave controlled Bose-Einstein condensates. These types need different control mechanisms. The ion traps use an electromagnetic field to trap the ions. Lasers create the field and keep the ion trapped and to “pump” the state of the electron of the ion. The electron will emit light only when the state matches the laser’s frequency.

This is the logical 1 state, with the logical 0 state is the opposite. This makes it simple to measure, but achieving precision is still a challenge. Manufacturing is also expensive using current technologies. Meanwhile, a Bose-Einstein condensate is a gas cooled to millikelvin temperatures. When the gas reaches this temperature all electrons take the same quantum state. Uses for this solution are, so far, limited to simulators – any actual computers are pipe dreams.

The interesting types are the different Josephson junction types – these actually are running in practical setups. IBM’s versions are even available for anyone who registers on the Q-experience web page.

D-wave’s machine uses Josephson junctions. These are superconducting Niobium and aluminium-oxide gates. At temperatures near absolute zero, a SQUID measures their magnetic properties. A SQUID is a sensitive magnetometer. The values show the quantum state of the junction, making the circuit a qubit. The principle this computer uses is quantum annealing.

IBM’s solution is Nuclear Magnetic Resonance (NMR). The qubit is still a Josephson gate. That solution uses microwave transmitters to interact with the qubit.

The difference between the two is that the IBM solution controls qubits to a higher degree. This has made it easier for Canadian company D-Wave to manufacture bigger chips. At the same time, this limits D-wave to fewer applications. For example, an annealing system can’t run Shor’s algorithm or Grover’s. It’s useful for optimisation and machine learning – no wonder Google already has one of its own D-wave quantum computers.

More is less work

As mentioned earlier, the algorithms in quantum computers are different. To explain what the difference is, you must bear in mind the physics that are involved. As most LinuxFormat readers will know, a conventional computer uses gates. The system uses Boolean logic to create the algorithms for calculating everything. The most important aspect of this is that it’s deterministic, so we only deal in certainties. The answer is either yes or no – at least on the circuit level.

In contrast, quantum computing involves all answers having a probability attached to them. No answer is certain – rather, it is probabilistic. For this to be efficient the algorithms must be adapted accordingly.

Quantum gates have an effect on one or several qubits at a time. When you measure qubits, the system usually does a complete analysis of the entire system. So, if you’re searching for one qubit, that one will stick out like a sore thumb in one operation. Note that one operation is made up of many shots of the same gates. This is one of the reasons why quantum computers are faster than a conventional one.

The most common scenario is to find the special number of many, such as a database search. The other most cited case is for breaking encryption. Using Shor’s algorithm, you measure the solution by the action of the gates. The gates run the input a fixed number of times before finding the answer. That number doesn’t change when the input is a higher number. A classical computer forces you to test all possible answers. This means that when the number reaches 2048 you are facing a potential million years

to solve it. More numbers mean an exponential workload increase. Note the difference is that the effort to solve the problem does not increase in a quantum computer.

Let’s have a Bloch party

Once you know how many states and transitions you have in each qubit, it’s time to code. Not so fast though – there’s a visual way to describe the gates. The Bloch sphere is the basis for all gates. The graph looks like a music score, so it’s called a quantum score. It looks a bit different depending on the platform but in general, the strings across are qubits. When you want to change the state of a qubit you place a gate on the string. To create entanglement between two qubits you drop the gate on one string and connect it to the other.

To describe the quantum state of a particle, you use spin, like a spinning ball. More precisely, the angle the “ball” spins. Even though there are no balls that spin in the classical sense, the mathematics describe it well. When the equipment measures an electron, it’ll be in spin up or spin down in one axis. The system can only measure in one dimension at a time. The three are x, y and z. So, if you measure x, you lose all information about the spin state on the z- and y-axis.

When you describe the quantum state, you use an imaginary arrow in the Bloch sphere.

The top of the sphere represents the qubits logical 0 and the bottom is logical 1. These are the only two states that the system can measure with 100 per cent certainty. To get a result in a quantum computer you make many “shots” and get the most probable answer.

A matrix contains the coordinates that show the arrows angle. The length of the arrow is always 1. The values we use to calculate the probability describe the components of the axes for the arrow. The Bloch sphere rules the gates and their naming, so keep that in mind when you try to understand.

The available gates depend on the application, and type of quantum computer. But the following are the common ones. The Pauli X Gate rotates the state around the x-axis changing the value of Z. This gate is also a bit-flip gate. The Pauli Y GATE rotates around the y-axis, changing both the x value and the z value. This gate is both a bit-flip and a phase-flip gate.

So far, the gates only flip the bits and phases. These don’t deal with superposition or entanglement. The Hadamard gate puts the qubit in a superposition. To make that clear, the qubit will have a 50 percent chance of being 0 or 1, flipping between X and Z.

It will act like a dice, only using two in a row will always give the starting value. More gates that extend the Hadamard gate are S and its transformed conjugate.

To use entanglement you use a CNOT gate, usually depicted with a plus sign in a circle and a line down to another qubit. The gate flips the target qubit when the control is 1.

Those are the basic gates that you’ll encounter as you start out. On the IBM Q Experience, you have the opportunity to also create subroutines. A better idea, though, is to use a development kit. There are many kits available, and you can extend your IDE with them. Eclipse, Netbeans and Visual Studio have modules. They use several classical languages. The programming tools for Python, for example, are available from IBM. Note that the routines prepare scripts for the quantum computer – it doesn’t run Python on it.

So get cracking. You won’t create much at first, but you will have a lot of fun – we guarantee it!

take a chance on me “In contrast, quantum computing involves all answers have a probability attached to them. No answer is certain – rather, it’s probabilistic”

Programmers use the Bloch sphere to illustrate how quantum gates manipulate the qubits.

When starting out programmers use a score, like a music score. The picture shows Quirk, an online simulator. The circuit is showing a Quantum Fourier transform.

Here, we’re employing Eclipse to develop our own quantum computing programs. Note that this particular tool-kit is using Python as the supporting programming language.