From a1d3e02a662d5fe53b8d90cb04d79f9f31ba8a24 Mon Sep 17 00:00:00 2001 From: AnnePicus Date: Thu, 2 Jan 2025 14:40:47 +0200 Subject: [PATCH 1/3] Discrete Poisson solver English suggestions --- .../discrete_poisson_solver.ipynb | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/algorithms/differential_equations/discrete_poisson_solver/discrete_poisson_solver.ipynb b/algorithms/differential_equations/discrete_poisson_solver/discrete_poisson_solver.ipynb index f4b6fd221..4e5d136f9 100644 --- a/algorithms/differential_equations/discrete_poisson_solver/discrete_poisson_solver.ipynb +++ b/algorithms/differential_equations/discrete_poisson_solver/discrete_poisson_solver.ipynb @@ -11,7 +11,7 @@ "$$\n", "\\nabla^2 u = b,\n", "$$\n", - "where the $\\nabla^2$ is the Laplacian (second derivatives) operator. One approach for numerically solving the Poisson equation is by moving from the continuos description to a discrete one, namely, by using the finite difference method that casts the problem into a set of linear equations. Then, the solution can be obtained by a linear solver." + "where the $\\nabla^2$ is the Laplacian (second derivatives) operator. One approach for numerically solving the Poisson equation is to move from the continuous description to a discrete one, using the finite difference method that casts the problem into a set of linear equations. Then, the solution can be obtained by a linear solver." ] }, { @@ -19,11 +19,11 @@ "id": "1", "metadata": {}, "source": [ - "In this notebook we treat the Poisson equation on a rectangular geometry, $L_x\\times L_y$, with Dirichlet boundary condition on the $x$ axis and a Neumann boundary condition on the $y$ axis:\n", + "In this notebook we treat the Poisson equation on a rectangular geometry, $L_x\\times L_y$, with a Dirichlet boundary condition on the $x$ axis and a Neumann boundary condition on the $y$ axis:\n", "$$\n", "u(0) = u(L_x)=f_0,\\,\\,\\,\\, \\partial_y u|_{y=0} = \\partial_y u|_{y=L_y} = g_0.\n", "$$\n", - "Furthermore, we will assume that $f_0=g_0=0$. The discritezation of space, including the treatment of the above boundary conditions, is given in Figure 1. The resulting linear equation reads:\n", + "Furthermore, we assume that $f_0=g_0=0$. The discretization of space, including the treatment of the above boundary conditions, is given in Figure 1. The resulting linear equation reads:\n", "$$\n", "\\mathcal{L}\\cdot \\vec{u} = \\vec{b}, \\,\\,\\,\\,\\,\\,\\, \\mathcal{L} = \\mathcal{L}_{xx} \\otimes I_y + I_x \\otimes \\mathcal{L}_{yy},\n", "$$\n", @@ -46,7 +46,7 @@ "0 & 0 & \\cdots & -1 & 1 \\\\\n", "\\end{pmatrix}\n", "$$\n", - "and $\\Delta x$ and $\\Delta y$ are the discretization of the $x$ and $y$ axes, respectively. The above square matrices, which are of dimensions $N_x$ and $N_y$ respectively, represent the solution at the inner part of our geometry." + "and $\\Delta x$ and $\\Delta y$ are the discretization of the $x$ and $y$ axes, respectively. The above square matrices, which are of dimensions $N_x$ and $N_y$, respectively, represent the solution at the inner part of our geometry." ] }, { @@ -56,7 +56,7 @@ "source": [ "
\n", "\n", - "
Figure 1. A schematic description of discrediting the Poisson equation. The area in which we would like to solve the problem is designated by the blue line. The linear equations are written only for the inner filled grid points. The unfilled ghost points are used to impose the boundary conditions. In the example above, a Dirichlet boundary condition is given by setting $u_{0,k}=-u_{-1,k}$, and $u_{3,k}=-u_{4,k}$, whereas a Neumann boundary condition reads $u_{j,0}=u_{j,-1}$, and $u_{j,3}=u_{j,4}$.
\n", + "
Figure 1. A schematic description of discrediting the Poisson equation. The blue line designates the area for solving the problem. The linear equations are written only for the inner filled grid points. The unfilled ghost points are used to impose the boundary conditions. In the example above, a Dirichlet boundary condition is given by setting $u_{0,k}=-u_{-1,k}$ and $u_{3,k}=-u_{4,k}$, whereas a Neumann boundary condition reads $u_{j,0}=u_{j,-1}$ and $u_{j,3}=u_{j,4}$.
\n", "
" ] }, @@ -75,7 +75,7 @@ "id": "4", "metadata": {}, "source": [ - "## How to Build the Algorithm with Classiq" + "## Building the Algorithm with Classiq" ] }, { @@ -83,7 +83,7 @@ "id": "5", "metadata": {}, "source": [ - "The HHL algorithm essentially applies a matrix inversion. Here we treat the Laplacian matrix, which can be diagonalized by a quantum sine and cosine transforms, thus, the matrix we need to invert is a diagonal one. The main four quantum blocks of the algorithm are thus (see Figure 2):\n", + "The HHL algorithm essentially applies a matrix inversion. Here we treat the Laplacian matrix, which can be diagonalized by quantum sine and cosine transforms. Thus, the matrix to invert is diagonal. The four main quantum blocks of the algorithm are thus (see Figure 2):\n", "1. Prepare the amplitudes of the source term on a quantum variable.\n", "2. Perform QST and QCT at the beginning of the computation. This is done by applying the QST to the x qubits and the QCT to the y qubits.\n", "3. Perform matrix inversion for a diagonal matrix.\n", @@ -97,7 +97,7 @@ "source": [ "
\n", "\n", - "
Figure 2. The quantum circuit that for solving the Poisson equation.
\n", + "
Figure 2. The quantum circuit for solving the Poisson equation.
\n", "
" ] }, @@ -136,7 +136,7 @@ "id": "10", "metadata": {}, "source": [ - "The eigenvalues of the Poisson equation with Dirichlet boundary conditions in the x direction and Neumann boundary conditions in the y direction are given by:\n", + "The eigenvalues of the Poisson equation with Dirichlet boundary conditions in the x direction and Neumann boundary conditions in the y direction are given by\n", "$$\n", "\\lambda_{k,j} \\equiv \\lambda_{x,k} +\\lambda_{y,j}\n", "$$\n", @@ -204,7 +204,7 @@ "source": [ "### Hamiltonian Evolution for QPE\n", "\n", - "The HHL is based on a [QPE](https://github.com/Classiq/classiq-library/blob/main/tutorials/advanced_tutorials/high_level_modeling_flexible_qpe/high_level_modeling_flexible_qpe.ipynb) applied on $e^{iHt}$. For this, we need to define a function implementing $\\left(e^{iHt}\\right)^p$ for an integer power $p$. Since in our case the Hamiltonian is diagonal, an exact implementation is given by the fisrt order Suzuki-Trotter formula, where in addition $\\left(e^{iHt}\\right)^p = e^{ipHt}$." + "The HHL is based on a [QPE](https://github.com/Classiq/classiq-library/blob/main/tutorials/advanced_tutorials/high_level_modeling_flexible_qpe/high_level_modeling_flexible_qpe.ipynb) applied on $e^{iHt}$. For this, we need to define a function implementing $\\left(e^{iHt}\\right)^p$ for an integer power $p$. Since in our case the Hamiltonian is diagonal, an exact implementation is given by the first order Suzuki-Trotter formula, where in addition $\\left(e^{iHt}\\right)^p = e^{ipHt}$." ] }, { @@ -312,7 +312,7 @@ "id": "20", "metadata": {}, "source": [ - "## Example: non-separable source term" + "## Example: Non-separable Source Term" ] }, { @@ -320,7 +320,7 @@ "id": "21", "metadata": {}, "source": [ - "We solve an example with a square grid of $N_x,\\, N_y=2^3$. For the source term we take a non-seperable $2^{N_x+N_y}$ vector that represents the function\n", + "We solve an example with a square grid of $N_x,\\, N_y=2^3$. For the source term we take a non-separable $2^{N_x+N_y}$ vector that represents the function\n", "$$\n", "b = F\\left[xy(x-L_x)(y-L_y)\\right].\n", "$$\n", @@ -446,9 +446,7 @@ { "name": "stdout", "output_type": "stream", - "text": [ - "" - ] + "text": [] } ], "source": [ @@ -533,7 +531,7 @@ "id": "34", "metadata": {}, "source": [ - "We define a postprocess function that gets the quantum solution out of the execution and returns solution" + "We define a postprocess function that gets the quantum solution out of the execution and returns a solution." ] }, { @@ -607,7 +605,7 @@ "id": "39", "metadata": {}, "source": [ - "Finally, we print the result and compare it to the classical solution" + "Finally, we print the result and compare it to the classical solution:" ] }, { @@ -688,11 +686,11 @@ "source": [ "## References\n", "\n", - "[1]: [Strang, Gilbert, 1999 SIAM Review 41 135. The Discrete Cosine Transform.](https://doi.org/10.1137/S0036144598336745)\n", + "[1]: [Strang, G., 1999 SIAM Review 41 135. The discrete cosine transform.](https://doi.org/10.1137/S0036144598336745)\n", "\n", - "[2]: [Yudong Cao et al 2013 New J. Phys. 15 013021. Quantum algorithm and circuit design solving the Poisson equation.](https://iopscience.iop.org/article/10.1088/1367-2630/15/1/013021/pdf)\n", + "[2]: [Yudong Cao et al., 2013 New J. Phys. 15 013021. Quantum algorithm and circuit design solving the Poisson equation.](https://iopscience.iop.org/article/10.1088/1367-2630/15/1/013021/pdf)\n", "\n", - "[3]: [Klappenecker, A., & Rotteler M., \"Discrete Cosine Transforms on Quantum Computers\".](https://arxiv.org/abs/quant-ph/0111038)\n" + "[3]: [Klappenecker, A., & Rotteler M., Discrete cosine transforms on quantum computers.](https://arxiv.org/abs/quant-ph/0111038)\n" ] } ], From 83953fdd98ba45a033afd292539f65e6cba9fd82 Mon Sep 17 00:00:00 2001 From: Nadav Ben Ami Date: Sun, 5 Jan 2025 15:23:59 +0200 Subject: [PATCH 2/3] Adding allowed link --- tests/test_links.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_links.py b/tests/test_links.py index 609853f35..bf3fc29b0 100644 --- a/tests/test_links.py +++ b/tests/test_links.py @@ -14,6 +14,7 @@ URL_IN_MARKDOWN_REGEX = re.compile(r"(?<=\]\()%s(?=\s*\))" % URL_REGEX) SKIPPED_URLS = [ "https://journals.aps.org/rmp/abstract/10.1103/RevModPhys.69.607", # From date: 19.12.24, notebook: hamiltonian_simulation_guide.ipynb + "https://doi.org/10.1137/S0036144598336745", # From date: 5.1.25, notebook: algorithms/differential_equations/discrete_poisson_solver/discrete_poisson_solver.ipynb ] From 2562e0ed19896d9288a48f26a16a2c26b06aaf11 Mon Sep 17 00:00:00 2001 From: Nadav Ben Ami Date: Sun, 5 Jan 2025 15:32:02 +0200 Subject: [PATCH 3/3] Adding missing timeout --- tests/resources/timeouts.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/resources/timeouts.yaml b/tests/resources/timeouts.yaml index c455c74fe..d12ff61da 100644 --- a/tests/resources/timeouts.yaml +++ b/tests/resources/timeouts.yaml @@ -110,6 +110,7 @@ hhl.ipynb: 312 hhl_exact.qmod: 100 hhl_example.ipynb: 800 hhl_lanchester.ipynb: 450 +hhl_lanchester.qmod: 450 hhl_trotter.qmod: 100 hhl_workshop.ipynb: 300 hidden_shift.ipynb: 272