4 ms·
I consider simulating a coin flip (aka creating a so-called “even superposition”) to be the hello world of quantum computing. In a quantum programming language
by reikonomusha 5y ago
I consider simulating a coin flip (aka creating a so-called “even superposition”) to be the hello world of quantum computing. In a quantum programming language called Quil, this looks like
DECLARE result BIT
H 0
MEASURE 0 result
This will put a 0 or a 1 in result with equal probability. ‘H 0’ is performing a Hadamard operation on qubit 0. The MEASURE allows us to extract a classical bit value out of a qubit.
Others might say the “Bell pair” is the hello world, and that looks like this:
H 0
CNOT 0 1
This is a bit harder to explain, because it requires understanding both superposition and entanglement.
- krastanov 5y agoI am just being annoyingly pedantic, but I do not think a Clifford circuit (both of your examples fall in this category) is a good quantum hello world, because they are trivial to simulate efficiently on a classical computer. But I do not have better suggestions.
- chunky1994 5y agoI don't think a "hello world" type of program/circuitry(?) needs to be unique to a quantum computer. It just needs to be expressible with a quantum circuit. Similar to how you can have hello world in both ruby and python, but arrive at them with different syntax and compilers.
- josefx 5y agoIsn't that the case for literally anything you could run on the current state of the art quantum computers? The troll answer of simulating a qbit using a qbit excluded.
- Bjartr 5y agoAnd displaying "Hello World" can be done trivially with a pencil and paper. That doesn't make doing so in a classical programming language devoid of value.
- krastanov 5y agoSure, but there is value in a "Hello World" being focused on what is special about the hardware/language. Look at Haskell and OCaml tutorials for instance: they all explicitly say stuff like "let us start with the 'Hello World' of functional languages, namely, implementing the Fibonacci (or factorial) function recursively".