Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions docs/guides/colibritd-pde.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@
"</Admonition>"
]
},
{
"cell_type": "markdown",
"id": "3a01cc47",
"metadata": {
"tags": [
"version-info"
]
},
"source": []
},
{
"cell_type": "markdown",
"id": "dde95705",
Expand Down Expand Up @@ -65,7 +55,7 @@
"\n",
"The arguments for CFD's differential equations are on a fixed grid, as follows:\n",
"\n",
"> $t$ is between 0 and 0.95 with 30 sample points. $x$ is between 0 and 0.95 with a step size of 0.2375.\n",
"- $t$ is between 0 and 0.95 with 30 sample points. $x$ is between 0 and 0.95 with a step size of 0.2375.\n",
"\n",
"### Material Deformation\n",
"\n",
Expand All @@ -81,7 +71,7 @@
"\n",
"The arguments for MD's differential equations are on a fixed grid, as follows:\n",
"\n",
"> $x$ is between 0 and 1 with a step size of 0.04."
"- $x$ is between 0 and 1 with a step size of 0.04."
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/get-started-with-primitives.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"\n",
"\n",
"<Admonition type=\"note\">\n",
"* While this documentation uses the primitives from Qiskit Runtime, which allow you to use IBM&reg; backends, the primitives can be run on any provider by using the [backend primitives](#backend) instead. Additionally, you can use the *reference* primitives to run on a local statevector simulator. See [Exact simulation with Qiskit primitives](/docs/guides/simulate-with-qiskit-sdk-primitives) for details.\n",
"While this documentation uses the primitives from Qiskit Runtime, which allow you to use IBM&reg; backends, the primitives can be run on any provider by using the [backend primitives](#backend) instead. Additionally, you can use the *reference* primitives to run on a local statevector simulator. See [Exact simulation with Qiskit primitives](/docs/guides/simulate-with-qiskit-sdk-primitives) for details.\n",
"</Admonition>"
]
},
Expand Down
10 changes: 6 additions & 4 deletions docs/migration-guides/qiskit-1.0-installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,12 @@ When you're done with a virtual environment, you can simply delete its directory

When running `import qiskit`, you might see an error such as:

> ImportError: Qiskit is installed in an invalid environment that has both Qiskit 1.0+ and an earlier version.
> You should create a new virtual environment, and ensure that you do not mix dependencies between Qiskit pre-1.0 and post-1.0.
> Any packages that depend on 'qiskit-terra' are not compatible with Qiskit 1.0 and will need to be updated.
> Qiskit unfortunately cannot enforce this requirement during environment resolution.
```bash
ImportError: Qiskit is installed in an invalid environment that has both Qiskit 1.0+ and an earlier version.
You should create a new virtual environment, and ensure that you do not mix dependencies between Qiskit pre-1.0 and post-1.0.
Any packages that depend on 'qiskit-terra' are not compatible with Qiskit 1.0 and will need to be updated.
Qiskit unfortunately cannot enforce this requirement during environment resolution.
```

<Admonition type="tip">
You might have run a completely valid `pip install` command, following all the recommendations in this guide, and still see this error message.
Expand Down
74 changes: 38 additions & 36 deletions docs/tutorials/quantum-approximate-optimization-algorithm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -208,43 +208,45 @@
"H_C=\\sum_{ij}Q_{ij}Z_iZ_j + \\sum_i b_iZ_i.\n",
"$$\n",
"\n",
"> **Reformulation steps from the QAOA problem to the Hamiltonian**\n",
"\n",
"> To demonstrate how the QAOA problem can be rewritten in this way, first replace the binary variables $x_i$ to a new set of variables $z_i\\in\\{-1, 1\\}$ via\n",
">\n",
"> $$\n",
"> x_i = \\frac{1-z_i}{2}.\n",
"> $$\n",
">\n",
"> Here you can see that if $x_i$ is $0$, then $z_i$ must be $1$. When the $x_i$'s are substituted for the $z_i$'s in the optimization problem ($x^TQx$), an equivalent formulation can be obtained.\n",
">\n",
"> $$\n",
"> x^TQx=\\sum_{ij}Q_{ij}x_ix_j \\\\ =\\frac{1}{4}\\sum_{ij}Q_{ij}(1-z_i)(1-z_j) \\\\=\\frac{1}{4}\\sum_{ij}Q_{ij}z_iz_j-\\frac{1}{4}\\sum_{ij}(Q_{ij}+Q_{ji})z_i + \\frac{n^2}{4}.\n",
"> $$\n",
">\n",
"> Now if we define $b_i=-\\sum_{j}(Q_{ij}+Q_{ji})$, remove the prefactor, and the constant $n^2$ term, we arrive at the two equivalent formulations of the same optimization problem.\n",
">\n",
"> $$\n",
"> \\min_{x\\in\\{0,1\\}^n} x^TQx\\Longleftrightarrow \\min_{z\\in\\{-1,1\\}^n}z^TQz + b^Tz\n",
"> $$\n",
">\n",
"> Here, $b$ depends on $Q$. Note that to obtain $z^TQz + b^Tz$ we dropped the factor of 1/4 and a constant offset of $n^2$ which do not play a role in the optimization.\n",
">\n",
">\n",
"> Now, to obtain a quantum formulation of the problem, promote the $z_i$ variables to a Pauli $Z$ matrix, such as a $2\\times 2$ matrix of the form\n",
">\n",
"> $$\n",
"> Z_i = \\begin{pmatrix}1 & 0 \\\\ 0 & -1\\end{pmatrix}.\n",
"> $$\n",
">\n",
"> When you substitute these matrices in the optimization problem above, you obtain the following Hamiltonian\n",
">\n",
"> $$\n",
"> H_C=\\sum_{ij}Q_{ij}Z_iZ_j + \\sum_i b_iZ_i.\n",
"> $$\n",
">\n",
"> *Also recall that the $Z$ matrices are embedded in the quantum computer's computational space, that is, a Hilbert space of size $2^n\\times 2^n$. Therefore, you should understand terms such as $Z_iZ_j$ as the tensor product $Z_i\\otimes Z_j$ embedded in the $2^n\\times 2^n$ Hilbert space. For example, in a problem with five decision variables the term $Z_1Z_3$ is understood to mean $I\\otimes Z_3\\otimes I\\otimes Z_1\\otimes I$ where $I$ is the $2\\times 2$ identity matrix.*\n",
"<summary>\n",
"**Reformulation steps from the QAOA problem to the Hamiltonian**\n",
"</summary>\n",
"<details>\n",
"To demonstrate how the QAOA problem can be rewritten in this way, first replace the binary variables $x_i$ to a new set of variables $z_i\\in\\{-1, 1\\}$ via\n",
"\n",
"$$\n",
"x_i = \\frac{1-z_i}{2}.\n",
"$$\n",
"\n",
"Here you can see that if $x_i$ is $0$, then $z_i$ must be $1$. When the $x_i$'s are substituted for the $z_i$'s in the optimization problem ($x^TQx$), an equivalent formulation can be obtained.\n",
"\n",
"$$\n",
"x^TQx=\\sum_{ij}Q_{ij}x_ix_j \\\\ =\\frac{1}{4}\\sum_{ij}Q_{ij}(1-z_i)(1-z_j) \\\\=\\frac{1}{4}\\sum_{ij}Q_{ij}z_iz_j-\\frac{1}{4}\\sum_{ij}(Q_{ij}+Q_{ji})z_i + \\frac{n^2}{4}.\n",
"$$\n",
"\n",
"Now if we define $b_i=-\\sum_{j}(Q_{ij}+Q_{ji})$, remove the prefactor, and the constant $n^2$ term, we arrive at the two equivalent formulations of the same optimization problem.\n",
"\n",
"$$\n",
"\\min_{x\\in\\{0,1\\}^n} x^TQx\\Longleftrightarrow \\min_{z\\in\\{-1,1\\}^n}z^TQz + b^Tz\n",
"$$\n",
"\n",
"Here, $b$ depends on $Q$. Note that to obtain $z^TQz + b^Tz$ we dropped the factor of 1/4 and a constant offset of $n^2$ which do not play a role in the optimization.\n",
"\n",
"\n",
"Now, to obtain a quantum formulation of the problem, promote the $z_i$ variables to a Pauli $Z$ matrix, such as a $2\\times 2$ matrix of the form\n",
"\n",
"$$\n",
"Z_i = \\begin{pmatrix}1 & 0 \\\\ 0 & -1\\end{pmatrix}.\n",
"$$\n",
"\n",
"When you substitute these matrices in the optimization problem above, you obtain the following Hamiltonian\n",
"\n",
"$$\n",
"H_C=\\sum_{ij}Q_{ij}Z_iZ_j + \\sum_i b_iZ_i.\n",
"$$\n",
"\n",
"*Also recall that the $Z$ matrices are embedded in the quantum computer's computational space, that is, a Hilbert space of size $2^n\\times 2^n$. Therefore, you should understand terms such as $Z_iZ_j$ as the tensor product $Z_i\\otimes Z_j$ embedded in the $2^n\\times 2^n$ Hilbert space. For example, in a problem with five decision variables the term $Z_1Z_3$ is understood to mean $I\\otimes Z_3\\otimes I\\otimes Z_1\\otimes I$ where $I$ is the $2\\times 2$ identity matrix.*\n",
"</details>\n",
"\n",
"This Hamiltonian is called the **cost function Hamiltonian**. It has the property that its ground state corresponds to the solution that **minimizes the cost function $f(x)$**.\n",
"Therefore, to solve your optimization problem you now need to prepare the ground state of $H_C$ (or a state with a high overlap with it) on the quantum computer. Then, sampling from this state will, with a high probability, yield the solution to $min~f(x)$."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,11 @@
"\n",
" Note that $n$ is common to both public key and private key, and is known as the modulus. We will need to use this later.\n",
"\n",
" <details>\n",
"\n",
" <summary>\n",
"\n",
" <summary>\n",
" Mathematical detail\n",
"\n",
" </summary>\n",
"\n",
" \n",
" <details>\n",
" - Choose two distinct prime numbers, $p$ and $q$.\n",
" - chosen at random (for security).\n",
" - They should be similar in magnitude, but differ in length by a few digits, to make factoring harder.\n",
Expand Down Expand Up @@ -348,14 +345,11 @@
" - Alice uses Bob's public key $(e, n)$ to encrypt the message into ciphertext $C$\n",
"\n",
"\n",
" <details>\n",
"\n",
" <summary>\n",
"\n",
" Mathematical detail\n",
"\n",
" </summary>\n",
"\n",
" <details>\n",
" - $M$ is an [integer][intrep] $0 ≤ M < n$.\n",
" - $C ≡ M^e (mod n)$, where $C$ is the ciphertext.\n",
"\n",
Expand All @@ -376,14 +370,11 @@
" - Bob uses his private key $(d, n)$ to decrypt the message back into message $M$\n",
"\n",
"\n",
" <details>\n",
"\n",
" <summary>\n",
"\n",
" Mathematical detail\n",
"\n",
" </summary>\n",
"\n",
" <details>\n",
" - $M ≡ C^d (mod n)$.\n",
"\n",
" </details>"
Expand Down Expand Up @@ -411,7 +402,9 @@
"\n",
"In the following code cells, we illustrate a simple example of the RSA algorithm using small integers and then demonstrate practical key distribution and digital signature applications using Python libraries implementing RSA.\n",
"\n",
"> Note: In this section we will show the math calculations in detail as part of the Python code\n",
"<Admonition type=\"note\">\n",
"Note: In this section we will show the math calculations in detail as part of the Python code\n",
"</Admonition>\n",
"\n",
"#### RSA key generation\n",
"\n",
Expand Down Expand Up @@ -1285,14 +1278,13 @@
"\n",
"Prime factorization of large integers is known to exhibit [super-polynomial][superpoly] or [subexponential][subexp] scaling on classical computers. The best-known classical algorithm for factoring integers larger than $10^{100}$ is the *[general number field sieve][gnfs]* [(GNFS)][73].\n",
"\n",
"<details>\n",
"\n",
"<summary>\n",
"\n",
"Mathematical detail\n",
"\n",
"</summary>\n",
"\n",
"<details>\n",
"\n",
"$L_n[\\frac{1}{3}, (\\frac{64}{9})^{(\\frac{1}{3})}] = e^{[((\\frac{64}{9})^{(\\frac{1}{3})} + o(1)) (log(n))^{\\frac{1}{3}}(log(log(n))^{\\frac{2}{3}})]}$\n",
"\n",
"as a function of the integer $n$ to be factorized.\n",
Expand Down Expand Up @@ -1334,14 +1326,11 @@
"id": "9c34e60f-2da7-4824-8e64-04a0bb488a72",
"metadata": {},
"source": [
"<details>\n",
"\n",
"<summary>\n",
"\n",
"Mathematical explanation of Shor's algorithm\n",
"\n",
"</summary>\n",
"\n",
"<details>\n",
"In the context of [RSA][rsa], [Shor's algorithm][shor] works by exploiting the [periodicity][period] of the [modular exponential function][modexp] $f(x) = a^x (mod~n)$ and provides a quantum [period][period]-finding primitive that enables efficient prime factorization of the [modulus][modulus] $n$.\n",
"\n",
"A simplified high-level outline of Shor's overall scheme for breaking RSA is as follows:\n",
Expand Down Expand Up @@ -1391,7 +1380,9 @@
"\n",
"In the following code cells, we illustrate an example of finding a private key given only the public key. This will use brute-force classical computation, but shows how Shor's algorithm could be used - including large keys.\n",
"\n",
"> Note: In this section we will show the math calculations in detail as part of the Python code\n",
"<Admoniton type=\"note\">\n",
"In this section we will show the math calculations in detail as part of the Python code\n",
"</Admoniton>\n",
"\n",
"In the example, we have a public key $(5, 247)$, and we will recover the private key.\n",
"\n",
Expand Down Expand Up @@ -1661,13 +1652,11 @@
"*Figure 1. Diffie-Hellman key exchange*\n",
"\n",
"\n",
"<details>\n",
"\n",
"<summary>\n",
"\n",
"Mathematical details of Diffie-Hellman key exchange\n",
"\n",
"</summary>\n",
"\n",
"<details>\n",
"With Alice and Bob being the two parties communicating, the protocol works as follows:\n",
"\n",
"- First, Alice and Bob agree on a large prime number $p$ and a primitive root or generator $a$.\n",
Expand Down Expand Up @@ -1698,7 +1687,9 @@
"\n",
"Let's look at a simple example of the DH protocol in Python using small prime numbers:\n",
"\n",
"> Note: In this section we will show the math calculations in detail as part of the Python code\n",
"<Admonition type=\"note\">\n",
"In this section we will show the math calculations in detail as part of the Python code\n",
"</Admonition>\n",
"\n",
"**Step 1:** Alice and Bob agree on a prime $p$ and a primitive root $a$. Let's choose $p=11, a=7$."
]
Expand Down Expand Up @@ -1790,14 +1781,11 @@
"\n",
"**Man-in-the-middle (MITM) attacks**: The fact that DH is an interactive scheme where the shared secret depends on combining one party's private key with the other party's public key makes it vulnerable to a so-called *Man-in-the-middle (MITM)* attack.\n",
"\n",
"<details>\n",
"\n",
"<summary>\n",
"\n",
"Mathematical details of DH security and MITM attacks\n",
"\n",
"</summary>\n",
"\n",
"<details>\n",
"In this scenario, a third party — say, Eve — intercepts the public keys $h_A, h_B$ during transmission and substitutes her own public key $h_E$ for each of $h_A$ and $h_B$ before forwarding them along to Bob and Alice, respectively.\n",
"\n",
"Then, instead of using $h_B$ to create her shared secret, Alice will use $h_E$ while thinking that she is using Bob's public key. Similarly, instead of using $h_A$ to create his shared secret, Bob will use $h_E$ while thinking that he is using Alice's public key.\n",
Expand Down Expand Up @@ -1841,14 +1829,11 @@
"\n",
" From this we choose a random number $x$ as private key, and are able to calculate a public key $y$\n",
"\n",
" <details>\n",
"\n",
" <summary>\n",
"\n",
" Mathematical details of key generation\n",
"\n",
" </summary>\n",
"\n",
" <details>\n",
" - **Parameter generation:** Mathematically, DSA involves a cyclic subgroup of $(\\mathbb{Z}_p)^{\\times}$ generated by an element $g$ of prime order q < p. The first step in the DSA is therefore to select two primes p, q to set up the necessary mathematical structures.\n",
"\n",
" - Choose an $N$-bit prime $q$.\n",
Expand Down Expand Up @@ -1893,14 +1878,11 @@
" - The signer can now sign a message $m$. The resulting signature is $(r,s)$\n",
" - The message and signature are both now sent to the recipient\n",
"\n",
" <details>\n",
"\n",
" <summary>\n",
"\n",
" Mathematical details of signing a message\n",
"\n",
" </summary>\n",
"\n",
" <details>\n",
" The signer signs a message $m$ as follows:\n",
"\n",
" - Choose a secret integer k at random from $\\{1,2...q-1\\}$\n",
Expand Down Expand Up @@ -1928,14 +1910,11 @@
"\n",
" and seeks to ascertain that the signer is someone with access to the private key $x$.\n",
"\n",
" <details>\n",
"\n",
" <summary>\n",
"\n",
" Mathematical details of DSA verification scheme\n",
"\n",
" </summary>\n",
"\n",
" <details>\n",
" - Verify that $0 \\lt r \\lt q$ and $0 \\lt s \\lt q$, that is, $r, s$ are valid modulo~q integers.\n",
" - Compute $w = s^{-1}~mod~q$.\n",
" - Compute $u_1 = H(m)w~mod~q$.\n",
Expand Down Expand Up @@ -1974,7 +1953,9 @@
"source": [
"In this example, we'll use small primes to illustrate the DSA process in a scenario where Alice sends a signed message to Bob. We'll use small integers in this example. A real-world scenario would employ much larger primes on the order of 2048-3072 bits.\n",
"\n",
"> You can try rerunning this example with different values to see how the algorithm behaves, but ensure you start running from the first cell in this section.\n",
"<Admonition type=\"note\">\n",
"You can try rerunning this example with different values to see how the algorithm behaves, but ensure you start running from the first cell in this section.\n",
"</Admonition>\n",
"\n",
"We start by importing necessary libraries and choosing our parameters."
]
Expand Down Expand Up @@ -2515,14 +2496,11 @@
"\n",
"Shor's algorithm is able to solve the discrete logarithm problem in polynomial time. It primarily achieves its efficiency by using quantum algorithms which can find the period of a function which depends on the input to the problem - which is then combined with more conventional operations.\n",
"\n",
"<details>\n",
"\n",
"<summary>\n",
"\n",
"Mathematical details of Shor's algorithm\n",
"\n",
"</summary>\n",
"\n",
"<details>\n",
"Shor's algorithm provides an efficient solution to the DLP by mapping it to a more general problem in group theory known as the [hidden subgroup problem][80] (HSP).\n",
"\n",
"In the HSP, one is given an algebraic group $G$ and a function $f: G \\rightarrow X$ from $G$ to some set $X$ such that $f$ is constant on each coset of some subgroup $H$ of $G$ (and distinct on different cosets). Then, the task is to determine $H$. It is known that quantum computers can solve the HSP on finite Abelian groups in time polynomial in $log~|G|$ where $|G|$ is the group order.\n",
Expand Down Expand Up @@ -2580,14 +2558,11 @@
"\n",
"Elliptic curve cryptography makes use of applying a series of arithmetic operations to points on the curve. Each effectively navigates to a new point on the curve. This is a simple process to follow in one direction, and with shorter key sizes is more efficient than other algorithms like RSA, but trying to reverse this is very difficult, hence its application to cryptography.\n",
"\n",
"<details>\n",
"\n",
"<summary>\n",
"\n",
"Mathematical principles of elliptic curve cryptography\n",
"\n",
"</summary>\n",
"\n",
"<details>\n",
"An [elliptic curve][82] over an algebraic field $K$ is defined by a mathematical equation, typically in the form $y^2 = x^3 + ax + b$ with the coefficients $a, b \\in K$ and describes points $(x, y) \\in K \\otimes K$ with the additional requirement that the curve have no kinks or self-intersections.\n",
"\n",
"\n",
Expand Down Expand Up @@ -2623,14 +2598,11 @@
"\n",
"This problem is known to be intractable on classical computers for large $n$ and provides a basis for cryptographic security.\n",
"\n",
"<details>\n",
"\n",
"<summary>\n",
"\n",
"Mathematical description of ECDLP\n",
"\n",
"</summary>\n",
"\n",
"<details>\n",
"Elliptic curve cryptography is primarily based on the ECDLP formulated on certain algebraic **finite fields**. In 1999, NIST recommended ten finite fields for use in ECC. These are:\n",
"\n",
" - Five **prime fields** $\\mathbb {F} _{p}$ for primes $p$ of size $\\{192, 224, 256, 384, 521\\}$ bits.\n",
Expand Down
Loading
Loading