The central object of REDUCE is the formal expression, which is
built with respect to the common mathematical rules. Elementary items are
- numbers (integers, rationals, rounded fractionals, real or
complex); the domain can be selected dynamically,
- symbols (names with or without indices)
- functional expressions (names followed by a parameter list)
- operator symbols +,-,*,/,**
- parentheses for precedence control.
A symbol here can play the role of an unknown in the mathematical sense,
as well as a placeholder for a value. An expression can be assigned to a
symbol as a value such that later all references to the symbol are
replaced by the assigned value.
Examples of elementary expressions:
3.1415928 % fraction
a % simple variable
(x+y)**2 / 2 % quadratic expression
log(u)+log(v) % function
There are data structures that collect a number of formal expressions:
- An equation is an object where the operator = takes
highest precedence, with two slots for expressions, the lhs and
rhs:
p=u**2
- A list is a linear sequence of expressions, where each of the
members is elementary or itself an aggregate. There are operations for
construction, join, decomposition and reordering of lists:
{2,3,5,7,11,13,17,19}
- An array is a rectangular multidimensional structure; the
elements are identified by integer indices. Elements always have a value,
which defaults to zero.
array primes(10);
primes(0):=2;
for i:=1: 10 do
primes(i):=nextprime(primes(i-1));
- A matrix is a named structure of rows and columns, whose
elements are identified by two positive integers. For matrices with
compatible dimensions and for matrices and scalars there are operations
corresponding to the laws of linear algebra.
E.g. using the derivative operator df to construct
a Jacobian
matrix jac(n,n);
for i:=1:n do for j:=1:n do
jac(i,j):=df(f(i),x(j));
Reduce Homepage
Winfried Neun,
13-July-1999