Good morning, enthusiasts of the quantum world.
I am learning Peter Shor's algorithm by "period finding" or "order finding".
The order of a modulo N. When N is even and is not a prime power. My a = 2, and N= 11.
So my permutation matrix Ma (16x16)is:
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
Because
| $x$ | $2x \mod 11$ | $binary$ |
|---|---|---|
| 0 | 0 | 0000 |
| 1 | 2 | 0010 |
| 2 | 4 | 0100 |
| 3 | 6 | 0110 |
| 4 | 8 | 1000 |
| 5 | 10 | 1010 |
| 6 | 1 | 0001 |
| 7 | 3 | 0011 |
| 8 | 5 | 0101 |
| 9 | 7 | 0111 |
| 10 | 9 | 1001 |
The rest keep the value.
I take it as a boolean function so I applied Karnaugh as the old good times. https://en.wikipedia.org/wiki/Karnaugh_map
If the input is: q3 q2 q1 q0,
the output is S3 S2 S1 S0: After using Karnaugh maps:
S3= ( q2 not(q1) ) + (q3 q1)
S2= ( q3 not(q1) ) + ( not(q3) not(q2) q1 )
S1= q0
S0= q3 + (q2 q1)
I use toffoli to add using De Morgan's Law.
OPENQASM 2.0;
include "qelib1.inc";
// Registro de 4 qubits
qreg input[4];
qreg ancillary[6];
qreg output[4];
//q3 q1
ccx input[3], input[1], ancillary[0];
//q2 q1
ccx input[2], input[1], ancillary[1];
x input[1];
//q2 q1'
ccx input[2], input[1], ancillary[2];
//q3 q1'
ccx input[3], input[1], ancillary[3];
x input[1];
x input[2];
x input[3];
//q3' q2' q1
c3x input[3], input[2],input[1], ancillary[4];
barrier input, ancillary;
//not (q2 q1)
x ancillary[1];
x output[0];
//q3' * (q2 q1)' === q3 + q2 q1
ccx ancillary[1], input[3], output[0];
barrier input, ancillary;
cx input[0], output[1];
barrier input, ancillary;
//(q3 q1')' * (q3' q2' q1)' === q3 q1' + q3' q2' q1
x output[2];
x ancillary[3];
x ancillary[4];
ccx ancillary[3], ancillary[4], output[2];
barrier input, ancillary;
//(q2 q1')' * (q3 q1)' === q2 q1' + q3 q1
x output[3];
//(q3 q1)'
x ancillary[0];
// (q2 q1')'
x ancillary[2];
ccx ancillary[0], ancillary[2], output[3];
Is There some quantum circuit that just only use 4 qubits?
I could create a circuit with 8 qubits using gray code sequence to identify the states, but the circuit size is near to the double.
Thank you in advance.