oreilly-qc / oreilly-qc.github.io

Code samples for Programming Quantum Computers, from O'Reilly Media
130 stars 59 forks source link

Measuring the Deutsch-Jozsa Example #30

Open simplygreatwork opened 4 years ago

simplygreatwork commented 4 years ago

I'm skipping around the chapters of your book quite a bit. I have a question about the Deutsch-Jozsa example. If I were to measure the qubits, they all have an probablity amplitude of 6.25%. I would expect for this example to function properly with measuring all qubits, the state 0-7 should be 0% and 8-15 should be 12.5%. Is this correct? Or does this example just assume that only three qubits are measured?

simplygreatwork commented 4 years ago

I found a QASM example online which provided a different configuration with a measurable result. I made an example for it. I also made a classical example. I know that Deutrsch-Jozsa is contrived and has no practical utility but it is a useful example for comparing a classical implementation with a quantum implementation using superposition.

https://github.com/simplygreatwork/obvious/blob/master/examples/algorithm-constant-or-balanced-quantum.js https://github.com/simplygreatwork/obvious/blob/master/examples/algorithm-constant-or-balanced-classical.js

I still need to work on allowing each example to use 2^n (any number of bits). Right now the classical version uses one bit and the quantum version uses 3 bits I think (qubits). It would be nice if each version shared the same number of bits (and customizable).