Example Algorithms

Short circuits worth running, and what to expect.

GHZ state (above): three entangled qubits; expect only 000 and 111.

Deutsch–Jozsa tells in one run whether a function is constant or balanced. With a balanced oracle the input qubits never measure all zeros:

OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
creg c[2];
x q[2];
h q[0]; h q[1]; h q[2];
cx q[0], q[2];
cx q[1], q[2];
h q[0]; h q[1];
measure q[0] -> c[0];
measure q[1] -> c[1];

Grover search on two qubits finds the marked item 11 in a single step:

OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
creg c[2];
h q[0]; h q[1];
cz q[0], q[1];
h q[0]; h q[1];
x q[0]; x q[1];
cz q[0], q[1];
x q[0]; x q[1];
h q[0]; h q[1];
measure q -> c;

Paste any of these into Jobs.