oreilly-qc / oreilly-qc.github.io

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

Example 8-2 implementation of code is missing and seems to be a duplicate of 8-1. #16

Closed cfpgomes closed 4 years ago

cfpgomes commented 4 years ago

Context

In Chapter 8: Quantum Phase Estimation, in The Fine Print part (Choosing the Size of the Output Register), the book refers to an example of determining an eigenphase of 150º with an output register having only three qubits that can be run online at http://oreilly-qc.github.io?p=8-2.

"For example, Figure 8-5 shows the actual output state we obtain when running phase estimation to determine an eigenphase of 150º with an output register having only three qubits. This complete example can be run online at http://oreilly-qc.github.io?p=8-2."

Issue

However, the example seems to be a duplicate of Example 8-1 and does not implement the expected code for the example 8-2. The circuit is identical to the Example 8-1 and contains an output register with four qubits (should be three) and does not use the aforementioned 150º eigenphase.

machinelevel commented 4 years ago

You're correct, great catch! It looks like we refer to that sample twice, and the 3-qubit output was missed in our last revision. By going back through the Git history, I can see that @sparrigan had it correct in 54e91bc18df0c02690fead57f69aa69a2ea77ae8 and then I accidentally clobbered it in e771eedfc5189fd4100e9182dcdce2aa85692be7.

I've updated online sample 8-1 to be 3-qubit output and with a Nic's correct unitary which provides a 150-degree eigenphase, so the output now matches the book.

Book:

image

New online result:

image

I'll also ask @tcNickolas for help adjusting the Q# version, that should be pretty straightforward.

In any case, the sample now matches the book. Thank you!

machinelevel commented 4 years ago

For the record, here's the diff for this: https://github.com/oreilly-qc/oreilly-qc.github.io/compare/b9d5c676..63e102b8