Herein, we collect a family of programs that implement Pauli rotations on the target qubit, via one of \(R_X\), \(R_Y\), or \(R_Z\) gates, controlled by the state of multiple qubits.
Let \(d\) be the degree of \(p(x)\) and \(q_j \in \{0,1\}\) be the value of the \(j\)-th qubit, where \(q_0\) is the least significant qubit involved in the state \(\ket{x}_n\). Then for
\[
x=\sum_{j=0}^{n-1} 2^j q_j,
\]
For example, if \(n=3\), the bit pattern is \((q_2q_1q_0)=101\) and \(x=1\cdot2^2+0\cdot2^1+1\cdot2^0=5\). Then we can write
\[
p(x) = \sum_{j=0}^{d} c_j x^j
\]
where \(c\) are the input coefficients, coeffs, which has a length of \(d\). For example, given coeffs=[c_0,c_1,c_2], \(p(x)\) becomes \(c_0+c_1x+c_2x^2\).
Note that as we can see in Qiskit’s documentation [25][26], the above formula-based program specification can only denotes the case basis="Y". For other bases, the rotation is applied around the corresponding Pauli axis. Here, we generalize the formula to other bases as follows:
If the basis is X or Y, since \(\ket{x}\) is initialized as a pure state, the results of \(p(x)\) are reflected in amplitudes of two basis states whose target qubit is in state 0 and 1 respectively. Probabilities of these two states obtained by measurement can verify the correctness of the implementation. Without losing the phase information for basis X and Z, results are obtained by state-vector backend in our tests.
A circuit implementing uniformly controlled rotations [29].
Assume an initial state of \(n\) control qubits and one target qubit, \(\ket{0}_1\ket{\psi}_n\), where we can rewrite \(\ket{\psi}_n\) in the computational basis \(\{\ket{x}_n\}_{x=0}^{2^n-1}\) as:
Applies a rotation on the ancilla qubit controlled by the state of n qubits.
Parameters:
theta_list (list[float]) – List of rotation angles for each control state, i.e.,
\([\theta_0, \theta_1, \ldots, \theta_{2^n-1}]\).
The length of the list must be the power of two,
i.e., \(2^n\) for \(n\) control qubits.
if_barrier (bool) – Whether to add barriers. Default is False.
name (str | None) – Optional name of the circuit.
Raises:
ValueError – If the length of theta_list is not a power of two.
Note
The circuit applies RY rotations on the ancilla qubit.