# Microsoft.Quantum.Math namespace

This namespace contains classical mathematical functions and data types.

## Description

A lot of functions in this namespace offer the same functionality as the arithmetic expressions.

## Operations

Name | Summary |
---|---|

RandomInt | > [!WARNING] |

RandomIntPow2 | > [!WARNING] |

RandomReal | > [!WARNING] |

RandomSingleQubitPauli | > [!WARNING] |

## Functions

Name | Summary |
---|---|

AbsComplex | Returns the absolute value of a complex number of type `Complex` . |

AbsComplexPolar | Returns the absolute value of a complex number of type `ComplexPolar` . |

AbsD | Returns the absolute value of a double-precision floating-point number. |

AbsI | Returns the absolute value of an integer. |

AbsL | Returns the absolute value of an integer. |

AbsSquaredComplex | Returns the squared absolute value of a complex number of type `Complex` . |

AbsSquaredComplexPolar | Returns the squared absolute value of a complex number of type `ComplexPolar` . |

ApproximateFactorial | Returns an approximate factorial of a given number. |

ArcCos | Returns the angle whose cosine is the specified number. |

ArcCosh | Computes the inverse hyperbolic cosine of a number. |

ArcSin | Returns the angle whose sine is the specified number. |

ArcSinh | Computes the inverse hyperbolic sine of a number. |

ArcTan | Returns the angle whose tangent is the specified number. |

ArcTan2 | Returns the angle whose tangent is the quotient of two specified numbers. |

ArcTanh | Computes the inverse hyperbolic tangent of a number. |

ArgComplex | Returns the phase of a complex number of type `Complex` . |

ArgComplexPolar | Returns the phase of a complex number of type `ComplexPolar` . |

Binom | Returns the binomial coefficient of two integers. |

BitSizeI | For a non-negative integer `a` , returns the number of bits required to represent `a` . |

BitSizeL | For a non-negative integer `a` , returns the number of bits required to represent `a` . |

Ceiling | Returns the smallest integer greater than or equal to the specified number. |

ComplexAsComplexPolar | Converts a complex number of type `Complex` to a complex number of type `ComplexPolar` . |

ComplexPolarAsComplex | Converts a complex number of type `ComplexPolar` to a complex number of type `Complex` . |

ContinuedFractionConvergentI | Finds the continued fraction convergent closest to `fraction` with the denominator less or equal to `denominatorBound` |

ContinuedFractionConvergentL | Finds the continued fraction convergent closest to `fraction` with the denominator less or equal to `denominatorBound` |

Cos | Returns the cosine of the specified angle. |

Cosh | Returns the hyperbolic cosine of the specified angle. |

DivRemL | Divides one BigInteger value by another, returns the result and the remainder as a tuple. |

DividedByC | Returns the quotient of two inputs. |

DividedByCP | Returns the quotient of two inputs. |

DividedByD | Returns the quotient of two inputs. |

DividedByI | Returns the quotient of two inputs. |

DividedByL | Returns the quotient of two inputs. |

E | Returns the natural logarithmic base to double-precision. |

ExpD | Returns the natural logarithmic base raised to a specified power. |

ExpModI | Returns an integer raised to a given power, with respect to a given modulus. |

ExpModL | Returns an integer raised to a given power, with respect to a given modulus. |

ExtendedGreatestCommonDivisorI | Returns the GCD of two integers, decomposed into a linear combination. |

ExtendedGreatestCommonDivisorL | Returns the GCD of two integers, decomposed into a linear combination. |

FactorialI | Returns the factorial of a given number. |

FactorialL | Returns the factorial of a given integer. |

Floor | Returns the smallest integer greater than or equal to the specified number. |

GreatestCommonDivisorI | Computes the greatest common divisor of two integers. |

GreatestCommonDivisorL | Computes the greatest common divisor of two integers. |

HalfIntegerBinom | Returns a binomial coefficient of the form "½-choose-k." |

IEEERemainder | Returns the remainder resulting from the division of a specified number by another specified number. |

InverseModI | Returns the multiplicative inverse of a modular integer. |

InverseModL | Returns $b$ such that $a \cdot b = 1 (\operatorname{mod} \texttt{modulus})$. |

IsCoprimeI | Returns if two integers are co-prime. |

IsCoprimeL | Returns if two integers are co-prime. |

IsFinite | Returns whether a given floating-point value is a finite number. |

IsInfinite | Returns whether a given floating-point value is either positive or negative infinity. |

IsNaN | Returns whether a given floating-point value is not a number (i.e. is NaN). |

LargestFixedPoint | Returns the largest representable number for specific fixed point dimensions. |

Lg | Computes the base-2 logarithm of a number. |

Log | Returns the natural (base $e$) logarithm of a specified number. |

Log10 | Returns the base-10 logarithm of a specified number. |

LogFactorialD | Returns the approximate natural logarithm of the factorial of a given integer. |

LogGammaD | Returns the natural logarithm of the gamma function (aka the log-gamma function). |

LogOf2 | Returns the natural logarithm of 2. |

Max | Given an array of integers, returns the largest element. |

MaxD | Returns the larger of two specified numbers. |

MaxI | Returns the larger of two specified numbers. |

MaxL | Returns the larger of two specified numbers. |

Min | Given an array of integers, returns the smallest element. |

MinD | Returns the smaller of two specified numbers. |

MinI | Returns the smaller of two specified numbers. |

MinL | Returns the smaller of two specified numbers. |

MinusC | Returns the difference between two inputs. |

MinusCP | Returns the difference between two inputs. |

MinusD | Returns the difference between two inputs. |

MinusI | Returns the difference between two inputs. |

MinusL | Returns the difference between two inputs. |

ModI | Returns the modulus of a number with respect to another number. |

ModL | Returns the modulus of a number with respect to another number. |

ModPowL | Performs modular division on a number raised to the power of another number. |

ModulusI | Computes the canonical residue of `value` modulo `modulus` . |

ModulusL | Computes the canonical residue of `value` modulo `modulus` . |

NaN | Returns a value that is not a number (i.e. NaN). |

NegationC | Returns the unary negation of an input. |

NegationCP | Returns the unary negation of an input. |

NegationD | Returns the unary negation of an input. |

NegationI | Returns the unary negation of an input. |

NegationL | Returns the unary negation of an input. |

PI | Represents the ratio of the circumference of a circle to its diameter. |

PNorm | Returns the p-norm of a vector of real numbers. |

PNormalized | Normalizes a vector of real numbers according to the p-norm for a given p. |

PlusA | Returns the sum (concatenation) of two inputs. |

PlusC | Returns the sum of two inputs. |

PlusCP | Returns the sum of two inputs. |

PlusD | Returns the sum of two inputs. |

PlusI | Returns the sum of two inputs. |

PlusL | Returns the sum of two inputs. |

PowC | Returns a number raised to a given power. |

PowCP | Returns a number raised to a given power. |

PowD | Returns the number x raised to the power y. |

PowI | Returns a number raised to a given power. |

PowL | Returns a number raised to a given power. |

RealMod | Computes the modulus between two real numbers. |

Round | Returns the nearest integer to the specified number. |

SignD | Returns an integer that indicates the sign of a number. |

SignI | Returns an integer that indicates the sign of a number. |

SignL | Returns an integer that indicates the sign of a number. |

Sin | Returns the sine of the specified angle. |

Sinh | Returns the hyperbolic sine of the specified angle. |

SmallestFixedPoint | Returns the smallest representable number for specific fixed point dimensions. |

Sqrt | Returns the square root of a specified number. |

SquaredNorm | Returns the squared 2-norm of a vector. |

Tan | Returns the tangent of the specified angle. |

Tanh | Returns the hyperbolic tangent of the specified angle. |

TimesC | Returns the product of two inputs. |

TimesCP | Returns the product of two inputs. |

TimesD | Returns the product of two inputs. |

TimesI | Returns the product of two inputs. |

TimesL | Returns the product of two inputs. |

Truncate | Returns the integral part of a number. |

_ContinuedFractionConvergentI | Internal recursive call to calculate the GCD with a bound |

_ContinuedFractionConvergentL | Internal recursive call to calculate the GCD with a bound |

_ExtendedGreatestCommonDivisorI | Internal recursive call to calculate the GCD. |

_ExtendedGreatestCommonDivisorL | Internal recursive call to calculate the GCD. |

## User-defined types

Name | Summary |
---|---|

BigFraction | Represents a rational number of the form `p/q` . Integer `p` is the first element of the tuple and `q` is the second element of the tuple. |

Complex | Represents a complex number by its real and imaginary components. The first element of the tuple is the real component, the second one - the imaginary component. |

ComplexPolar | Represents a complex number in polar form. |

Fraction | Represents a rational number of the form `p/q` . Integer `p` is the first element of the tuple and `q` is the second element of the tuple. |

## Feedback

Submit and view feedback for