Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kudos on Shor's Algorithm Implementation and Chapter #31

Open
simplygreatwork opened this issue Jun 20, 2020 · 2 comments
Open

Kudos on Shor's Algorithm Implementation and Chapter #31

simplygreatwork opened this issue Jun 20, 2020 · 2 comments

Comments

@simplygreatwork
Copy link

The only other moderately digestable implementation of Shor's algorithm in JavaScript I have found is the jsqubits example from David Kemp. However I discovered that example uses some powermod shortcuts to construct the circuit. I really like your Shor example - particularly that you have linked the fully classical implementation and the quantum implementation so cleanly. Great job. I'm beginning to work on transforming this example to run against the Quantastica engine.

@machinelevel
Copy link
Contributor

Hi Philip,
Thanks so much! I'm glad you like it, and your note made my day. Funny story about this one. My background is engineering, not QC, and in 2015 I'd started as a part-time researcher at Univ of Bristol's Centre for Quantum Photonics, filling in the massive gaps in my quantum knowledge.

There was a short-notice project where one of the really awesome senior researchers (Anthony Laing) needed a Shor implementation for noise modelling. I stayed up all night reading three papers on Shor, and by morning I realized I didn't understand two of them at all, and the third one didn't work.

On the 2-hour train ride from London to Bristol, I started with no time left and a blank page, suddenly realized I could shortcut the exponentiation by using 2 as the coprime, and by the time the train pulled in at Bristol Temple Meads it was running.

It's not optimal, and the modulo operation is a big bag of hamsters, but I've been using variations on this implementation ever since. :]

Cheers and thanks,

  • ej

@simplygreatwork
Copy link
Author

simplygreatwork commented Jun 24, 2020

I did begin refactoring the Shor algorithm example to suit my personal structural taste. I've been using a pared down version of Quantastica: 9000 lines of code down to about 700 lines of code. Just the basics. So my own example is technically not using the Quantastica engine off the shelf. Anyway, this is what I have so far but I still need to dive more into num_shifts, condition, precision.bits(), .rollLeft() and all of the modulo code.

https://github.com/simplygreatwork/obvious/blob/master/examples/algorithm-semiprime-factoring-quantum.js
https://github.com/simplygreatwork/obvious/blob/master/examples/algorithm-semiprime-factoring-classical.js
https://github.com/simplygreatwork/obvious/blob/master/examples/algorithm-semiprime-factoring-naive.js

So not quite correct or finished - I might casually finish the rest one piece at a time. Lots of hamsters, yes.

  • Philip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants