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
  • Circuit and noise model
  • Circuit (right-to-left): H2 → CNOT21 → H0 → CNOT03. Only the two CNOTs are noisy. Each CNOT is followed by a 2-qubit depolarizing channel acting on its two qubits that applies one of the 15 non-identity 2-qubit Paulis with probability p/15 (and identity with probability 1 − p).
  • State fidelity with a pure target |ψ⟩ is F = ⟨ψ|ρ|ψ⟩, where ρ is the actual (mixed) output state. This follows from the standard fidelity definition specialized to a pure state. (docs.quantum.ibm.com)

  • Ideal (noiseless) output state

  • The pair (2,1) after H2–CNOT21 is a Bell state |Φ+⟩ = (|00⟩+|11⟩)/√2. Likewise, the pair (0,3) after H0–CNOT03 is another |Φ+⟩. Hence the final 4-qubit ideal state factorizes as
\[ |\psi_{\text{ideal}}\rangle = |\Phi^+\rangle_{03}\otimes|\Phi^+\rangle_{12}. \]
The fact that H on the control followed by CX prepares |Φ+⟩ and that |Φ+⟩ is stabilized by XX and ZZ is standard (and shown explicitly in the cited example). ([docs.quantum.ibm.com](https://docs.quantum.ibm.com/api/qiskit/qiskit.quantum_info.StabilizerState?utm_source=openai), [qubit.guide](https://qubit.guide/7.2-pauli-stabilisers.html?utm_source=openai))
  • Stabilizer facts we will use
  • For any stabilizer state |ψ⟩ and any Pauli P, ⟨ψ|P|ψ⟩ = 0 unless P ∈ ±Stab(|ψ⟩), in which case ⟨ψ|P|ψ⟩ = ±1. (arxiv.org)
  • For |Φ+⟩, a generating set of stabilizers is {XX, ZZ}; their product gives −YY, so the non-identity Paulis with |⟨Φ+|P|Φ+⟩| = 1 are exactly {XX, ZZ, YY}. (qubit.guide)

  • One noisy CNOT (single pair) contribution

  • Consider one Bell pair (say qubits 1–2). The 2-qubit depolarizing channel selects:
    • Identity with probability 1 − p (fidelity contribution = 1).
    • A non-identity two-qubit Pauli with probability p/15. Among the 15 possibilities, exactly 3 (XX, ZZ, YY) satisfy |⟨Φ+|P|Φ+⟩|^2 = 1; the other 12 give 0.
  • Therefore the fidelity for a single Bell pair after one noisy CNOT is
\[ F_{\text{pair}}(p) = (1-p)\cdot 1 + \frac{p}{15}\cdot 3\cdot 1 = 1 - \frac{4p}{5}. \]
  • Two independent noisy CNOTs on disjoint pairs
  • The overall ideal state factorizes as |ψideal⟩ = |Φ+⟩03 ⊗ |Φ+⟩12, and the noise acts independently on the two disjoint pairs. Fidelity for product states factorizes:
\[ F\big(\rho_1\!\otimes\!\rho_2,\sigma_1\!\otimes\!\sigma_2\big) = F(\rho_1,\sigma_1)\,F(\rho_2,\sigma_2). \]
Hence the total fidelity equals the product of the two single-pair fidelities, i.e.,
\[ F_{\text{total}}(p) = \big[F_{\text{pair}}(p)\big]^2 = \left(1-\frac{4p}{5}\right)^2. \]
([eu-de.quantum.cloud.ibm.com](https://eu-de.quantum.cloud.ibm.com/learning/courses/general-formulation-of-quantum-information/purifications-and-fidelity/fidelity?utm_source=openai))
  • Direct counting cross-check (same result)
  • Expanding the product gives
\[ \]
which is identical to (1 − 4p/5)^2.
  • Interpretation: the three “good” Pauli errors per pair (XX, ZZ, YY) preserve the corresponding Bell state up to a phase (hence unit overlap magnitude); all other single- or weight-2 Paulis are orthogonal in expectation and do not contribute to fidelity. (arxiv.org, qubit.guide)
  1. Mathematical Typesetting

All equations provided above use LaTeX.

  1. Conventions and Units
  • Qubits ordered as (0,1,2,3); pairs affected by noisy CNOTs are (2,1) and (0,3).
  • Fidelity is dimensionless.
  1. Final Answer:
\[ F_{\text{physical}}(p) = \left(1 - \frac{4p}{5}\right)^2 = 1 - \frac{8}{5}\,p + \frac{16}{25}\,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
  1. Step-by-Step Derivation
  • Circuit, target, and noise model
  • Circuit (right-to-left): H2 → CNOT21 → H0 → CNOT03. Only the two CNOTs are noisy, each followed by a two-qubit depolarizing channel that applies one of the 15 non-identity two-qubit Paulis with probability p/15 (identity with probability 1 − p). The fidelity with a pure target |ψ⟩ is F = ⟨ψ|ρ|ψ⟩. The “Bell-state from H+CNOT” fact will be used below. (en.wikipedia.org)
  • The [[4,2,2]] code has stabilizers {XXXX, ZZZZ}. We will post-select on the +1 outcomes of both, i.e., accept no detectable errors. (errorcorrectionzoo.org)

  • Ideal (noiseless) output state and its relation to the code

  • H2–CNOT21 prepares a Bell pair |Φ+⟩ on qubits (2,1), and H0–CNOT03 prepares |Φ+⟩ on qubits (0,3). Hence the ideal four-qubit state is
\[ |\Psi_{\rm ideal}\rangle=|\Phi^+\rangle_{03}\otimes|\Phi^+\rangle_{12}. \]
Each Bell pair |Φ+⟩ is stabilized by XX and ZZ; therefore the product state is stabilized by XXXX and ZZZZ and lies in the [[4,2,2]] codespace. ([en.wikipedia.org](https://en.wikipedia.org/wiki/Bell_state?utm_source=openai), [learning.quantum.ibm.com](https://learning.quantum.ibm.com/course/foundations-of-quantum-error-correction/the-stabilizer-formalism?utm_source=openai))
  • How Pauli errors act on a Bell pair
  • The Bell state |Φ+⟩ on a given pair is stabilized by the group ⟨X⊗X, Z⊗Z⟩ = {I⊗I, X⊗X, Z⊗Z, −Y⊗Y}. Conjugating |Φ+⟩ by any of these leaves it invariant (up to a phase); the other three cosets of this group map |Φ+⟩ to the other three Bell states. Thus, after a single two-qubit depolarizing channel:

    • P(Φ+) = (1 − p) + 3·(p/15) = 1 − 4p/5,
    • P(Φ−) = P(Ψ+) = P(Ψ−) = 4p/15. This uses that two-qubit Paulis partition into four size-4 cosets of the Bell stabilizer, with exactly three non-identity elements in the stabilizer coset. (learning.quantum.ibm.com)
  • What “no detectable error” means for this preparation

  • The code stabilizers factor as XXXX = (XX)03 ⊗ (XX)12 and ZZZZ = (ZZ)03 ⊗ (ZZ)12. Measuring XXXX (ZZZZ) on the product of two Bell pairs returns the product of the XX (ZZ) eigenvalues of the two pairs. Consequently, the post-selection “+1 for XXXX and ZZZZ” accepts exactly those outcomes where the two pairs land in the same Bell state (Φ+ with Φ+, or Φ− with Φ−, or Ψ+ with Ψ+, or Ψ− with Ψ−). This follows from standard Pauli-commutation/syndrome logic for stabilizer codes. (errorcorrectionzoo.org, learning.quantum.ibm.com)

  • Logical state given acceptance and the resulting logical fidelity

  • Upon acceptance, the logical two-qubit state (A,B) is the Bell state corresponding to the common Bell type of the physical pairs (since the logical observables X_A X_B ≡ IXXI and Z_A Z_B ≡ IZZI act on the 12 pair). Therefore, the logical fidelity with the target logical Bell |Φ+⟩_{AB} equals the conditional probability that both physical pairs are Φ+.
  • Let a ≡ 1 − 4p/5 and b ≡ 4p/15. For the two independent pairs:
    • P(accept) = a^2 + 3 b^2,
    • P(both Φ+) = a^2.
  • Hence the post-selected logical fidelity is
\[ =\frac{(1-\tfrac{4p}{5})^2}{(1-\tfrac{4p}{5})^2+3(\tfrac{4p}{15})^2} \]
Small‑p expansion: $F_{\rm logical}(p)=1-\tfrac{16}{75}p^2+O(p^3)$, i.e., logical errors are second order once all detectable errors are discarded. (Uses independence of the two noisy CNOTs and the Bell‑stabilizer eigenvalue table.) ([en.wikipedia.org](https://en.wikipedia.org/wiki/Bell_state?utm_source=openai), [learning.quantum.ibm.com](https://learning.quantum.ibm.com/course/foundations-of-quantum-error-correction/the-stabilizer-formalism?utm_source=openai))
  1. Mathematical Typesetting

All mathematics is typeset in LaTeX above.

  1. Conventions and Units
  • Qubit order (0,1,2,3). Pairs (0,3) and (1,2).
  • Fidelity is dimensionless.
  1. Final Answer:
\[ \]
User #5

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 #6
Tool Call (code to execute)
import itertools
from collections import defaultdict

# Define single-qubit Pauli multiplication ignoring overall phase
mult = {
    ('I','I'):'I', ('I','X'):'X', ('I','Y'):'Y', ('I','Z'):'Z',
    ('X','I'):'X', ('X','X'):'I', ('X','Y'):'Z', ('X','Z'):'Y',
    ('Y','I'):'Y', ('Y','X'):'Z', ('Y','Y'):'I', ('Y','Z'):'X',
    ('Z','I'):'Z', ('Z','X'):'Y', ('Z','Y'):'X', ('Z','Z'):'I'
}

# Pauli letters
paulis = ['I','X','Y','Z']
# Multiplication on strings (ignoring global phase)
def mult_strings(a,b):
    return [mult[(x,y)] for x,y in zip(a,b)]

# Conjugation of a 5-qubit Pauli string through a CNOT (control c, target t)
# Returns new string after P' = CNOT P CNOT^

def conj_cnot(P, c, t):
    P = P.copy()
    Lc, Lt = P[c], P[t]
    # If control has X or Y, multiply X onto target
    if Lc in ('X','Y'):
        # Lt := Lt * X
        Lt = mult[(Lt,'X')]
    # If target has Z or Y, multiply Z onto control
    if Lt in ('Z','Y'):
        # BUT careful: above we updated Lt; in conjugation rules, the effect of target->control should use original Lt
        pass
    # To implement correctly, we should use original letters before any update

# Let's implement properly: use originals

def conj_cnot(P, c, t):
    P = P.copy()
    Lc0, Lt0 = P[c], P[t]
    # Apply target->control update based on original target
    if Lt0 in ('Z','Y'):
        P[c] = mult[(P[c],'Z')]
    # Apply control->target update based on original control
    if Lc0 in ('X','Y'):
        P[t] = mult[(P[t],'X')]
    # The letters on c and t themselves remain the same otherwise (we already updated them via multiplications)
    return P

# Build list of 2-qubit Paulis for a given pair (i,j)
# We'll include identity as well

pair_paulis = [(a,b) for a in paulis for b in paulis]

# Locations after CNOTs: order of noisy locations with the pair of qubits for the CNOT at that step
# Gates (right to left sequence): H1, CNOT12, CNOT10, CNOT23, CNOT34, CNOT04
# Noises after each CNOT in that order: after CNOT12 (loc0), after CNOT10 (loc1), after CNOT23 (loc2), after CNOT34 (loc3), after CNOT04 (loc4)
noisy_pairs = [(1,2),(1,0),(2,3),(3,4),(0,4)]

# Subsequent CNOTs after each location
subseqs = {
    0: [(1,0),(2,3),(3,4),(0,4)],  # after first CNOT12
    1: [(2,3),(3,4),(0,4)],
    2: [(3,4),(0,4)],
    3: [(0,4)],
    4: []
}

# Precompute mapping from each location and each 2-qubit Pauli on its pair to the 5-qubit Pauli at the end of circuit (conjugated forward)
# Represent 5-qubit Pauli string as list of 5 letters

end_maps = []
for loc, (i,j) in enumerate(noisy_pairs):
    m = []
    # Iterate over 2-qubit (including identity)
    for a,b in pair_paulis:
        P = ['I']*5
        P[i] = a
        P[j] = b
        # Conjugate through all subsequent CNOTs
        for (c,t) in subseqs[loc]:
            P = conj_cnot(P, c, t)
        m.append(tuple(P))
    end_maps.append(m)

# Now set up codewords on qubits 0-3
import numpy as np

# Basis states map index->bitstring of length4
basis_states = [tuple(((i>>k)&1) for k in (3,2,1,0)) for i in range(16)]
# Build vectors for codewords over C^16

vecs = {}
# |overline{00}> = (|0000>+|1111>)/sqrt2
v00 = np.zeros(16, dtype=complex)
# index for |0000> is 0; for |1111> is 15
v00[0] = 1/np.sqrt(2)
v00[15] = 1/np.sqrt(2)
vecs['00'] = v00
# 01: (|0011> + |1100>)/sqrt2  -> indices for |0011>= 3, |1100>=12
v01 = np.zeros(16, dtype=complex)
v01[3] = 1/np.sqrt(2)
v01[12] = 1/np.sqrt(2)
vecs['01'] = v01
# 10: (|0101> + |1010>)/sqrt2 -> indices 5 and 10
v10 = np.zeros(16, dtype=complex)
v10[5] = 1/np.sqrt(2)
v10[10] = 1/np.sqrt(2)
vecs['10'] = v10
# 11: (|0110> + |1001>)/sqrt2 -> indices 6 and 9
v11 = np.zeros(16, dtype=complex)
v11[6] = 1/np.sqrt(2)
v11[9] = 1/np.sqrt(2)
vecs['11'] = v11

# Function: apply 4-qubit Pauli string (on qubits 0..3) to |0000> and |1111> basis to get resulting vector s'

def apply_pauli_to_basis(bits, letters):
    # bits: tuple of 4 bits
    phase = 1+0j
    new_bits = list(bits)
    for q in range(4):
        b = new_bits[q]
        L = letters[q]
        if L=='I':
            pass
        elif L=='X':
            new_bits[q] = 1-b
        elif L=='Z':
            if b==1:
                phase *= -1
        elif L=='Y':
            # Y|0> = i|1>, Y|1> = -i|0>
            if b==0:
                phase *= 1j
                new_bits[q] = 1
            else:
                phase *= -1j
                new_bits[q] = 0
        else:
            raise ValueError
    return tuple(new_bits), phase

# Build a cache mapping 4-letter Pauli to resulting vector when applied to v00 (GHZ) to avoid recomputation

pauli4_letters = list(itertools.product(paulis, repeat=4))
pauli4_to_state = {}
for letters in pauli4_letters:
    # Apply to |0000> and |1111>
    b0, p0 = apply_pauli_to_basis((0,0,0,0), letters)
    b1, p1 = apply_pauli_to_basis((1,1,1,1), letters)
    v = np.zeros(16, dtype=complex)
    idx0 = (b0[0]<<3)|(b0[1]<<2)|(b0[2]<<1)|b0[3]
    idx1 = (b1[0]<<3)|(b1[1]<<2)|(b1[2]<<1)|b1[3]
    v[idx0] += p0/np.sqrt(2)
    v[idx1] += p1/np.sqrt(2)
    pauli4_to_state[letters] = v

# Function to check which codeword state equals a given state vector (up to global phase). Returns key '00','01','10','11' or None

def which_codeword(v):
    # Compute overlaps squared
    overlaps = {k: abs(np.vdot(vecs[k], v))**2 for k in vecs}
    # Find max
    kmax = max(overlaps, key=lambda k: overlaps[k])
    if abs(overlaps[kmax]-1.0) < 1e-12:
        return kmax
    else:
        return None

# Check acceptance conditions helper

def accept_conditions(P_end):
    # P_end is 5-letter tuple
    # Ancilla acceptance: letter 4 in {I,Z}
    if P_end[4] not in ('I','Z'):
        return False
    # Code stabilizer acceptance: commute with XXXX and ZZZZ
    letters = P_end[:4]
    # Parity of Z or Y must be even (commute with XXXX)
    count_ZY = sum(1 for L in letters if L in ('Z','Y'))
    if count_ZY % 2 != 0:
        return False
    # Parity of X or Y must be even (commute with ZZZZ)
    count_XY = sum(1 for L in letters if L in ('X','Y'))
    if count_XY % 2 != 0:
        return False
    return True

# Enumerate all patterns (16^5). For each, compute total end Pauli and classify

counts_accept_by_k = defaultdict(int)
counts_correct_by_k = defaultdict(int)

# Precompute end_maps again to ensure correct indexing order per location from 0..4
# end_maps[loc][pidx] gives 5-letter tuple

# We'll iterate pidx per location over 0..15 correspond to pair_paulis order

# Precompute total number patterns for sanity check
n_total = 16**5

# Let's loop
for p0 in range(16):
    P0 = end_maps[0][p0]
    for p1 in range(16):
        # Multiply P0 and P1
        P01 = tuple(mult[(x,y)] for x,y in zip(P0, end_maps[1][p1]))
        for p2 in range(16):
            P012 = tuple(mult[(x,y)] for x,y in zip(P01, end_maps[2][p2]))
            for p3 in range(16):
                P0123 = tuple(mult[(x,y)] for x,y in zip(P012, end_maps[3][p3]))
                for p4 in range(16):
                    Pend = tuple(mult[(x,y)] for x,y in zip(P0123, end_maps[4][p4]))
                    # Count number of non-identity applied across the 5 locations
                    k = (p0!=0) + (p1!=0) + (p2!=0) + (p3!=0) + (p4!=0)
                    if accept_conditions(Pend):
                        counts_accept_by_k[k] += 1
                        # Determine whether logical state is |00>
                        letters4 = Pend[:4]
                        v = pauli4_to_state[letters4]
                        which = which_codeword(v)
                        if which == '00':
                            counts_correct_by_k[k] += 1

# Produce counts
counts_accept = [counts_accept_by_k[k] for k in range(6)]
counts_correct = [counts_correct_by_k[k] for k in range(6)]
print('Total patterns:', n_total)
print('Accepted counts by k=0..5:', counts_accept)
print('Correct counts by k=0..5:', counts_correct)
# Sanity: all counts should be integers and <= 16^5

# For small-p expansion, compute coefficients of P_acc and P_corr polynomials: sum_k counts * (1-p)^{5-k} * (p/15)^k

from fractions import Fraction

# We can produce expanded polynomials with rational coefficients
import sympy as sp
p = sp.symbols('p')
Pacc = 0
Pcorr = 0
for k in range(6):
    cA = counts_accept_by_k.get(k,0)
    cC = counts_correct_by_k.get(k,0)
    term = (sp.Integer(cA)) * (1-p)**(5-k) * (p/15)**k
    Pacc += term
    termC = (sp.Integer(cC)) * (1-p)**(5-k) * (p/15)**k
    Pcorr += termC

# Simplify and express as rational polynomials
Pacc_simpl = sp.simplify(sp.together(Pacc))
Pcorr_simpl = sp.simplify(sp.together(Pcorr))
print('P_acc(p) =', sp.simplify(Pacc_simpl))
print('P_corr(p) =', sp.simplify(Pcorr_simpl))
F = sp.simplify(sp.together(Pcorr_simpl / Pacc_simpl))
print('F_logical(p) =', F)
# Series expansion around p=0 up to p^3
print('Series F_logical:', sp.series(F, p, 0, 4))
Tool #7
Total patterns: 1048576
Accepted counts by k=0..5: [1, 7, 282, 4222, 31637, 94923]
Correct counts by k=0..5: [1, 7, 138, 1198, 7397, 24027]
P_acc(p) = -262144*p**5/253125 + 253952*p**4/50625 - 32768*p**3/3375 + 704*p**2/75 - 68*p/15 + 1
P_corr(p) = -229376*p**5/253125 + 223232*p**4/50625 - 29312*p**3/3375 + 656*p**2/75 - 68*p/15 + 1
F_logical(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)
Series F_logical: 1 - 16*p**2/25 - 704*p**3/375 + O(p**4)
Assistant #8
  1. Step-by-Step Derivation
  • Circuit, target state, and noise model
  • Circuit (right-to-left): H1 → CNOT12 → CNOT10 → CNOT23 → CNOT34 → CNOT04. The five CNOTs are the only noisy gates. Each is followed by an independent two‑qubit depolarizing channel that applies one of the 15 non‑identity two‑qubit Paulis with probability p/15 (identity with probability 1−p).
  • The ideal final 4‑qubit code state (qubits 0–3) prepared by this circuit is the [[4,2,2]] logical |00⟩:
\[ \big|\overline{00}\big\rangle=\frac{|0000\rangle+|1111\rangle}{\sqrt{2}}, \]
with the ancilla (qubit 4) ideally in |0⟩. The four logical basis states of the [[4,2,2]] code are
\[ \big|\overline{00}\big\rangle&=\tfrac{1}{\sqrt{2}}(|0000\rangle+|1111\rangle),\\ \big|\overline{10}\big\rangle&=\tfrac{1}{\sqrt{2}}(|0101\rangle+|1010\rangle),\\ \big|\overline{01}\big\rangle&=\tfrac{1}{\sqrt{2}}(|0011\rangle+|1100\rangle),\\ \big|\overline{11}\big\rangle&=\tfrac{1}{\sqrt{2}}(|0110\rangle+|1001\rangle). \]
We will postselect on: (i) both code stabilizers XXXX and ZZZZ measuring +1; and (ii) the ancilla measurement outcome |0. These conditions reject all detectable errors. The above logical basis and stabilizerpostselection principle follow from standard stabilizercode facts. ([arxiv.org](https://arxiv.org/html/2405.03032v1?utm_source=openai), [learning.quantum.ibm.com](https://learning.quantum.ibm.com/course/foundations-of-quantum-error-correction/the-stabilizer-formalism?utm_source=openai))
  • Push all Pauli errors to the end (Clifford conjugation)
  • Each CNOT is a Clifford gate; hence conjugation maps any Pauli error to another Pauli on the same qubits (possibly spreading between the two involved qubits). Specifically, for a CNOT with control c and target t, the Heisenberg‑action on Paulis is
\[ X_c\mapsto X_cX_t,\quad Z_t\mapsto Z_cZ_t,\quad Z_c\mapsto Z_c,\quad X_t\mapsto X_t, \]
with the remaining single‑qubit Pauli letters updated accordingly (Y up to a phase). Therefore, an error inserted after any CNOT can be conjugated forward through all later CNOTs to yield an equivalent single 5‑qubit Pauli at the circuit end; the total error is the product (up to a global phase) of these pushed‑forward Paulis. ([zxcalc.github.io](https://zxcalc.github.io/book/html/main_htmlch6.html?utm_source=openai))
  • Acceptance (post‑selection) conditions from stabilizer theory
  • A Pauli error P_code on the data (qubits 0–3) passes the stabilizer checks iff it commutes with both XXXX and ZZZZ; otherwise it flips at least one syndrome bit and is detected. Equivalently, letting P_code = P_0⊗P_1⊗P_2⊗P_3,
    • commute with XXXX ⇔ the number of letters among {Z,Y} in {P_0,P_1,P_2,P_3} is even;
    • commute with ZZZZ ⇔ the number of letters among {X,Y} is even. These are the standard commutation rules of Paulis with stabilizers. (learning.quantum.ibm.com)
  • For the ancilla (initially |0⟩ and never entangled at the end because pushed‑forward errors are tensor‑product Paulis), the measurement outputs 0 iff its local Pauli letter is I or Z; letters X or Y flip it to |1⟩ and are rejected by the flag measurement.

  • Logical state after acceptance

  • If a pushed‑forward error E_end = P_code ⊗ P_anc is accepted, then P_code commutes with XXXX and ZZZZ, hence maps the codespace to itself. Among such Paulis, those in the stabilizer or multiplied by any logical Z (Z_A, Z_B) act trivially on |overline{00}⟩, whereas any logical X (X_A or X_B) flips the logical state. Thus, the accepted state is logically correct iff the equivalence class of P_code modulo the stabilizer contains only logical Zs (no logical X). This is the usual “centralizer vs stabilizer” distinction. (en.wikipedia.org)

  • Exhaustive counting over all error patterns

  • Method. Using the above CNOT‑conjugation rules, we enumerated all 16^5 Pauli‑error patterns (16 options per noisy CNOT: identity + 15 non‑identity), pushed each to the end of the circuit, checked the two acceptance conditions (stabilizers + ancilla), and—when accepted—determined the resulting logical codeword by acting on |overline{00}⟩ and comparing with the four logical basis states quoted above. This yields, for patterns with exactly k non‑identity errors (k=0,…,5), the integer counts:
    • accepted patterns: [1, 7, 282, 4222, 31637, 94923],
    • accepted and logically correct: [1, 7, 138, 1198, 7397, 24027].
  • From independence of the noise at each CNOT, a pattern with k non‑identity errors occurs with probability (1−p)^{5−k}(p/15)^k. Therefore
\[ P_{\rm acc}(p)&=\sum_{k=0}^5 A_k\,(1-p)^{5-k}\Big(\tfrac{p}{15}\Big)^k,\\ P_{\rm corr}(p)&=\sum_{k=0}^5 C_k\,(1-p)^{5-k}\Big(\tfrac{p}{15}\Big)^k, \]
with A_k and C_k the above counts. The post‑selected logical fidelity is the conditional probability of being in |overline{00}⟩ given acceptance:
\[ F_{\rm logical}(p)=\frac{P_{\rm corr}(p)}{P_{\rm acc}(p)}. \]
  • Closed forms (expanded and simplified)
  • Acceptance and correct‑state probabilities:
\[ P_{\rm acc}(p) &= 1-\frac{68}{15}p+\frac{704}{75}p^2-\frac{32768}{3375}p^3+\frac{253952}{50625}p^4-\frac{262144}{253125}p^5,\\[4pt] P_{\rm corr}(p) &= 1-\frac{68}{15}p+\frac{656}{75}p^2-\frac{29312}{3375}p^3+\frac{223232}{50625}p^4-\frac{229376}{253125}p^5. \]
  • Hence the post‑selected logical fidelity is the rational function
\[ \boxed{\,F_{\rm 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}\,} \]
which has the small‑p expansion
\[ F_{\rm logical}(p)=1-\frac{16}{25}p^2-\frac{704}{375}p^3+O(p^4). \]
As expected for a fault‑tolerant flagged preparation with post‑selection, all first‑order (O(p)) logical errors are eliminated; the leading logical infidelity is O(p^2). The stabilizer‑commutation logic and the explicit [[4,2,2]] codewords used in this derivation are standard. ([learning.quantum.ibm.com](https://learning.quantum.ibm.com/course/foundations-of-quantum-error-correction/the-stabilizer-formalism?utm_source=openai), [arxiv.org](https://arxiv.org/html/2405.03032v1?utm_source=openai))
  1. Mathematical Typesetting

All equations above are expressed in LaTeX.

  1. Conventions and Units
  • Physical qubits: 0,1,2,3 (data) and 4 (ancilla).
  • Stabilizers: XXXX and ZZZZ on qubits 0–3.
  • Fidelity is dimensionless.
  • Pauli conjugation through CNOT uses the standard Clifford action. (zxcalc.github.io)
  1. Final Answer:
\[ F_{\rm 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}, \]

so that for small p, \(F_{\rm logical}(p)=1-\tfrac{16}{25}p^2-\tfrac{704}{375}p^3+O(p^4)\).

User #9

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 #10
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