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\).

Checkpoints

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, noise model, and target state
  • The circuit is applied right-to-left: 1) H2 2) CNOT21 3) H0 4) CNOT03
  • Only the two CNOTs are followed by two-qubit depolarizing channels acting on the gate’s two qubits. The model states that with probability p an error occurs and, conditioned on an error, one of the 15 non-identity two-qubit Paulis is applied uniformly at random, i.e.,
\[ \mathcal{E}^{(2)}(\rho)=(1-p)\rho+\frac{p}{15}\sum_{P\in\mathcal{P}_2\setminus\{II\}}P\rho P, \]
where $\mathcal{P}_2=\{I,X,Y,Z\}^{\otimes 2}$. This is the “uniform Pauli” form of the 2-qubit depolarizing/Pauli channel. ([qiskit.github.io](https://qiskit.github.io/qiskit-aer/stubs/qiskit_aer.noise.depolarizing_error.html?utm_source=openai), [docs.quantum.ibm.com](https://docs.quantum.ibm.com/api/qiskit/0.42/qiskit_aer.noise.depolarizing_error?utm_source=openai), [qml-tutorial.github.io](https://qml-tutorial.github.io/chapter2/2/?utm_source=openai))
  • H followed by CNOT on |00⟩ prepares a Bell state; hence each pair (2,1) and (0,3) is prepared into \(|\Phi^+\rangle=(|00\rangle+|11\rangle)/\sqrt{2}\). Therefore, the ideal final 4-qubit state is a product of two Bell pairs,
\[ |\Psi_{\mathrm{ideal}}\rangle = |\Phi^+\rangle_{21}\otimes|\Phi^+\rangle_{03}. \]
([en.wikipedia.org](https://en.wikipedia.org/wiki/Bell_state))
  • Factorization of the noisy state
  • The first error channel acts on qubits (2,1) immediately after CNOT21. No later gate touches qubits 1 or 2. The second error channel acts on (0,3) after CNOT03. Therefore, the final state factors as a tensor product of two two-qubit states:
\[ \rho_{\text{final}}=\rho_{21}\otimes\rho_{03}, \]
with
\[ \]
  • Bell-pair survival under a 2-qubit depolarizing/Pauli channel
  • For a single pair (say, 21), the fidelity with the ideal Bell state is
\[ =(1-p)\underbrace{\langle\Phi^+|\Phi^+\rangle}_{=1} \]
  • Using the stabilizer properties of \(|\Phi^+\rangle\),
\[ (Z\!\otimes\!Z)|\Phi^+\rangle=|\Phi^+\rangle,\quad \]
so $|\langle\Phi^+|P|\Phi^+\rangle|^2=1$ for $P\in\{XX,YY,ZZ\}$ and 0 for the remaining 12 non-identity two-qubit Paulis (they map $|\Phi^+\rangle$ to some orthogonal Bell state, e.g., $ZI|\Phi^+\rangle=|\Phi^-\rangle$). Hence,
\[ =1-\frac{12}{15}\,p \]
(The three Paulis XX, YY, ZZ leave the pure density matrix unchanged, since $P|\Phi^+\rangle\langle\Phi^+|P=|\Phi^+\rangle\langle\Phi^+|$ even when the eigenvalue is −1.)
  • Four-qubit physical-state fidelity
  • The target is a product state \(|\Psi_{\mathrm{ideal}}\rangle=|\Phi^+\rangle_{21}\otimes|\Phi^+\rangle_{03}\) and the noisy state factors: \(\rho_{\text{final}}=\rho_{21}\otimes\rho_{03}\). Using \(\mathrm{Tr}[(A\otimes B)(C\otimes D)]=\mathrm{Tr}[AC]\mathrm{Tr}[BD]\),
\[ =\langle\Phi^+|\rho_{21}|\Phi^+\rangle\;\langle\Phi^+|\rho_{03}|\Phi^+\rangle =\left(F_{\text{pair}}(p)\right)^2 \]

2) Mathematical details used - Depolarizing/Pauli channel acting uniformly on non-identity n-qubit Paulis (here n=2) and the standard H–CNOT Bell-state preparation. (qiskit.github.io, docs.quantum.ibm.com, en.wikipedia.org)

3) Conventions and units - Qubits labeled 0,1,2,3 as in the prompt. Gates are ideal except for the specified post-CNOT two-qubit depolarizing channels of error probability p. Fidelity is the state overlap with the ideal pure state, \(F=\langle\psi|\rho|\psi\rangle\).

Final Answer:

\[ F_{\mathrm{phys}}(p)=\left(1-\frac{4}{5}p\right)^2. \]
User #3

The correct answer is: $ F_{\rm{physical}}=(1-\frac{12}{15}p)^2 $

Now let’s solve the next Checkpoint.

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

  • Setup: code, circuit, noise, target
  • [[4,2,2]] code with stabilizers S = ⟨XXXX, ZZZZ⟩. A convenient choice of logical Paulis (up to stabilizers) is X_A = X I X I, X_B = X X I I, Z_A = Z Z I I, Z_B = Z I Z I, in the physical-qubit order (0,1,2,3). The codespace basis and stabilizers are standard for this code. (errorcorrectionzoo.org, ar5iv.org)
  • The state-preparation circuit acts right-to-left: H2 → CNOT21 → H0 → CNOT03. Ideal action on |0000⟩: H2+CNOT21 prepares |Φ+⟩21; H0+CNOT03 prepares |Φ+⟩03, so the ideal 4-qubit state is |Ψideal⟩ = |Φ+⟩21 ⊗ |Φ+⟩03, where |Φ+⟩ = (|00⟩+|11⟩)/√2. (qubit.guide, en.wikipedia.org)
  • Noise model: After each CNOTij, a two-qubit depolarizing (uniform Pauli) channel acts on those two qubits: with probability 1−p nothing happens; with probability p a random non-identity 2-qubit Pauli from the 15 possibilities is applied uniformly (probability p/15 each). For n qubits this is the “uniform Pauli” point of the depolarizing family. (qiskit.github.io)

  • One Bell pair under a two-qubit Pauli channel

  • The Bell state |Φ+⟩ is stabilized by XX and ZZ, and (up to a global phase) any two-qubit Pauli maps a Bell state to some Bell state. In particular, the four operators {I, XX, YY, ZZ} leave |Φ+⟩ invariant (eigenvalue ±1), while the remaining 12 Paulis map |Φ+⟩ to the other three Bell states in 4-to-1 groupings (cosets). Therefore, for a single depolarized pair: P(Φ+) = (1−p) + 3·(p/15) = 1 − 12p/15, P(Φ−) = P(Ψ+) = P(Ψ−) = 4p/15. (This uses that Bell states are permuted by local/two-qubit Paulis and |Φ+⟩ is an eigenstate of XX and ZZ.) (en.wikipedia.org)

  • Independent noise on the two disjoint pairs

  • The two error channels act independently on (2,1) and (0,3), and no later gate mixes the pairs, so the joint distribution for the pair-types factorizes.

  • Post-selection criterion (detectable errors rejected)

  • Measuring the stabilizers XXXX and ZZZZ yields the trivial syndrome (+1,+1) iff the total Pauli error P commutes with both stabilizers, i.e., P lies in the normalizer of S. Equivalently for our two-Bell-pair picture, write the pairwise parities sXX(pair) = eigenvalue of X⊗X on that pair, sZZ(pair) = eigenvalue of Z⊗Z, which for the four Bell states are Φ+: (+,+), Φ−: (−,+), Ψ+: (+,−), Ψ−: (−,−). Since XXXX = (X2X1)(X0X3) and ZZZZ = (Z2Z1)(Z0Z3), the stabilizer outcomes are the products of the corresponding pairwise parities. Hence the run is accepted iff the two pairs have the same Bell label (their (sXX,sZZ) agree componentwise). (quantum.cloud.ibm.com)

  • Acceptance probability

  • Let q := P(Φ+) = 1 − 12p/15 = 1 − 4p/5 and r := P(Φ−) = P(Ψ+) = P(Ψ−) = 4p/15 for each pair. The acceptance probability is Pacc = q^2 + 3 r^2 = (1 − 4p/5)^2 + 3 (4p/15)^2 = 1 − 8p/5 + (64/75)p^2.

  • Which accepted events keep the logical Bell state correct?

  • The target logical state is the logical Bell state |Φ+⟩AB, which our physical product |Φ+⟩21|Φ+⟩03 realizes. Accepted events fall into four classes: 1) (Φ+,Φ+): P = P21⊗P03 with Ppair ∈ {I, XX, YY, ZZ}. Using XXXX = (X2X1)(X0X3) and ZZZZ = (Z2Z1)(Z0Z3), one checks that any such P equals a stabilizer times one of {I, X_A X_B, Z_A Z_B, Y_A Y_B}. All of these act as ±1 on |Φ+⟩AB (global phase allowed), so the logical state remains the target. (errorcorrectionzoo.org, ar5iv.org) 2) (Φ−,Φ−): A representative is P = Z2 · Z0, which equals the logical Z_B (up to stabilizers) because Z_B = Z0 Z2. This maps |Φ+⟩AB → |Φ−⟩AB, orthogonal to the target. All choices in this class are equivalent to logical Z_B (times stabilizers), hence “bad” for fidelity. (ar5iv.org) 3) (Ψ+,Ψ+): A representative is P = X2 · X0 = X_A, mapping |Φ+⟩AB → |Ψ+⟩AB (orthogonal). All such are equivalent to logical X_A (times stabilizers), so “bad.” (ar5iv.org) 4) (Ψ−,Ψ−): A representative is P = Y2 · Y0 ∝ X_A Z_B, mapping |Φ+⟩AB → |Ψ−⟩AB (orthogonal). Again “bad.” (ar5iv.org)
  • Therefore, among accepted runs, only the (Φ+,Φ+) sector produces the correct logical Bell state.

  • Logical fidelity conditioned on post-selection

  • The (conditional) logical state fidelity is the probability mass of the (Φ+,Φ+) sector conditioned on acceptance: Flogical(p) = P[(Φ+,Φ+)] / Pacc = q^2 / (q^2 + 3 r^2) = (1 − 4p/5)^2 / [ (1 − 4p/5)^2 + 3 (4p/15)^2 ].
  • Series for small p: Flogical(p) = 1 − (16/75) p^2 + O(p^3), reflecting the removal (by post-selection) of all O(p) logical errors. (quantum.cloud.ibm.com)

2) Mathematical identities and facts used - Bell-state properties and preparation by H–CNOT; |Φ+⟩ stabilized by XX and ZZ; Paulis permute the Bell basis. (en.wikipedia.org) - [[4,2,2]] code stabilizers and typical logical representatives used above. (errorcorrectionzoo.org, ar5iv.org) - Error detection accepts exactly errors commuting with all stabilizer generators (normalizer elements). (quantum.cloud.ibm.com) - Uniform two-qubit depolarizing channel (uniform Pauli at the “Pauli point”). (qiskit.github.io)

3) Conventions and units - Qubits labeled (0,1,2,3); logical qubits A,B. Gates ideal except for the specified two-qubit depolarizing channel of strength p applied after each CNOT. Fidelity is the pure-state overlap with the conditional logical state.

4) Final Answer:

\[ F_{\rm logical}(p) =\frac{\bigl(1-\tfrac{4}{5}p\bigr)^2} {\bigl(1-\tfrac{4}{5}p\bigr)^2+3\bigl(\tfrac{4}{15}p\bigr)^2} =\frac{1-\tfrac{8}{5}p+\tfrac{16}{25}p^2}{1-\tfrac{8}{5}p+\tfrac{64}{75}p^2}\,. \]
User #5

The correct answer is: $ F_{\rm{logical}}=1 - \frac{\frac{16}{75}p^2}{1-\frac{8}{5}p + \frac{64}{75}p^2} $

Now let’s solve the next Checkpoint.

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)
from itertools import product

# Define Pauli multiplication ignoring global phase
mul_table = {
    ('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'
}

def pauli_mul(p,q):
    # p and q are strings over {I,X,Y,Z} of same length
    return ''.join(mul_table[(pi,qi)] for pi,qi in zip(p,q))

# Conjugation of a Pauli string by CNOT(control, target)
# Returns U P U^†

def conj_by_cnot(P, c, t):
    P = list(P)
    # Copy to avoid interfering updates; apply rules based on original
    Pc, Pt = P[c], P[t]
    # If X on control, multiply X on target
    if Pc in ('X','Y'):
        # multiply current P[t] by X
        P[t] = mul_table[(P[t],'X')]
    # If Z on target, multiply Z on control
    if Pt in ('Z','Y'):
        P[c] = mul_table[(P[c],'Z')]
    return ''.join(P)

# Commutation check via symplectic product
symp_map = {'I':(0,0),'X':(1,0),'Y':(1,1),'Z':(0,1)}

def anticommutes(P,Q):
    # P,Q strings same length
    s=0
    for p,q in zip(P,Q):
        xp,zp = symp_map[p]
        xq,zq = symp_map[q]
        s ^= (xp & zq) ^ (zp & xq)
    return s==1

# Circuit specification
# Qubits indices: 0,1,2,3 are data; 4 is ancilla
# Time order (after H1): gates are g0: CNOT12, g1: CNOT10, g2: CNOT23, g3: CNOT34, g4: CNOT04
cnots = [(1,2),(1,0),(2,3),(3,4),(0,4)]

# Precompute propagation to end for each gate and each local 2-qubit Pauli
single_qubit_labels = 'IXYZ'
paulis2 = [a+b for a in single_qubit_labels for b in single_qubit_labels]  # 16 including II

# Map from two-qubit Pauli (on control,target) to full 5-qubit Pauli after propagation
prop_effects = []  # list of dicts for each gate
for gi,(c,t) in enumerate(cnots):
    effects = {}
    # Past gates after this gate
    later = cnots[gi+1:]
    for P2 in paulis2:
        # Embed into 5-qubit string at positions c and t
        P = ['I']*5
        P[c], P[t] = P2[0], P2[1]
        P = ''.join(P)
        # propagate through later CNOTs
        for (cc,tt) in later:
            P = conj_by_cnot(P, cc, tt)
        effects[P2] = P
    prop_effects.append(effects)

# Stabilizers extended to 5 qubits (ancilla I)
S1 = 'XXXXI'  # XXXX on 0..3
S2 = 'ZZZZI'  # ZZZZ on 0..3
# Logical Zs (on data)
Z_A = 'ZZI I'.replace(' ','')  # Z on 0,1
Z_B = 'ZIZ I'.replace(' ','')  # Z on 0,2
# Extend with ancilla I
Z_A5 = Z_A + 'I'
Z_B5 = Z_B + 'I'

# Enumerate all patterns
# For each gate choose one of 16 paulis (identity or non-identity)
counts = {
    'accepted_total':[0]*6,  # by k errors
    'accepted_good':[0]*6,
    'accepted_bad':[0]*6
}

# Precompute identity detection etc for speed? We'll do on the fly.

# Iterate over all choices of P2 for each gate (5 nested loops)
# We'll optimize by using integer indexes and lookups.
paulis2_list = paulis2
len(paulis2_list)

from itertools import product

# For speed, convert to list of 16 ints representing non-identity vs identity
# We'll define helper to compute final error by multiplying strings

def is_identity2(P2):
    return P2 == 'II'

# We'll also precompute 5x16 mapping to 5-qubit strings P_effects
prop = prop_effects

# Multiplication function across 5-qubit strings

def multiply_many(Ps):
    out = 'IIIII'
    for P in Ps:
        if P != 'IIIII':
            out = pauli_mul(out,P)
    return out

# Main loop
n_total = 0
for idxs in product(range(16), repeat=5):
    n_total += 1
    Ps = []
    k = 0
    for gi,idx in enumerate(idxs):
        P2 = paulis2_list[idx]
        if P2 != 'II':
            k += 1
        Ps.append(prop[gi][P2])
    # total propagated error at end
    Ptot = multiply_many(Ps)
    # Ancilla acceptance: ancilla Pauli must be I or Z (no X or Y)
    anc = Ptot[4]
    if anc in ('X','Y'):
        continue  # rejected by ancilla measurement (since ideal ancilla is |0>)
    # Code detection acceptance: data part must commute with both stabilizers
    # Equivalent to Ptot must commute with S1,S2 since ancilla I/Z commutes with them trivially
    if anticommutes(Ptot, S1) or anticommutes(Ptot, S2):
        continue
    # accepted
    counts['accepted_total'][k] += 1
    # Goodness: if data commutes with both Z_A and Z_B -> logical |00> unchanged
    if (not anticommutes(Ptot, Z_A5)) and (not anticommutes(Ptot, Z_B5)):
        counts['accepted_good'][k] += 1
    else:
        counts['accepted_bad'][k] += 1

counts, n_total
Tool #7
''
Assistant #8
print('Done')
Tool #9
Done
Assistant #10
# Let's print counts
from pprint import pprint
pprint(counts)
Tool #11
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
NameError: name 'counts' is not defined
Assistant #12
# Rerun the enumeration because the previous scope was ephemeral? Let's wrap it into a function to reuse.
from itertools import product

mul_table = {
    ('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'
}

def pauli_mul(p,q):
    return ''.join(mul_table[(pi,qi)] for pi,qi in zip(p,q))

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

def anticommutes(P,Q):
    s=0
    for p,q in zip(P,Q):
        xp,zp = symp_map[p]
        xq,zq = symp_map[q]
        s ^= (xp & zq) ^ (zp & xq)
    return s==1

def conj_by_cnot(P, c, t):
    P = list(P)
    Pc, Pt = P[c], P[t]
    if Pc in ('X','Y'):
        P[t] = mul_table[(P[t],'X')]
    if Pt in ('Z','Y'):
        P[c] = mul_table[(P[c],'Z')]
    return ''.join(P)

single_qubit_labels = 'IXYZ'
paulis2 = [a+b for a in single_qubit_labels for b in single_qubit_labels]

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

# Precompute propagation
prop_effects = []
for gi,(c,t) in enumerate(cnots):
    effects = {}
    later = cnots[gi+1:]
    for P2 in paulis2:
        P = ['I']*5
        P[c], P[t] = P2[0], P2[1]
        P = ''.join(P)
        for (cc,tt) in later:
            P = conj_by_cnot(P, cc, tt)
        effects[P2] = P
    prop_effects.append(effects)

S1 = 'XXXXI'
S2 = 'ZZZZI'
Z_A5 = 'ZZI II'.replace(' ','')
Z_B5 = 'ZIZ II'.replace(' ','')

counts = {'accepted_total':[0]*6,'accepted_good':[0]*6,'accepted_bad':[0]*6}

# Main enumeration
for idxs in product(range(16), repeat=5):
    Ps = []
    k = 0
    for gi,idx in enumerate(idxs):
        P2 = paulis2[idx]
        if P2 != 'II':
            k += 1
        Ps.append(prop_effects[gi][P2])
    # Multiply
    Ptot = 'IIIII'
    for P in Ps:
        if P != 'IIIII':
            Ptot = pauli_mul(Ptot, P)
    # Ancilla acceptance (must be I or Z)
    if Ptot[4] in ('X','Y'):
        continue
    # Code detection acceptance
    if anticommutes(Ptot, S1) or anticommutes(Ptot, S2):
        continue
    # Accepted
    counts['accepted_total'][k] += 1
    if (not anticommutes(Ptot, Z_A5)) and (not anticommutes(Ptot, Z_B5)):
        counts['accepted_good'][k] += 1
    else:
        counts['accepted_bad'][k] += 1

from pprint import pprint
pprint(counts)
Tool #13
{'accepted_bad': [0, 0, 144, 3024, 24240, 70896],
 'accepted_good': [1, 7, 138, 1198, 7397, 24027],
 'accepted_total': [1, 7, 282, 4222, 31637, 94923]}
Assistant #14
Tool Call (code to execute)
from fractions import Fraction

A = [1,7,282,4222,31637,94923]
G = [1,7,138,1198,7397,24027]

# Build polynomials D(p) and N(p) with rational coefficients
# D(p) = sum_k A_k * (1-p)^{5-k} * (p/15)^k
# Expand using binomial theorem

from math import comb

def poly_add(p,q):
    # polynomials as list of coefficients [c0, c1, ..., cn]; extend to max length
    n = max(len(p),len(q))
    p = p + [Fraction(0)]*(n-len(p))
    q = q + [Fraction(0)]*(n-len(q))
    return [pi+qi for pi,qi in zip(p,q)]

def poly_mul(p,q):
    r = [Fraction(0)]*(len(p)+len(q)-1)
    for i,pi in enumerate(p):
        for j,qj in enumerate(q):
            r[i+j] += pi*qj
    return r

# Represent (1-p)^{m} as polynomial

def poly_one_minus_p_pow(m):
    coeffs = []
    for j in range(m+1):
        coeffs.append(Fraction(comb(m,j)) * (Fraction(-1) ** j))
    # That gives sum_{j} (-1)^j C(m,j) p^j; but we want as a polynomial in p with constant term 1
    return coeffs

# Represent (p/15)^k as polynomial (0,...,0, (1/15)^k) of degree k

def poly_p_pow_over_15(k):
    coeffs = [Fraction(0)]*k + [Fraction(1, 15**k)]
    return coeffs

# Build D,N
D = [Fraction(0)]
N = [Fraction(0)]
for k in range(6):
    # (1-p)^{5-k}
    om = poly_one_minus_p_pow(5-k)
    pp = poly_p_pow_over_15(k)
    termD = poly_mul([Fraction(A[k])], poly_mul(om, pp))
    termN = poly_mul([Fraction(G[k])], poly_mul(om, pp))
    D = poly_add(D, termD)
    N = poly_add(N, termN)

# Print polynomials
print('D coefficients (from p^0 to p^5):')
print([f'{c.numerator}/{c.denominator}' for c in D])
print('N coefficients:')
print([f'{c.numerator}/{c.denominator}' for c in N])

# Simplify by multiplying by 15^5 to remove denominators and by 5!/ etc? We'll just present as ratio of integer polynomials.
from math import lcm

def lcm_list(lst):
    from math import gcd
    L = 1
    for x in lst:
        L = L*x//gcd(L,x)
    return L

# Compute common denominators to convert coefficients to integers
D_denoms = [c.denominator for c in D]
N_denoms = [c.denominator for c in N]
L_D = lcm_list(D_denoms)
L_N = lcm_list(N_denoms)
D_int = [int(c*L_D) for c in D]
N_int = [int(c*L_N) for c in N]
print('D integer coeffs with common denom', L_D, ':', D_int)
print('N integer coeffs with common denom', L_N, ':', N_int)
Tool #15
D coefficients (from p^0 to p^5):
['1/1', '-68/15', '704/75', '-32768/3375', '253952/50625', '-262144/253125']
N coefficients:
['1/1', '-68/15', '656/75', '-29312/3375', '223232/50625', '-229376/253125']
D integer coeffs with common denom 253125 : [253125, -1147500, 2376000, -2457600, 1269760, -262144]
N integer coeffs with common denom 253125 : [253125, -1147500, 2214000, -2198400, 1116160, -229376]
Assistant #16
Tool Call (code to execute)
# Verify small-p expansion
from fractions import Fraction

# Convert to floats or keep Fractions
D = [Fraction(253125,253125), Fraction(-1147500,253125), Fraction(2376000,253125), Fraction(-2457600,253125), Fraction(1269760,253125), Fraction(-262144,253125)]
N = [Fraction(253125,253125), Fraction(-1147500,253125), Fraction(2214000,253125), Fraction(-2198400,253125), Fraction(1116160,253125), Fraction(-229376,253125)]

# Expand F = N/D to p^2
# F = (N0 + N1 p + N2 p^2 + ...)/(D0 + D1 p + D2 p^2 + ...)
# Use series formula F = (N0/D0) + (N1 D0 - N0 D1)/D0^2 p + (N2 D0^2 - N1 D0 D1 + N0(D1^2 - D0 D2))/D0^3 p^2
N0,N1,N2 = N[0],N[1],N[2]
D0,D1,D2 = D[0],D[1],D[2]

F0 = N0/D0
F1 = (N1*D0 - N0*D1) / (D0*D0)
F2 = (N2*D0*D0 - N1*D0*D1 + N0*(D1*D1 - D0*D2)) / (D0*D0*D0)
print('Series: F ≈', F0, '+', F1, 'p +', F2, 'p^2')
print('As floats:', float(F0), float(F1), float(F2))
Tool #17
Series: F  1 + 0 p + -16/25 p^2
As floats: 1.0 0.0 -0.64
Assistant #18

1) Step-by-step derivation

  • Code, logicals, and target state
  • [[4,2,2]] detection code with stabilizers S = ⟨XXXX, ZZZZ⟩ on qubits (0,1,2,3). A convenient choice of logical Paulis is X_A = X I X I, X_B = X X I I, Z_A = Z Z I I, Z_B = Z I Z I (up to stabilizers). The logical computational basis contains |00̄⟩ = (|0000⟩ + |1111⟩)/√2, which is stabilized by XXXX and ZZZZ. (errorcorrectionzoo.org, ar5iv.labs.arxiv.org)
  • We prepare |00̄⟩ using the circuit (right-to-left in time) H1 → CNOT12 → CNOT10 → CNOT23 → CNOT34 → CNOT04 → measure ancilla 4 in Z. Ideally, the last two CNOTs parity-check Z0Z3 onto ancilla, and for the GHZ-like |00̄⟩ the ancilla deterministically yields 0. Parity readout of Z-parities with two CNOTs and a Z-measurement is standard. (en.wikipedia.org)

  • Noise model and acceptance rule

  • After each two-qubit CNOTij we apply an independent two-qubit depolarizing/Pauli channel that, with probability p, applies one of the 15 non-identity two-qubit Paulis uniformly (p/15 each), and with probability 1−p applies I⊗I. This is the “uniform Pauli point” of the n-qubit depolarizing family. (qiskit.github.io, quantumcomputing.stackexchange.com)
  • Post-selection: keep only shots with (i) ancilla measurement result 0 and (ii) no detectable code syndrome, i.e., the effective data Pauli P commutes with both stabilizers XXXX and ZZZZ. (Commutation with stabilizers characterizes undetected errors in stabilizer codes.) (en.wikipedia.org)

  • Clifford/Pauli propagation and classification

  • Because the circuit is Clifford and the noise is Pauli, any fault pattern maps to a single Pauli Ptot on the five qubits at the end of the circuit. Propagation through CNOT uses the standard conjugation rules: X on control → X_c X_t, Z on target → Z_c Z_t (Z on control and X on target unchanged). (zxcalc.github.io, en.wikipedia.org)
  • Acceptance conditions in terms of Ptot: 1) Ancilla acceptance: with the ideal final state having ancilla |0⟩ decoupled, Ptot must have no X or Y on qubit 4 (I or Z are allowed) to observe outcome 0 deterministically. (en.wikipedia.org) 2) Code acceptance: the data restriction Pdata must commute with XXXX and ZZZZ. (en.wikipedia.org)
  • Logical correctness among accepted events: the target is the +1 eigenstate of Z_A and Z_B. Thus, among accepted Pdata in the normalizer, the output is “good” iff Pdata commutes with both Z_A and Z_B (i.e., it is a stabilizer or Z-type logical), and “bad” iff it anticommutes with either (i.e., includes an X_A or X_B component). (ar5iv.labs.arxiv.org)

  • Exhaustive Pauli enumeration (exact counting)

  • There are five noisy CNOTs; at each location the error is chosen from {II}∪(15 non-identity two-qubit Paulis). We exhaustively propagated all 16^5 patterns to the end, tested the two acceptance criteria above, and classified accepted events as “good” or “bad” by commutation with Z_A and Z_B.
  • Let Ak be the number of accepted patterns with exactly k non-identity gate faults, and Gk (Bk) the number of accepted-good (accepted-bad) patterns with k faults. Exact counts are:
    • Accepted totals Ak for k=0..5: [1, 7, 282, 4222, 31637, 94923]
    • Accepted good Gk: [1, 7, 138, 1198, 7397, 24027]
    • Accepted bad Bk: [0, 0, 144, 3024, 24240, 70896]
  • From these, the accepted probability and the conditional logical fidelity are polynomials in p. Writing the weight of a k-fault pattern as (1−p)^{5−k} (p/15)^k, we have
    • Acceptance probability: Pacc(p) = ∑_{k=0}^{5} Ak (1−p)^{5−k} (p/15)^k.
    • Numerator for fidelity: Ngood(p) = ∑_{k=0}^{5} Gk (1−p)^{5−k} (p/15)^k.
    • Logical fidelity conditioned on acceptance: Flogical(p) = Ngood(p)/Pacc(p).
  • Expanding and simplifying yields exact rational polynomials
\[ 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, \]
\[ N_{\rm good}(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
\[ F_{\rm logical}(p)=\frac{N_{\rm good}(p)}{P_{\rm acc}(p)}. \]
  • Small-p expansion:
\[ F_{\rm logical}(p)=1 - \frac{16}{25}\,p^2 + O(p^3), \]
i.e., all O(p) logical errors are removed by the post-selection and the ancilla (flag) parity check, as expected for a single-fault-tolerant state-preparation gadget. ([arxiv.org](https://arxiv.org/abs/1811.00566?utm_source=openai))

2) Mathematical identities and rules used - Stabilizer-code acceptance criterion = commutation of error with stabilizers; logical operators defined modulo stabilizers; commuting with Z-logicals preserves the |00̄⟩ state. (en.wikipedia.org, ar5iv.labs.arxiv.org) - Clifford/Pauli conjugation through CNOT (used to propagate faults). (zxcalc.github.io) - Two-qubit depolarizing/Pauli channel at the uniform-Pauli point (15 non-identity Paulis with equal probability). (qiskit.github.io) - Parity measurement with two CNOTs to a Z-measured ancilla. (en.wikipedia.org)

3) Conventions and units - Qubits 0–3 are data; qubit 4 is an ancilla measured in Z. H and measurements are ideal. A two-qubit depolarizing error acts after each CNOT. Fidelity F = ⟨ψtarget|ρlogical|ψtarget⟩.

4) Final Answer:

\[ F_{\rm logical}(p) =\frac{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} {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} = 1 - \frac{\frac{16}{25}p^2 - \frac{128}{125}p^3 + \frac{2048}{3375}p^4 - \frac{32768}{253125}p^5} {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}\,, \]

so in particular \(F_{\rm logical}(p)=1-\frac{16}{25}p^2+O(p^3)\).

User #19

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 #20
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 ------------------
    num = (
        1
        - sp.Rational(68, 15) * p
        + sp.Rational(656, 75) * p**2
        - sp.Rational(29312, 3375) * p**3
        + sp.Rational(223232, 50625) * p**4
        - sp.Rational(229376, 253125) * p**5
    )
    den = (
        1
        - sp.Rational(68, 15) * p
        + sp.Rational(704, 75) * p**2
        - sp.Rational(32768, 3375) * p**3
        + sp.Rational(253952, 50625) * p**4
        - sp.Rational(262144, 253125) * p**5
    )
    F_logical = num / den  # a SymPy expression of inputs
    # ---------------------------------------------------------------

    return F_logical