Programming quantum computers for non-physics majors



I come from a non-physics background and I am very much interested in pursuing Quantum Computing - especially how to program them. Any guidance on how to get started will be very helpful.


Posted 2018-03-28T06:32:28.333

Reputation: 887

A classical programmer need not understand the workings of the electron. This applies to QED as well. – tgm1024--Monica was mistreated – 2019-08-17T13:59:36.173

By the way, the formatting mechanism here seems horribly broken compared to other stackexchange sites. I tried to create a real answer and had to give up, thus resorting to a very simple comment. The lists here do not behave within quotes. I had thought that all stackexchange sites share the same UI code. – tgm1024--Monica was mistreated – 2019-08-17T14:00:53.957

@tgm1024 what are you referring to exactly? What formatting doesn't work here but does on other sites? Lists within quotes work perfectly fine for me – glS – 2019-10-16T10:17:02.837



You could start with an introduction to quantum computers such as this one from Voxxed Days Vienna 2018 - it's intended for people with a programming background but little to no prior knowledge in quantum mechanics. After that you can check out the guides in the IBM Quantum Experience or those for the Microsoft Quantum Development Kit.

In addition to that, there are loads of videos on YouTube, for example, that can help you understand the topic more deeply.


Posted 2018-03-28T06:32:28.333

Reputation: 1 080


I think that quantum programmers won’t necessarily need to know about quantum physics and linear algebra. These are certainly things that will help broaden a quantum programmers knowledge, but they should not be regarded as prerequisites.

Even so, most resources to help a budding quantum programmer start with an assumption of linear algebra. The ones that don’t mostly focus on QISKit, the SDK for IBM’s quantum device (and some of them were written by me).

The simplest program you can come up with is a “Hello World”. How do you do that for quantum computers? My proposal is a superposition of emoticons.

Once you’ve moved beyond “Hello World” in quantum programming, you’ll want to do something more complex. Often people make simple games. So let’s do that with a quantum computer. I made Battleships.

You will find these and many more examples of quantum programming at the QISKit tutorial. I think that is probably the best place for new quantum programmers to see what can be done, and how to do it.

James Wootton

Posted 2018-03-28T06:32:28.333

Reputation: 9 708


It's not necessary to fully understand Quantum Mechanics to understand the theory behind QC. I'm a math BSc/programmer and I read about the topic and also did the old edX QC course (unfortunately it's not available, but there are others). I think I can say that I understand the gist of QC, but I know next to nothing about Quantum Mechanics.

The key part is that Quantum Computing uses mostly linear algebra, which is based on math that is commonly taught at engineering/computer science undergraduate studies. Contrast this to real Quantum Mechanics that uses infinite-dimensional spaces (or functional analysis, if you'd like).

If you feel comfortable with these undergraduate math topics you can check out Susskind's Quantum Mechanics: Theoretical Minimum - it isn't actually about 'real' quantum mechanics, it's mostly stuff that is useful for QC. BTW the whole Theoretical Minimum book series is aimed at people who know some math (like computer scientists, or engineering majors), and would like to know more about physics. There are also lots of courses online, for example, there are new courses on edX, but I didn't do any of them, so I can't recommend one.

Jakub Bartczuk

Posted 2018-03-28T06:32:28.333

Reputation: 161


pyQuil is an open source quantum programming library in Python. The documentation includes a hands on introduction to quantum computing where you learn by programming. It doesn't assume any physics background.

Here are some links to the main topics:

Will Zeng

Posted 2018-03-28T06:32:28.333

Reputation: 51


Quantum computers are programmed by (evolving programming languages representing) so-called quantum circuits. These are a sequence of quantum gates plus the information on which quantum bits (qubits) they act.

The only thing you really need to know about quantum gates is that they represent rotations (in a higher dimensional space, so-called Hilbert space). Hence they are reversible: Quantum computers are programmed with reversible logic.

What do quantum gates rotate? It is the hyperspheres on whose surface qubit states live. Each state of the computational basis ($\left|00\right>$, $\left|01\right>$, $\left|10\right>$, $\left|11\right>$ for a 2-qubit system in the usual Dirac notation) gets a complex number as a coefficient or as a so-called probability amplitude. The basis vectors are orthogonal and span the state's Hilbert space, the probability amplitudes can be seen as coordinates in it. This is the picture in which quantum gates effect rotations. You will find that physicists often use a different picture, the Bloch sphere, for single qubit systems, in which quantum gates also cause rotations (but sometimes by a larger angle or by one that is omitted in that picture altogether).

All conventional logic can be implemented by a quantum computer by first expressing it in reversible logic (which may require ancilla bits). The classical NOT gate corresponds to the X quantum gate, but unlike the classical case where the only 1-bit reversible gates are the identity and the NOT gate, a quantum computer has four corresponding gates (X, Y, Z according to rotations on the Bloch sphere, plus the identity). Further, you can have rotations that rotate only by a fraction of how far these gates rotate; a few particularly interesting ones have special names and abbreviations such as the Hadamard gate or H gate that creates the equal superposition of all states.

Unfortunately, early quantum software engineers will probably have to know a bit about the quantum computer hardware they will be using: Due to the arbitrarily and continuously choosable angle of a quantum gate's effective rotation, there is a sort-of analog element to quantum computers that necessarily creates errors (and physical quantum computers have even more error sources than just that). There's a way to deal with it, quantum error correction that discretizes errors and corrects the most likely discretizations of them to achieve (ideally) arbitrarily complex computations with bound errors. But optimization will likely mean that one quantum computer with one choice of quantum error correction will be more apt at the certain quantum gate or even algorithms than others, in ways that are a bit more subtle than just looking up a speed factor.


Posted 2018-03-28T06:32:28.333

Reputation: 2 575

Anyone else wondering if the only ones who will understand how to easily write quantum algorithms will be self-evolved quantum AI's? – tgm1024--Monica was mistreated – 2019-10-16T14:06:34.640


If you want to go beyond learning how to write quantum circuits in the various quantum programming frameworks such as Q#, pyQuil and QISKit, I highly recommend this recent paper with the title Quantum Algorithm Implementations for Beginners from the Los Alamos National Laboratory. It's a great resource for understanding how to compile and implement various quantum algorithms as well as their oracles and specific subroutines as quantum circuits with the IBM Q Experience. I'd recommend you to implement them in any of the aforementioned programming frameworks and learn the nitty-gritty details as you go.

Mark Fingerhuth

Posted 2018-03-28T06:32:28.333

Reputation: 1 055