Editorial
In this problem, you need to realize two state transtitions simultaneously.
Let's consider the example circuit below.
First, let's consider the superposition states of ∣ 00 ⟩ \ket{00} ∣ 00 ⟩ and ∣ 10 ⟩ \ket{10} ∣ 10 ⟩ as follows. Here, a 0 , a 1 a_0, a_1 a 0 , a 1 are the probability amplitudes of each state.
a 0 ∣ 00 ⟩ + a 1 ∣ 10 ⟩ = ( a 0 ∣ 0 ⟩ + a 1 ∣ 1 ⟩ ) ∣ 0 ⟩ \begin{equation}
a_0 \ket{00} + a_1 \ket{10} = (a_0 \ket{0} + a_1 \ket{1}) \ket{0}
\end{equation} a 0 ∣ 00 ⟩ + a 1 ∣ 10 ⟩ = ( a 0 ∣ 0 ⟩ + a 1 ∣ 1 ⟩ ) ∣ 0 ⟩
Next, by applying the R y ( θ ) Ry(\theta) R y ( θ ) gate with θ = 2 arctan ( 2 ) \theta = 2 \arctan{(\sqrt{2})} θ = 2 arctan ( 2 ) to this state, we create the probability amplitude 1 / 3 1 / \sqrt{3} 1/ 3 as described in the problem.
(For details on the rotation gate, please refer to the QPC001 A5 Editorial .)
( a 0 ∣ 0 ⟩ + a 1 ∣ 1 ⟩ ) ∣ 0 ⟩ → R y ( θ , 1 ) ( a 0 ∣ 0 ⟩ + a 1 ∣ 1 ⟩ ) ( 1 3 ∣ 0 ⟩ + 2 3 ∣ 1 ⟩ ) \begin{equation}
(a_0 \ket{0} + a_1 \ket{1}) \ket{0}
\xrightarrow{Ry(\theta, 1)}
(a_0 \ket{0} + a_1 \ket{1}) \left( \frac{1}{\sqrt{3}} \ket{0} + \frac{\sqrt{2}}{\sqrt{3}} \ket{1}\right)
\end{equation} ( a 0 ∣ 0 ⟩ + a 1 ∣ 1 ⟩ ) ∣ 0 ⟩ R y ( θ , 1 ) ( a 0 ∣ 0 ⟩ + a 1 ∣ 1 ⟩ ) ( 3 1 ∣ 0 ⟩ + 3 2 ∣ 1 ⟩ )
Then, by applying the controlled Hadamard gate C H ( 1 , 0 ) CH(1, 0) C H ( 1 , 0 ) , we prepare the superposition state that can be enclosed by 1 / 3 1 / \sqrt{3} 1/ 3 .
( a 0 ∣ 0 ⟩ + a 1 ∣ 1 ⟩ ) ( 1 3 ∣ 0 ⟩ + 2 3 ∣ 1 ⟩ ) → C H ( 1 , 0 ) 1 3 ( a 0 ∣ 00 ⟩ + a 1 ∣ 10 ⟩ + ( a 0 + a 1 ) ∣ 01 ⟩ + ( a 0 − a 1 ) ∣ 11 ⟩ ) \begin{equation}
(a_0 \ket{0} + a_1 \ket{1}) \left( \frac{1}{\sqrt{3}} \ket{0} + \frac{\sqrt{2}}{\sqrt{3}} \ket{1}\right)
\xrightarrow{CH(1, 0)}
\frac{1}{\sqrt{3}} ( a_0 \ket{00} + a_1 \ket{10} + (a_0 + a_1) \ket{01} + (a_0 - a_1) \ket{11} )
\end{equation} ( a 0 ∣ 0 ⟩ + a 1 ∣ 1 ⟩ ) ( 3 1 ∣ 0 ⟩ + 3 2 ∣ 1 ⟩ ) C H ( 1 , 0 ) 3 1 ( a 0 ∣ 00 ⟩ + a 1 ∣ 10 ⟩ + ( a 0 + a 1 ) ∣ 01 ⟩ + ( a 0 − a 1 ) ∣ 11 ⟩ )
Next, by applying the X X X gate and the controlled X X X gate, we swap the probability amplitudes of the states ∣ 00 ⟩ \ket{00} ∣ 00 ⟩ and ∣ 10 ⟩ \ket{10} ∣ 10 ⟩ .
( a 0 ∣ 00 ⟩ + a 1 ∣ 10 ⟩ + ( a 0 + a 1 ) ∣ 01 ⟩ + ( a 0 − a 1 ) ∣ 11 ⟩ ) → X ( 0 ) → C X ( 0 , 1 ) → X ( 0 ) 1 3 ( ( a 0 + a 1 ) ‾ ∣ 00 ⟩ + a 1 ∣ 10 ⟩ + a 0 ‾ ∣ 01 ⟩ + ( a 0 − a 1 ) ∣ 11 ⟩ ) \begin{align}
&( a_0 \ket{00} + a_1 \ket{10} + (a_0 + a_1) \ket{01} + (a_0 - a_1) \ket{11} ) \nonumber \\
&\xrightarrow{X(0)} \xrightarrow{CX(0, 1)} \xrightarrow{X(0)} \frac{1}{\sqrt{3}} ( \underline{(a_0 + a_1)} \ket{00} + a_1 \ket{10} + \underline{a_0} \ket{01} + (a_0 - a_1) \ket{11} )
\end{align} ( a 0 ∣ 00 ⟩ + a 1 ∣ 10 ⟩ + ( a 0 + a 1 ) ∣ 01 ⟩ + ( a 0 − a 1 ) ∣ 11 ⟩ ) X ( 0 ) CX ( 0 , 1 ) X ( 0 ) 3 1 ( ( a 0 + a 1 ) ∣ 00 ⟩ + a 1 ∣ 10 ⟩ + a 0 ∣ 01 ⟩ + ( a 0 − a 1 ) ∣ 11 ⟩ )
Finally, by applying the controlled Z Z Z gate, we flip the sign of the probability amplitude of the state ∣ 11 ⟩ \ket{11} ∣ 11 ⟩ .
1 3 ( ( a 0 + a 1 ) ∣ 00 ⟩ + a 1 ∣ 10 ⟩ + a 0 ∣ 01 ⟩ + ( a 0 − a 1 ) ∣ 11 ⟩ ) → C Z ( 1 , 0 ) 1 3 ( ( a 0 + a 1 ) ∣ 00 ⟩ + a 1 ∣ 10 ⟩ + a 0 ∣ 01 ⟩ − ( a 0 − a 1 ) ‾ ∣ 11 ⟩ ) \begin{align}
&\frac{1}{\sqrt{3}} ( (a_0 + a_1) \ket{00} + a_1 \ket{10} + a_0 \ket{01} + (a_0 - a_1) \ket{11} ) \nonumber \\
&\xrightarrow{CZ(1, 0)} \frac{1}{\sqrt{3}} ( (a_0 + a_1) \ket{00} + a_1 \ket{10} + a_0 \ket{01} \underline{- (a_0 - a_1)} \ket{11} )
\end{align} 3 1 (( a 0 + a 1 ) ∣ 00 ⟩ + a 1 ∣ 10 ⟩ + a 0 ∣ 01 ⟩ + ( a 0 − a 1 ) ∣ 11 ⟩ ) CZ ( 1 , 0 ) 3 1 (( a 0 + a 1 ) ∣ 00 ⟩ + a 1 ∣ 10 ⟩ + a 0 ∣ 01 ⟩ − ( a 0 − a 1 ) ∣ 11 ⟩ )
Summarizing the operations above, the following state transition is established.
a 0 ∣ 00 ⟩ + a 1 ∣ 10 ⟩ → q c 1 3 ( ( a 0 + a 1 ) ∣ 00 ⟩ + a 1 ∣ 10 ⟩ + a 0 ∣ 01 ⟩ − ( a 0 − a 1 ) ∣ 11 ⟩ ) \begin{equation}
a_0 \ket{00} + a_1 \ket{10}
\xrightarrow{\mathrm{qc}}
\frac{1}{\sqrt{3}} ( (a_0 + a_1) \ket{00} + a_1 \ket{10} + a_0 \ket{01} - (a_0 - a_1) \ket{11} )
\end{equation} a 0 ∣ 00 ⟩ + a 1 ∣ 10 ⟩ qc 3 1 (( a 0 + a 1 ) ∣ 00 ⟩ + a 1 ∣ 10 ⟩ + a 0 ∣ 01 ⟩ − ( a 0 − a 1 ) ∣ 11 ⟩ )
When a 0 = 1 , a 1 = 0 a_0 = 1, a_1 = 0 a 0 = 1 , a 1 = 0 , we have
∣ 00 ⟩ → q c 1 3 ( ∣ 00 ⟩ + ∣ 01 ⟩ − ∣ 11 ⟩ ) . \begin{equation}
\ket{00}
\xrightarrow{\mathrm{qc}}
\frac{1}{\sqrt{3}} ( \ket{00} + \ket{01} - \ket{11} ).
\end{equation} ∣ 00 ⟩ qc 3 1 ( ∣ 00 ⟩ + ∣ 01 ⟩ − ∣ 11 ⟩ ) .
When a 0 = 0 , a 1 = 1 a_0 = 0, a_1 = 1 a 0 = 0 , a 1 = 1 , we have
∣ 10 ⟩ → q c 1 3 ( ∣ 00 ⟩ + ∣ 10 ⟩ + ∣ 11 ⟩ ) . \begin{equation}
\ket{10}
\xrightarrow{\mathrm{qc}}
\frac{1}{\sqrt{3}} ( \ket{00} + \ket{10} + \ket{11} ).
\end{equation} ∣ 10 ⟩ qc 3 1 ( ∣ 00 ⟩ + ∣ 10 ⟩ + ∣ 11 ⟩ ) .
Consequently, the above operations solve the problem.
Sample Code
Below is a sample program:
import math
from qiskit import QuantumCircuit
def solve () -> QuantumCircuit:
qc = QuantumCircuit( 2 )
theta = 2 * math.atan(math.sqrt( 2 ))
qc.ry(theta, 1 )
qc.ch( 1 , 0 )
qc.x( 0 )
qc.cx( 0 , 1 )
qc.x( 0 )
qc.cz( 1 , 0 )
return qc