Quantum Circuits for Classical Functions
Unit: Quantum Computing
Later Topics
Lesson Preview
In classical computing, we often use functions that aren't reversible. For example, the gate takes two inputs and produces one output: , , , .
Given the output , we can't determine which of the three possible inputs produced it. It could have been , , or . Information has been lost.
Quantum computing, however, requires all operations to be reversible. This is because, as we know, quantum operations must be unitary, and unitary matrices are always invertible.
If we tried to implement a non-reversible function like , directly as a quantum gate , we would map both and to , i.e.
But clearly, this operation is not reversible. From , we have no idea whether we started with or before applying the function. Thus, this isn't a unitary operation (since all unitary operations are reversible), and therefore this is not a valid quantum operation.

The solution is to use an ancilla (also known as auxiliary) qubit and implement the function as:
Here, denotes addition modulo 2 (). In addition modulo 2, , , , and . This is also referred to as the classical gate, shorthand for "exclusive or".
This transformation is reversible because applying it twice returns the original state:
And, indeed, it can be shown that this transformation is unitary.

To see why it is unitary, note that it acts as a permutation on the computational basis states—each basis state maps to exactly one other basis state , and different inputs map to different outputs.
...
... continued in the full lesson.
Ready to Start Learning?
Sign up now to access the full Quantum Circuits for Classical Functions lesson and our entire curriculum!