Checkpoint-3

System #0

You are a physics research assistant specializing in solving complex, research-level problems using precise, step-by-step reasoning.

Input Problems will be provided in Markdown format.

Output (Markdown format)

  1. Step-by-Step Derivation - Show every non-trivial step in the solution. Justify steps using relevant physical laws, theorems, mathematical identities or numerical codes.
  2. Mathematical Typesetting - Use LaTeX for all mathematics: $...$ for inline expressions, $$...$$ for display equations.
  3. Conventions and Units - Follow the unit system and conventions specified in the problem.
  4. Final Answer - At the end of the solution, start a new line with “Final Answer:”, and present the final result.

    For final answers involving values, follow the precision requirements specified in the problem. If no precision is specified: - If an exact value is possible, provide it (e.g., \$\sqrt(2)\$, \$\pi/4\$). - If exact form is not feasible, retain at least 12 significant digits in the result.

  5. Formatting Compliance - If the user requests a specific output format (e.g., code, table), provide the final answer accordingly. You must use web search engine to gather all the necessary information before solving the problem. You must use web search engine to gather all the necessary information before solving the problem. You must use web search engine to gather all the necessary information before solving the problem.

User #1

Problem setup:

In quantum error correction, you encode quantum states into logical states made of many qubits in order to improve their resilience to errors. In quantum error detection, you do the same but can only detect the presence of errors and not correct them. In this problem, we will consider a single [[4,2,2]] quantum error detection code, which encodes two logical qubits into four physical qubits, and investigate how robust logical quantum operations in this code are to quantum errors.

Our convention is that the four physical qubits in the [[4,2,2]] code are labelled 0,1,2,3. The two logical qubits are labelled A and B. The stabilizers are \(XXXX\) and \(ZZZZ\), where \(X\) and \(Z\) are Pauli matrices. The logical \(X\) and \(Z\) operators on the two qubits are \(X_A = XIXI\), \(X_B=XXII\), \(Z_A = ZZII\), \(Z_B = ZIZI\), up to multiplication by stabilizers.

We will consider different state preparation circuits consisting of controlled not \(CNOT_{ij}\) gates, where \(CNOT_{ij}\) has control qubit \(i\) and target qubit \(j\). As a simple model of quantum errors in hardware, we will suppose that each \(CNOT_{ij}\) gate in the circuit has a two qubit depolarizing error channel following it that produces one of the 15 non-identity two-qubit Paulis with equal probability \(p/15\). The probability \(p\) indicates the probability of an error in a single two-qubit gate. We will assess the logical infidelity of certain state preparation protocols as a function of the physical infidelity \(p\).

Checkpoint 1

Suppose that we wish to prepare a logical two-qubit GHZ state \((|00\rangle_{AB}+|11\rangle_{AB})/\sqrt{2}\) in the [[4,2,2]] code. To do so, we use the following state preparation circuit:

\[ (CNOT_{03}) (H_0) (CNOT_{21}) (H_2). \]

Note that this equation is written in matrix multiplication order, while the quantum operations in the circuit occur in the reverse order (from right-to-left in the above equation). \(H\) is a single-qubit Hadamard gate.

What is the physical state fidelity of the final physical 4-qubit state at the end of the circuit as a function of the two-qubit gate error rate \(p\)?

Assistant #2

1) Step-by-Step Derivation

  • Noise model and goal

Each CNOT in the circuit is followed by an independent two-qubit depolarizing channel on the same two qubits that, with probability p, applies one of the 15 non-identity two-qubit Pauli operators equiprobably (probability p/15 each), and with probability 1 − p applies identity. We are asked for the physical state fidelity F(p) = ⟨ψideal|ρout|ψideal⟩ of the final 4-qubit state produced by the noisy circuit with respect to the ideal state produced by the same circuit without noise.

  • Ideal state prepared by the circuit

Circuit (right-to-left order): H2 → CNOT21 → H0 → CNOT03, acting on |0000⟩.

Use H|0⟩ = (|0⟩ + |1⟩)/√2 and that CNOT flips the target iff the control is |1⟩. (en.wikipedia.org)

1) After H2: |ψ1⟩ = |0⟩0 |0⟩1 (|0⟩2 + |1⟩2)/√2 |0⟩3 = (|0000⟩ + |0110⟩)/√2.

2) After CNOT21 (control 2, target 1): already included above; |ψ1⟩ = (|0000⟩ + |0110⟩)/√2.

3) After H0: |ψ2⟩ = (1/2)(|0000⟩ + |1000⟩ + |0110⟩ + |1110⟩).

4) After CNOT03 (control 0, target 3): |ψideal⟩ = (1/2)(|0000⟩ + |1001⟩ + |0110⟩ + |1111⟩).

Recognize this as a tensor product of two Bell states (on qubit pairs 0–3 and 1–2): |ψideal⟩ = |Φ+⟩03 ⊗ |Φ+⟩12 with |Φ+⟩ = (|00⟩ + |11⟩)/√2. (en.wikipedia.org)

  • Where the noise acts

The depolarizing channels act: - after CNOT21 on qubits (2,1) (i.e., the pair 1–2), and - after CNOT03 on qubits (0,3) (the pair 0–3).

No subsequent gates touch those qubits across pairs, so the two error channels act independently on the two disjoint Bell pairs and do not propagate to the other pair.

  • Fidelity for a single Bell pair under a two-qubit depolarizing channel

Let ρ = |Φ+⟩⟨Φ+| and apply the two-qubit depolarizing channel once: Λ(ρ) = (1 − p)ρ + (p/15)∑P≠I PρP, where the sum ranges over the 15 non-identity two-qubit Paulis on that pair (as stated in the problem). The state fidelity with respect to |Φ+⟩ is

Fpair(p) = ⟨Φ+|Λ(ρ)|Φ+⟩ = (1 − p) + (p/15)∑P≠I |⟨Φ+|P|Φ+⟩|^2.

For |Φ+⟩, the only two-qubit Paulis with nonzero expectation are X ⊗ X, Y ⊗ Y, Z ⊗ Z, with eigenvalues +1, −1, +1, respectively; all other two-qubit Paulis have expectation 0. Therefore ∑P≠I |⟨Φ+|P|Φ+⟩|^2 = 1^2 + (−1)^2 + 1^2 = 3.

Hence Fpair(p) = (1 − p) + (p/15)·3 = 1 − (4/5)p.

  • Total 4-qubit fidelity

The final ideal state is |Φ+⟩03 ⊗ |Φ+⟩12 and the two depolarizing channels act independently on 03 and 12. The overall fidelity is therefore the product of the independent pair fidelities: F(p) = Fpair(p)^2 = [1 − (4/5)p]^2.

As a quick consistency check: at p = 1, each pair has fidelity 3/15 = 1/5 with |Φ+⟩, so the 4-qubit fidelity is (1/5)^2 = 1/25 = 0.04, which matches F(1) = [1 − 4/5]^2 = (1/5)^2.

2) Mathematical Typesetting

  • Key equations provided above in LaTeX form.

3) Conventions and Units

  • Qubits labeled 0,1,2,3; CNOTij has control i and target j; H as standard Hadamard; Bell state definition |Φ+⟩ = (|00⟩ + |11⟩)/√2. (en.wikipedia.org)

4) Final Answer: F(p) = [1 − (4/5)p]^2.

User #3

Checkpoint 2

Suppose that we wish to prepare a logical two-qubit GHZ state \((|00\rangle_{AB}+|11\rangle_{AB})/\sqrt{2}\) in the [[4,2,2]] code. To do so, we use the following state preparation circuit:

\[ (CNOT_{03}) (H_0) (CNOT_{21}) (H_2). \]

Note that this equation is written in matrix multiplication order, while the quantum operations in the circuit occur in the reverse order (from right-to-left in the above equation). \(H\) is a single-qubit Hadamard gate.

What is the logical state fidelity of the final 2-qubit logical state at the end of the circuit as a function of the two-qubit gate error rate \(p\), assuming the state is post-selected on all detectable errors in the code?

Assistant #4
Tool Call (code to execute)
from itertools import product
letters = ['I','X','Y','Z']
# mapping: (vX, vZ) bits for a single site relative to X and Z anticommute parity
bit = {'I':(0,0),'X':(0,1),'Y':(1,1),'Z':(1,0)}
# two-qubit on a pair (ordered letters)
all_pairs = [(a,b) for a in letters for b in letters]
# exclude identity pair
nonid_pairs = [p for p in all_pairs if not (p[0]=='I' and p[1]=='I')]
# compute parity class for each pair
par = lambda p: ((bit[p[0]][0]^bit[p[1]][0]), (bit[p[0]][1]^bit[p[1]][1]))
from collections import Counter
cnt = Counter(par(p) for p in nonid_pairs)
print('counts per parity on a pair:', cnt)
# Accept if par(P)==par(Q)
nonid_pairs_list = nonid_pairs
N_acc = 0
N_good = 0
acc_examples = []
for P in nonid_pairs_list:
    for Q in nonid_pairs_list:
        # acceptance if par(P)==par(Q)
        if par(P)==par(Q):
            N_acc += 1
            # good if both parities are (0,0)
            if par(P)==(0,0):
                N_good += 1
                acc_examples.append((P,Q))

print('N_acc', N_acc, 'N_good', N_good)
# sanity: examples
print('first few good examples:', acc_examples[:6])
Tool #5
counts per parity on a pair: Counter({(0, 1): 4, (1, 1): 4, (1, 0): 4, (0, 0): 3})
N_acc 57 N_good 9
first few good examples: [(('X', 'X'), ('X', 'X')), (('X', 'X'), ('Y', 'Y')), (('X', 'X'), ('Z', 'Z')), (('Y', 'Y'), ('X', 'X')), (('Y', 'Y'), ('Y', 'Y')), (('Y', 'Y'), ('Z', 'Z'))]
Assistant #6
Tool Call (code to execute)
import sympy as sp
p=sp.symbols('p')
Pacc=(1-p)**2 + (6/15)*p*(1-p) + (57/(15**2))*p**2
Pgood=(1-p)**2 + (6/15)*p*(1-p) + (9/(15**2))*p**2
F=sp.simplify(Pgood/Pacc)
sp.simplify(F)
print('F=',sp.together(F))
print('expanded numerator=',sp.expand(sp.together(F).as_numer_denom()[0]))
print('expanded denominator=',sp.expand(sp.together(F).as_numer_denom()[1]))
Tool #7
F= (0.64*p**2 - 1.6*p + 1.0)/(0.853333333333333*p**2 - 1.6*p + 1.0)
expanded numerator= 0.64*p**2 - 1.6*p + 1.0
expanded denominator= 0.853333333333333*p**2 - 1.6*p + 1.0
Assistant #8

1) Step-by-Step Derivation

  • Setup, code and circuit

  • [[4,2,2]] code: stabilizers S = ⟨XXXX, ZZZZ⟩. The codespace is the simultaneous +1 eigenspace of these two commuting generators. (ar5iv.labs.arxiv.org, en.wikipedia.org)

  • Logical GHZ target on logical qubits A,B: (|00⟩AB + |11⟩AB)/√2.
  • Circuit (right-to-left action): H2 → CNOT21 → H0 → CNOT03 on input |0000⟩.

  • Ideal output state of the circuit

Apply H and CNOT pairwise: 1) H2; CNOT21 prepares a Bell pair on qubits (2,1): |Φ+⟩12. 2) H0; CNOT03 prepares another Bell pair on qubits (0,3): |Φ+⟩03.

Therefore the ideal 4-qubit output is

\[ \]

The Bell state |Φ+⟩ is stabilized by XX and ZZ (equivalently by {II, XX, ZZ, −YY} with generators XX, ZZ). Hence

\[ (X_0X_3X_1X_2)|\psi_{\text{ideal}}\rangle=(X^{\otimes 4})|\psi_{\text{ideal}}\rangle=|\psi_{\text{ideal}}\rangle, \]
\[ (Z_0Z_3Z_1Z_2)|\psi_{\text{ideal}}\rangle=(Z^{\otimes 4})|\psi_{\text{ideal}}\rangle=|\psi_{\text{ideal}}\rangle, \]

so the state lies in the [[4,2,2]] codespace. (en.wikipedia.org, medium.com, errorcorrectionzoo.org)

  • Noise model

Each CNOT gate is followed by an independent two-qubit depolarizing channel on the same two qubits that, with probability p, applies one of the 15 non-identity two-qubit Pauli operators uniformly (probability p/15 each), and with probability 1−p applies identity. This is the standard “Pauli version” of a two-qubit depolarizing channel. (en.wikipedia.org, quantumchannelzoo.org)

Since the only two-qubit gates are CNOT21 and CNOT03 and the errors occur after these gates, the final error has the form

\[ E = P_{03}\otimes Q_{12}, \]

where each of P03, Q12 ∈ {II, IX, IY, IZ, XI, …, ZZ} and independently equals II with probability 1−p and any non-identity two-qubit Pauli with probability p/15.

  • Post-selection (“detect and discard”)

We post-select on the “no-error-detected” syndrome, i.e., both stabilizer measurements XXXX and ZZZZ return +1. For a Pauli error E, this occurs iff E commutes with both stabilizer generators; otherwise it anticommutes with at least one and is rejected. (learning.quantum.ibm.com, en.wikipedia.org)

  • Commutation bookkeeping by parity classes

For a two-qubit Pauli on a pair (say, qubits a,b), define the parity vector

\[ \pi(P_{ab})=\big(\pi_Z(P_{ab}),\,\pi_X(P_{ab})\big)\in\{0,1\}^2, \]

where πZ(Pab) is 1 iff Pab anticommutes with Z⊗Z on that pair, and πX(Pab) is 1 iff Pab anticommutes with X⊗X on that pair.

Using the binary (symplectic) representation of Paulis, the parity components are just the XOR of the single-qubit “Z-part” and “X-part” bits across the two sites. Concretely, for single-qubit L∈{I,X,Y,Z}, write bits b(L)=(vZ,vX) with I:(0,0), X:(0,1), Y:(1,1), Z:(1,0). Then for a pair Pab = La⊗Lb,

\[ \pi(P_{ab}) = b(L_a)\oplus b(L_b). \]

The full 4-qubit error E = P03⊗Q12 commutes with X⊗4 (resp. Z⊗4) iff the X-parities (resp. Z-parities) of the two pairs match. Thus,

\[ E\ \text{is accepted} \iff \pi(P_{03})=\pi(Q_{12}). \]

This parity/symplectic-commutation correspondence is standard in stabilizer theory. (en.wikipedia.org)

  • Enumerating parity classes on one pair

The 15 non-identity two-qubit Paulis on a given pair split into four parity classes:

\[ \text{class} & \# \\ \hline \pi=(0,0)\ \text{(commutes with both XX, ZZ)} & 3\ \ (\{XX,YY,ZZ\})\\ \pi=(0,1) & 4\\ \pi=(1,0) & 4\\ \pi=(1,1) & 4 \]

(Easy to check by the XOR rule, or by listing.) The class (0,0) is exactly the nontrivial stabilizer of |Φ+⟩ on that pair, so acting with any of {XX,YY,ZZ} maps |Φ+⟩ to ±|Φ+⟩. (medium.com)

  • Which accepted errors are “good” (i.e., preserve the target state)?

Since the ideal state is |Φ+⟩03⊗|Φ+⟩12 and the 16 Bell-product states form an orthonormal basis, an accepted error E has nonzero overlap with the target if and only if it preserves each pair’s |Φ+⟩ up to a global phase; otherwise it maps at least one pair to a different Bell state orthogonal to |Φ+⟩, yielding zero overlap. Therefore: - On a single pair, “good” non-identity Paulis are exactly {XX,YY,ZZ}, i.e., class (0,0). - For the full error E = P03⊗Q12, - Acceptance requires π(P03)=π(Q12). - Goodness (nonzero overlap) requires P03∈{XX,YY,ZZ} and Q12∈{XX,YY,ZZ}. Hence among accepted double errors, only the 3×3=9 choices are good; the other accepted classes (matching non-(0,0) parities) are logical errors that change the encoded state within the codespace. (medium.com)

  • Counting accepted vs. good events by error weight

Let “weight” mean how many gates suffered a non-identity two-qubit Pauli. - Weight 0: probability (1−p)^2. Accepted and good. - Weight 1: exactly one of the two gates has a non-identity 2-qubit Pauli. - Acceptance requires that single-pair error be in class (0,0), i.e., one of {XX,YY,ZZ}. Count per gate = 3 of the 15 possibilities; with two gates total, accepted singles = 2×3. - All such singles are good because {XX,YY,ZZ} stabilizes |Φ+⟩ on that pair. Probability contribution: 2·(p/15)·(1−p)·3 = (6/15)p(1−p). Accepted = good. - Weight 2: both gates have non-identity 2-qubit Paulis. - Acceptance requires parity match across pairs. Using the class counts above, total accepted ordered pairs = 3·3 + 4·4 + 4·4 + 4·4 = 9 + 16 + 16 + 16 = 57. - Good among these are exactly 3·3 = 9 (both in class (0,0)). Probability contribution: (p/15)^2 times the respective counts.

Therefore

\[ P_{\text{acc}}(p) &= (1-p)^2 + \frac{6}{15}p(1-p) + \frac{57}{15^2}p^2,\\ P_{\text{good}}(p) &= (1-p)^2 + \frac{6}{15}p(1-p) + \frac{9}{15^2}p^2. \]
  • Logical-state fidelity under post-selection

Conditioning on acceptance, the (normalized) post-selected state is a classical mixture over accepted Pauli-error images. The only terms with nonzero overlap with |ψideal⟩ are the “good” ones above; all other accepted terms are orthogonal (they are other Bell-product basis states). Hence the logical-state fidelity equals the good fraction of accepted shots:

\[ F_{\text{logical}}(p)=\frac{P_{\text{good}}(p)}{P_{\text{acc}}(p)}. \]

Plugging in and simplifying,

\[ F_{\text{logical}}(p) &= \frac{(1-p)^2 + \frac{6}{15}p(1-p) + \frac{9}{225}p^2} {(1-p)^2 + \frac{6}{15}p(1-p) + \frac{57}{225}p^2}\\[2mm] &= \frac{75 - 120p + 48p^2}{75 - 120p + 64p^2}. \]

Series at small p: \(F_{\text{logical}}(p)=1 - \frac{16}{75}p^2 + O(p^3)\), i.e., all single-gate errors are detected and discarded; logical infidelity appears only at order p^2.

2) Mathematical Typesetting

  • All key relations shown above in LaTeX.

3) Conventions and Units

  • Qubits labeled 0,1,2,3; stabilizers XXXX and ZZZZ; Bell-state facts (stabilizers XX, ZZ) and stabilizer-code detection rule (anticommute ⇒ detected) used as standard. (medium.com, learning.quantum.ibm.com)

4) Final Answer:

\[ F_{\text{logical}}(p)=\frac{75 - 120\,p + 48\,p^2}{75 - 120\,p + 64\,p^2}. \]

This satisfies Flogical(0)=1 and, to lowest order, 1−Flogical(p)=\tfrac{16}{75}p^2+O(p^3).

User #9

Checkpoint 3

Suppose that we prepare a logical two-qubit \(|00\rangle_{AB}\) state in the [[4,2,2]] code. To do so, we introduce an ancilla qubit, qubit 4, and use the following state preparation circuit:

\[ M_4 (CNOT_{04}) (CNOT_{34}) (CNOT_{23}) (CNOT_{10}) (CNOT_{12}) (H_1) \]

Note that this equation is written in matrix multiplication order, while the quantum operations in the circuit occur in the reverse order (from right-to-left in the above equation). \(H\) is a single-qubit Hadamard gate and \(M\) is a single-qubit measurement. The ancilla is used to detect errors in the state preparation circuit and makes the circuit fault-tolerant. If the ancilla measurement is \(|0\rangle\) (\(|1\rangle\)), the state preparation succeeds (fails).

What is the logical state fidelity of the final 2-qubit logical state at the end of the circuit as a function of two-qubit gate error rate \(p\), assuming the state is post-selected on all detectable errors in the code and on the ancilla qubit measuring \(|0\rangle\)?

Assistant #10
Tool Call (code to execute)
from itertools import product

# Pauli representation helpers
single_to_bits = {
    'I': (0,0),
    'X': (1,0),
    'Y': (1,1),
    'Z': (0,1),
}

bits_to_single = {(0,0):'I',(1,0):'X',(1,1):'Y',(0,1):'Z'}

# propagate Pauli (x,z) through CNOT(c->t): conjugation U P U^
# x,z are lists of 5 ints (0/1)
def propagate_through_cnot(x,z,c,t):
    # Copy to avoid in-place illusions
    x = x[:]
    z = z[:]
    # X on control propagates to target: x_t ^= x_c
    x[t] ^= x[c]
    # Z on target propagates to control: z[c] ^= z[t]
    z[c] ^= z[t]
    return x,z

# Build list of gates in time order (1..5): CNOT12, CNOT10, CNOT23, CNOT34, CNOT04
gates = [(1,2),(1,0),(2,3),(3,4),(0,4)]

# For each error location i in 0..4 (after gate i), subsequent gates indices are i+1..4

# 2-qubit Pauli alphabet for a pair
letters = ['I','X','Y','Z']
pair_paulis = [(a,b) for a in letters for b in letters]  # includes II

# Map 2-qubit Pauli on pair (c,t) to 5-qubit x,z

def pair_to_5bits(pair, c, t):
    x = [0]*5
    z = [0]*5
    a,b = pair
    xa,za = single_to_bits[a]
    xb,zb = single_to_bits[b]
    x[c]=xa; z[c]=za
    x[t]=xb; z[t]=zb
    return x,z

# Combine two Paulis in (x,z) rep: XOR sum

def combine(x1,z1,x2,z2):
    x = [(a^b) for a,b in zip(x1,x2)]
    z = [(a^b) for a,b in zip(z1,z2)]
    return x,z

# Evaluate acceptance and goodness

def accepted_and_good(x,z):
    # Ancilla acceptance: no X or Y on qubit 4 => x4==0
    anc_ok = (x[4]==0)
    # Code acceptance: commute with XXXX and ZZZZ on data 0..3
    # Commute with XXXX <=> even number of Z/Y on 0..3 => parity of z[0..3]==0
    # Commute with ZZZZ <=> even number of X/Y on 0..3 => parity of x[0..3]==0
    data_x_par = (x[0]^x[1]^x[2]^x[3])
    data_z_par = (z[0]^z[1]^z[2]^z[3])
    stab_ok = (data_x_par==0 and data_z_par==0)
    acc = anc_ok and stab_ok
    if not acc:
        return False, False
    # Goodness: within accepted, we require no logical X_A or X_B component
    # Determine a,b by commutation with Z_A=ZZII (on 0,1) and Z_B=ZIZI (on 0,2)
    a = (x[0]^x[1])  # anticommute with Z_A
    b = (x[0]^x[2])  # anticommute with Z_B
    good = (a==0 and b==0)
    return True, good

# Propagate a chosen pair Pauli at location i forward to end, return (x,z)

def forward_image_of_error_at_location(pair, loc):
    c,t = gates[loc]
    x,z = pair_to_5bits(pair, c, t)
    # propagate through subsequent gates
    for j in range(loc+1, len(gates)):
        cj,tj = gates[j]
        x,z = propagate_through_cnot(x,z,cj,tj)
    return x,z

# Precompute forward images for all locations and pair Paulis
forward_images = [[None]*len(pair_paulis) for _ in range(5)]
for i in range(5):
    for idx,pair in enumerate(pair_paulis):
        x,z = forward_image_of_error_at_location(pair, i)
        forward_images[i][idx] = (x,z)

# Enumerate all combinations across 5 locations
# For each location choose index 0..15; index 0 corresponds to II; non-identity others
from collections import defaultdict
counts_acc = [0]*6
counts_good = [0]*6
counts_total = [0]*6

# We'll also compute acceptance/goodness ignoring weight to verify sum counts

# iterate over all 16^5 ~ 1,048,576 combinations

choices = range(16)
for sel in product(choices, repeat=5):
    # Build final x,z by combining images for all 5 locations
    x = [0]*5
    z = [0]*5
    weight = 0
    for loc, idx in enumerate(sel):
        if idx!=0:
            weight += 1
            xi,zi = forward_images[loc][idx]
            x,z = combine(x,z,xi,zi)
    acc, good = accepted_and_good(x,z)
    counts_total[weight]+=1
    if acc:
        counts_acc[weight]+=1
        if good:
            counts_good[weight]+=1

counts_acc, counts_good, counts_total
Tool #11
''
Assistant #12
print('counts_total by weight k=0..5:', counts_total)
print('counts_acc by weight:', counts_acc)
print('counts_good by weight:', counts_good)
# sanity checks: total combos = 16^5
print('total combos=', sum(counts_total))
print('acc_total=', sum(counts_acc), 'good_total=', sum(counts_good))
Tool #13
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'counts_total' is not defined
Assistant #14
# Rerun enumeration carefully
from itertools import product

single_to_bits = {
    'I': (0,0),
    'X': (1,0),
    'Y': (1,1),
    'Z': (0,1),
}
letters=['I','X','Y','Z']
pair_paulis = [(a,b) for a in letters for b in letters]

def propagate_through_cnot(x,z,c,t):
    x = x[:]; z = z[:]
    x[t] ^= x[c]
    z[c] ^= z[t]
    return x,z

gates = [(1,2),(1,0),(2,3),(3,4),(0,4)]


def pair_to_5bits(pair, c, t):
    x=[0]*5; z=[0]*5
    a,b = pair
    xa,za = single_to_bits[a]
    xb,zb = single_to_bits[b]
    x[c]=xa; z[c]=za
    x[t]=xb; z[t]=zb
    return x,z


def accepted_and_good(x,z):
    anc_ok = (x[4]==0)
    data_x_par = x[0]^x[1]^x[2]^x[3]
    data_z_par = z[0]^z[1]^z[2]^z[3]
    stab_ok = (data_x_par==0 and data_z_par==0)
    acc = anc_ok and stab_ok
    if not acc:
        return False, False
    a = x[0]^x[1]
    b = x[0]^x[2]
    return True, (a==0 and b==0)


def forward_image_of_error_at_location(pair, loc):
    c,t = gates[loc]
    x,z = pair_to_5bits(pair, c, t)
    for j in range(loc+1, len(gates)):
        cj,tj = gates[j]
        x,z = propagate_through_cnot(x,z,cj,tj)
    return x,z

# precompute images
forward_images = [[None]*16 for _ in range(5)]
for i in range(5):
    for idx,pair in enumerate(pair_paulis):
        forward_images[i][idx] = forward_image_of_error_at_location(pair, i)

from collections import defaultdict
counts_total = [0]*6
counts_acc = [0]*6
counts_good = [0]*6

for sel in product(range(16), repeat=5):
    x=[0]*5; z=[0]*5
    weight=0
    for loc, idx in enumerate(sel):
        if idx!=0:
            weight+=1
            xi,zi = forward_images[loc][idx]
            x = [a^b for a,b in zip(x, xi)]
            z = [a^b for a,b in zip(z, zi)]
    acc,good = accepted_and_good(x,z)
    counts_total[weight]+=1
    if acc:
        counts_acc[weight]+=1
        if good:
            counts_good[weight]+=1

print('total combos =', sum(counts_total), 'should be', 16**5)
print('counts_total by weight:', counts_total)
print('counts_acc by weight:', counts_acc)
print('counts_good by weight:', counts_good)
Tool #15
total combos = 1048576 should be 1048576
counts_total by weight: [1, 75, 2250, 33750, 253125, 759375]
counts_acc by weight: [1, 7, 282, 4222, 31637, 94923]
counts_good by weight: [1, 7, 138, 1198, 7397, 24027]
Assistant #16
Tool Call (code to execute)
import sympy as sp
p=sp.symbols('p')
counts_acc=[1,7,282,4222,31637,94923]
counts_good=[1,7,138,1198,7397,24027]
# probability polynomials
Pacc=0
Pgood=0
for k,c in enumerate(counts_acc):
    Pacc += c*(p/15)**k*(1-p)**(5-k)
for k,c in enumerate(counts_good):
    Pgood += c*(p/15)**k*(1-p)**(5-k)
F = sp.simplify(sp.together(Pgood/Pacc))
print('F(p) =', F)
num,den = sp.together(F).as_numer_denom()
print('num degrees', sp.degree(num), 'den degrees', sp.degree(den))
print('num expanded =', sp.expand(num))
print('den expanded =', sp.expand(den))
Tool #17
F(p) = (229376*p**5 - 1116160*p**4 + 2198400*p**3 - 2214000*p**2 + 1147500*p - 253125)/(262144*p**5 - 1269760*p**4 + 2457600*p**3 - 2376000*p**2 + 1147500*p - 253125)
num degrees 5 den degrees 5
num expanded = 229376*p**5 - 1116160*p**4 + 2198400*p**3 - 2214000*p**2 + 1147500*p - 253125
den expanded = 262144*p**5 - 1269760*p**4 + 2457600*p**3 - 2376000*p**2 + 1147500*p - 253125
Assistant #18
Tool Call (code to execute)
import sympy as sp
p=sp.symbols('p')
F = (229376*p**5 - 1116160*p**4 + 2198400*p**3 - 2214000*p**2 + 1147500*p - 253125)/(262144*p**5 - 1269760*p**4 + 2457600*p**3 - 2376000*p**2 + 1147500*p - 253125)
print(sp.series(F, p, 0, 4))
Tool #19
1 - 16*p**2/25 - 704*p**3/375 + O(p**4)
Assistant #20
Tool Call (code to execute)
import sympy as sp
p=sp.symbols('p')
counts_acc=[1,7,282,4222,31637,94923]
Pacc=sum(counts_acc[k]*(p/15)**k*(1-p)**(5-k) for k in range(6))
print(sp.expand(Pacc))
print(sp.series(Pacc,p,0,4))
Tool #21
-262144*p**5/253125 + 253952*p**4/50625 - 32768*p**3/3375 + 704*p**2/75 - 68*p/15 + 1
1 - 68*p/15 + 704*p**2/75 - 32768*p**3/3375 + O(p**4)
Assistant #22
Tool Call (code to execute)
import sympy as sp
p=sp.symbols('p')
F = (229376*p**5 - 1116160*p**4 + 2198400*p**3 - 2214000*p**2 + 1147500*p - 253125)/(262144*p**5 - 1269760*p**4 + 2457600*p**3 - 2376000*p**2 + 1147500*p - 253125)
print('F(0)=', float(F.subs(p,0)))
print('F(1)=', float(F.subs(p,1)))
Tool #23
F(0)= 1.0
F(1)= 0.25312095066527607
Assistant #24

1) Step-by-Step Derivation

  • Circuit, code and target

  • [[4,2,2]] code stabilizers: S = ⟨XXXX, ZZZZ⟩ on data qubits 0–3. A standard logical basis is $ {|\overline{00}\rangle,|\overline{01}\rangle,|\overline{10}\rangle,|\overline{11}\rangle} = \left{ \tfrac{|0000\rangle+|1111\rangle}{\sqrt2}, \tfrac{|0011\rangle+|1100\rangle}{\sqrt2}, \tfrac{|0101\rangle+|1010\rangle}{\sqrt2}, \tfrac{|0110\rangle+|1001\rangle}{\sqrt2} \right}. $ Hence \(|\overline{00}\rangle=(|0000\rangle+|1111\rangle)/\sqrt2\) and is stabilized by XXXX and ZZZZ. (errorcorrectionzoo.org, ar5iv.labs.arxiv.org)

  • Logical Pauli representatives (as given in the problem): \(X_A=X I X I\), \(X_B=X X I I\), \(Z_A=Z Z I I\), \(Z_B=Z I Z I\).
  • Circuit (right-to-left): \(H_1 \to \mathrm{CNOT}_{12}\to \mathrm{CNOT}_{10}\to \mathrm{CNOT}_{23}\to \mathrm{CNOT}_{34}\to \mathrm{CNOT}_{04}\to M_4\). Acting on \(|0000\rangle_{0..3}|0\rangle_4\), the first four gates prepare \(|\overline{00}\rangle\) on data (a 4-qubit GHZ). The two CNOTs to the ancilla compute the X-parity of data qubits 0 and 3 into the ancilla; on the ideal GHZ the ancilla is \(|0\rangle\). (en.wikipedia.org)

  • Noise model and acceptance

  • After each two-qubit gate, an independent two-qubit depolarizing channel acts on the same two qubits: with probability \(p\) a uniformly random non-identity two-qubit Pauli (15 choices) is applied, and with probability \(1-p\) the identity acts. (algassert.com)

  • We post-select on: (i) code checks pass (no syndrome) and (ii) ancilla outcome \(0\). In stabilizer language, a Pauli error \(E\) on the data is accepted by code checks iff it commutes with XXXX and ZZZZ. Ancilla acceptance in this circuit is equivalent to having no \(X\)-support on qubit 4 at the end (otherwise the final \(Z\)-basis readout flips). These are standard stabilizer/Heisenberg facts; we use Pauli propagation through CNOT in the Heisenberg picture. (ar5iv.labs.arxiv.org, arxiv.org)

  • Heisenberg propagation rules we use (conjugation by CNOT with control c and target t): $ X_c\mapsto X_c X_t,\quad Z_t\mapsto Z_c Z_t,\quad X_t\mapsto X_t,\quad Z_c\mapsto Z_c. $ We encode Paulis by binary “symplectic” \((\boldsymbol{x}|\boldsymbol{z})\) vectors and update with the linear rules $ x_t\leftarrow x_t\oplus x_c,\quad z_c\leftarrow z_c\oplus z_t, $ leaving other bits unchanged. (arxiv.org)

  • What counts as a “good” accepted event?

Let \(E_{\mathrm{fin}}\) be the final Pauli on qubits 0–4 after pushing each fault forward through the remaining gates (Heisenberg). Condition on acceptance: 1) Code acceptance ⇔ parity constraints on data bits: $ \sum_{i=0}^3 x_i\equiv 0\pmod 2,\qquad \sum_{i=0}^3 z_i\equiv 0\pmod 2, $ i.e., \(E_{\mathrm{fin}}\) commutes with XXXX and ZZZZ. (ar5iv.labs.arxiv.org) 2) Ancilla acceptance ⇔ \(x_4=0\) (no \(X/Y\) on qubit 4).

Among accepted events, the logical state equals the target \(|\overline{00}\rangle\) iff the logical \(X\) exponents vanish. Equivalently, \(E_{\mathrm{fin}}\) must commute with both logical \(Z\)’s \(Z_A=ZZII\) and \(Z_B=ZIZI\) (so that no \(X_A\) or \(X_B\) component is present). In symplectic bits this is the pair of constraints $ a = x_0\oplus x_1=0,\qquad b=x_0\oplus x_2=0. $ Any residual \(Z_A\)/\(Z_B\) and/or stabilizer factors are harmless on \(|\overline{00}\rangle\). (ar5iv.labs.arxiv.org)

  • Exact combinatorial enumeration (Clifford–Pauli method)

There are five noisy CNOT locations. At each location the fault is one of 16 two-qubit Paulis (II or one of the 15 non-identity). We enumerated all \(16^5\) fault patterns, propagated each to the end using the CNOT rules above, and tallied: - the Hamming weight \(k\) (number of non-identity faults), - whether it is accepted (both code checks pass and ancilla is 0), - whether, conditioned on acceptance, it is “good” (leaves \(|\overline{00}\rangle\) unchanged up to stabilizers and logical \(Z\)’s).

Let \(c_{\text{acc}}(k)\) and \(c_{\text{good}}(k)\) be the counts by weight \(k\). The exhaustive symplectic enumeration gives $ \begin{aligned} &(c_{\text{acc}}(0),c_{\text{acc}}(1),c_{\text{acc}}(2),c_{\text{acc}}(3),c_{\text{acc}}(4),c_{\text{acc}}(5))\ &\qquad= (1,\,7,\,282,\,4222,\,31637,\,94923),\ &(c_{\text{good}}(0),c_{\text{good}}(1),c_{\text{good}}(2),c_{\text{good}}(3),c_{\text{good}}(4),c_{\text{good}}(5))\ &\qquad= (1,\,7,\,138,\,1198,\,7397,\,24027). \end{aligned} $ In particular, all accepted single-fault events are benign (no logical error), i.e., \(c_{\text{acc}}(1)=c_{\text{good}}(1)=7\) (fault tolerance to first order).

  • From counts to probabilities and fidelity

Each specific pattern with weight \(k\) occurs with probability \((p/15)^k(1-p)^{5-k}\). Therefore $ \begin{aligned} P_{\text{acc}}(p) &=\sum_{k=0}^{5} c_{\text{acc}}(k)\,\Big(\tfrac{p}{15}\Big)^k(1-p)^{5-k},\ P_{\text{good}}(p) &=\sum_{k=0}^{5} c_{\text{good}}(k)\,\Big(\tfrac{p}{15}\Big)^k(1-p)^{5-k}. \end{aligned} $ The post-selected logical-state fidelity is the good fraction of accepted runs: $ F_{\text{logical}}(p)=\dfrac{P_{\text{good}}(p)}{P_{\text{acc}}(p)}. $

Simplifying the ratio yields the exact closed form $ \boxed{\ F_{\text{logical}}(p) = \frac{229376\,p^{5}-1116160\,p^{4}+2198400\,p^{3}-2214000\,p^{2}+1147500\,p-253125} {262144\,p^{5}-1269760\,p^{4}+2457600\,p^{3}-2376000\,p^{2}+1147500\,p-253125}\ . } $ Small-\(p\) expansion: $ F_{\text{logical}}(p)=1-\frac{16}{25}p^{2}-\frac{704}{375}p^{3}+O(p^{4}), $ consistent with first-order fault tolerance (no \(p\) term). The stabilizer/Heisenberg manipulations used here are standard. (arxiv.org, ar5iv.labs.arxiv.org)

2) Mathematical Typesetting

  • Key algebra and the final expression are presented above in LaTeX.
  • Pauli propagation rules and stabilizer-commutation parity tests are used explicitly. (arxiv.org)

3) Conventions and Units

  • Qubits are labeled 0–3 (data) and 4 (ancilla).
  • Stabilizers are XXXX and ZZZZ; logical operators as given in the problem.
  • CNOT control-target convention and action are standard. (en.wikipedia.org)

4) Final Answer: $ F_{\text{logical}}(p) = \frac{229376\,p^{5}-1116160\,p^{4}+2198400\,p^{3}-2214000\,p^{2}+1147500\,p-253125} {262144\,p^{5}-1269760\,p^{4}+2457600\,p^{3}-2376000\,p^{2}+1147500\,p-253125}. $

User #25

Populate your final answer into the code template provided below. This step is purely for formatting/display purposes. No additional reasoning or derivation should be performed. Do not import any modules or packages beyond what is provided in the template.

import sympy as sp

p = sp.symbols('p')

def answer(p):
    r"""
    Return the expression of the logical state fidelity of the final 2-qubit logical state
    at the end of the circuit as a function of two-qubit gate error rate $p$.

    Inputs
    ----------
    p: sympy.Symbol, two-qubit gate error rate, $p$

    Outputs
    ----------
    F_logical: sympy.Expr, logical state fidelity of the final 2-qubit logical state
    """

    # ------------------ FILL IN YOUR RESULTS BELOW ------------------
    F_logical = ...  # a SymPy expression of inputs
    # ---------------------------------------------------------------

    return F_logical
Assistant #26
import sympy as sp

p = sp.symbols('p')

def answer(p):
    r"""
    Return the expression of the logical state fidelity of the final 2-qubit logical state
    at the end of the circuit as a function of two-qubit gate error rate $p$.

    Inputs
    ----------
    p: sympy.Symbol, two-qubit gate error rate, $p$

    Outputs
    ----------
    F_logical: sympy.Expr, logical state fidelity of the final 2-qubit logical state
    """

    # ------------------ FILL IN YOUR RESULTS BELOW ------------------
    F_logical = (229376*p**5 - 1116160*p**4 + 2198400*p**3 - 2214000*p**2 + 1147500*p - 253125) / (262144*p**5 - 1269760*p**4 + 2457600*p**3 - 2376000*p**2 + 1147500*p - 253125)
    # ---------------------------------------------------------------

    return F_logical