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.

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
  • Ideal target state and its stabilizers
  • The circuit acts (right-to-left) as H2 → CNOT21 → H0 → CNOT03 on |0000⟩.
  • H2 followed by CNOT21 prepares the Bell state |Φ+⟩ on qubits (2,1).
  • H0 followed by CNOT03 prepares the Bell state |Φ+⟩ on qubits (0,3).
  • Hence the ideal final state is
\[ |\psi_{\text{ideal}}\rangle = |\Phi^+\rangle_{21}\otimes|\Phi^+\rangle_{03},\quad |\Phi^+\rangle=\frac{|00\rangle+|11\rangle}{\sqrt{2}}. \]
  • A Bell state |Φ+⟩ is stabilized by X⊗X and Z⊗Z. Therefore
\[ \mathcal{S} = \langle X_1X_2,\ Z_1Z_2,\ X_0X_3,\ Z_0Z_3\rangle. \]
Equivalently (using the logical-operator identifications provided), this equals
\[ \langle XXXX,\ ZZZZ,\ IZZI,\ IXXI\rangle. \]
  • The full stabilizer group has 16 elements and factorizes across the pairs (1,2) and (0,3) as
\[ \mathcal{S}=\{P_{12}\otimes Q_{03}\,:\, P,Q\in\{II,\,XX,\,YY,\,ZZ\}\}. \]
  • Noise model and propagation
  • A two-qubit depolarizing channel follows each CNOT:
    • With probability 1−p it applies identity.
    • With probability p it applies uniformly one of the 15 non-identity two-qubit Paulis.
  • The first channel acts on qubits (2,1) after CNOT21; subsequent gates act only on qubits (0,3), so errors on (2,1) do not propagate.
  • The second channel acts on qubits (0,3) after CNOT03; there are no later gates.
  • Thus the net error at the end is E = E_{21} ⊗ E_{03}, with E_{21} supported on (1,2) and E_{03} on (0,3), independently drawn from their respective two-qubit depolarizing channels.

  • Fidelity under Pauli noise for a stabilizer state

  • For a pure stabilizer state |ψ⟩ and a Pauli channel ρ = ∑_E p_E E|ψ⟩⟨ψ|E, the fidelity is
\[ F=\langle\psi|\rho|\psi\rangle=\sum_E p_E\,|\langle\psi|E|\psi\rangle|^2, \]
which equals the total probability that E lies in the stabilizer group of |ψ⟩ (since ⟨ψ|E|ψ⟩=0 unless E∈𝒮, in which case it equals ±1).
  • Counting the harmless (stabilizer) errors
  • E ∈ 𝒮 if and only if E_{21} ∈ {II,XX,YY,ZZ} and E_{03} ∈ {II,XX,YY,ZZ}.
  • For a two-qubit depolarizing channel on a given pair:
    • P(E_pair = II) = 1 − p.
    • Among the 15 non-identity Paulis, exactly 3 are in {XX,YY,ZZ}, so P(E_pair ∈ {XX,YY,ZZ}) = 3·(p/15) = p/5.
    • Therefore the “harmless” probability per pair is
\[ P_{\text{ok (per pair)}} = (1-p) + \frac{p}{5} = 1 - \frac{4p}{5}. \]
  • The two pairs are independent, so the total fidelity is the product:
\[ F(p) = \left(1 - \frac{4p}{5}\right)^2. \]
  1. Mathematical Typesetting
  • Already included above.
  1. Conventions and Units
  • Dimensionless error probability p; no units involved.
  1. Final Answer: F(p) = (1 - 4p/5)^2 = 1 - (8/5)p + (16/25)p^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
  • Ideal state and error locations
  • The circuit prepares the physical state
\[ |\psi_{\mathrm{ideal}}\rangle=|\Phi^+\rangle_{21}\otimes|\Phi^+\rangle_{03},\quad |\Phi^+\rangle=\frac{|00\rangle+|11\rangle}{\sqrt{2}}. \]
  • A two-qubit depolarizing channel acts after each CNOT. Thus the final error is a product
\[ E=E_{21}\otimes E_{03}, \]
where each $E_{\mathrm{pair}}$ is a two-qubit Pauli with
- $P(E_{\mathrm{pair}}=II)=1-p$,
- each of the 15 non-identity Paulis with probability $p/15$,
and the two pairs are independent.
  • Detectability condition (membership in the code normalizer)
  • The code stabilizers are \(S_X=XXXX\) and \(S_Z=ZZZZ\), which factor across the pairs as
\[ S_X=(X_2X_1)\otimes(X_0X_3),\qquad S_Z=(Z_2Z_1)\otimes(Z_0Z_3). \]
  • For a Pauli \(P\) on a given pair, define its pair-syndrome
\[ s(P)=(s_X(P),s_Z(P))\in\{0,1\}^2, \]
where $s_X(P)=0$ if $P$ commutes with $X\otimes X$ and $1$ if it anticommutes (similarly for $s_Z$ with $Z\otimes Z$).
  • The total error \(E=E_{21}\otimes E_{03}\) commutes with both \(S_X,S_Z\) (i.e., is undetected) if and only if the pair-syndromes match:
\[ s(E_{21})=s(E_{03}). \]
  • Distribution of pair-syndromes under two-qubit depolarizing noise
  • On a pair, the 16 Paulis split into 4 equally sized classes by \(s\in\{(0,0),(1,0),(0,1),(1,1)\}\).
  • Among non-identity elements, the counts are:
    • class \((0,0)\): 3 elements (XX, YY, ZZ),
    • classes \((1,0)\), \((0,1)\), \((1,1)\): 4 elements each.
  • Therefore, for a single pair:
\[ P_{00} &:= P\big(s=(0,0)\big) = (1-p)+3\frac{p}{15}=1-\frac{12}{15}p=1-\frac{4p}{5},\\ P_{10} &= P_{01}=P_{11}=4\frac{p}{15}. \]
  • Acceptance probability (post-selecting on no detected error)
  • Because the two pairs are independent,
\[ = \left(1-\frac{4p}{5}\right)^2+3\left(\frac{4p}{15}\right)^2 \]
  • Logical fidelity of the post-selected state
  • The logical target is the Bell state \((|00\rangle_{AB}+|11\rangle_{AB})/\sqrt{2}\), whose logical stabilizer is generated by \(X_A X_B\) and \(Z_A Z_B\). A Pauli error preserves this logical state iff, modulo the code stabilizer, it is in
\[ \{I,\,X_A X_B,\,Y_A Y_B,\,Z_A Z_B\}. \]
  • Physically, these correspond exactly to the class where both pairs lie in \(s=(0,0)\) (i.e., \(E_{21},E_{03}\in\{II,XX,YY,ZZ\}\)). Any accepted error with \(s\neq(0,0)\) maps the logical Bell state to an orthogonal Bell state and contributes zero to the fidelity.
  • Hence the numerator (accepted and logically correct) is
\[ P_{\mathrm{good}}=\left(1-\frac{12}{15}p\right)^2=\left(1-\frac{4p}{5}\right)^2. \]
  • The logical fidelity conditioned on acceptance is
\[ = \frac{P_{\mathrm{good}}}{P_{\mathrm{acc}}} = \frac{\left(1-\frac{12}{15}p\right)^2} \]
  • Small-p expansion (sanity check)
  • Using the above,
\[ F_{\mathrm{logical}}(p) = 1 - \frac{16}{75}p^2 + O(p^3), \]
showing first-order errors are fully detected and removed by post-selection.
  1. Mathematical Typesetting
  • All expressions are given in LaTeX above.
  1. Conventions and Units
  • Dimensionless error probability \(p\); no units.
  1. Final Answer:
\[ F_{\mathrm{logical}}(p) = \frac{\left(1-\frac{12}{15}p\right)^2} {\left(1-\frac{12}{15}p\right)^2 + 3\left(\frac{4}{15}p\right)^2} = \frac{\left(1-\frac{4p}{5}\right)^2}{1-\frac{8p}{5}+\frac{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)
# We'll enumerate the error patterns to compute acceptance and logical fidelity.
from itertools import product

n=5  # number of qubits 0..4

# Utility functions for Pauli representation in symplectic binary form
# Use tuple (x_mask, z_mask) where each is an integer with n bits.

def pauli_mul(p,q):
    # Multiply Pauli p and q ignoring phase: XOR masks
    x1,z1=p
    x2,z2=q
    return (x1 ^ x2, z1 ^ z2)


def conj_cnot(p, c, t):
    x,z=p
    # Extract bits
    xc=(x>>c)&1
    xt=(x>>t)&1
    zc=(z>>c)&1
    zt=(z>>t)&1
    # After conjugation by CNOT(c,t):
    # x_t' = x_t XOR x_c; x_c' = x_c
    # z_c' = z_c XOR z_t; z_t' = z_t
    xtp = xt ^ xc
    xcp = xc
    zcp = zc ^ zt
    ztp = zt
    # Now update masks
    # Clear bits c,t and set new
    x &= ~(1<<c)
    x &= ~(1<<t)
    z &= ~(1<<c)
    z &= ~(1<<t)
    x |= (xcp<<c) | (xtp<<t)
    z |= (zcp<<c) | (ztp<<t)
    return (x,z)

# Function to get Pauli from a 2-qubit operator on pair (i,j)
# where local operator is in {I,X,Y,Z}^2 encoded as two chars like 'IX','YZ', etc.
pauli_char_to_bits={'I':(0,0),'X':(1,0),'Z':(0,1),'Y':(1,1)}

def pauli_on_pair(pair, s):
    i,j=pair
    x=z=0
    a,b=s
    xi,zi=pauli_char_to_bits[a]
    xj,zj=pauli_char_to_bits[b]
    if xi: x |= (1<<i)
    if zi: z |= (1<<i)
    if xj: x |= (1<<j)
    if zj: z |= (1<<j)
    return (x,z)

# Enumerate 16 two-qubit Paulis on a pair
symbols=['I','X','Y','Z']
all2=[(a,b) for a in symbols for b in symbols]

# Gate sequence and errors after each gate
# Gates: (1,2), (1,0), (2,3), (3,4), (0,4)
Gates=[(1,2),(1,0),(2,3),(3,4),(0,4)]

# Precompute conjugated errors to end for each gate and each 2-qubit Pauli
conj_to_end=[[] for _ in range(5)]
for k,(c,t) in enumerate(Gates):
    for s in all2:
        p = pauli_on_pair((c,t), s)
        # propagate through subsequent gates
        for (cc,tt) in Gates[k+1:]:
            p = conj_cnot(p, cc, tt)
        conj_to_end[k].append(p)

# Define stabilizers and logical Zs on data qubits 0..3 (bitmasks for 5 qubits, but we'll restrict)
# We'll use 5-qubit masks but ensure qubit 4 bits are zero

def make_pauli_on(qubits, ops):
    x=z=0
    for q,op in zip(qubits, ops):
        xi,zi=pauli_char_to_bits[op]
        if xi: x |= (1<<q)
        if zi: z |= (1<<q)
    return (x,z)

Sx = make_pauli_on([0,1,2,3], list('XXXX'))
Sz = make_pauli_on([0,1,2,3], list('ZZZZ'))
ZA = make_pauli_on([0,1,2,3], list('ZZII'))
ZB = make_pauli_on([0,1,2,3], list('ZIZI'))

# Function to restrict to data (zero out ancilla bits)

def restrict_data(p):
    x,z=p
    # zero out qubit 4 bit
    mask=((1<<4)-1)  # bits 0..3 set
    return (x & mask, z & mask)

# Commutation check for two Pauli operators p and q
# They commute iff p.x · q.z + p.z · q.x = 0 (mod 2)

def commute(p,q):
    x1,z1=p; x2,z2=q
    # bit dot product mod 2
    return (bin((x1 & z2)).count('1') + bin((z1 & x2)).count('1')) % 2 == 0

# Generate the good-group G = <Sx, Sz, ZA, ZB> as a set of (x,z) on data qubits
from itertools import product as itprod

# Build the group (ignoring phases): we can generate all 16 combinations
G_good=set()
# We'll encode Paul's as 5-qubit masks but with bit 4 zero; We'll restrict for comparison simplicity
gens=[Sx, Sz, ZA, ZB]
combos=list(itprod([0,1], repeat=4))
for coeffs in combos:
    p=(0,0)
    for g,co in zip(gens, coeffs):
        if co:
            p=pauli_mul(p, g)
    G_good.add(restrict_data(p))

# Acceptance tests

def accept_code(p):
    pd=restrict_data(p)
    return commute(pd, Sx) and commute(pd, Sz)

def accept_ancilla(p):
    x,z=p
    # accept if no X on ancilla (bit 4 of x is 0). Z on ancilla is fine
    return ((x>>4) & 1) == 0

def good_logical(p):
    pd=restrict_data(p)
    return pd in G_good

# Enumerate all patterns: for each gate choose one of 16 Paulis.
# We'll accumulate counts A_k and G_k for k = number of non-identity insertions.
A=[0]*6
G=[0]*6
B=[0]*6  # bad accepted counts (accepted but not good)

# We'll also compute total number of patterns for each k for sanity: T[k]
T=[0]*6

# Map symbol index to whether it's identity
is_id=[(a=='I' and b=='I') for (a,b) in all2]

# Pre-list conj Paul's and whether id to count k easily
conj_by_gate = conj_to_end

# We'll enumerate using indices 0..15 for each gate
for idxs in product(range(16), repeat=5):
    # Count number of non-identity selections
    k = sum(0 if is_id[i] else 1 for i in idxs)
    T[k]+=1
    # Compute final error Pauli
    p=(0,0)
    for gate_index, sym_index in enumerate(idxs):
        p = pauli_mul(p, conj_by_gate[gate_index][sym_index])
    # Acceptance checks
    if accept_code(p) and accept_ancilla(p):
        A[k]+=1
        if good_logical(p):
            G[k]+=1
        else:
            B[k]+=1

# Let's print counts and totals
print('Totals by k:')
print('k, T[k], A[k], G[k], B[k]')
for k in range(6):
    print(k, T[k], A[k], G[k], B[k])

# Now we can write P_acc(p) and P_good(p), F = P_good / P_acc
# We'll express them as polynomials in q=(p/15) and r=(1-p)

from fractions import Fraction

# We'll produce coefficients as fractions 

def poly_acc(p):
    # compute value symbolically representation as dict of powers of p up to 5 maybe convert to expanded polynomials later
    pass

# But easiest: We'll produce symbolic expression using sympy if allowed, else compute rational coefficients by expanding terms numerically then reconstruct
Tool #7
Totals by k:
k, T[k], A[k], G[k], B[k]
0 1 1 1 0
1 75 7 7 0
2 2250 282 138 144
3 33750 4222 1198 3024
4 253125 31637 7397 24240
5 759375 94923 24027 70896
Assistant #8
Tool Call (code to execute)
from fractions import Fraction

A=[1,7,282,4222,31637,94923]
G=[1,7,138,1198,7397,24027]
B=[0,0,144,3024,24240,70896]

# Build polynomials for P_acc and P_good as rational functions values in Fraction
# Represent polynomial as list of coefficients c0 + c1 p + c2 p^2 + ...

def poly_add(a,b):
    n=max(len(a), len(b))
    a=a+[Fraction(0)]*(n-len(a))
    b=b+[Fraction(0)]*(n-len(b))
    return [a[i]+b[i] for i in range(n)]


def poly_mul(a,b):
    res=[Fraction(0)]*(len(a)+len(b)-1)
    for i,ai in enumerate(a):
        for j,bj in enumerate(b):
            res[i+j]+=ai*bj
    return res

# Build (1-p)^(n) polynomials

def poly_pow_one_minus_p(n):
    # (1-p)^n = sum_{j=0}^n C(n,j) * 1^{n-j} * (-p)^j
    from math import comb
    return [Fraction(((-1)**j)*comb(n,j)) for j in range(n+1)]

# build term for given k: A[k]*(1-p)^(5-k)*(p/15)^k

def term_poly(count, k):
    # polynomial for (1-p)^(5-k)
    p1=poly_pow_one_minus_p(5-k)
    # multiply by (p/15)^k: scale by 1/15^k and shift degree by k
    scale=Fraction(1, 15**k)
    p2=[Fraction(0)]*k + [scale]  # placeholder for p^k; we'll multiply by p1
    # Multiply p1 and p2: (1-p)^(5-k) * p^k / 15^k
    poly=poly_mul(p1, p2)
    # Multiply by count
    poly=[count*coeff for coeff in poly]
    return poly

# sum for P_acc and P_good
Pacc=[Fraction(0)]
Pgood=[Fraction(0)]
for k in range(6):
    Pacc=poly_add(Pacc, term_poly(A[k], k))
    Pgood=poly_add(Pgood, term_poly(G[k], k))

print('P_acc coefficients (Fractions) up to p^5:')
print(Pacc)
print('P_good coefficients:')
print(Pgood)

# Simplify into common denominator maybe multiply by 15^5 to show nicer integers? But expression uses denominators 15^k; We'll just print exact fractions.

# Now compute P_bad_acc = Pacc - Pgood
Pbad=[Pacc[i]-Pgood[i] if i < len(Pgood) else Pacc[i] for i in range(len(Pacc))]
print('P_bad coefficients:')
print(Pbad)

# Let's also produce the fidelity F(p) = Pgood/Pacc; We can keep as ratio of polynomials.

# For sanity, numerical approximation coefficients for small p: F=1 - cp^2 + O(p^3)? We'll compute series by dividing polynomials.

import math

def series_div(num, den, order=5):
    # compute series num/den up to p^order where num,den are lists of Fractions
    a=num + [Fraction(0)]*(order+1 - len(num))
    b=den + [Fraction(0)]*(order+1 - len(den))
    q=[Fraction(0)]*(order+1)
    r=a[:]
    for i in range(order+1):
        if b[0] == 0:
            raise ZeroDivisionError
        q[i]=r[0]/b[0]
        # subtract q_i * den shifted by i
        for j in range(len(b)):
            if i+j <= order:
                r[i+j] -= q[i]*b[j]
        # drop r[0]
        r=r[1:]+[Fraction(0)]
    return q

series=series_div(Pgood, Pacc, order=5)
print('Series coefficients for F(p) = sum c_n p^n:')
print(series)

# Also print P_acc in a more compact factorized form like sum a_k (1-p)^(5-k) (p/15)^k, we already have counts; maybe we can present that directly.
Tool #9
P_acc coefficients (Fractions) up to p^5:
[Fraction(1, 1), Fraction(-68, 15), Fraction(704, 75), Fraction(-32768, 3375), Fraction(253952, 50625), Fraction(-262144, 253125)]
P_good coefficients:
[Fraction(1, 1), Fraction(-68, 15), Fraction(656, 75), Fraction(-29312, 3375), Fraction(223232, 50625), Fraction(-229376, 253125)]
P_bad coefficients:
[Fraction(0, 1), Fraction(0, 1), Fraction(16, 25), Fraction(-128, 125), Fraction(2048, 3375), Fraction(-32768, 253125)]
Series coefficients for F(p) = sum c_n p^n:
[Fraction(1, 1), Fraction(0, 1), Fraction(-16, 25), Fraction(128, 125), Fraction(112, 3375), Fraction(-701632, 253125)]
Assistant #10
Tool Call (code to execute)
from fractions import Fraction
Pacc=[Fraction(1, 1), Fraction(-68, 15), Fraction(704, 75), Fraction(-32768, 3375), Fraction(253952, 50625), Fraction(-262144, 253125)]
from math import isclose
# Evaluate at p=1
p1=sum(Pacc[i] for i in range(len(Pacc)))
print('P_acc(1)=', float(p1), p1)
# Compare to A5 / 15^5
from fractions import Fraction
print('A5/15^5 =', float(Fraction(94923, 15**5)), Fraction(94923, 15**5))
# Evaluate F(1) and check good ratio
Pgood=[Fraction(1, 1), Fraction(-68, 15), Fraction(656, 75), Fraction(-29312, 3375), Fraction(223232, 50625), Fraction(-229376, 253125)]
pg1=sum(Pgood)
print('P_good(1)=', float(pg1), pg1)
print('G5/15^5=', float(Fraction(24027, 15**5)), Fraction(24027, 15**5))
F1=float(pg1/p1)
print('F(1)=', F1)
Tool #11
P_acc(1)= 0.1250014814814815 10547/84375
A5/15^5 = 0.1250014814814815 10547/84375
P_good(1)= 0.03164049382716049 8009/253125
G5/15^5= 0.03164049382716049 8009/253125
F(1)= 0.25312095066527607
Assistant #12
  1. Step-by-Step Derivation
  • Target state and circuit
  • The circuit executes, right-to-left: 1) H1, 2) CNOT12, 3) CNOT10, 4) CNOT23, 5) CNOT34, 6) CNOT04, then measure M4 in the Z basis.
  • In the noiseless case, the data qubits 0–3 are prepared in the logical state |00⟩AB (the unique +1 eigenstate of the code stabilizers XXXX, ZZZZ and logical Zs Z_A=ZZII, Z_B=ZIZI), and the ancilla 4 ends in |0⟩, unentangled from the data.

  • Noise model

  • After each CNOT gate there is an independent two-qubit depolarizing channel:

    • With probability 1−p: identity II on that pair.
    • With probability p: one of the 15 non-identity two-qubit Paulis, each with probability p/15.
  • Pauli propagation through CNOTs

  • Conjugation by CNOT(c→t) on a Pauli with symplectic bits (x,z) acts linearly:
    • x′_c = x_c, x′_t = x_t ⊕ x_c
    • z′_c = z_c ⊕ z_t, z′_t = z_t
  • We insert the error after the kth CNOT and conjugate it forward through all subsequent CNOTs to get its effect at the end. The total error is the product (in Pauli group, up to a global phase) of the 5 propagated errors.

  • Acceptance and logical-correctness criteria

  • Code post-selection: accept only if the data-qubit error E_data commutes with both stabilizers XXXX and ZZZZ (i.e., E_data ∈ normalizer N(𝒮)). Otherwise it is “detected by the code” and the run is rejected.
  • Ancilla post-selection: in the ideal state the ancilla is |0⟩ and unentangled. Measuring Z4 yields 0 iff the final Pauli on qubit 4 is I or Z. Hence accept iff the ancilla factor has no X (i.e., the X-bit on qubit 4 is 0).
  • Logical fidelity among accepted runs: “good” errors are precisely those that fix the target logical state |00⟩AB. Since |00⟩AB is stabilized by the code stabilizers plus the logical Zs, the good set on the data is 𝒢_good = ⟨XXXX, ZZZZ, Z_A, Z_B⟩. Thus an accepted error is logically correct iff E_data ∈ 𝒢_good.

  • Exact counting by stabilizer-Pauli enumeration

  • For each gate, there are 16 two-qubit Paulis; for 5 gates, 16^5 patterns. Let k be the number of non-identity insertions (k=0,…,5). Each pattern has probability (1−p)^(5−k) (p/15)^k.
  • Exhaustive enumeration (propagating each Pauli forward and checking the two acceptance tests and the “good” membership) yields, for each k, the number of accepted patterns A_k and the number of accepted-and-good patterns G_k:

    • k=0: A_0=1, G_0=1
    • k=1: A_1=7, G_1=7
    • k=2: A_2=282, G_2=138
    • k=3: A_3=4222, G_3=1198
    • k=4: A_4=31637, G_4=7397
    • k=5: A_5=94923, G_5=24027
  • Therefore

    • Acceptance probability: P_acc(p) = ∑_{k=0}^5 A_k (1−p)^{5−k} (p/15)^k.
    • Good-accepted probability: P_good(p) = ∑_{k=0}^5 G_k (1−p)^{5−k} (p/15)^k.
    • Logical fidelity conditioned on acceptance: F_logical(p) = P_good(p) / P_acc(p).
  • Closed-form polynomials

  • Expanding the above sums gives
    • P_acc(p) = 1 − (68/15) p + (704/75) p^2 − (32768/3375) p^3 + (253952/50625) p^4 − (262144/253125) p^5.
    • P_good(p) = 1 − (68/15) p + (656/75) p^2 − (29312/3375) p^3 + (223232/50625) p^4 − (229376/253125) p^5.
  • The (accepted but) logically-wrong probability is P_bad(p) = P_acc(p) − P_good(p) = (16/25) p^2 − (128/125) p^3 + (2048/3375) p^4 − (32768/253125) p^5.

  • Sanity check: small-p series

  • Dividing P_good by P_acc, F_logical(p) = 1 − (16/25) p^2 + (128/125) p^3 + (112/3375) p^4 − (701632/253125) p^5 + O(p^6), showing first-order faults are fully detected/removed (no p term), as expected for a fault-tolerant preparation.
  1. Mathematical Typesetting
  • As above.
  1. Conventions and Units
  • Error probability p is dimensionless.
  1. Final Answer: The logical fidelity conditioned on post-selecting both the code’s detectable errors and the ancilla outcome M4=0 is
\[ F_{\mathrm{logical}}(p) =\frac{P_{\mathrm{good}}(p)}{P_{\mathrm{acc}}(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}. \]

Equivalently,

\[ F_{\mathrm{logical}}(p) =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}. \]
User #13

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 #14
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 ------------------
    numerator = (
        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
    )
    denominator = (
        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 = numerator / denominator  # a SymPy expression of inputs
    # ---------------------------------------------------------------

    return F_logical