3

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.

2 Answers2

1

looking for a way to implement a matrix permutation without ancillary qubits or workspace qubits

Multiplying by 2 mod 11 has a period of 10, meaning it corresponds to an odd permutation (because it takes 10-1=9 swaps to cycle 10 elements). If you have an ancillary qubit then the permutation would be even, because it would occur both for the part of the space where the ancilla was OFF and where it was ON.

X, CX, and CCX all correspond to even parity permutations (for systems with more than 3 qubits), so it's not possible to implement odd parity permutations using just these gates. Therefore you either need an ancilla qubit or you need to use other gates, like H and T, as in algassert.com/circuits/2015/06/22/Using-Quantum-Gates-instead-of-Ancilla-Bits.html.

The best known general technique for exact low-space multiplication is by Zalka in https://arxiv.org/abs/quant-ph/0601097 . It uses $n/2$ workspace qubits. Special cases can of course be lower, e.g. mod 15 multiplication is unusually easy. For low space factoring, it's best to use an approximate multiplier.

Craig Gidney
  • 47,099
  • 1
  • 44
  • 119
0

Given the papers and the documentation that Mr Craig Gidney yielded or awarded to us or to me.

It is very probable that there is no solution that I was looking for. Therefore, As a tribute to you (Craig Gidney) I am showing my Quirk solutions using your simulator that I found.

A controlled U - with 9 qubits.

And Short version with 13-qubits.

I think setting A and R with (Modular multiplication gate) is the best way in your simulator.

Thanks you!