Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quantum Fourier Transform code for 3 qbits

Background

I came across a Javascript quantum simulator and was trying to write the code (i.e. the quantum circuit) to implement a 3 qbit Quantum Fourier transform.

The closest I could get is shown below: QFT result

This is based on the chapter on the QFT from "Quantum Computation and Quantum Information" by Nielsen and Chuang. (The Conditional NOT gates at the end of the circuit are intended to swap the output bits into the correct order - the QFT reverses the order of the bits.)

I also tried a circuit based on the wikipedia QFT article, but got no closer to the answer.

Question

Can anyone help correct my algorithm to compute the QFT?

(I think it is most likely that the bug is in my circuit, but I guess it is also possible that there is an error in the underlying Javascript implementation?)

like image 501
Peter de Rivaz Avatar asked Oct 21 '22 09:10

Peter de Rivaz


1 Answers

The reason the circuit from wikipedia isn't working is because the provided phase gates are turning clockwise instead of counter-clockwise (e.g. -45 degrees instead of +45 degrees). The circuit on Wikipedia (and probably the text book too) is using an R_(pi/2) gate, but you have an R_(-pi/2) gate.

There are several ways to deal with the issue:

  • Simulate the +45 degree gate using a Z (-180), -90, and -45. Similar idea for the +90.
  • Turn the circuit upside down, so the gates on wire 1 now are on wire 3 after, and vice versa.
  • Move the swapping part (the last three X gates) from the end to the start
  • Reverse the order of all the gates except for the three Xs at the end.
  • (I think) Apply exactly three of the above.
  • Probably a bunch more ways. Figuring out why each one works is interesting.

Sorry the backwards phases were confusing. (It's actually my circuit simulator, which I wrote for a blog post that includes a solution.)

like image 84
Craig Gidney Avatar answered Oct 23 '22 03:10

Craig Gidney