Skip to content

Exponential State Preparation

View on GitHub Experiment in the IDE

The prepare_exponential_state function creates a state with exponentially decreasing amplitudes. Namely, the probability for a state representing an integer \(n\) is

\[P\left(n\right) = \frac{1}{Z} e^{-\lambda n}\]

where \(\lambda\) is the rate, and \(Z\) is a normalization factor. If \(q\) in the number of qubits, then

\[Z = \sum_{n=0} ^{n = 2^q - 1} e^{-\lambda n} = \frac{1 - e^{-\lambda 2^q}}{1 - e^{-\lambda}}\]

Function: prepare_exponential_state

Arguments:

  • rate: CReal

  • q: QArray[QBit]

Notice that the function acts inplace on the qubits.

Example

Prepare a state with probabilities:

\[P\left(n\right) = \frac{1}{Z} e^{-0.1 n}\]

where \(n\) is in the range \([0, 31]\).

from classiq import (
    Output,
    QArray,
    QBit,
    allocate,
    create_model,
    prepare_exponential_state,
    qfunc,
)


@qfunc
def main(x: Output[QArray[QBit]]):
    allocate(5, x)
    prepare_exponential_state(0.1, x)


qmod = create_model(main)
from classiq import synthesize, write_qmod

write_qmod(qmod, "prepare_exponential_state")
qprog = synthesize(qmod)