Editorial
The objective is to prepare a superposition of the three computational basis states , , and . 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 () gates.
First, applying a Hadamard gate to the first qubit effects the transformation
Subsequently applying a controlled-Hadamard gate which targets the right qubit and which is controlled by the left qubit effects
Finally, applying a controlled- gate which targets the left qubit and is controlled by the right qubit effects
In this way, a superposition state of the three computational basis states , , and 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