<p>Peter Shor nailed the reason. This is because OpenQASM and Quirk have different conventions for how the order of wires maps into the order of bits shown in the kets. The simplest way to check this is to use a circuit that toggles only the top qubit.</p>

<p>Quirk considers the top qubit to be the least significant qubit, and labels kets in big endian order (i.e. the ordering humans use; why 12 represents twelve instead of twenty-one). So the 4-output chance display is showing outputs in the following order: probability of top=bottom=0; probability of top=1 and bottom=0, probability of top=0 and bottom=1; probability of top=bottom=1.</p>

<p>The reason I chose this order when making Quirk is because it makes the displays behave better when resizing. If you resize the chance display from 2-qubits to 3-qubits, and the third qubit is off, the original four outputs stay together in the top half instead of being spread apart. Also it's just the natural thing to do when programming: the wire at index k has weight <code>1&lt;&lt;k</code>. Quirk's tendency to expand circuits and gates downward pushed it towards a "down means more/bigger" convention in other places as well, e.g. in the arithmetic circuits.</p>

CC BY-SA 4.0
2018-08-14T21:58:03.787Z
2018-08-14T22:03:24.617Z
2018-08-14T22:03:24.617Z
Craig Gidney
<p>I'm learning about quantum computing in order to code a simulator. I tried the <a href="http://algassert.com/quirk#circuit=%7B%22cols%22:[[%22X%22,%22X%22],[%22H%22],[%22%E2%80%A2%22,%22H%22],[%22H%22,%22X%22],[%22H%22,%22%E2%80%A2%22],[1,%22Y%22],[1,%22H%22],[%22Chance2%22]]%7D" rel="nofollow noreferrer">following circuit in Quirk</a></p>

<p><a href="https://i.sstatic.net/csQo3.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/csQo3.png" alt="enter image description here"></a></p>

<p>And ran the same circuit using OPENQASM 2.0:
<a href="https://i.sstatic.net/G31w8.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/G31w8.png" alt="enter image description here"></a></p>

<p>Notice that the input is |11> in both cases, but it seems that the probabilities for 01 and 10 are switched. What I'm missing here? Thank you!</p>

CC BY-SA 4.0
2018-08-14T02:17:44.407Z
Maybe Openqasm and Quirk have different conventions for the order of the qubits.
Peter Shor 
<quantum-computing><quantum-information>
Quantum circuit simulation divergence in results
Fernando
# Quantum circuit simulation divergence in results

(Asked by: username_0 on 2018-08-13)

I'm learning about quantum computing in order to code a simulator. I tried the [following circuit in Quirk](http://algassert.com/quirk#circuit=%7B%22cols%22:[[%22X%22,%22X%22],[%22H%22],[%22%E2%80%A2%22,%22H%22],[%22H%22,%22X%22],[%22H%22,%22%E2%80%A2%22],[1,%22Y%22],[1,%22H%22],[%22Chance2%22]]%7D)

[![enter image description here](https://i.sstatic.net/csQo3.png)](https://i.sstatic.net/csQo3.png)

And ran the same circuit using OPENQASM 2.0:
[![enter image description here](https://i.sstatic.net/G31w8.png)](https://i.sstatic.net/G31w8.png)

Notice that the input is |11> in both cases, but it seems that the probabilities for 01 and 10 are switched. What I'm missing here? Thank you!

**Tags:** quantum-computing, quantum-information
> **Comments:**
> **username_1**: Maybe Openqasm and Quirk have different conventions for the order of the qubits.  

---

## 1 answers

### Answer by username_2 on 2018-08-14. Score: 3 | Accepted answer

Peter Shor nailed the reason. This is because OpenQASM and Quirk have different conventions for how the order of wires maps into the order of bits shown in the kets. The simplest way to check this is to use a circuit that toggles only the top qubit.

Quirk considers the top qubit to be the least significant qubit, and labels kets in big endian order (i.e. the ordering humans use; why 12 represents twelve instead of twenty-one). So the 4-output chance display is showing outputs in the following order: probability of top=bottom=0; probability of top=1 and bottom=0, probability of top=0 and bottom=1; probability of top=bottom=1.

The reason I chose this order when making Quirk is because it makes the displays behave better when resizing. If you resize the chance display from 2-qubits to 3-qubits, and the third qubit is off, the original four outputs stay together in the top half instead of being spread apart. Also it's just the natural thing to do when programming: the wire at index k has weight `1<. Quirk's tendency to expand circuits and gates downward pushed it towards a "down means more/bigger" convention in other places as well, e.g. in the arithmetic circuits.`


---

