jackhidary / quantumcomputingbook Goto Github PK
View Code? Open in Web Editor NEWCompanion site for the textbook Quantum Computing: An Applied Approach
Companion site for the textbook Quantum Computing: An Applied Approach
1-(c). Projectors are |0\rangle
\langle1|$. Also, it says the same thing twice. p(0) = \langle\psi|\Pi_0\psi\rangle and p(0) = \langle\psi|\Pi_0\psi\rangle
. It should be p(1) = \langle\psi|\Pi_1\psi\rangle
3-(a) The problem seems to be about solving on <XY> but suddenly <XZ> appears. Is it intended? where is 3-(b)?
In the first paragraph, should be "superposition" rather than "superpositon" (missing "i")
Hello,
It seems that the qnn.py
script in chapter 9 is broken for Cirq versions v0.11.0 and further, as per the release notes here, notably:
If you have old gate implementations with
_resolve_parameter
that doesn't support therecursive
parameter, you will get an error message:TypeError: _resolve_parameters_() takes 2 positional arguments but 3 were given
, you will need to add support for therecursive:bool
parameter
Solution
The script can be solved by:
recursive=True
as an argument to def _resolve_parameters_(self, param_resolver):
wf = result.final_state
with wf = result.final_state_vector
I can submit a pull request unless you have specified somewhere you're using a Cirq version older than the v0.11.0.
Best regards,
Quentin
Invalid PDF
In the the first paragraph under equation 11.169 (on page 245), the text references "the first vector as a 1 x 2 matrix and the second vector as a 2 x 1 matrix" and later says "the product of a 1 x 2 matrix and a 2 x 1 matrix yields a 2 x 2 matrix".
I believe the text needs to be changed to "the first vector as a 2 x 1 matrix and the second vector as a 1 x 2 matrix" and "the product of a 2 x 1 matrix and a 1 x 2 matrix yields a 2 x 2 matrix" ?
The matrices being referred to are shown in equation 11.167 (also on page 245), and the text right under 11.167 references the relevant matrices correctly I believe, calling them "a 2 x 1 matrix and a 1 x 2 matrix".
At the bottom of the page 243, Hadamard operator H 's inverse should be H^{-1}
rather than H^{1}
.
Apparently the numbering of directories in the repo vs. chapters in the book does not match.
e.g.
The book contains in chapter 9 "Quantum Computing Methods", with 9.1. VQE
whereas the repo has the Deutsch-Josza algorithm etc.
https://github.com/JackHidary/quantumcomputingbook/blob/master/chapter09/cirq/deutsch-jozsa.py
This makes it tedious to find out whether code from the book is listed on the website or not, e.g. the VQE sample in pyQuil seems not to be here in the repo. Not in chapter 9, not in chapter 10, or should it be chapter 8?
There are quite a few code examples, Ch.9 for instance, that are listed in the book in split up form, but aren't here on the site (e.g. Circ QAOA, quantum chemistry example). Will those be uploaded soon?
Also, some examples are mentioned where no code is given (e.g. Ch.8 Simon's Problem), but in the book mentions to check the website.
Page 357, equation 12.165: a redundant \otimes
symbol in the last element.
Hi,
The new notebook of the Shor Algorithm is amazing!
I found two small typos that were addressed in PR #18
Thanks
Page 348, equation 12.117 - is it valid for a complex scalar a? In the context of examples in the section 12.4. Wouldn't it be easier to reformulate as the linearity in the second argument instead?
I understand there might be different conventions for mathematicians and quantum mechanics practitioners. And pardon me, if I got lost in it.
Can I get LaTeX format of them?
For example, in chapter02.pdf, the problem 1. says "Divicenzo criteria", but the correct term is "DiVincenzo's criteria"
On page 295, 9th line from bottom there is “each basis element v.j from i e {1, ..., n}”. So I think ‘j’ should be element of this set not i, or vice versa but then all other ‘j’ needs to be replaced with ‘i’ in the text.
See quantumlib/Cirq#2649 and simon_algorithm.py as a guide or link to these directly.
Just thought that this would make the problem sets much more useful. Thanks!
Question 4b in exercise 11.1 (self test in maths) seems to give the wrong matrix answer (the 1 should be on the top right of the matrix). The correct answer is provided later in the chapter in equation 11.171.
In the Python file teleportation.py the circuit first measures and then applies another gate with a simple if condition, I would have expected a c_if
instruction to be used instead. It is also unclear why the operations to create the entangled pair and the creation of the arbitary state to teleport are both applied to qubit 0.
I would have expected the entangled pair and the arbitary state to be created on different qubits and the use of c_if
instead of the simple if condition.
I would have followed this guide and created something like:
from qiskit import *
qc = QuantumCircuit(3)
c0 = ClassicalRegister(1)
c1 = ClassicalRegister(1)
c2 = ClassicalRegister(1)
qc.add_register(c0)
qc.add_register(c1)
qc.add_register(c2)
qc.barrier()
# arbitrary state creation
qc.u(0.3,0.2,0.1,0)
# entangled pair creation
qc.h(1)
qc.cx(1,2)
qc.barrier()
qc.cx(0,1)
qc.barrier()
qc.h(0)
qc.barrier()
qc.measure([0,1],[0,1])
qc.barrier()
qc.x(2).c_if(c1, 1)
qc.z(2).c_if(c0, 1)
qc.draw()
Output:
░ ░ ░ ┌───┐ ░ ┌─┐ ░
q_0: ─░────────────░───■───░─┤ H ├─░─┤M├────░───────────────
░ ┌───┐ ░ ┌─┴─┐ ░ └───┘ ░ └╥┘┌─┐ ░
q_1: ─░─┤ H ├──■───░─┤ X ├─░───────░──╫─┤M├─░───────────────
░ └───┘┌─┴─┐ ░ └───┘ ░ ░ ║ └╥┘ ░ ┌───┐ ┌───┐
q_2: ─░──────┤ X ├─░───────░───────░──╫──╫──░──┤ X ├──┤ Z ├─
░ └───┘ ░ ░ ░ ║ ║ ░ └─╥─┘ └─╥─┘
║ ║ ║ ┌──╨──┐
c15: 1/═════════════════════════════════╩══╬═══════╬═══╡ 0x1 ╞
0 ║ ┌──╨──┐└─────┘
c16: 1/════════════════════════════════════╩════╡ 0x1 ╞═══════
0 └─────┘
c17: 1/═══════════════════════════════════════════════════════
Thanks in advance, I wish you a happy and productive day.
I have been reporting issues in Kindle - I assumed they would be coming here. Are they going to /dev/null?
On page 270 (11.244) it should be probably {..., -3, -2, -1, 0, 1, 2, 3, ...}
Value 1 is missing from integer set
Hi. I read that the two sub problems mention Question 7, but I guess it was Question 4, because they are trying to comparing the number of gates required for QPE vs IQPE. Question 7 itself is just a problem of describing how to generate a random number in a classical computer...
Hello, the following error occurred when I tried to implement the code on p. 65 in Jupyter Notebook. Any guidance?
AttributeError: module 'googleapiclient' has no attribute 'version'
I did read up on SO:
I had the same error and changing the import fixed it for me. The developers recommend importing from googleapiclient instead of apiclient.
So you will need to change from apiclient import errors to from googleapiclient import errors
But it looks like this change would be to the init.py file ?
I was thinking I could go edit this file, but didn't know if there was some other way?
This is the error text:
`---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in
1 # Import the Cirq package
----> 2 import cirq
3
4 # Pick a qubit
5 qubit = cirq.GridQubit(0,0)
~/Desktop/Anaconda/anaconda3/envs/cirq/lib/python3.8/site-packages/cirq/init.py in
36 study,
37 )
---> 38 from cirq import (
39 # Core
40 circuits,
~/Desktop/Anaconda/anaconda3/envs/cirq/lib/python3.8/site-packages/cirq/google/init.py in
40 )
41
---> 42 from cirq.google.engine import (
43 Calibration,
44 Engine,
~/Desktop/Anaconda/anaconda3/envs/cirq/lib/python3.8/site-packages/cirq/google/engine/init.py in
19 Calibration,)
20
---> 21 from cirq.google.engine.engine import (
22 Engine,
23 JobConfig,
~/Desktop/Anaconda/anaconda3/envs/cirq/lib/python3.8/site-packages/cirq/google/engine/engine.py in
36 import warnings
37
---> 38 from apiclient import discovery, http as apiclient_http
39 from apiclient.errors import HttpError
40 from apiclient.http import HttpRequest
~/Desktop/Anaconda/anaconda3/envs/cirq/lib/python3.8/site-packages/apiclient/init.py in
20 from googleapiclient import schema
21
---> 22 version = googleapiclient.version
23
24 _SUBMODULES = {
AttributeError: module 'googleapiclient' has no attribute 'version'
`
I'm not very happy with the exposition of the Bloch sphere. All the necessary mathematics is developed in Part III of the book but the definition of the Bloch sphere is left out. When reading the table on page 341 (Fig. 12.3) one could even get the impression that the Bloch sphere is the unit sphere S^3 in the Hilbert space C^2 which is wrong because the Bloch sphere is S^2 topologically.
Consider the sequence of maps
S^3 --> H\{0} --> PH --> C+ --> S^2
where H is the two dimensional complex Hilbert space C^2, PH is the projective space over H and C+ is the one-point compactification of the complex numbers. Furthermore, the first map is the inclusion onto the unit sphere, the second map is the projection, the fourth map is the stereographic projection and the third map sends [c:1] to c for any complex number c and [1:0] to the point at infinity. Consider the following unit vector in C^2: (cos(t/2), exp(ip)sin(t/2)) for t in [0,pi] and p in [0,2pi]. Then one can calculate that the image of such a vector under the map above (from S^3 to S^2) is the unit vector in R^3 represented by (t,p) in spherical coordinates. In my opinion, a more detailed explanation of these facts would give a good impression of the relationship between state representations in Hilbert space and the actual states on the Bloch sphere.
By the way, the map S^3 --> S^2 is the beautiful Hopf fibration.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.