A2: Generate State 12(∣0⟩−∣3⟩)\frac{1}{\sqrt{2}}\lparen\ket{0}-\ket{3}\rparen

Time Limit: 3 seconds

Memory Limit: 512 MiB

Score: 200 points

Writer:ST12

Editorial

In problem A1, we addressed the inversion of the global phase.

Now, how can we prepare a state with a different phase between two computational basis states?

First, prepare 12(∣00⟩+∣11⟩)\frac{1}{\sqrt{2}} \lparen \ket{00} + \ket{11} \rparen without considering the phase. Apply the Hadamard (HH) gate to the 11st qubit.

∣00⟩→H(0)12(∣00⟩+∣10⟩)\begin{equation} \ket{00} \xrightarrow{H(0)} \frac{1}{\sqrt{2}} \lparen \ket{00} + \ket{10} \rparen \end{equation}

By applying the Hadamard gate, we can create a superposition state of qubits.

Next, we need to transform ∣10⟩\ket{10} to ∣11⟩\ket{11}. To do this, we use the controlled XX (CXCX) gate, with the 11st qubit as the control qubit and the 22nd qubit as the target qubit. This controlled XX gate applies the XX gate to the 22nd qubit only in ∣10⟩\ket{10}, where the 11st qubit is ∣1⟩\ket{1}.

12(∣00⟩+∣10⟩)→CX(0,1)12(∣00⟩+∣11⟩)\begin{equation} \frac{1}{\sqrt{2}} \lparen \ket{00} + \ket{10} \rparen \xrightarrow{CX(0,1)} \frac{1}{\sqrt{2}} \lparen \ket{00} + \ket{11} \rparen \end{equation}

Finally, apply a ZZ gate to the 11st qubit of 12(∣00⟩+∣11⟩)\frac{1}{\sqrt{2}} \lparen \ket{00} + \ket{11} \rparen to transform ∣11⟩\ket{11} into −∣11⟩-\ket{11}.

12(∣00⟩+∣11⟩)→Z(0)12(∣00⟩−∣11⟩)\begin{equation} \frac{1}{\sqrt{2}} \lparen \ket{00} + \ket{11} \rparen \xrightarrow{Z(0)} \frac{1}{\sqrt{2}} \lparen \ket{00} - \ket{11} \rparen \end{equation}

Sample Code

Below is a sample program:

from qiskit import QuantumCircuit
 
 
def solve() -> QuantumCircuit:
    qc = QuantumCircuit(2)
 
    qc.h(0)
    qc.cx(0, 1)
    qc.z(0)
 
    return qc

Supplementary Information

  • Measuring either qubit in the state 12(∣00⟩−∣11⟩)\frac{1}{\sqrt{2}} (\ket{00} - \ket{11}) will determine the outcome of the other qubit. This phenomenon is known as quantum entanglement.
  • The controlled gate can be generalized to the multi-controlled gate which operates upon multiple control qubits. This modifies computational basis states wherein all control qubits are in the state ∣1⟩\ket{1}.