From 6c1f8e7ba66020052c6250fd4e58e0313989e2e0 Mon Sep 17 00:00:00 2001 From: Guillermo Alonso-Linaje <65235481+KetpuntoG@users.noreply.github.com> Date: Wed, 6 Sep 2023 10:36:05 -0400 Subject: [PATCH] Fixing tutorial_apply_qsvt (#912) This is a PR to solve [this issue](https://github.com/PennyLaneAI/qml/issues/910). --------- Co-authored-by: Jay Soni --- demonstrations/tutorial_apply_qsvt.metadata.json | 2 +- demonstrations/tutorial_apply_qsvt.py | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/demonstrations/tutorial_apply_qsvt.metadata.json b/demonstrations/tutorial_apply_qsvt.metadata.json index ee9e3abcc8..76ed22a7f5 100644 --- a/demonstrations/tutorial_apply_qsvt.metadata.json +++ b/demonstrations/tutorial_apply_qsvt.metadata.json @@ -9,7 +9,7 @@ } ], "dateOfPublication": "2023-08-22T00:00:00+00:00", - "dateOfLastModification": "2023-08-22T00:00:00+00:00", + "dateOfLastModification": "2023-09-05T00:00:00+00:00", "categories": [ "Quantum Computing", "Algorithms", diff --git a/demonstrations/tutorial_apply_qsvt.py b/demonstrations/tutorial_apply_qsvt.py index bcba41884f..86b2381e9f 100644 --- a/demonstrations/tutorial_apply_qsvt.py +++ b/demonstrations/tutorial_apply_qsvt.py @@ -288,16 +288,17 @@ def loss_func(phi): # # .. math:: # -# \hat{U}_{real}(\vec{\phi}) = \frac{1}{2} \ ( \hat{U}_{qsvt}(\vec{\phi}) + \hat{U}^{\dagger}_{qsvt}(\vec{\phi}) ). +# \hat{U}_{real}(\vec{\phi}) = \frac{1}{2} \ ( \hat{U}_{qsvt}(\vec{\phi}) + \hat{U}^{*}_{qsvt}(\vec{\phi}) ). # -# Here we use a two-term LCU to define the quantum function for this operator: +# Here we use a two-term LCU to define the quantum function for this operator. We obtain the complex +# conjugate of :math:`\hat{U}_{qsvt}` by taking the adjoint of the operator block-encoding :math:`A^{T}`: def real_u(A, phi): qml.Hadamard(wires="ancilla1") qml.ctrl(sum_even_odd_circ, control=("ancilla1",), control_values=(0,))(A, phi, "ancilla2", [0, 1, 2]) - qml.ctrl(qml.adjoint(sum_even_odd_circ), control=("ancilla1",), control_values=(1,))(A, phi, "ancilla2", [0, 1, 2]) + qml.ctrl(qml.adjoint(sum_even_odd_circ), control=("ancilla1",), control_values=(1,))(A.T, phi, "ancilla2", [0, 1, 2]) qml.Hadamard(wires="ancilla1") @@ -306,8 +307,9 @@ def real_u(A, phi): # # Solving a Linear System with QSVT # --------------------------------- -# Our goal is to solve the equation :math:`A \cdot \vec{x} = \vec{b}`. Let's begin by -# defining the specific matrix :math:`A` and vector :math:`\vec{b}` : +# Our goal is to solve the equation :math:`A \cdot \vec{x} = \vec{b}`. This method assumes +# the matrix we will invert is hermitian. Let's begin by defining the specific matrix :math:`A` +# and vector :math:`\vec{b}` : # A = np.array(