Skip to main content

View on GitHub

Open this notebook in GitHub to run it yourself
The prepare_exponential_state function creates a state with exponentially decreasing amplitudes. Namely, the probability for a state representing an integer nn is P(n)=1Ze−λnP\left(n\right) = \frac{1}{Z} e^{-\lambda n} where λ\lambda is the rate, and ZZ is a normalization factor. If qq in the number of qubits, then Z=∑n=0n=2q−1e−λn=1−e−λ2q1−e−λ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(n)=1Ze−0.1nP\left(n\right) = \frac{1}{Z} e^{-0.1 n} where nn is in the range [0,31][0, 31].