AbsoluteValue (x)
Aliases: abs
Absolute value of a number and if x
is
a complex value the modulus of x
. I.e. this
the distance of x
to the origin. This is equivalent
to |x|
.
See Wikipedia, Planetmath (absolute value), Planetmath (modulus), Mathworld (absolute value) or Mathworld (complex modulus) for more information.
Chop (x)
Replace very small number with zero.
ComplexConjugate (z)
Aliases: conj
Conj
Calculates the complex conjugate of the complex number z
. If z
is a vector or matrix,
all its elements are conjugated.
See Wikipedia for more information.
Denominator (x)
Get the denominator of a rational number.
See Wikipedia for more information.
FractionalPart (x)
Return the fractional part of a number.
See Wikipedia for more information.
Im (z)
Aliases: ImaginaryPart
Get the imaginary part of a complex number. For example Re(3+4i)
yields 4.
See Wikipedia for more information.
IntegerQuotient (m,n)
Division without remainder.
IsComplex (num)
Check if argument is a complex (non-real) number. Do note that we really mean nonreal number. That is,
IsComplex(3)
yields false, while
IsComplex(3-1i)
yields true.
IsComplexRational (num)
Check if argument is a possibly complex rational number. That is, if both real and imaginary parts are given as rational numbers. Of course rational simply means "not stored as a floating point number."
IsFloat (num)
Check if argument is a real floating point number (non-complex).
IsGaussInteger (num)
Aliases: IsComplexInteger
Check if argument is a possibly complex integer. That is a complex integer is a number of
the form n+1i*m
where n
and m
are integers.
IsInteger (num)
Check if argument is an integer (non-complex).
IsNonNegativeInteger (num)
Check if argument is a non-negative real integer. That is, either a positive integer or zero.
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 (num)
Check if argument is a rational number (non-complex). Of course rational simply means "not stored as a floating point number."
IsReal (num)
Check if argument is a real number.
Numerator (x)
Get the numerator of a rational number.
See Wikipedia for more information.
Re (z)
Aliases: RealPart
Get the real part of a complex number. For example Re(3+4i)
yields 3.
See Wikipedia for more information.
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 (x)
Aliases: Ceiling
Get the lowest integer more than or equal to n
. Examples:
genius>
ceil(1.1)
= 2genius>
ceil(-1.1)
= -1
Note that you should be careful and notice that floating point
numbers are stored in binary and so may not be what you
expect. For example ceil(420/4.2)
returns 101 instead of the expected 100. This is because
4.2 is actually very slightly less than 4.2. Use rational
representation 42/10
if you want
exact arithmetic.
exp (x)
The exponential function. This is the function
e^x
where e
is the base of the natural
logarithm.
See Wikipedia or Planetmath or Mathworld for more information.
float (x)
Make number a floating point value. That is returns the floating point representation of the number x
.
floor (x)
Aliases: Floor
Get the highest integer less than or equal to n
.
ln (x)
The natural logarithm, the logarithm to base e
.
See Wikipedia or Planetmath or Mathworld for more information.
log (x)
log (x,b)
Logarithm of x
base b
(calls DiscreteLog
if in modulo mode), if base is not given, e
is used.
log10 (x)
Logarithm of x
base 10.
log2 (x)
Aliases: lg
Logarithm of x
base 2.
max (a,args...)
Aliases: Max
Maximum
Returns the maximum of arguments or matrix.
min (a,args...)
Aliases: Min
Minimum
Returns the minimum of arguments or matrix.
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 (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)
= 3genius>
randint(4,2)
= [0 1]genius>
randint(4,2,3)
= [2 2 1 0 0 3]
round (x)
Aliases: Round
Round a number.
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.41421356237genius>
sqrt(-1)
= 1igenius>
sqrt(4) mod 7
= [2 5]genius>
2*2 mod 7
= 4
See Wikipedia or Planetmath for more information.
trunc (x)
Aliases: Truncate
IntegerPart
Truncate number to an integer (return the integer part).