AssertProbInt operation

Warning

This documentation refers to the Classic QDK, which has been replaced by the Modern QDK.

Please see https://aka.ms/qdk.api for the API documentation for the Modern QDK.

Namespace: Microsoft.Quantum.Arithmetic

Package: Microsoft.Quantum.Standard

Asserts that the probability of a specific state of a quantum register has the expected value.

operation AssertProbInt (stateIndex : Int, expected : Double, qubits : Microsoft.Quantum.Arithmetic.LittleEndian, tolerance : Double) : Unit

Description

Given an $n$-qubit quantum state $\ket{\psi}=\sum^{2^n-1}_{j=0}\alpha_j \ket{j}$, asserts that the probability $|\alpha_j|^2$ of the state $\ket{j}$ indexed by $j$ has the expected value.

Input

stateIndex : Int

The index $j$ of the state $\ket{j}$ represented by a LittleEndian register.

expected : Double

The expected value of $|\alpha_j|^2$.

qubits : LittleEndian

The qubit register that stores $\ket{\psi}$ in little-endian format.

tolerance : Double

Absolute tolerance on the difference between actual and expected.

Output : Unit

Example

Suppose that the qubits register encodes a 3-qubit quantum state $\ket{\psi}=\sqrt{1/8}\ket{0}+\sqrt{7/8}\ket{6}$ in little-endian format. This means that the number states $\ket{0}\equiv\ket{0}\ket{0}\ket{0}$ and $\ket{6}\equiv\ket{0}\ket{1}\ket{1}$. Then the following asserts succeed:

AssertProbInt(0, 0.125, qubits, 10e-10);
AssertProbInt(6, 0.875, qubits, 10e-10);