AssertPhase 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.Diagnostics
Package: Microsoft.Quantum.Standard
Asserts that the phase of an equal superposition state has the expected value.
operation AssertPhase (expected : Double, qubit : Qubit, tolerance : Double) : Unit
Description
This operation asserts that the phase $\phi$ of a quantum state that may be expressed as $\frac{e^{i t}}{\sqrt{2}}(e^{i\phi}\ket{0} + e^{-i\phi}\ket{1})$ for some arbitrary real $t$ has the expected value.
Input
expected : Double
The expected value of $\phi \in (-\pi,\pi]$.
qubit : Qubit
The qubit that stores the expected state.
tolerance : Double
Absolute tolerance on the difference between actual and expected.
Output : Unit
Example
The following assert succeeds:
qubit
is in state $\ket{\psi}=e^{i 0.5}\sqrt{1/2}\ket{0}+e^{i 0.5}\sqrt{1/2}\ket{1}$;
AssertPhase(0.0, qubit, 10e-10);
qubit
is in state $\ket{\psi}=e^{i 0.5}\sqrt{1/2}\ket{0}+e^{-i 0.5}\sqrt{1/2}\ket{1}$;
AssertPhase(0.5, qubit, 10e-10);
qubit
is in state $\ket{\psi}=e^{-i 2.2}\sqrt{1/2}\ket{0}+e^{i 0.2}\sqrt{1/2}\ket{1}$;
AssertPhase(-1.2, qubit, 10e-10);
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for