A5: Generate state 13(∣0⟩+∣1⟩+∣2⟩))\frac{1}{\sqrt{3}} (\ket{0} + \ket{1} + \ket{2})) II

Time Limit: 3 seconds

Memory Limit: 512 MiB

Score: 100 points

Writer:admin

Editorial

In problem A4, we prepared the superposition state 12∣00⟩+12(∣10⟩+∣01⟩)\frac{1}{\sqrt{2}} \ket{00} + \frac{1}{2}(\ket{10} + \ket{01}), composed of the three computational basis states ∣00⟩, ∣10⟩, ∣01⟩\ket{00},\ \ket{10},\ \ket{01}.

In this problem, we establish a uniform superposition state of these states, changing their complex amplitudes to 1/31/\sqrt{3}.

This can be achieved by replacing the Hadamard gate in Equation (1)(1) of editorial A4 with a rotation gate. Choose a rotation that prepares 13∣00⟩+23∣10⟩\frac{1}{\sqrt{3}} \ket{00} + \sqrt{\frac{2}{3}} \ket{10}. The following gates then produce the desired uniform superposition state:

∣00⟩→Ry(θ,0)13∣00⟩+23∣10⟩→CH(0,1)13(∣00⟩+∣10⟩+∣11⟩)→CX(1,0)13(∣00⟩+∣10⟩+∣01⟩)\begin{align} \ket{00} &\xrightarrow{Ry(\theta, 0)} \frac{1}{\sqrt{3}} \ket{00} + \sqrt{\frac{2}{3}} \ket{10} \nonumber\\ &\xrightarrow{CH(0, 1)} \frac{1}{\sqrt{3}} (\ket{00} + \ket{10} + \ket{11}) \nonumber\\ &\xrightarrow{CX(1, 0)} \frac{1}{\sqrt{3}} (\ket{00} + \ket{10} + \ket{01}) \end{align}

We will now find the axis of rotation and the angle to perform such a transformation.

An arbitrary state ∣ψ⟩\ket{\psi} of 11 qubit can be expressed by two angle parameters, θ, ϕ\theta,\ \phi, as follows:

∣ψ⟩=cos⁡(θ/2)∣0⟩+(cos⁡(ϕ)+isin⁡(ϕ))sin⁡(θ/2)∣1⟩\begin{equation} \ket{\psi} = \cos(\theta/2) \ket{0} + (\cos(\phi) + i \sin(\phi))\sin(\theta/2) \ket{1} \end{equation}

The method of representing the quantum state of one qubit on the surface of a sphere with radius 11 is called the Bloch sphere, and by using phase gates and rotation gates based on the angular parameters θ, ϕ\theta,\ \phi, it is possible to transition any 11-qubit state to any other arbitrary state.

Bloch SphereBloch sphere

Let us find the Bloch angular parameters θ, ϕ\theta,\ \phi for the state 13∣00⟩+23∣10⟩\frac{1}{\sqrt{3}} \ket{00} + \sqrt{\frac{2}{3}} \ket{10}.

Since the imaginary component is 00, we can set ϕ=0\phi = 0, and establish the following system of equations:

{ cos⁡(θ/2)=1/3sin⁡(θ/2)=2/3\begin{equation} \left\{ \, \begin{aligned} & \cos(\theta/2) = 1/\sqrt{3} \\ & \sin(\theta/2) = \sqrt{2/3} \end{aligned} \right. \end{equation}

By solving the above equation within the range 0≤θ<2π0 \leq \theta < 2 \pi, we obtain the following solution:

θ=4arctan⁡(63+3)\begin{equation} \theta = 4 \arctan\left(\frac{\sqrt{6}}{3 + \sqrt{3}}\right) \end{equation}

Looking at the Bloch sphere, we see that the angle parameter θ\theta represents the rotation angle about the yy-axis.

Thus, using the RyR_y gate, which is a rotation gate about the yy-axis, we can implement the rotation by θ\theta to achieve the transition ∣00⟩→Ry(θ,0)13∣00⟩+23∣10⟩\ket{00} \xrightarrow{Ry(\theta, 0)} \frac{1}{\sqrt{3}} \ket{00} + \sqrt{\frac{2}{3}} \ket{10}

As a result, the problem can be solved through the following transitions:

∣00⟩→Ry(θ,0)13∣00⟩+23∣10⟩→CH(0,1)13(∣00⟩+∣10⟩+∣11⟩)→CX(1,0)13(∣00⟩+∣10⟩+∣01⟩)\begin{align} \ket{00} &\xrightarrow{Ry(\theta, 0)} \frac{1}{\sqrt{3}} \ket{00} + \sqrt{\frac{2}{3}} \ket{10} \nonumber \\ &\xrightarrow{CH(0, 1)} \frac{1}{\sqrt{3}} (\ket{00} + \ket{10} + \ket{11}) \nonumber \\ &\xrightarrow{CX(1, 0)} \frac{1}{\sqrt{3}} (\ket{00} + \ket{10} + \ket{01}) \end{align}

Sample Code

Below is a sample program:

from qiskit import QuantumCircuit
import math
 
def solve() -> QuantumCircuit:
    qc = QuantumCircuit(2)
 
    theta = 4 * math.atan(math.sqrt(6)/ (3 + math.sqrt(3)))
 
    qc.ry(theta, 0)
    qc.ch(0, 1)
    qc.cx(1, 0)
 
    return qc