Do the Two Counters Click Together?

measurement · correlation · Born rule · bit order · entanglement

A lab measures all qubits of an n-qubit register and looks at two of them, i and j. How often do they show the same bit?

The state is a list state of 2^n complex amplitudes; measuring all qubits gives basis state k with probability |a_k|^2 (abs(state[k]) ** 2, the Born rule). Basis state |b_0 b_1 \dots b_{n-1}\rangle has index int("b0b1...", 2): qubit 0 is the leftmost bit, so in 3 qubits |011\rangle is index 3, and in it qubit 0 shows 0 while qubits 1 and 2 show 1.

Write agreement(state, i, j) that returns a pair (p_same, corr):

  1. p_same: the probability that qubits i and j show the same bit,
  2. corr = p_same - p_diff, where p_diff = 1 - p_same is the probability that they differ. It is 1 when the two always agree, -1 when they always disagree, and 0 when agreeing is a coin toss.

Press Run with a loop over pairs (i, j) to see which qubits of a state move together.

Examples

Input:  state = [0.7071067811865476, 0, 0, 0.7071067811865476], i = 0, j = 1
Output: (1.0, 1.0)
Explanation: only |00> and |11> can come out: the two qubits always agree.

Input:  state = [0.5, 0.5, 0.5, 0.5], i = 0, j = 1
Output: (0.5, 0.0)

Input:  state = [0, 1, 0, 0, 0, 0, 0, 0], i = 1, j = 2
Output: (0.0, -1.0)
Explanation: the state is |001>: qubit 1 shows 0 and qubit 2 shows 1.

Input:  state = [0, 0.5773502691896258, 0.5773502691896258, 0, 0.5773502691896258, 0, 0, 0], i = 0, j = 1
Output: (0.3333333333333334, -0.3333333333333331)
Explanation: |001>, |010> and |100>, each with probability 1/3; qubits 0 and 1
agree only in |001>.

Constraints

  • the state has 2 to 10 qubits; i != j, and i may be larger than j
  • answers are compared with a tolerance of 1e-6

Goals

  • Read the bit of qubit k out of a basis index, qubit 0 leftmost
  • Add Born-rule probabilities over the outcomes where two qubits agree
  • Turn agreement into a correlation between -1 and 1
Starting Python…