Playground

Type, paste, or edit your circuit here. Then tap “Apply” to generate an interactive circuit diagram and other output formats below. You can learn more about Q’s plain text format in “Writing quantum circuits.”



Result probabilities

Circuit as ASCII diagram

This can be particularly helpful within the JavaScript console when you need to double check the composition of a circuit in a way that’s more illustrative than simple plain text.

Circuit as LaTeX code

This code can be used within LaTeX with the QCircuit library to create circuit diagrams. Note that ctrl{} commands do not yet contain valid index values. Check back in May 2020.

Circuit as plain text

If all’s gone well then copying this and pasting this code in to the original text input box should have no effect on the maths.


Sample circuits

This page previously contained the following pre-loaded sample circuits for experimenting with. Their plain text representations are included here for reference. (You can copy and paste their text in to the input field at the top of the page to load them.)

Bell state

Here’s a Bell state (which produces quantum entanglement), but with Pauli X operations added to both registers as a finale—so the only two possible results are 00 and 11; all or nothing!


H X#0 X
I X#1 X

Deutsch oracle

which The Deutsch–Jozsa algorithm is a deterministic quantum algorithm proposed by David Deutsch and Richard Jozsa in 1992 with improvements by Richard Cleve, Artur Ekert, Chiara Macchiavello, and Michele Mosca in 1998.[1][2] Although of little practical use, it is one of the first examples of a quantum algorithm that is exponentially faster than any possible deterministic classical algorithm and is the inspiration for Simon's Algorithm, which is, in turn, the inspiration for Shor's Algorithm. [Wikipedia]


H-I-X#0-I---I-H
H-I-I---X#0-I-H
X-H-X#1-X#1-H-X

Whiplash

This monster demonstrates some overlapping multi-register operations and an “upside-down CNOT” finale. Notice too how in the diagram version the boxes within each column (moment) are equal widths and there’s an attempt to center the text labels within their boxes. Also note how the overlapping connectors are dealt with, eh? Of course this circuit would make little sense in the real world. It’s here purely to test different aspects of rendering a circuit visually.


H  X.0#0  Y    Z    X#1
H  X.1#0  X#0  I    X#0
H  X.0#1  Y    X#0  S
H  X      X#1  X#1  I
H  X.1#1  Y    Z    S



1
2
3
4
5