C2: Generate Uniform Amplitude Superposition State II

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 600

Writer: admin

Editorial

Quantum algorithms such as Grover's algorithm and amplitude amplification work by amplifying the probability amplitudes of specific computational basis states. The probability of observing the desired computational basis state in these algorithms is expressed as a periodic function of the number of iterations. Although this probability can be amplified to values close to 1.01.0, it typically cannot reach exactly 1.01.0.

In contrast, an algorithm called fixed-point amplitude amplification can monotonically increase the probability amplitude of the desired computational basis state relative to the number of iterations. That is, the observation probability converges to 1.01.0 with a sufficient number of iterations.

Therefore, this problem can be solved using fixed-point amplitude amplification.

Next, we describe an overview of fixed-point amplitude amplification. While various methods have been proposed, here we consider Grover's π/3\pi/3 phase-shift method.

First, we define the pre-amplification initial state as s\ket{s} 1 and the desired post-amplification state as t\ket{t}. In the π/3\pi/3 phase-shift method, amplitude amplification is performed by applying to the initial state s\ket{s} an operator UmU_m recursively defined by the following equation, with respect to some unitary operation UU 2.

Um+1=UmRsUmRtUm,     (U0=U)\begin{equation} U_{m+1} = U_m R_s U_m^{\dagger} R_t U_m, \ \ \ \ \ (U_0 = U) \end{equation}

where ()(\cdot)^{\dagger} denotes the Hermitian transpose, and the selective phase shift operators RsR_s and RtR_t are defined by

Rs=I[1exp(iπ3)]ss    Rt=I[1exp(iπ3)]tt    .\begin{align} R_s &= I - \left[1 - \exp\left(i\frac{\pi}{3}\right)\right]\ket{s}\bra{s}\;\;\\ R_t &= I - \left[1 - \exp\left(i\frac{\pi}{3}\right)\right]\ket{t}\bra{t}\;\; \end{align}.

Note that the oracle RtR_t can use the implementation from problem B4 3.

For details and background of the algorithm, please refer to the sample code and the literatures [1], [2], and [3].

Next, we perform an error analysis.

Define the initial error ϵ0\epsilon_0 as the probability of observing any computational basis state other than those desired when measuring state UsU\ket{s}. That is, the probability of observing a desired state is 1ϵ01 - \epsilon_0. In this problem, if UU prescribed "apply the Hadamard gate to all qubits (HnH^{\otimes n})" as seen in C1, applying UmU_m to the first log2(L)\lceil\log_2(L)\rceil-th qubits ensures 1ϵ0>0.5ϵ0<0.51 - \epsilon_0 > 0.5 \Rightarrow \epsilon_0 < 0.5 4.

Here, the error between UmsU_m\ket{s} and t\ket{t} is represented by ϵ03m\epsilon_0^{3^m} 5.

Therefore, the recursive depth mm required to reduce the error to less than 5.0×1035.0 \times 10^{-3} can be determined by solving the following equation:

(0.5)3m<5.0×103\begin{equation} (0.5)^{3^m} < 5.0 \times 10^{-3} \end{equation}

The solution to Equation (4)(4) includes m>1.86m > 1.86. Thus, setting m=2m = 2 ensures the error is sufficiently reduced within the problem constraints.

Sample Code

Below is a sample program:

from qiskit import QuantumCircuit
from qiskit.circuit.library import PhaseGate
import math
 
 
def Rt(n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
 
    for i in range(n):
        if not (L >> i) & 1:
            continue
        for j in range(i + 1, n):
            if not (L >> j) & 1:
                qc.x(j)
        qc.x(i)
        if i == n - 1:
            qc.p(math.pi / 3, i)
        else:
            qc.append(PhaseGate(math.pi / 3).control(n - i - 1), range(i, n))
        qc.x(i)
        for j in range(i + 1, n):
            if not (L >> j) & 1:
                qc.x(j)
 
    return qc
 
 
def Rs(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
 
    qc.x(range(n))
 
    if n == 1:
        qc.p(math.pi / 3, 0)
    else:
        qc.append(PhaseGate(math.pi / 3).control(n - 1), range(n))
 
    qc.x(range(n))
 
    return qc
 
 
def U(m: int, n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
 
    if m == 0:
        qc.h(range(n))
        return qc
 
    u = U(m - 1, n, L)
 
    qc.compose(u, inplace=True)
    qc.compose(Rt(n, L), inplace=True)
    qc.compose(u.inverse(), inplace=True)
    qc.compose(Rs(n), inplace=True)
    qc.compose(u, inplace=True)
 
    return qc
 
 
def solve(n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
 
    k = math.ceil(math.log2(L))
    if k == 0:
        return qc
 
    m = 2
    qc.compose(U(m, k, L), inplace=True)
 
    return qc

References

Footnotes

  1. In this question, the initial state s\ket{s} before amplification can be considered as the zero state.

  2. Any unitary operation UU that allows for the observation of any desired computational basis state from the state UsU\ket{s} can be used. For more details, please refer to the error analysis described later. Here, it is acceptable to interpret UU as the operation of applying a Hadamard gate to all qubits (HnH^{\otimes n}).

  3. More precisely, the oracle for problem B4 does not satisfy the Equation (3)(3), and can be defined as an operator RtR_t satisfying the following conditions:
    (1) RtU0s=(I[1exp(iπ3)]tt)U0s(2) Rtt=(I[1exp(iπ3)]tt)t(1) \ R_t U_0 \ket{s} = \left(I - \left[1 - \exp\left(i\frac{\pi}{3}\right)\right]\ket{t}\bra{t}\right) U_0 \ket{s}\\ (2) \ R_t \ket{t} = \left(I - \left[1 - \exp\left(i\frac{\pi}{3}\right)\right]\ket{t}\bra{t}\right) \ket{t}
    While we omit the proof, even in the case of this definition, it can be shown that fixed-point amplitude amplification works.
    *This part was pointed out by the user PSL. We appreciate your contribution.

  4. When UU is applied to all qubits, the initial error ϵ0\epsilon_0 increases, requiring a greater recursion depth mm. In some test cases, it may not be possible to meet the constraints on the depth of the circuit.

  5. Initially, it was ϵ03m\epsilon_0^{3m}, but it has been corrected to ϵ03m\epsilon_0^{3^m}.
    *This part was pointed out by the user PSL. We appreciate your contribution.