The Shor Circuit
We'll take a look at how we can implement Shor's Algorithm through a quantum circuit that is similar to QPE.
Modular exponentiation
The first step to implementing Shor’s Algorithm would be to create a quantum circuit to calculate Modular Exponentiation. Let’s recall our function .
As, quantum operations are reversible, we will implement as a quantum oracle with and an ancilla register as input, defined as follows:
We need to operate on a random value that we have picked, using quantum gates.
The number can be represented in the binary form as . We can use this binary representation to understand how we can apply a gate to each input qubit in our register making up .
Now that we have reduced our problem to each qubit, we will make an abstraction here for the sake of simplicity that we have a quantum gate that can perform the calculation using classical logic. This classical logic is, in fact, the slowest part of the algorithm. Various optimizations have been achieved, but they’re out of the scope of our course.
Let us focus on the quantum aspect of the algorithm. Recall that we need to do . So as always, to implement the XOR operation, we need a controlled version of this gate. Let’s have a look at our quantum oracle now.
Get hands-on with 1400+ tech skills courses.