The Control Qubit Feels the Turn

controlled gate · phase kickback · eigenvector · relative phase · product state

A controlled-U gate uses one qubit, the control, to decide whether the gate U acts on the other qubits, the target register:

CU\,|0\rangle|w\rangle = |0\rangle|w\rangle, \qquad CU\,|1\rangle|w\rangle = |1\rangle\,(U|w\rangle).

Here the control is qubit 0, the leftmost bit, and the target register is the m qubits after it. So a state of the whole system has 2 \cdot 2^m amplitudes: the first half are the amplitudes with control 0, the second half those with control 1, and as a matrix CU is \begin{pmatrix} I & 0 \\ 0 & U\end{pmatrix} (in 2 qubits, |10\rangle is index 2).

The control starts in the state c = [c_0, c_1] and the target register in u, an eigenvector of U: U|u\rangle = e^{2\pi i\varphi}|u\rangle for some \varphi in [0, 1). The whole input is the product |c\rangle\otimes|u\rangle, whose amplitude k * 2**m + w is c[k] * u[w]. After CU the target is still |u\rangle, and the system is again a product |c'\rangle\otimes|u\rangle: the gate has changed only the control.

Write kick(U, u, c) that returns |c'\rangle, the control qubit's state after CU, as a list of 2 amplitudes. U is a list of rows (2^m \times 2^m, acting as new = U @ state). Any global phase is accepted: [1j, 0] is the same state as [1, 0].

Examples

Input:  U = [[1, 0], [0, 1j]], u = [0, 1], c = [0.7071067811865476, 0.7071067811865476]
Output: [0.7071067811865476, 0.7071067811865476j]
Explanation: S|1> = i|1>, so only the part of the state with control 1 picks up the factor i.

Input:  U = [[0, 1], [1, 0]], u = [0.7071067811865476, -0.7071067811865476], c = [0.7071067811865476, 0.7071067811865476]
Output: [0.7071067811865476, -0.7071067811865476]
Explanation: X multiplies this u by -1; the minus sign lands on the control.

Input:  U = [[1, 0], [0, (0.7071067811865476+0.7071067811865476j)]], u = [0, 1], c = [0, 1]
Output: [0, (0.7071067811865476+0.7071067811865476j)]
Explanation: this is the same state as [0, 1]: with the control in |1> alone, the turn is a global phase.

Amplitudes are compared with a tolerance of 1e-6.

Goals

  • Apply a controlled-U gate whose control is qubit 0 to a product state
  • See the eigenvalue of the target move onto the control qubit as a relative phase
Starting Python…