Mathematics
Module math
Elementary mathematical functions.
- e
- Euler's number
2.71828...
- pi
3.14159...
- nan
- Not a number.
- inf
- Infinity.
- floor(x)
- Round down. Returns floating point numbers.
- ceil(x)
- Round up. Returns floating point numbers.
- sqrt(x)
- Square root of
x.
- exp(x)
- Exponential function.
- log2(x)
- Logarithm to base 2.
- ln(x)
- Logarithm to base e.
- lg(x)
- Logarithm to base 10.
- lg(x,b)
- Logarithm to base
b.
- sin(x), cos(x), tan(x)
- Sine, cosine and tangent.
- asin(x), acos(x), atan(x)
- Arc sine, arc cosine and arc tangent.
- sinh(x), cosh(x), tanh(x)
- Hyperbolic sine, hyperbolic cosine and hyperbolic tangent.
- asinh(x), acosh(x), atanh(x)
- Inverse functions of the hyperbolic functions.
- fac(x)
- Factorial function. Returns floating point numbers.
- gamma(x)
- Gamma function.
- lgamma(x)
- Return
ln(abs(gamma(x))).
- sgngamma(x)
- Return
sgn(gamma(x)).
- erf(x)
- Error function.
- hypot(x1,...,xn)
- Return
sqrt(x1^2+...+xn^2).
- atan2(y,x)
- Return the phase angle of the coordinate vector
[x,y].
- expm1(x)
- Return
exp(x)-1.
- ln1p(x)
- Return
ln(1+x).
- isfinite(x)
- Return true if
x is not infinite and not a NaN.
- isnan(x)
- Return true if
x is a NaN.
- isinf(x)
- Return true if
x is infinite.
- frexp(x)
- Take
x==m*2^n and return [m,n].
The type of m is float, the type of n is int.
- ldexp(m,n)
- Return
m*2^n.
Module cmath
Elementary mathematical functions that can take or return complex
numbers.
- re(z)
- Real part of
z.
- im(z)
- Imaginary part of
z.
- conj(z)
- Complex conjugate.
- sqrt(z)
- Square root.
- exp(z)
- Exponential function.
- ln(z)
- Natural logarithm.
- sin(z), cos(z), tan(z)
- Sine, cosine and tangent.
- sinh(z), cosh(z), tanh(z)
- Hyperbolic sine, hyperbolic cosine and hyperbolic tangent.
- asinh(z), acosh(z), atanh(z)
- Inverse functions of the hyperbolic functions.
- gamma(z)
- Gamma function.
Module math.rational
- Rat
- Rational numbers data type.
- rat(n,d)
- Rational number
n/d.
- r.n
- Numerator.
- r.d
- Denominator.
Module math.nt
Number theory.
- base(n,b)
- Transform the number
n into positional notation
by base b. The result is in little endian
(least significant digit first).
- base(n,b).rev()
- Big endian (least significant digit last) of the
positional notation above.
- isprime(n)
- Deterministic primality test.
- isprime(n,e)
- Probalistic primality test with false positive probability of less than
1/(4^e).
- gcd(a,b)
- Greatest common divisor of
a and b.
- lcm(a,b)
- Least common multiple of
a and b.
- lcm(a)
- Least common multiple of the numbers in the iterable
a.
- factor(n)
- Prime factorization of
n.
- divisors(n)
- The list of divisors of
n.
- phi(n)
- Euler's totient function.
- lambda(n)
- Carmichael function.
Module math.cf
Combinatorical functions.
- fac(n)
- Factorial function.
- rf(n,k)
- Raising factorial.
- ff(n,k)
- Falling factorial.
- bc(n,k)
- Binomial coefficient.
- mc([k1,...,kn])
- Multinomial coefficient.
- stirling1(n,k)
- Stirling number of the first kind.
- stirling2(n,k)
- Stirling number of the second kind.
- euler1(n,k)
- Eulerian number.
- euler2(n,k)
- Eulerien number of the second order.
- bell(n)
- Bell numbers.
- pf(n)
- Partition function.
- pf(n,k)
- Number of partitions of
n into exactly k
parts.
- permutations(a)
- Permutations of the list
a.
- combinations(k,s)
- Combinations of set/list/string
s into
sets of k elements.
- partitions(n,k)
- Partitions of
n into k parts.
Module math.la
- vector(a1,...,an)
- Return a coordinate vector.
- matrix([a11,...,a1n],...,[am1,...,amn])
- Return a matrix.
- array(N,data)
- Return a coordinate tensor of order
N.
Note that:
array(1,a) = vector.apply(a),
array(2,a) = matrix.apply(a).
- diag(a1,...,an)
- Return a diagonal matrix.
- scalar(a)
- Return a scalar matrix.
- a.T
- Transposed matrix.
- a.H
- Conjugate transpose.
- a.conj
- Conjugated complex matrix.
- a.tr
- Trace.
- a.diag
- Main diagonal as a coordinate vector.
- a.shape
- Shape of the array.
- a.copy
- Shallow copy of the array.
- a.list
- Convert the array into a list.
- a.map(f)
- Return
(f(a[i,j])).
- a[k]
- Component of a vector (
k=0 upto n-1).
Row of a matrix.