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

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 200

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, apply the Hadamard (HH) gate to the first qubit.

00H(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-X (CX) gate, with the first qubit as the control bit and the second qubit as the target bit. The CXCX gate only applies the XX gate to the target bit when the control bit 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, to invert the phase of the 11\ket{11} state and create 12(0011)\frac{1}{\sqrt{2}} \left( \ket{00} - \ket{11} \right), apply a ZZ gate to the second qubit.

12(00+11)Z(0)12(0011)\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(0011)\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}.