Blog

Here at ANS we’re passionate about investigating new technology and seeing how it can help our customers. Our tech gurus love nothing more than playing around with emerging technology, so we let them loose to write their first quantum computer program. But don’t worry, we haven’t blown the entire hardware budget on a new geeky toy. Those nice people at IBM let us have a go on theirs – just to see what it can do. So without further ado, this is what we learnt.

Quantum computing is getting very exciting but it’s got a long way to go. If you asked me what a quantum computer could do for your business right now, honestly, I’d say not a lot.

Right now, quantum computing is at an experimental stage. Google recently announced their machine had achieved “quantum supremacy”. This might be a cool buzzword but we take the results with a pinch of salt. You can find out what the New Scientist, has to say and here’s IBM’s (kinda predictable) disputation. Research teams at Google and IBM are starting to get results and quantum software *may* become very important sometime in the next decade. This is because it will help us to crack codes faster than ever before. You see, most of the encryption used to secure data and communications relies on generating very large prime numbers. Having a computer that is really quick at doing that means you can crack any code with ease. Quantum computers are, potentially, brilliant at it. A quantum computer in the wrong hands would give its user the power to break the encryption of pretty much everything anyone ever thought was secure on the internet.

The solution to this is to create new means of keeping things secure using quantum encryption on, you guessed it, another quantum computer. You probably won’t even notice the difference but once the first quantum computers start getting used in the real world, everyone responsible for keeping data and communications private is going to need one – or sign up to services provided by companies offering them.

For all those who want to know: here’s the “science bit”!

Quantum mechanics is counter intuitive, but you don’t need to “change the way you perceive reality”. Danish physicist and Nobel Prize winner, Niels Bohr once said “Anyone who is not shocked by quantum theory has not understood it.” Here at ANS we take a more pragmatic approach. Engineers like us have been dodging quantum theory for decades. You don’t need to bend your head around the crazy concepts to use the maths and make amazing things. The people who design lasers, transistors and traditional computers know all about quantum theory but cock a deaf ear when it comes to the philosophical implications. You should too.

So what do Quantrum computers do I hear you cry. Well in short, they solve problems in a completely different way to traditional methods. Rather than storing information in “bits” that are either “0” or “1”, quantum computers use “qubits” (pronounced cubits). A qubit can have a value of “|0>”, “|1>” or (in “superposition“) any linear combination of the two defined by the equation a|0> + b|1> where a and b are complex numbers such that |a|^{2} + |b|^{2} = 1.

Imagine we have a traditional computer register with eight bits. It can take in eight bits (any number from 0 to 255) and output eight bits (any number up to 255). Those bits can be manipulated by hardware or some other register to change the state of any of the bits. Now consider a quantum register with eight qubits. It can still only take in 8 traditional bits and output 8 traditional bits. The difference is what can be achieved inside.

Whatever processing happens inside the traditional computer is limited to bits. Each bit can only be 0 or 1 so the state of the register is limited to 1’s and 0’s i.e. it can only ever be in one of 2^bits states. The inside the quantum register is a lot bigger. The state of a single qubit can be any complex number. Our qubit register requires 2^bits complex numbers to describe its state.

The bad news is that you can’t see what the value of a qubit is without measuring it and when you do it “collapses” to a real bit value. The probability the value will be a 0 is |a|^{2} and the probability it will be a 1 is |b|^{2}. The trick is to manipulate the qubits inside the computer while we can’t predict their values.

Once you have mastered that trick your software can achieve an effect called “quadratic speed up“. Problems that would take 2^{N} time to solve take 2^{N/2} time. Factoring large numbers to find primes stops being an exponential problem and starts being a polynomial one.

It all seems a bit mind blowing but, luckily, greater minds than ours have developed a mathematical model using linear algebra. Even better they’ve abstracted it down to a simple set of quantum gates which are a wee bit like logic gates. For example, a quantum “CNOT” gate is a bit like an “XOR” gate but it works by entangling two qubits even if they are in superposition. Even better still: they have created simple programming languages that lets us programmers forget about the cat entirely and get on with the work. Cherry on top: IBM have provided a graphical user interface so that you can program a quantum computer without even writing a line of code.

So, without any more waffle, here’s that program we promised you. A simple demonstration of “superposition”, “entanglement” and “collapsing”.

// Name of Experiment: Experiment #20170529140745 v3

OPENQASM 2.0;

include “qelib1.inc”;

qreg q[3];

creg c[3];

// Place 2 qubits in superposition

h q[0];

h q[1];

// Flip another bit to “true”

x q[2];

// entangle the bits

cx q[1],q[2];

cx q[0],q[2];

// Collapse and measure

h q[0];

h q[1];

h q[2];

measure q[2] -> c[2];

measure q[1] -> c[1];

measure q[0] -> c[0];

It is a little prosaic but what’s exciting is that we got to run it on a real quantum computer. If you’re interested you can too. IBM have opened their computer to partners and D-Wave have made their programming language open source. Quantum computers are coming and now is a great time to get involved.