Quantum Processing – The Controled Gates.
Posted on Thu 04 September 2025 in misc
We have seen before some quantum gates acting on a single qbit. We will now see a family of qgates taking 2 qbits as input and returning 2 qbits: the Controlled gates.
– Why does it return 2 qbits ? In classical logic, gates take 2 bits and return only 1 bit.
Ah, yes, that's a very good point. Let me open a parenthesis here.
Conservation of quantum information
One of the fundamental principles in quantum mechanics is that information cannot disappear. Well, it is much more complicated, but that's the main idea. This implies that, when you use information to compute a result, you should be able to find back which information was used knowing only the result. More formally, let's define a function \(f: E -> F\) representing a quantum process acting on an information \(x\).
To respect quantum mechanics, it means there exists a function \(g\) that gives us the initial \(x\) knowing the result \(y\):
This means \(f\) is bijective, or invertible, and \(g = f^{-1}\).
– OK, but what about qgates ?
As we saw in the previous article, a qgate can be represented by a matrix. That's also true for qgates acting on several qbits. To be invertible, a matrix must, among other things, be square. So, input dimension = output dimension.
Representing multiple qbits
A single qbit \(\left| \Psi \right>\) can be represented in the 2D base \(\left| 0 \right>\) and \(\left| 1 \right>\) by:
\(\alpha\) and \(\beta\) are thus coordinates of \(\Psi\) inside canonical base \(\left| 0 \right>\) and \(\left| 1 \right>\).
The quantum state \(\left| \Psi \right>\) corresponding to 2 qbit \(\left| \psi_1 \right>\) and \(\left| \psi_1 \right>\) can be represented using the tensor product (\(\otimes\)):
Let's decompose this.
If you don't feel fluent with tensor products, you might take a look at The Quantum Cheatsheet.
We end up with the canonical base \(\left| 00 \right>, \left| 01 \right>, \left| 10 \right>, \left| 10 \right>\), and coordinates of \(\left| \psi_1 \psi_2 \right>\) being \((\alpha_1 \alpha2, \alpha1 \beta_2, \beta_1 \alpha_2, \beta_1, \beta_2)\).
To summarize:
\(\left| \Psi \right>\) is represented by 4 complex coordinates. So, a qgate acting on 2 qbits will be represented by a 4x4 matrix.
Controlled gates
Controlled gates are a family of gates acting on 2 qbits. One of the qbits acts as a "control" and is not modified by the gates, and the other one will be modified by the gate. If the first qbit is \( \left| 0 \right>\), the gate is disabled and the second qubit remains unchanged. If the first qbit is \( \left| 1 \right>\), the gate is enabled and the second qbit is modified.
Matrices of such gates are 4x4 block matrices that look like this:
The top left block is identity, which won't change the control qbit, and the bottom right block is some single qbit gate operation called \(U\), with
Let's prove this matrix implements a controlled gate.
- case \(\left| \psi_1 \right> = \left| 0 \right>\)
So \(\left| \psi_1 \right>\) and \(\left| \psi_2 \right>\) remaine unchanged.
- case \(\left| \psi_1 \right> = \left| 1 \right>\)
Reminder: a quantum state \(\left| \Psi \right>\) composed of \(n\) qbits is \(\left| \psi_0 \right> \otimes \left| \psi_1 \right> \otimes \left| \psi_2 \right> \otimes ... \left| \psi_n \right>\)
So \(\left| \psi_1 \right>\) is unchanged and gate \(U\) is applied to \(\left| \psi_2 \right>\).
– Do I really need to understand all of this to create a quantum gate ?
No.
We'll see some classical controlled gates, based on the PauliX/Y/Z gate we have seen before.
CNOT Gate
This gate apply a NOT on the second qbit only when the first qbit is \(\left| 1 \right>\). It is sometime called CX for Controleld PauliX. Indeed, PauliX is NOT gate for qbits.
Controlled Y Gate
This gate apply a NOT and a phase shift on the second qbit only when the first qbit is \(\left| 1 \right>\).
Controlled Z Gate
or also:
No, this gate do not Undo the last action. It apply a phase shift qbit only when the first qbit is \(\left| 1 \right>\).
Takeways
- The quantum state \(\left| \Psi \right>\) corresponding to 2 qbit \(\left| \psi_1 \right>\) and \(\left| \psi_1 \right>\) is written \(\left| \psi_1 \right> \otimes \left| \psi_2 \right>\) or \(\left| \psi_1 \psi_2 \right>\)
- Unlike classical logic gates, quantum gates must have the same number of input and ouput qbits, because operation must be invertible.
- For any single qbit gate, you can build the corresponding controlled gates using a block matrix.