Coder Social home page Coder Social logo

jackhidary / quantumcomputingbook Goto Github PK

View Code? Open in Web Editor NEW
764.0 58.0 209.0 11.54 MB

Companion site for the textbook Quantum Computing: An Applied Approach

Python 13.06% C# 0.16% Jupyter Notebook 86.39% Q# 0.39%
quantum quantum-computing cirq qiskit rigetti quantum-processor sycamore quantum-supremacy quantum-information quantum-information-science

quantumcomputingbook's People

Contributors

dlyongemallo avatar jackhidary avatar jaeyoo avatar joetricot avatar kikejimenez avatar rmlarose avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quantumcomputingbook's Issues

Problem 9 has some typos.

1-(c). Projectors are $|0\rangle\langle0|$ and $|1\rangle\langle1|$. However, it says $|0\rangle\langle0|$ and $|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)?

Typo in section 1.3

In the first paragraph, should be "superposition" rather than "superpositon" (missing "i")

qnn.py issues with recent Cirq versions

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 the recursive 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 the recursive:bool parameter

Solution

The script can be solved by:

  • line 36 -- adding recursive=True as an argument to def _resolve_parameters_(self, param_resolver):
  • line 79 -- replacing 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

Typo in section 11.5

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".

Typo in section 11.4

At the bottom of the page 243, Hadamard operator H 's inverse should be H^{-1} rather than H^{1}.

Numbering of chapters in repo differs from book

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?

Missing code examples from the book

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.

Typos Shor Algorithm

Hi,
The new notebook of the Shor Algorithm is amazing!
I found two small typos that were addressed in PR #18
Thanks

Section 12.4: inner product linearity in the first vs. second argument

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.

Typo in section 12.1

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.

Typo in Section 1.3

Typo in Section 1.3 Schrodinger Equation in the first pargraph, 3rd line: The word superposition is misspelled.
Screenshot 2023-08-28 230106

Question 4b in exercise 11.1 errata

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.

Non-ideomatic teleportation algorithm, no `c_if` not used

Environment

  • qiskit.version: 0.45.2
  • Python version: 3.10.12
  • Operating system: Ubuntu 20.04

What is happening?

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.

What should happen?

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.

Any suggestions?

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.

Typo in section 11.8

On page 270 (11.244) it should be probably {..., -3, -2, -1, 0, 1, 2, 3, ...}
Value 1 is missing from integer set

Questions on Chapter 9 5-(e) and (f) problems

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...

Error when importing Cirq

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'
`

Missing explanation of Bloch sphere

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.