Trigonometric Functions#

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

ArcSin#

Compute the arcsine of a fixed-point number.

Implements the unitary:

\[ |a\rangle|0\rangle \rightarrow |a\rangle|\arcsin(a)\rangle \]

Parameters#

  • bitsize: Number of bits used to represent the number.

  • num_frac: Number of fraction bits in the number.

  • num_iters: Number of Newton-Raphson iterations. Defaults to 4; the reference studies 3, 4, or 5 iterations.

  • degree: Degree of the polynomial of the initial approximation. Defaults to 4; the reference studies degree-3, 4, 5, or 6 polynomials.

Registers#

  • x: bitsize-sized input register.

  • result: bitsize-sized output register.

References#

from qualtran.bloqs.arithmetic.trigonometric import ArcSin

Example Instances#

arcsin = ArcSin(bitsize=10, num_frac=7)

Graphical Signature#

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

Call Graph#

from qualtran.resource_counting.generalizers import ignore_split_join
arcsin_g, arcsin_sigma = arcsin.call_graph(max_depth=1, generalizer=ignore_split_join)
show_call_graph(arcsin_g)
show_counts_sigma(arcsin_sigma)
../../../_images/d0cbab6242f7cfbdf41594128042ae5ea183356f87803d1a40dd6a349d31579b.svg

Counts totals:

  • Toffoli: 13425