A polynomial in the variables x,y (say) with rational coefficients (say) is a sum of terms of the form a xi yj, where a is a rational number and i, j are integers. Since this term can be input with the syntax a * x^i * y^j , we see that polynomials can be easily constructed with the operators +, * and ^.
Polynomials belong to the type Polynomial.
|
is? (p, Polynomial) variables(p) |
|
We can ascertain if an expression
p is a polynomial with the call
is?(p, Polynomial). The list of variables
of a polynomial
p
is given by
variables(p)
Examples: polynomial.t |
|
gcd (a, b) lcm (a, b) |
|
If
a
and
b
are integers or univariate polynomials,
gcd(a,b)
and
lcm(a,b)
return the
greatest common divisor
and the least common multiple of
span a
and
b.
Examples: gcd-lcm.t |
| phi_euler (n) |
|
This function gives the number of
k in
1..(n-1)
such that
gcd(k,n) = 1.
Examples: phi-euler.t |
|
length(c) range(c) c.k head(c) last(c) |
|
If c is a
Chain,
length(c)
gives the number of its elements, say
n;
range(c)
provides the range
1..n; if
k
is in the range of
c,
c.k yields the
k-th element of
c. Instead of
c.1 we can use
head(c) and
instead of
c.n we can use
last(c).
The functions described above work also for the types Range and Rule. Examples: chain.t |
| join (a, b) ≡ a | b |
|
If a
and
b
are chains of the same sort,
a | b
constructs the chain obtained by joining
b to
the end of
a.
The infix operator
a | b for chains
is equivalent to the prefix form
join(a, b).
Examples: join.t |
| Combinatorial
functions |
Meaning |
Examples |
| bernoulli_number(n:Pos) B_(n:Pos) |
<> (-1)n-1 ·
worpitzki_bernouilli_number(2·n) <> (-1)n-1 · WB_(2·n) |
B_(7) » 7/6 |
| denominator_bernoulli_number(n:Pos) | The denominator of the Bernoulli
number B2·n , or of B_(n). |
@ n=100 » 1366530 |
| stirling_number(n, k) S_(n, k) |
Stirling
number of the second kind: Number of partitions of a set of n+1 elements into k+1 non-empty subsets |
S_(4,2) » 7 |
| worpitzki_bernoulli_number(n:Nat) WB_(n:Nat) |
The n-th
Bernoulli number Bn: B0=1, B1=1/2, B2=1/6, B3=0, B4=-1/30, ... |
WB_(14) » 7/6 |
| worpitzki_number(n:Nat, k:Nat) W_(n:Nat, k:Nat) |
k! · stirling_number(n+1, k+1) k! · S_(n+1, k+1) |
W_(3,1) » 7 |
| Identifier*
functions |
Meaning |
Examples |
| identifier(x:Name, k:Nat) |
Identifier formed by
concatenating the Name x and the integer k. |
@ x=a, k=3 » a3 |
| x=v |
If x is a Name, x is assigned the value v. The value of the expression is v |
Z=2+3 » 5 |
| x:=v | Delayed assignment |
| List
functions |
Meaning |
| {x1,...,xn} |
List formed with the sequence x1,...,xn |
| list(r:Range) |
The list formed with the actual
values of r |
| Matrix
functions |
Meaning |
| transpose(A) A' |
The transpose of A |
| A|B (A and B matrices with the same number of columns) |
Row splicing of A and B |
| A|v (A a matrix and v a vector with length equal to the number of rows of A) |
A
| [v]' |
| number_of_rows(A:Matrix) n_rows(A:Matrix) |
The number of rows of A |
| number_of_columns(A:Matrix) n_columns(A:Matrix) |
The number of columns of A |
| range(A) |
If r=n_rows(A), 1..r |
| A.i.j
(i in
range(A), j in 1..n_columns(A)) |
Element in row i and column j |
| determinant(A) det(A) |
The determinant of A, assuming A is a square matrix |
| trace(A) | The trace of A, assuming A es a saquare matrix |
| A*v
(A matrix, v vector of length n_columns(A) ) |
The matrix product of A with the vector v transposed |
| v*A (A matrix, v vector of length n_rows(A) ) | The matrix
product of v by A |
| Binary |
Meaning |
Examples |
| + |
plus (addition) | 1+1, x+2 |
| - |
minus (subtraction) |
2-1, x-y |
| * |
times (product) |
2*3 |
| ^ |
power |
2^3 |
| / |
quotient (division) |
5/4 |
| / |
list or vector
difference |
[1,2,3,4]/[2,4] |
| // |
quotient in
Euclidean division |
5//4 |
| mod |
remainder in Euclidean division |
5 mod 4 |
| | |
concatenation of vectors and lists | [1,1]|[0,2,4] |
| | |
splicing of matrices with the
same number or rows |
|
| | |
logical or |
true|false List|Vector |
| & |
logical and |
false & true |
| & |
stacking of vectors of the same
length |
[1,1] & [2,3] » [[1,1],[2,3]] |
| & |
stacking of matrices with the
same number of columns |
|
| \ |
make postfix a prefix function |
36\factor |
| \\ |
make postfix and recursive a
Substitution
call |
| Unary prefix |
Meaning |
Examples |
| + |
prefix plus |
+5 |
| - |
prefix minus |
-3 |
| Unary postfix |
Meaning |
Examples |
| + |
prefix plus |
+5 |
| - |
prefix minus |
-3 |
| ! |
factorial (postfix) |
6! |
| !! |
semifactorial (postfix) |
10!! |
| not |
logical negation |
not false |
| ' |
apostrophy: transposition operator for matrices |
([1,1]&[2,2])' |
| ' |
apostrophy: derivative operator
for univariate polynomials |
(x^2+x)' |
| ' | apostrophy: negation of Boolean values (true' <> false) |
false' |
| Range
functions |
Meaning |
Examples |
| a..b |
a..b..1 | 1..3 »'1,2,3' |
| a..b..d | If a and b are real numbers, the (potential*)
sequence of numbers a+j·d, for j>=0 and a+j·d<=b |
10..57..13 » '10,23,36,49' |
| r·j |
If r is a Range, the (actual) j-th member of r, provided j is in its range of indices. |
(10..57..13).2 » 23 |
| length(r:Range) |
The number of terms in r |
length(10..57..13) » 4 |
| Real
functions |
Meaning |
| ln(x:Real) |
For x>0, the natural logarithm of x |
| log(x:Real) |
For x>0, the decimal logarithm of x |
| log(x:Real, b:Real) |
If x,
b>0, the logarithm of x
to the base b |
| Special symbols | Meaning |
| B_ |
bernoulli_number (see Combinatorial Functions) |
| C_ or CC |
Complex (see types) |
| e_ |
2.7283... decimal representation
of e |
| E_ |
e (base of natural logarithms) |
| GF |
Finite_field |
| i_ |
i (imaginary unit, i2
= -1) |
| pi_ |
3.141592... decimal representation of p |
| Pi_ |
p |
| R_ or RR |
Real (see Types) |
| W_ |
wolpitzki_number (see Combinatorial Functions) |
| WB_ |
wolpitzki_bernoulli_number (see Combinatorial Functions) |
| Z_ or ZZ |
Integer (see Types) |
| Types |
Meaning |
Examples |
| Chain |
Range|List|Vector|Relation|Rule |
|
| Complex |
The complex numbers |
|
| Float |
Decimal numbers (up to 15
siginificant digits) |
3.1416 |
| Integer |
The integers |
-3, 0, 5 |
| List |
The type of lists |
{1,a,b^2} |
| Matrix |
A vector whose components are
vectors of the same length |
[[1,2],[3,4]] |
| Name |
Identifiers, including those
that have a value assigned |
|
| Nat |
Non-negative Integer |
0, 17, 2^20 |
| Null |
The type of the empty sequence |
null |
| Pos |
Positive Integer |
1, 2, 3 |
| Range |
The type of ranges. A range can
be thought as a finite sequence of numbers. |
11..19 11..19..2 |
| Real |
The real numbers |
Pi_ |
| Relation |
The type of relations. A
Relation is a list of objects of the form x->v (relators) |
|
| Rule |
The type of rules. A Rule is a
list of objects of the form x=>v. |
|
| Sequence |
The type of sequences |
|
| Vector |
The type of
vectors |
|
| String |
The type of strings of
characters. |
|
| Vector(T) |
The type of
vectors whose components have type T |
| Vector
functions |
Meaning |
Examples |
| [x1,...,xn] [] |
Vector formed with the objects [x1,...,xn] Empty vector |
|
| [r:Range] |
[r1,...,rn], where |
[1..3] » [1,2,3] |
| [ e in R such_that P(e)] |
If R is a Chain and P a Boolean function defined for any expression e in R, it yields the vector of the elements of R that satisfy P |
[n in 1..100 such_that
prime?(n)] |
| x.j |
If x is a Vector and j in its range of indices, x.j is its j-th component of x. |
[1,2,3].2 » 2 |
| x.r |
If r is a range, the vector
whose components are the components of x with index in r |
[3..10..2].{1,3} » [3,7] |
| range(x:Vector) |
1..length(x) |
@ [2,3,3] » 1..3 |
| constant_vector(n:Pos, a) |
[a,...,a], a repeated n times |
@ n=3, a=t » [t,t,t] |
| constant_vector(n:Pos) | [0,...,0], 0 repeated n times | @ n=3 » [0,0,0] |
| convolution(u:Vector,v:Vector,k:Integer) | (k-1)-component of the convolution of u and v |
@ u=[a,b], v=[5,7] n=3 » 7·a+5·b |
| convolution(u:Vector,v:Vector, R:Chain) | convolution(u,v).R |
|
| convolution(u:Vector,v:Vector) | Convolution vector of u and v |
@ u=[a,b], v=[5,7] » [5·a, 7·a+5·b,7·b] |
| cut_off(x:Vector, k:Integer) | if k<0 then [] elif k<length(x) then take(x,k) else x end |
|
| length(x:Vector) |
The number of components of x |
@ [1,2,3] » 3 |
| purge(x:Vector,a) | The vector formed with the
components of x that are not equal to a |
@ x=[1,2,3], a=2 » [1,3] |
| tail(x:Vector) |
take(x,n-1) |
@ [1,2,3] » [2,3] |
| take(x:Vector, k:Integer) |
If k is in the range of indices of x, the vector [x.1,...,x.k]; if k=0, the vector []; if k=-r, with r in the range of x, the vector [xn-r+1,...,xn] |
@ x=[1,2,3], r=2 » [1,2] @ '', r=-2 » [2,3] |
| tensor(u:Vector, v:Vector) |
[u.i*v.j with (i,j) in (range(u),range(v))] | |
| trim(x:Vector) | The vector
formed with the non-zero components of x. |
@ x=[1,0,3] » [1,3] |
| trim_left(x:Vector) | Drops the
leading 0's of x |
@ x=[0,1,2] » [1,2] |
| trim_right(x:Vector) | Drops the trailing 0's of x | @ x=[1,2,0] » [1,2] |
| vector(x:Name, n:Integer) | [x1,x2,...,xn] (x1, x2, ... are
variables) |
@ x=a, n=3 » [a1,a2,a3] |