Chebyshev Polynomial#

from qualtran import Bloq, CompositeBloq, BloqBuilder, Signature, Register
from qualtran import QBit, QInt, QUInt, QAny
from qualtran.drawing import show_bloq, show_call_graph, show_counts_sigma
from typing import *
import numpy as np
import sympy
import cirq

ChebyshevPolynomial#

Block encoding of \(T_j(A / \alpha)\) where \(T_j\) is the \(j\)-th Chebyshev polynomial.

Given a Hermitian matrix \(A\) with spectral norm \(|A| \le 1\), recall:

\[\begin{align*} T_0[A] &= I \\ T_1[A] &= A \\ T_2[A] &= 2 A^2 - I \\ T_3[A] &= 4 A^3 - 3 A \\ &\dots \end{align*}\]

If block_encoding block encodes \(A\) with normalization factor \(\alpha\), i.e. it constructs \(\mathcal{B}[A/\alpha]\), then this bloq constructs \(\mathcal{B}[T_j(A/\alpha)]\) with normalization factor 1. Note that \(\mathcal{B}[T_j(A/\alpha)]\) is not a multiple of \(\mathcal{B}[T_j(A)]\) in general; use ScaledChebyshevPolynomial if \(\alpha \neq 1\).

See https://github.com/quantumlib/Qualtran/issues/984 for an alternative.

Parameters#

  • block_encoding: Block encoding of a Hermitian matrix \(A\), \(\mathcal{B}[A]\). Assumes the \(|G\rangle\) state of the block encoding is the identity operator.

  • order: order of Chebychev polynomial.

References#

from qualtran.bloqs.block_encoding import ChebyshevPolynomial

Example Instances#

from qualtran.bloqs.basic_gates import Hadamard, XGate
from qualtran.bloqs.block_encoding import LinearCombination, Unitary

bloq = LinearCombination((Unitary(XGate()), Unitary(Hadamard())), (0.5, 0.5), lambd_bits=1)
chebyshev_poly_even = ChebyshevPolynomial(bloq, order=4)
from qualtran.bloqs.basic_gates import Hadamard
from qualtran.bloqs.block_encoding import Unitary

bloq = Unitary(Hadamard())
chebyshev_poly_odd = ChebyshevPolynomial(bloq, order=5)

Graphical Signature#

from qualtran.drawing import show_bloqs
show_bloqs([chebyshev_poly_even, chebyshev_poly_odd],
           ['`chebyshev_poly_even`', '`chebyshev_poly_odd`'])

Call Graph#

from qualtran.resource_counting.generalizers import ignore_split_join
chebyshev_poly_even_g, chebyshev_poly_even_sigma = chebyshev_poly_even.call_graph(max_depth=1, generalizer=ignore_split_join)
show_call_graph(chebyshev_poly_even_g)
show_counts_sigma(chebyshev_poly_even_sigma)
../../_images/208cfab0d105bd44097eb4cfb9f52a905dd6e6ceb670912bb14250b081f4a229.svg

Counts totals:

  • B[XGate+H]: 2

  • B[XGate+H]†: 2

  • ReflectionUsingPrepare: 4

ScaledChebyshevPolynomial#

Block encoding of \(T_j(A)\) where \(T_j\) is the \(j\)-th Chebyshev polynomial.

Unlike ChebyshevPolynomial, this bloq accepts \(\mathcal{B}[A/\alpha]\) with \(\alpha \neq 1\) and constructs \(\mathcal{B}[T_j(A)]\) which is not a multiple of \(\mathcal{B}[T_j(A/\alpha)]\) in general. It does so by constructing \(T_k(t)\) in terms of \(T_j(t/\alpha)\) for \(j \in [0, k]\).

Parameters#

  • block_encoding: Block encoding of a Hermitian matrix \(A\), \(\mathcal{B}[A/\alpha]\). Assumes the \(|G\rangle\) state of the block encoding is the identity operator.

  • order: order of Chebychev polynomial.

  • lambd_bits: number of bits to represent coefficients of linear combination precisely.

References#

from qualtran.bloqs.block_encoding import ScaledChebyshevPolynomial

Example Instances#

from qualtran.bloqs.basic_gates import Hadamard, XGate
from qualtran.bloqs.block_encoding import LinearCombination, Unitary

bloq = LinearCombination((Unitary(XGate()), Unitary(Hadamard())), (1.0, 1.0), lambd_bits=1)
scaled_chebyshev_poly_even = ScaledChebyshevPolynomial(bloq, order=4)
from attrs import evolve

from qualtran.bloqs.basic_gates import Hadamard
from qualtran.bloqs.block_encoding import Unitary

bloq = evolve(Unitary(Hadamard()), alpha=3.14)
scaled_chebyshev_poly_odd = ScaledChebyshevPolynomial(bloq, order=5)

Graphical Signature#

from qualtran.drawing import show_bloqs
show_bloqs([scaled_chebyshev_poly_even, scaled_chebyshev_poly_odd],
           ['`scaled_chebyshev_poly_even`', '`scaled_chebyshev_poly_odd`'])

Call Graph#

from qualtran.resource_counting.generalizers import ignore_split_join
scaled_chebyshev_poly_even_g, scaled_chebyshev_poly_even_sigma = scaled_chebyshev_poly_even.call_graph(max_depth=1, generalizer=ignore_split_join)
show_call_graph(scaled_chebyshev_poly_even_g)
show_counts_sigma(scaled_chebyshev_poly_even_sigma)
../../_images/9edf3decbc24d11d828c9e2998b22c38f37eac00304b763b94eda805f8a20561.svg

Counts totals:

  • B[T_0(B[XGate+H])+T_1(B[XGate+H])+T_2(B[XGate+H])+T_3(B[XGate+H])+T_4(B[XGate+H])]: 1