A6: Zeta / Moebius Transform I

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 200

Writer: fortoobye

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} and 10\ket{10} as follows. Here, a0,a1a_0, a_1 are the probability amplitudes of each state.

a000+a110=(a00+a11)0\begin{equation} a_0 \ket{00} + a_1 \ket{10} = (a_0 \ket{0} + a_1 \ket{1}) \ket{0} \end{equation}

Next, by applying the Ry(θ)Ry(\theta) gate with θ=2arctan(2)\theta = 2 \arctan{(\sqrt{2})} to this state, we create the probability amplitude 1/31 / \sqrt{3} as described in the problem. (For details on the rotation gate, please refer to the QPC001 A5 Editorial.)

(a00+a11)0Ry(θ,1)(a00+a11)(130+231)\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}

Then, by applying the controlled Hadamard gate CH(1,0)CH(1, 0), we prepare the superposition state that can be enclosed by 1/31 / \sqrt{3}.

(a00+a11)(130+231)CH(1,0)13(a000+a110+(a0+a1)01+(a0a1)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}

Next, by applying the XX gate and the controlled XX gate, we swap the probability amplitudes of the states 00\ket{00} and 10\ket{10}.

(a000+a110+(a0+a1)01+(a0a1)11)X(0)CX(0,1)X(0)13((a0+a1)00+a110+a001+(a0a1)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}

Finally, by applying the controlled ZZ gate, we flip the sign of the probability amplitude of the state 11\ket{11}.

13((a0+a1)00+a110+a001+(a0a1)11)CZ(1,0)13((a0+a1)00+a110+a001(a0a1)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}

Summarizing the operations above, the following state transition is established.

a000+a110qc13((a0+a1)00+a110+a001(a0a1)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}

When a0=1,a1=0a_0 = 1, a_1 = 0, we have

00qc13(00+0111).\begin{equation} \ket{00} \xrightarrow{\mathrm{qc}} \frac{1}{\sqrt{3}} ( \ket{00} + \ket{01} - \ket{11} ). \end{equation}

When a0=0,a1=1a_0 = 0, a_1 = 1, we have

10qc13(00+10+11).\begin{equation} \ket{10} \xrightarrow{\mathrm{qc}} \frac{1}{\sqrt{3}} ( \ket{00} + \ket{10} + \ket{11} ). \end{equation}

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