VEX IQ Python API
math Namespace Reference

PyMite's math module, using Python 2.6 math library as a reference https://docs.python.org/2.6/library/math.html. More...

## Functions

def is_prime (n)

Number theoretic and representation functions
def ceil (x)
Return the ceiling of x as a float, the smallest integer value greater than or equal to x. More...

def copysign (x, y)
Return x with the sign of y. More...

def fabs (x)
Return the absolute value of x. More...

def factorial (x)
Return x factorial. More...

def floor (x)
Return the floor of x as a float, the largest integer value less than or equal to x. More...

def fmod (x, y)
Returns the modulus (remainder) of x divided by y. More...

def frexp (x)
Return the mantissa and exponent of x as the pair (m, e). More...

def fsum (list)
Return a floating point sum of items in the list/tuple. More...

def isinf (x)
Check if the float x is positive or negative infinity. More...

def isnan (x)
Check if the float x is a NaN (not a number). More...

def ldexp (x, exp)
Return x * (2**exp). More...

def modf (x)
Return the fractional and integer parts of x. More...

def trunc (x)
Return the nearest integral value that is not larger in magnitude than x. More...

Trigonometric functions
def acos (x)
Return the arc cosine of x, in radians. More...

def asin (x)
Return the arc sine of x, in radians. More...

def atan (x)
Return the arc tangent of x, in radians. More...

def atan2 (y, x)
Return atan(y / x), in radians. More...

def cos (x)
Return the cosine of x radians. More...

def hypot (x, y)
Return the Euclidean norm, sqrt(x*x + y*y). More...

def sin (x)
Return the sine of x radians. More...

def tan (x)
Return the tangent of x radians. More...

Angular conversion
def degrees (x)
Converts angle x from radians to degrees. More...

Converts angle x from degrees to radians. More...

## Power and logarithmic functions

float pi = 3.1415926535897931
The mathematical constant PI = 3.141592..., to available precision. More...

float e = 2.7182818284590451
The mathematical constant e = 2.718281..., to available precision. More...

def exp (x)
Return e**x. More...

def log (x, base=None)
With one argument, return the natural logarithm of x (to base e). More...

def log1p (x)
Return the natural logarithm of 1+x (base e). More...

def log10 (x)
Return the base-10 logarithm of x. More...

def pow (x, y)
Return x raised to the power y. More...

def sqrt (x)
Return the square root of x. More...

## Detailed Description

PyMite's math module, using Python 2.6 math library as a reference https://docs.python.org/2.6/library/math.html.

## ◆ ceil()

 def math.ceil ( x )

Return the ceiling of x as a float, the smallest integer value greater than or equal to x.

## ◆ copysign()

 def math.copysign ( x, y )

Return x with the sign of y.

## ◆ fabs()

 def math.fabs ( x )

Return the absolute value of x.

## ◆ factorial()

 def math.factorial ( x )

Return x factorial.

Raises ValueError if x is negative.

## ◆ floor()

 def math.floor ( x )

Return the floor of x as a float, the largest integer value less than or equal to x.

## ◆ fmod()

 def math.fmod ( x, y )

Returns the modulus (remainder) of x divided by y.

## ◆ frexp()

 def math.frexp ( x )

Return the mantissa and exponent of x as the pair (m, e).

m is a float and e is an integer such that x == m * 2**e exactly. If x is zero, returns (0.0, 0), otherwise 0.5 <= abs(m) < 1. This is used to "pick apart" the internal representation of a float in a portable way.

## ◆ fsum()

 def math.fsum ( list )

Return a floating point sum of items in the list/tuple.

## ◆ isinf()

 def math.isinf ( x )

Check if the float x is positive or negative infinity.

## ◆ isnan()

 def math.isnan ( x )

Check if the float x is a NaN (not a number).

## ◆ ldexp()

 def math.ldexp ( x, exp )

Return x * (2**exp).

This is essentially the inverse of function frexp().

## ◆ modf()

 def math.modf ( x )

Return the fractional and integer parts of x.

Both results carry the sign of x and are floats.

## ◆ trunc()

 def math.trunc ( x )

Return the nearest integral value that is not larger in magnitude than x.

## ◆ exp()

 def math.exp ( x )

Return e**x.

## ◆ log()

 def math.log ( x, base = `None` )

With one argument, return the natural logarithm of x (to base e).

With two arguments, return the logarithm of x to the given base, calculated as log(x)/log(base)

## ◆ log1p()

 def math.log1p ( x )

Return the natural logarithm of 1+x (base e).

The result is calculated in a way which is accurate for x near zero.

## ◆ log10()

 def math.log10 ( x )

Return the base-10 logarithm of x.

This is usually more accurate than log(x, 10)

## ◆ pow()

 def math.pow ( x, y )

Return x raised to the power y.

## ◆ sqrt()

 def math.sqrt ( x )

Return the square root of x.

## ◆ acos()

 def math.acos ( x )

Return the arc cosine of x, in radians.

## ◆ asin()

 def math.asin ( x )

Return the arc sine of x, in radians.

## ◆ atan()

 def math.atan ( x )

Return the arc tangent of x, in radians.

## ◆ atan2()

 def math.atan2 ( y, x )

Return atan(y / x), in radians.

The result is between -pi and pi. The vector in the plane from the origin to point (x, y) makes this angle with the positive X axis. The point of atan2() is that the signs of both inputs are known to it, so it can compute the correct quadrant for the angle. For example, atan(1) and atan2(1, 1) are both pi/4, but atan2(-1, -1) is -3*pi/4.

## ◆ cos()

 def math.cos ( x )

Return the cosine of x radians.

## ◆ hypot()

 def math.hypot ( x, y )

Return the Euclidean norm, sqrt(x*x + y*y).

This is the length of the vector from the origin to point (x, y).

## ◆ sin()

 def math.sin ( x )

Return the sine of x radians.

## ◆ tan()

 def math.tan ( x )

Return the tangent of x radians.

## ◆ degrees()

 def math.degrees ( x )

Converts angle x from radians to degrees.

Converts angle x from degrees to radians.

## ◆ is_prime()

 def math.is_prime ( n )

## ◆ pi

 float math.pi = 3.1415926535897931

The mathematical constant PI = 3.141592..., to available precision.

## ◆ e

 float math.e = 2.7182818284590451

The mathematical constant e = 2.718281..., to available precision.