diff --git a/demonstrations_v2/tutorial_apply_qsvt/demo.py b/demonstrations_v2/tutorial_apply_qsvt/demo.py index ad59ee52d0..efd7ae1bfe 100644 --- a/demonstrations_v2/tutorial_apply_qsvt/demo.py +++ b/demonstrations_v2/tutorial_apply_qsvt/demo.py @@ -76,6 +76,12 @@ def my_circuit(): # This ultimately requires computing :math:`\vec{x} = A^{-1} \cdot \vec{b},` where for simplicity we # assume that :math:`A` is invertible. # +# .. note:: +# Be careful to follow the notation in this section carefully. +# :math:`x` is a scalar and :math:`\vec{x}` is a vector. Sometimes we are talking about the scalar +# function :math:`P(x) = s \cdot \frac{1}{x}` and sometimes we are talking about the matrix-vector +# function :math:`A \cdot \vec{x} = \vec{b}.` +# # :math:`A^{-1}` can be constructed directly by inverting the singular values of :math:`A^{T}.` We can # leverage QSVT to accomplish this by finding the phase angles which apply a polynomial approximation # to the transformation :math:`\frac{1}{x}.` This may seem simple in theory, but in practice there are diff --git a/demonstrations_v2/tutorial_intro_qsvt/demo.py b/demonstrations_v2/tutorial_intro_qsvt/demo.py index 74db43a1a3..d17e99d748 100644 --- a/demonstrations_v2/tutorial_intro_qsvt/demo.py +++ b/demonstrations_v2/tutorial_intro_qsvt/demo.py @@ -91,10 +91,20 @@ :math:`(5 x^3 - 3x)/2`. As you will soon learn, QSP can be viewed as a special case of QSVT. We thus use the :func:`~.pennylane.qsvt` operation to construct the output matrix and compare the resulting transformation to -the target polynomial. +the target polynomial. This function implements alternate products of :math:`U(a)` and :math:`S(\phi)` +as described above: """ +target_poly = [0, -3 * 0.5, 0, 5 * 0.5] +a = 0.5 +qml.draw_mpl(qml.qsvt(a, target_poly, encoding_wires=[0], block_encoding="embedding").decomposition)() + +############################################################################## +# In this figure :math:`\Pi_\phi` are phase angle rotations (:math:`S(\phi)`) and `BlockEncode` calls +# are implementations of a block encoding of the scalar :math:`a`. (this needs to be rewritten because +# block encoding is not explaine yet in the demo) + import pennylane as qml import numpy as np import matplotlib.pyplot as plt @@ -113,8 +123,8 @@ def qsvt_output(a): qsvt = [np.real(qsvt_output(a)) for a in a_vals] # neglect small imaginary part target = [np.polyval(target_poly[::-1], a) for a in a_vals] # evaluate polynomial -plt.plot(a_vals, target, label="target") -plt.plot(a_vals, qsvt, "*", label="qsvt") +plt.plot(a_vals, target, label="target polynomial: (5x^3 - 3x)/2") +plt.plot(a_vals, qsvt, "*", label="qsvt circuit matrix top left entry") plt.legend() plt.show()