10.5. Numeric

AbsoluteValue
AbsoluteValue (x)

Aliases: abs

Absolute value of a number and if x is a complex value the modulus of x.

See Planetmath (absolute value), Planetmath (modulus), Mathworld (absolute value) or Mathworld (complex modulus) for more information.

Chop
Chop (x)

Replace very small number with zero

ComplexConjugate
ComplexConjugate (M)

Aliases: conj Conj

Calculates the conjugate

Denominator
Denominator (x)

Get the denominator of a rational number

FractionalPart
FractionalPart (x)

Return the fractional part of a number

Im
Im (z)

Aliases: ImaginaryPart

Get the imaginary part of a complex number

IntegerQuotient
IntegerQuotient (m,n)

Division w/o remainder

IsComplex
IsComplex (num)

Check if argument is a complex (non-real) number

IsComplexRational
IsComplexRational (num)

Check if argument is a possibly complex rational number

IsFloat
IsFloat (num)

Check if argument is a floating point number (non-complex)

IsGaussInteger
IsGaussInteger (num)

Aliases: IsComplexInteger

Check if argument is a possibly complex integer

IsGaussianInteger
IsGaussianInteger (z)

Check if argument is a gaussian integer

IsInteger
IsInteger (num)

Check if argument is an integer (non-complex)

IsNonNegativeInteger
IsNonNegativeInteger (num)

Check if argument is a non-negative real integer.

IsPositiveInteger
IsPositiveInteger (num)

Aliases: IsNaturalNumber

Check if argument is a positive real integer. Note that we accept the convention that 0 is not a natural number.

IsRational
IsRational (num)

Check if argument is a rational number (non-complex)

IsReal
IsReal (num)

Check if argument is a real number

Numerator
Numerator (x)

Get the numerator of a rational number

Re
Re (z)

Aliases: RealPart

Get the real part of a complex number

Sign
Sign (x)

Aliases: sign

Return the sign of a number. That is returns -1 if value is negative, 0 if value is zero and 1 if value is positive. If x is a complex value then Sign returns the direction or 0.

ceil
ceil (x)

Aliases: Ceiling

Get the lowest integer more than or equal to n

exp
exp (x)

The exponential function. This is the function e^x where e is the base of the natural logarithm.

See Planetmath or Mathworld for more information.

float
float (x)

Make number a floating point value. That is returns the floating point representation of the number x.

floor
floor (x)

Aliases: Floor

Get the highest integer less than or equal to n

ln
ln (x)

The natural logarithm, the logarithm to base e.

log
log (x,b...)

Logarithm of x base b (calls DiscreteLog if in modulo mode), if base is not given, e is used.

log10
log10 (x)

Logarithm of x base 10

log2
log2 (x)

Aliases: lg

Logarithm of x base 2

max
max (a,args...)

Aliases: Max Maximum

Returns the maximum of arguments or matrix

min
min (a,args...)

Aliases: Min Minimum

Returns the minimum of arguments or matrix

rand
rand (size...)

Generate random float in the range [0,1). If size is given then a matrix (if two numbers are specified) or vector (if one number is specified) of the given size returned.

randint
randint (max,size...)

Generate random integer in the range [0,max). If size is given then a matrix (if two numbers are specified) or vector (if one number is specified) of the given size returned. For example

genius> randint(4)
= 3
genius> randint(4,2)
=
[0      1]
genius> randint(4,2,3)
=
[2      2       1
 0      0       3]

round
round (x)

Aliases: Round

Round a number

sqrt
sqrt (x)

Aliases: SquareRoot

The square root. When operating modulo some integer will return either a null or a vector of the square roots. Examples:

genius> sqrt(2)
= 1.41421356237
genius> sqrt(-1)
= 1i
genius> sqrt(4) mod 7
=
[2      5]
genius> 2*2 mod 7
= 4

See Planetmath for more information.

trunc
trunc (x)

Aliases: Truncate IntegerPart

Truncate number to an integer (return the integer part)