A4: Generate state 13(0+1+2))\frac{1}{\sqrt{3}} (\ket{0} + \ket{1} + \ket{2})) I

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 200

Writer: admin

Editorial

The objective is to prepare a superposition of the three computational basis states 00\ket{00}, 10\ket{10}, and 11\ket{11}. Note we are treating the leftmost qubit as the least significant.

A superposition involving a non-power-of-two number of computational basis states can be prepared by using controlled-Hadamard (CHCH) gates.

First, applying a Hadamard gate to the first qubit effects the transformation

00H(0)12(00+10).\begin{equation} \ket{00} \xrightarrow{H(0)} \frac{1}{\sqrt{2}} (\ket{00} + \ket{10}). \end{equation}

Subsequently applying a controlled-Hadamard gate which targets the right qubit and which is controlled by the left qubit effects

12(00+10)CH(0,1)1200+12(10+11).\begin{equation} \frac{1}{\sqrt{2}} (\ket{00} + \ket{10}) \xrightarrow{CH(0, 1)} \frac{1}{\sqrt{2}} \ket{00} + \frac{1}{2}(\ket{10} + \ket{11}). \end{equation}

Finally, applying a controlled-XX gate which targets the left qubit and is controlled by the right qubit effects

1200+12(10+11)CX(1,0)1200+12(10+01).\begin{equation} \frac{1}{\sqrt{2}} \ket{00} + \frac{1}{2}(\ket{10} + \ket{11}) \xrightarrow{CX(1, 0)} \frac{1}{\sqrt{2}} \ket{00} + \frac{1}{2}(\ket{10} + \ket{01}). \end{equation}

In this way, a superposition state of the three computational basis states 00\ket{00}, 10\ket{10}, and 01\ket{01} is prepared.

As we will see in A5, this is not quite the state we wish to prepare.

Sample Code

Below is a sample program:

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