RealMod function

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.Math

Package: Microsoft.Quantum.Standard

Computes the modulus between two real numbers.

function RealMod (value : Double, modulo : Double, minValue : Double) : Double

Input

value : Double

A real number $x$ to take the modulus of.

modulo : Double

A real number to take the modulus of $x$ with respect to.

minValue : Double

The smallest value to be returned by this function.

Output : Double

Example

    // Returns 3 π / 2.
    let y = RealMod(5.5 * PI(), 2.0 * PI(), 0.0);
    // Returns -1.2, since +3.6 and -1.2 are 4.8 apart on the real line,
    // which is a multiple of 2.4.
    let z = RealMod(3.6, 2.4, -1.2);

Remarks

This function computes the real modulus by wrapping the real line about the unit circle, then finding the angle on the unit circle corresponding to the input. The minValue input then effectively specifies where to cut the unit circle.