Checkpoint-2

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
Tool Call (code to execute)
import numpy as np

# Pauli matrices
I = np.array([[1,0],[0,1]], dtype=complex)
X = np.array([[0,1],[1,0]], dtype=complex)
Y = np.array([[0,-1j],[1j,0]], dtype=complex)
Z = np.array([[1,0],[0,-1]], dtype=complex)
paulis = [I,X,Y,Z]

# Two-qubit depolarizing set (excluding identity)
non_id_twoq = []
for a in [X,Y,Z]:
    for b in [I,X,Y,Z]:
        pass
# Instead define all 16, then exclude identity
all2 = []
labels2 = []
for a_label, A in zip('IXYZ', [I,X,Y,Z]):
    for b_label, B in zip('IXYZ', [I,X,Y,Z]):
        all2.append(np.kron(A,B))
        labels2.append(a_label+b_label)

non_id_idx = [i for i,l in enumerate(labels2) if l != 'II']
non_id_twoq = [all2[i] for i in non_id_idx]
non_id_labels = [labels2[i] for i in non_id_idx]

# 4-qubit operations helpers

def kron_n(*ops):
    out = np.array([[1]], dtype=complex)
    for op in ops:
        out = np.kron(out, op)
    return out

# Basis ordering: qubits 0,1,2,3 left-to-right

# Define H and CNOT( control, target )
H = (1/np.sqrt(2))*np.array([[1,1],[1,-1]], dtype=complex)

def CNOT(control, target, n=4):
    X = np.array([[0,1],[1,0]], dtype=complex)
    I = np.eye(2)
    P0 = np.array([[1,0],[0,0]], dtype=complex)
    P1 = np.array([[0,0],[0,1]], dtype=complex)
    ops0 = [I]*n
    ops1 = [I]*n
    ops0[control] = P0
    ops1[control] = P1
    U0 = ops0[0]
    for op in ops0[1:]:
        U0 = np.kron(U0, op)
    ops1[target] = X
    U1 = ops1[0]
    for op in ops1[1:]:
        U1 = np.kron(U1, op)
    return U0 + U1

# Build the noiseless circuit state from |0000>
ket0 = np.zeros(16, dtype=complex)
ket0[0] = 1

U = np.eye(16, dtype=complex)
# Right-to-left order: H2, CNOT21, H0, CNOT03
U = CNOT(0,3,4) @ (np.kron(H,np.kron(np.eye(2),np.eye(2))) @ np.kron(np.eye(4),np.eye(4)))
# Wait fix: Compose stepwise
U = np.eye(16, dtype=complex)
# Apply H on qubit 2
U = np.kron(np.eye(4), H) @ U  # but this puts H on qubit 3; fix ordering
# Let's write a function to apply single-qubit op on qubit q

def U_single(op, q, n=4):
    ops = [np.eye(2)]*n
    ops[q] = op
    U = ops[0]
    for M in ops[1:]:
        U = np.kron(U, M)
    return U

U = np.eye(16, dtype=complex)
U = CNOT(0,3,4) @ U_single(H,0,4) @ CNOT(2,1,4) @ U_single(H,2,4)

psi = U @ ket0

# Build target state explicitly as product of Bell pairs (21) and (03)
Phi = (np.kron([1,0,0,1],[1,0,0,1])/2**0.5) # wrong, not shaped; let's do differently
phi = (np.array([1,0,0,1], dtype=complex)/np.sqrt(2)) # two qubits
phi21 = phi  # basis order 2,1? We'll need to embed carefully; it's messy
# Instead, just trust psi is the final state

# Now compute fidelity under noise model: brute-force sum over all error combos

# Build two-qubit paulis on (2,1)
P21 = []
labels21 = []
for a_label, A in zip('IXYZ', [I,X,Y,Z]):
    for b_label, B in zip('IXYZ', [I,X,Y,Z]):
        # apply on q2 and q1: 0,1,2,3 ordering => for q0,q1,q2,q3
        Uop = kron_n(np.eye(2), np.eye(2), A, B)  # q0 I, q1 I, q2 A, q1 B? Wrong order: This gives 0,1,2,3 -> I,I,A,B; B acts on q3 actually
Tool #3
Traceback (most recent call last):
  File "<stdin>", line 64, in <module>
ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 16 is different from 8)
Assistant #4
  1. Step-by-Step Derivation
  • Model and notation
  • Two-qubit depolarizing channel applied after each CNOTij: E(ρ) = (1 − p) ρ + (p/15) ΣP≠II P ρ P, where the sum runs over the 15 non-identity two-qubit Paulis {I,X,Y,Z}⊗{I,X,Y,Z} \ {II}. This is the standard two-qubit depolarizing model with equal weight on the 15 non-identity Paulis. citeturn1search2
  • Physical state fidelity with target pure state |ψ⟩ is F = ⟨ψ| ρ |ψ⟩.

  • Ideal output of the circuit (no errors)

  • The circuit is (CNOT03)(H0)(CNOT21)(H2), applied right-to-left.
  • Starting from |0000⟩, the right branch prepares a Bell pair on qubits (2,1): H2 maps |0⟩2 → (|0⟩2 + |1⟩2)/√2, and CNOT21 entangles control 2 with target 1 to yield |Φ+⟩21 = (|00⟩21 + |11⟩21)/√2. citeturn1search3
  • Independently, the left branch prepares a Bell pair on qubits (0,3): H0 followed by CNOT03 yields |Φ+⟩03 = (|00⟩03 + |11⟩03)/√2. citeturn1search3
  • Therefore, the ideal 4-qubit output state is |ψid⟩ = |Φ+⟩21 ⊗ |Φ+⟩03.

  • Where the noise acts

  • A two-qubit depolarizing channel E21 acts immediately after CNOT21 on qubits (2,1).
  • A two-qubit depolarizing channel E03 acts immediately after CNOT03 on qubits (0,3).
  • No gate after CNOT21 touches qubits 2 or 1, and the two noisy pairs are disjoint, so the resulting noise is a product of independent two-qubit Paulis on (2,1) and on (0,3).

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

  • Let |Φ+⟩ be the two-qubit Bell state. The fidelity after E is f := ⟨Φ+| E(|Φ+⟩⟨Φ+|) |Φ+⟩ = (1 − p) ⟨Φ+|Φ+⟩ + (p/15) ΣP≠II |⟨Φ+| P |Φ+⟩|^2.
  • Action of two-qubit Paulis on |Φ+⟩:
    • X ⊗ X |Φ+⟩ = |Φ+⟩, Z ⊗ Z |Φ+⟩ = |Φ+⟩, Y ⊗ Y |Φ+⟩ = −|Φ+⟩, hence all three have overlap magnitude 1.
    • Any other two-qubit Pauli (e.g., X⊗I, I⊗X, X⊗Z, etc.) maps |Φ+⟩ to one of the other Bell states {|Φ−⟩, |Ψ+⟩, |Ψ−⟩}, which are orthogonal to |Φ+⟩, giving overlap 0. These properties follow from the Bell-state stabilizers XX and ZZ (with YY = −XX·ZZ) and the orthonormality of the four Bell states. citeturn1search1turn1search3
  • Counting contributions: among the 15 non-identity two-qubit Paulis, exactly three have |overlap| = 1 (XX, YY, ZZ), and the remaining twelve give 0. Therefore, f = (1 − p) · 1 + (p/15) · 3 · 1 = 1 − p + p/5 = 1 − 4p/5.

  • Total 4-qubit fidelity

  • The two noisy pairs are independent and act on disjoint Bell states. The final state is ρ = E21(|Φ+⟩⟨Φ+|21) ⊗ E03(|Φ+⟩⟨Φ+|03), so the total fidelity with |ψid⟩ = |Φ+⟩21 ⊗ |Φ+⟩03 factorizes: F(p) = f21 · f03 = f^2 = (1 − 4p/5)^2.
  1. Mathematical Typesetting
  • Two-qubit depolarizing channel:
\[ \mathcal{E}(\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}.\) citeturn1search2

  • Single-pair fidelity:
\[ \]
  • Total fidelity:
\[ F(p) = f^2 = \left(1 - \frac{4p}{5}\right)^2. \]
  1. Conventions and Units
  • Fidelity is defined as \(F = \langle \psi_{\mathrm{id}} | \rho | \psi_{\mathrm{id}} \rangle\) for target pure state \(|\psi_{\mathrm{id}}\rangle\).
  1. Final Answer: F(p) = (1 − 4p/5)^2.
User #5

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 #6
  1. Step-by-Step Derivation
  • Setup and noise model
  • Circuit (right-to-left): H2 → CNOT21 → H0 → CNOT03. Errors are applied after each CNOT as an independent two-qubit depolarizing channel acting on that CNOT’s two qubits. For an n-qubit gate, the depolarizing channel is
\[ \mathcal{D}_n(\rho)=(1-p)\rho+\frac{p}{4^n-1}\sum_{P\in\{I,X,Y,Z\}^{\otimes n}\setminus\{I^{\otimes n}\}} P\rho P. \]
Here n=2, so each non-identity two-qubit Pauli follows with probability p/15. ([arxiv.org](https://arxiv.org/html/2310.12448v2?utm_source=openai))
  • Ideal output state and the [[4,2,2]] code
  • The two subcircuits H2–CNOT21 and H0–CNOT03 each prepare a Bell state |Φ+⟩ on their respective qubit pairs. Thus the ideal final 4-qubit state is
\[ |\psi_{\mathrm{id}}\rangle = |\Phi^+\rangle_{21}\otimes |\Phi^+\rangle_{03}. \]
(A Hadamard on the control followed by a CNOT prepares |Φ+⟩.) ([en.wikipedia.org](https://en.wikipedia.org/wiki/Bell_state))
  • The [[4,2,2]] code (qubits 0,1,2,3) has stabilizers S_X=XXXX and S_Z=ZZZZ; the code space is the simultaneous +1 eigenspace of S_X and S_Z. We post-select on measuring (+1,+1). (pmc.ncbi.nlm.nih.gov)

  • Commutation/detection rule

  • A Pauli error E on the data is detected iff it anti-commutes with at least one stabilizer generator; errors commuting with both generators are undetected (they lie in the centralizer of the stabilizer). For Pauli strings, commutation is determined by the symplectic product or, equivalently, by parity of X/Z mismatches on qubits where the operators have non-identity support. (en.wikipedia.org)

  • Where the errors sit

  • Let P21 be the two-qubit Pauli (possibly identity) inserted after CNOT21, acting on qubits (2,1), and P03 be the two-qubit Pauli inserted after CNOT03, acting on (0,3). No later gates touch those qubits, so the net error is E = P21 ⊗ P03.

  • Parity classification (per pair)

  • For a two-qubit Pauli P, define its parity vector w(P)=(a,b) with a = (# of Z or Y in P) mod 2 (anticommutes with X), and b = (# of X or Y in P) mod 2 (anticommutes with Z).
  • For a fixed pair, the 16 Paulis partition evenly into four classes w∈{00,01,10,11} (four elements per class). The w=00 class is {II,XX,YY,ZZ}; each element commutes with both X⊗X and Z⊗Z on that pair. By the symplectic/commutation rule, global commutation with S_X=XXXX (resp. S_Z=ZZZZ) is obtained when the total parity (sum over the two pairs) is even for a (resp. b). (en.wikipedia.org)
  • Under the two-qubit depolarizing model at one location:
\[ p_{00}&=\Pr[w=00]=(1-p)+\frac{3}{15}p=1-\frac{12}{15}p,\\ p_{01}=p_{10}=p_{11}&=\Pr[w\in\{01,10,11\}]=\frac{4}{15}p. \]
(Among the 15 non-identity Paulis, three are in w=00 and four in each of the other classes.) ([arxiv.org](https://arxiv.org/html/2310.12448v2?utm_source=openai))
  • Post-selection (acceptance) probability
  • Acceptance requires matching parities across the two pairs: w(P21)=w(P03). Therefore
\[ \]
Substituting the expressions above,
\[ \]
  • Which accepted errors preserve the logical Bell state?
  • The logical target is the Bell state (|00⟩AB+|11⟩AB)/√2, which is stabilized by X_A X_B and Z_A Z_B. In the given representation of the [[4,2,2]] code, these coincide (up to stabilizers) with two-qubit Paulis XX and ZZ on qubits (2,1); similarly Y_A Y_B corresponds to YY(2,1). Hence any physical error equivalent (mod stabilizers) to I, X_A X_B, Y_A Y_B, or Z_A Z_B leaves the logical state invariant. (pmc.ncbi.nlm.nih.gov)
  • Every accepted error with w(P21)=w(P03)=00 is a product of {II,XX,YY,ZZ} on each pair, i.e., E∈{II,XX,YY,ZZ}{21}×{II,XX,YY,ZZ}{03}. Such errors lie in the centralizer and are equal, on the code space, to one of the four operators {I, X_A X_B, Y_A Y_B, Z_A Z_B} multiplied by a stabilizer; hence they stabilize the logical |Φ+⟩AB. Conversely, accepted errors with w in {01,10,11} correspond to single-logical flips (e.g., X_A, X_B, Z_A, Z_B, …) that map |Φ+⟩AB to an orthogonal Bell state. Therefore “good-and-accepted” ≡ both pairs in class w=00. (en.wikipedia.org, pmc.ncbi.nlm.nih.gov)

  • Conditional logical fidelity

  • Let N_good be the probability of accepted events that preserve the logical state. Then
\[ N_{\mathrm{good}}=p_{00}\cdot p_{00}=\left(1-\frac{12}{15}p\right)^2. \]
  • The logical fidelity conditioned on acceptance is
\[ \]
  • Small-p expansion: using p00=1−4p/5 and p01=4p/15,
\[ F_{\mathrm{logical}}(p)=1-\frac{16}{75}p^2+O(p^3), \]
i.e., post-selection removes all first-order (in p) logical errors.
  1. Mathematical Typesetting
  • Acceptance:
\[ \]
  • Logical fidelity (post-selected):
\[ 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}. \]
  1. Conventions and Units
  • Fidelity F = ⟨ψid|ρ|ψid⟩ for pure target state |ψid⟩.
  • Post-selection assumes perfect stabilizer measurements of S_X and S_Z. (pmc.ncbi.nlm.nih.gov)
  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{(1-\frac{4}{5}p)^2}{(1-\frac{4}{5}p)^2+\frac{48}{225}p^2}. \]
User #7

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 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$ in Sympy format.

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

    Outputs
    ----------
    F_logical: sympy.Expr, the logical state fidelity as a function of $p$
    """

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

    return F_logical
Assistant #8
import sympy as sp

p = sp.symbols('p')

def answer(p):
    r"""
    Return the expression of 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$ in Sympy format.

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

    Outputs
    ----------
    F_logical: sympy.Expr, the logical state fidelity as a function of $p$
    """

    # ------------------ FILL IN YOUR RESULTS BELOW ------------------
    F_logical = (1 - sp.Rational(4, 5)*p)**2 / ((1 - sp.Rational(4, 5)*p)**2 + sp.Rational(16, 75)*p**2)
    # ---------------------------------------------------------------

    return F_logical