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, or mathematical identities.
  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\).

Checkpoint 1

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

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

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

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

Assistant #2
  1. Step-by-Step Derivation
  • Noise model and effective error:
  • Only the two CNOTs are noisy. After CNOT21 a two-qubit depolarizing channel acts on qubits (2,1), and after CNOT03 a depolarizing channel acts on qubits (0,3).
  • Let the Pauli error after CNOT21 be \(P_{12}\) (acting on qubits 1,2; same as 2,1 up to ordering) and after CNOT03 be \(P_{03}\) (acting on qubits 0,3). Each takes value
    • \(II\) with probability \(1-p\),
    • each of the 15 non-identity two-qubit Paulis with probability \(p/15\).
  • Because the gates following \(P_{12}\) (namely \(H_0\) and CNOT03) act only on qubits 0 and 3, they commute with \(P_{12}\). Hence the effective Pauli at the end is simply
\[ P_{\text{eff}} = P_{03}\,P_{12} = P_{03} \otimes P_{12}, \]
acting on disjoint pairs.
  • Target state is a stabilizer state:
  • The code stabilizers are \(XXXX\) and \(ZZZZ\).
  • For the logical GHZ state \((|00\rangle_{AB}+|11\rangle_{AB})/\sqrt{2}\), the logical stabilizers are \(X_A X_B\) and \(Z_A Z_B\).
  • Using the given logical operators,
\[ X_A X_B = (XIXI)(XXII) = IXXI, \]
\[ Z_A Z_B = (ZZII)(ZIZI) = IZZI. \]
  • Thus the target 4-qubit state is the unique stabilizer state with generators
\[ \langle\, XXXX,\; ZZZZ,\; IXXI,\; IZZI \,\rangle. \]
  • Stabilizer factorization over the two disjoint pairs (0,3) and (1,2):
  • Restrict these generators to qubits (0,3):
    • \(XXXX \to XX\), \(ZZZZ \to ZZ\), \(IXXI \to II\), \(IZZI \to II\),
    • generating the subgroup \(\{II,\,XX,\,YY,\,ZZ\}\) on qubits (0,3).
  • Restrict to qubits (1,2):
    • \(XXXX \to XX\), \(ZZZZ \to ZZ\), \(IXXI \to XX\), \(IZZI \to ZZ\),
    • also generating \(\{II,\,XX,\,YY,\,ZZ\}\) on qubits (1,2).
  • Therefore the full stabilizer group is
\[ \mathcal{S}_{\text{target}} = \{P_{03}\otimes P_{12}\;|\;P_{03}\in\{II,XX,YY,ZZ\},\;P_{12}\in\{II,XX,YY,ZZ\}\}, \]
of size 16.
  • Fidelity with a stabilizer state under Pauli noise:
  • For a stabilizer state \(|\psi\rangle\), and a Pauli error \(P\), \(\langle\psi|P|\psi\rangle=1\) iff \(P\in\mathcal{S}_{\text{target}}\), and \(0\) otherwise.
  • The physical state fidelity is thus the probability that the effective Pauli lies in the stabilizer:
\[ F(p) = \Pr\big(P_{\text{eff}}\in\mathcal{S}_{\text{target}}\big). \]
  • Since \(P_{\text{eff}}=P_{03}\otimes P_{12}\) and \(\mathcal{S}_{\text{target}}\) factorizes as above, this becomes
\[ F(p) = \Pr\big(P_{03}\in\{II,XX,YY,ZZ\}\big)\cdot \Pr\big(P_{12}\in\{II,XX,YY,ZZ\}\big). \]
  • Probability for one noisy CNOT to yield a “good” pair:
  • For a two-qubit depolarizing channel with error rate \(p\):
\[ \Pr(P=II) = 1-p,\quad \Pr(P=Q\neq II)=\frac{p}{15}. \]
  • The “good” set is \(\{II,XX,YY,ZZ\}\), which contains \(II\) and 3 specific non-identity Paulis. Hence for one channel,
\[ \Pr(\text{good}) = (1-p) + 3\frac{p}{15} = 1 - \frac{4}{5}p. \]
  • Combine the two independent channels:
\[ F(p) = \left(1-\frac{4}{5}p\right)^2 = 1 - \frac{8}{5}p + \frac{16}{25}p^2. \]
  1. Mathematical Typesetting

All equations are presented above using LaTeX.

  1. Conventions and Units
  • Qubits labeled 0–3; logical qubits A,B; stabilizers and logical operators as provided.
  • Only two-qubit CNOT gates are noisy per the stated depolarizing model; single-qubit H gates are ideal.
  1. Final Answer: F(p) = (1 - 4p/5)^2 = 1 - (8/5)p + (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 and noise model
  • The only noisy operations are the two CNOTs. Right after each CNOT, a two-qubit depolarizing channel acts on that CNOT’s two qubits:
    • after CNOT21: an error \(P_{12}\) on qubits \((1,2)\),
    • after CNOT03: an error \(P_{03}\) on qubits \((0,3)\).
  • Each error is a Pauli on its two qubits: \(P\in\{II, IX,\dots, ZZ\}\) with
\[ \Pr(P=II)=1-p,\qquad \Pr(P=Q\neq II)=\frac{p}{15}. \]
  • The subsequent ideal gates act on disjoint qubits, so the effective end-of-circuit error is
\[ E = P_{03}\otimes P_{12}, \]
with $P_{03}$ and $P_{12}$ independent.
  • Target logical state and its physical stabilizer
  • The code stabilizers are \(XXXX\) and \(ZZZZ\).
  • For the logical Bell state \((|00\rangle_{AB}+|11\rangle_{AB})/\sqrt{2}\),
\[ X_A X_B = (XIXI)(XXII) = IXXI,\qquad Z_A Z_B = (ZZII)(ZIZI) = IZZI. \]
  • Hence the physical 4-qubit target state is the unique stabilizer state with generators
\[ \langle\, XXXX,\; ZZZZ,\; IXXI,\; IZZI \,\rangle. \]
  • Restricted to the disjoint pairs (0,3) and (1,2), this is exactly the product of two Bell pairs:
\[ \{II,XX,YY,ZZ\}_{03}\ \times\ \{II,XX,YY,ZZ\}_{12}. \]
  • Post-selection condition (detectable vs. undetectable)
  • We post-select on “no detectable error,” i.e., on errors \(E\) that commute with both \(XXXX\) and \(ZZZZ\).
  • For a two-qubit Pauli \(P\) on a pair, define the commutation signatures
\[ s_X(P)=\pm1 \text{ for } [P,XX]=0\text{ or }\{P,XX\}=0,\qquad s_Z(P)=\pm1 \text{ for } [P,ZZ]=0\text{ or }\{P,ZZ\}=0. \]
  • For the full error \(E=P_{03}\otimes P_{12}\), we have
\[ s_X(E)=s_X(P_{03})\,s_X(P_{12}),\qquad s_Z(E)=s_Z(P_{03})\,s_Z(P_{12}). \]
  • Post-selection acceptance requires
\[ s_X(E)=+1,\quad s_Z(E)=+1\quad\Longleftrightarrow\quad s_X(P_{03})=s_X(P_{12})\text{ and } s_Z(P_{03})=s_Z(P_{12}). \]
Thus $P_{03}$ and $P_{12}$ must lie in the same signature class.
  • Classifying two-qubit Paulis by signature
  • The 16 two-qubit Paulis on a pair split into four classes by \((s_X,s_Z)\in\{(+,+),(+,-),(-,+),(-,-)\}\), with exactly 4 Paulis per class.
  • The \((+,+)\) class is \(\{II,XX,YY,ZZ\}\); the other three classes each contain 4 non-identity Paulis.
  • Under the depolarizing model, the per-pair class probabilities are
\[ w_0:=\Pr\big((+,+)\big)=(1-p)+3\frac{p}{15}=1-\frac{4}{5}p, \]
\[ w_2=\Pr\big((-,+)\big)=\frac{4}{15}p,\quad \]
  • Acceptance probability (yield)
  • We accept iff the two independent draws \(P_{03}\) and \(P_{12}\) fall in the same class:
\[ = \left(1-\frac{4}{5}p\right)^2 + 3\left(\frac{4}{15}p\right)^2 \]
  • Logical fidelity conditioned on acceptance
  • Within the accepted set, the final logical 2-qubit state matches the target Bell state iff \(E\) fixes the target physical state, i.e., \(E\) lies in its stabilizer. From above, this requires
\[ P_{03}\in\{II,XX,YY,ZZ\},\quad P_{12}\in\{II,XX,YY,ZZ\}, \]
which occurs with probability $w_0^2 = \left(1-\frac{4}{5}p\right)^2$.
  • Any other accepted error is an undetectable logical Pauli (e.g., \(X_B\), \(Z_A\), or \(Y_A Y_B\) up to stabilizers) that maps the target Bell state to an orthogonal Bell state, yielding zero overlap.
  • Therefore the conditional logical state fidelity is
\[ = \frac{\Pr(E\in \text{stabilizer of target})}{\Pr(\text{accepted})} = \frac{\left(1-\frac{4}{5}p\right)^2}{\left(1-\frac{4}{5}p\right)^2 + 3\left(\frac{4}{15}p\right)^2} \]
  • Small-\(p\) expansion:
\[ F_{\text{logical}}(p)=1-\frac{16}{75}p^2+O(p^3), \]
i.e., all first-order logical errors are detected and discarded.
  1. Mathematical Typesetting

All expressions are typeset in LaTeX above.

  1. Conventions and Units
  • Qubits are labeled 0–3; logical qubits A,B as given.
  • Depolarizing noise only on the two CNOTs; Hadamards are ideal.
  • Post-selection keeps only errors commuting with \(XXXX\) and \(ZZZZ\).
  1. Final Answer: F_logical(p) = [(1 - 4p/5)^2] / [(1 - 4p/5)^2 + 3(4p/15)^2] = [1 - (8/5)p + (16/25)p^2] / [1 - (8/5)p + (64/75)p^2].
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
  1. Step-by-Step Derivation
  • Circuit, noise model, and acceptance
  • Data qubits are 0–3; ancilla is 4. The (right-to-left) circuit is
\[ H_1 \;\to\; CNOT_{12} \;\to\; CNOT_{10} \;\to\; CNOT_{23} \;\to\; CNOT_{34}\;\to\; CNOT_{04}\;\to\; M_4, \]
with a two-qubit depolarizing error after each CNOT: with probability $1-p$ no error, and with probability $p$ a uniformly random non-identity two-qubit Pauli (15 choices, each $p/15$).
  • Post-selection/acceptance: keep runs with ancilla outcome 0 and with no code-detectable error on the data (i.e., the final data Pauli error commutes with both stabilizers \(XXXX\) and \(ZZZZ\)).

  • Target encoded state and its stabilizer

  • The target is the encoded logical two-qubit state \(\lvert 00\rangle_{AB}\) in the [[4,2,2]] code, whose stabilizer we may take as
\[ \mathcal{S}_{\text{tgt}}=\langle XXXX,\; ZZZZ,\; Z_A:=ZZII,\; Z_B:=ZIZI\rangle. \]
  • Equivalently, the four commuting checks we will use are
\[ S_X:=XXXX, \quad S_Z:=ZZZZ,\quad Z_A=Z_0Z_1,\quad Z_B=Z_0Z_2. \]
  • The ancilla sequence \(CNOT_{34},CNOT_{04}\) followed by \(M_4\) in the \(Z\) basis measures \(Z_0Z_3\); for the ideal target state, the outcome is +1 (we keep outcome “0”).

  • Where leading-order logical errors can come from

  • Any single two-qubit fault that is accepted (i.e., passes the two code checks and the ancilla parity) must act as an element of the target stabilizer \(\mathcal{S}_{\text{tgt}}\), hence does not reduce fidelity (no \(O(p)\) infidelity). Therefore the first nontrivial contribution to logical infidelity is \(O(p^2)\), from two-fault combinations among the three “data-building” CNOTs: \(CNOT_{12}\), \(CNOT_{10}\), \(CNOT_{23}\).
  • Faults on the ancilla CNOTs do not affect the data (they cannot propagate back to controls), and while they can flip the ancilla outcome, they cannot by themselves induce data logical errors; mixed pairs (one data, one ancilla fault) cannot produce an undetected logical error after code post-selection.

  • Signature method: how an error transforms the four checks

  • For any final data Pauli error \(E\), define its commutation signatures with the four checks as
\[ s_X(E)=\pm1\ \text{for } [E,S_X]=0 \text{ or } \{E,S_X\}=0, \]
\[ s_Z(E)=\pm1\ \text{for } [E,S_Z]=0 \text{ or } \{E,S_Z\}=0, \]
\[ \]
  • Acceptance constraints:
    • code post-selection requires s_X(E)=+1 and s_Z(E)=+1,
    • ancilla parity +1 (outcome 0) requires \(s_{Z_0Z_3}(E)=+1\). Noting \(Z_0Z_3 = S_Z \cdot Z_A \cdot Z_B\), we have
\[ s_{Z_0Z_3}(E)=s_Z(E)\,s_A(E)\,s_B(E). \]
  With $s_Z(E)=+1$ from code post-selection, this reduces to $s_A(E)\,s_B(E)=+1$.
  • Logical correctness vs. logical error:

    • The target state is stabilized by \(Z_A\) and \(Z_B\), so it is preserved iff \(s_A(E)=+1\) and \(s_B(E)=+1\).
    • Among accepted events (where \(s_A(E)\,s_B(E)=+1\)), the only way to be wrong is \(s_A(E)=s_B(E)=-1\) (this corresponds to a logical \(X_A X_B\)-type error up to stabilizers).
  • Per-gate signature distribution for a single fault

  • We place a two-qubit Pauli error immediately after a given CNOT and propagate it forward through any later data CNOTs to the end (ancilla CNOTs can be ignored for data signatures). For each of the three data CNOTs we compute the map from the 15 non-identity two-qubit Paulis to the signature vector
\[ v=(s_X, s_Z, s_A, s_B)\in\{\pm1\}^4. \]
  • Location L1: after \(CNOT_{12}\) (on qubits 1,2), only later CNOTs are \(CNOT_{10}\) and \(CNOT_{23}\). A two-qubit Pauli \(P_1\otimes P_2\) on (1,2) with bits
\[ x_k=\mathbf{1}[P_k\in\{X,Y\}],\quad z_k=\mathbf{1}[P_k\in\{Z,Y\}],\quad k=1,2, \]
yields the final signatures
\[ s_X=(-1)^{z_1+z_2},\quad s_Z=+1,\quad s_A=+1,\quad s_B=(-1)^{x_1+x_2}. \]
Thus $v$ depends only on the parities $(z_1+z_2)\bmod2$ and $(x_1+x_2)\bmod2$. Counting over the 15 non-identity $P_1\otimes P_2$ gives:
- $(+,+,+,+)$: 3
- $(-,+,+,+)$: 4
- $(+,+,+,-)$: 4
- $(-,+,+,-)$: 4
  • Location L2: after \(CNOT_{10}\) (on qubits 1,0), with no later data CNOT touching these qubits:
\[ s_X=(-1)^{z_1+z_0},\quad s_Z=(-1)^{x_1+x_0},\quad s_A=(-1)^{x_1+x_0},\quad s_B=(-1)^{x_0}. \]
Counting over 15 non-identity pairs yields:
- $(+,-,-,+)$: 2,  $(-,-,-,+)$: 2,  $(-,+,+,+)$: 2,  $(+,+,+,+)$: 1,
- $(+,-,-,-)$: 2,  $(+,+,+,-)$: 2,  $(-,+,+,-)$: 2,  $(-,-,-,-)$: 2.
  • Location L3: after \(CNOT_{23}\) (on qubits 2,3), with no later data CNOT at all:
\[ s_X=(-1)^{z_2+z_3},\quad s_Z=(-1)^{x_2+x_3},\quad s_A=+1,\quad s_B=(-1)^{x_2}. \]
Counting over 15 non-identity pairs yields:
- $(+,-,+,+)$: 1,  $(-,-,+,+)$: 2,  $(-,+,+,+)$: 2,  $(+,+,+,+)$: 2,
- $(+,-,+,-)$: 2,  $(+,+,+,-)$: 2,  $(-,+,+,-)$: 2,  $(-,-,+,-)$: 2.
  • No first-order logical error
  • For a single fault to be accepted it must satisfy \(s_X=+1\), \(s_Z=+1\), and \(s_A s_B=+1\). From the above distributions, all such single faults, if any, lie in the target stabilizer (e.g., \(Z_0Z_1\), \(Z_2Z_3\), or \(XXXX\)), hence they contribute no \(O(p)\) loss of fidelity.

  • Counting the \(O(p^2)\) accepted logical errors

  • For two independent faults at locations \(g\) and \(h\), the total signature is the componentwise product of the two signature vectors: \(v_{gh}=v_g\cdot v_h\).
  • An accepted logical error (to second order) requires:
\[ s_X^{(g)}s_X^{(h)}=+1,\quad s_Z^{(g)}s_Z^{(h)}=+1,\quad s_A^{(g)}s_A^{(h)}=-1,\quad s_B^{(g)}s_B^{(h)}=-1. \]
That is, the $s_X$ and $s_Z$ signs must match between the two faults, while $s_A$ and $s_B$ must be opposite.
  • Using the per-location distributions above, we count for each unordered pair of data CNOTs:
    • Pair (L1,L2): impossible, because L1 has \(s_A=+1\) always, while acceptance requires \(s_Z^{(1)}s_Z^{(2)}=+1\), which with L1’s \(s_Z=+1\) would force \(s_Z^{(2)}=+1\), but then \(s_A^{(2)}=s_Z^{(2)}=+1\) for L2 (since \(s_A=s_Z\) at L2), contradicting \(s_A^{(1)}s_A^{(2)}=-1\). So 0 combinations.
    • Pair (L1,L3): impossible, because both L1 and L3 have \(s_A=+1\), hence \(s_A^{(1)}s_A^{(2)}=+1\) cannot equal −1. So 0 combinations.
    • Pair (L2,L3): feasible. Imposing the four constraints and summing over the tabulated categories gives
\[ N_{\text{bad}}(L2,L3)=14. \]
  (Details: from L2 we must choose categories with $s_A^{(2)}=-1$ (equivalently $s_Z^{(2)}=-1$), and from L3 we must choose categories with $s_Z^{(3)}=-1$; then require equal $s_X$, and opposite $s_B$ signs. The count by matching the listed categories is 14.)
  • Therefore, among the \(15\times15=225\) ordered pairs of non-identity Pauli faults at a given unordered gate pair, only the (L2,L3) pair yields accepted logical errors, with 14 such combinations. There is only one such unordered pair among the three data CNOTs, so the total second-order probability of an accepted logical error is
\[ P_{\text{bad}} = \frac{14}{225}\,p^2 + O(p^3). \]
  • Logical fidelity to second order
  • The overall acceptance probability is \(1-O(p)\), so normalizing by acceptance affects the \(p^2\) coefficient only at \(O(p^3)\). Hence the logical state fidelity conditioned on acceptance is
\[ F_{\text{logical}}(p) = 1 - \frac{14}{225}\,p^2 + O(p^3). \]
  1. Mathematical Typesetting

All relevant formulas are expressed using LaTeX above.

  1. Conventions and Units
  • Only two-qubit CNOTs are noisy with a two-qubit depolarizing channel at rate \(p\); \(H\) and \(M\) are ideal.
  • Qubit labels and logical operators follow the problem statement.
  1. Final Answer: F_logical(p) = 1 - (14/225) p^2 + O(p^3).
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 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 #8
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 = 1 - sp.Rational(14, 225)*p**2 + sp.O(p**3)
    # ---------------------------------------------------------------

    return F_logical