REDUCE is a general-purpose
computer algebra system
A computer algebra system (CAS) or symbolic algebra system (SAS) is any mathematical software with the ability to manipulate mathematical expressions in a way similar to the traditional manual computations of mathematicians and scientists. The de ...
originally geared towards applications in physics.
The development of REDUCE was started in 1963 by
Anthony C. Hearn; since then, many scientists from all over the world have contributed to its development.
REDUCE was
open-sourced in December 2008 and is available for free under a
modified BSD license
BSD licenses are a family of permissive free software licenses, imposing minimal restrictions on the use and distribution of covered software. This is in contrast to copyleft licenses, which have share-alike requirements. The original BSD licen ...
on
SourceForge
SourceForge is a web service founded by Geoffrey B. Jeffery, Tim Perdue, and Drew Streib in November 1999. SourceForge provides a centralized software discovery platform, including an online platform for managing and hosting open-source soft ...
. Previously it had cost $695.
REDUCE is written entirely in its own
Lisp
Lisp (historically LISP, an abbreviation of "list processing") is a family of programming languages with a long history and a distinctive, fully parenthesized Polish notation#Explanation, prefix notation.
Originally specified in the late 1950s, ...
dialect called Standard Lisp, expressed in an
ALGOL
ALGOL (; short for "Algorithmic Language") is a family of imperative computer programming languages originally developed in 1958. ALGOL heavily influenced many other languages and was the standard method for algorithm description used by the ...
-like syntax called RLISP that is also used as the basis for REDUCE's user-level language.
Implementations of REDUCE are available on most variants of
Unix
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
,
Linux
Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
,
Microsoft Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
, or
Apple Macintosh
Mac is a brand of personal computers designed and marketed by Apple Inc., Apple since 1984. The name is short for Macintosh (its official name until 1999), a reference to the McIntosh (apple), McIntosh apple. The current product lineup inclu ...
systems by using an underlying
Portable Standard Lisp (PSL) or Codemist Standard Lisp (CSL) implementation. CSL REDUCE offers a
graphical user interface
A graphical user interface, or GUI, is a form of user interface that allows user (computing), users to human–computer interaction, interact with electronic devices through Graphics, graphical icon (computing), icons and visual indicators such ...
. REDUCE can also be built on other Lisps, such as
Common Lisp
Common Lisp (CL) is a dialect of the Lisp programming language, published in American National Standards Institute (ANSI) standard document ''ANSI INCITS 226-1994 (S2018)'' (formerly ''X3.226-1994 (R1999)''). The Common Lisp HyperSpec, a hyperli ...
.
Features
*
arbitrary precision integer
An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
,
rational
Rationality is the quality of being guided by or based on reason. In this regard, a person acts rationally if they have a good reason for what they do, or a belief is rational if it is based on strong evidence. This quality can apply to an ...
,
complex
Complex commonly refers to:
* Complexity, the behaviour of a system whose components interact in multiple ways so possible interactions are difficult to describe
** Complex system, a system composed of many components which may interact with each ...
and
floating-point
In computing, floating-point arithmetic (FP) is arithmetic on subsets of real numbers formed by a ''significand'' (a Sign (mathematics), signed sequence of a fixed number of digits in some Radix, base) multiplied by an integer power of that ba ...
arithmetic
Arithmetic is an elementary branch of mathematics that deals with numerical operations like addition, subtraction, multiplication, and division. In a wider sense, it also includes exponentiation, extraction of roots, and taking logarithms.
...
*
expressions and
functions involving one or more
variables
*
algorithms
In mathematics and computer science, an algorithm () is a finite sequence of mathematically rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for per ...
for
polynomials
In mathematics, a polynomial is a mathematical expression consisting of indeterminates (also called variables) and coefficients, that involves only the operations of addition, subtraction, multiplication and exponentiation to nonnegative int ...
,
rational
Rationality is the quality of being guided by or based on reason. In this regard, a person acts rationally if they have a good reason for what they do, or a belief is rational if it is based on strong evidence. This quality can apply to an ...
and
transcendental functions
* facilities for the
solution of a variety of
algebraic equations
In mathematics, an algebraic equation or polynomial equation is an equation of the form P = 0, where ''P'' is a polynomial with coefficients in some field, often the field of the rational numbers.
For example, x^5-3x+1=0 is an algebraic equation ...
* automatic and user-controlled
simplification of expressions
*
substitutions and
pattern matching
In computer science, pattern matching is the act of checking a given sequence of tokens for the presence of the constituents of some pattern. In contrast to pattern recognition, the match usually must be exact: "either it will or will not be a ...
in a wide variety of forms
*
symbolic differentiation,
indefinite and
definite integration
* solution of
ordinary differential equations
In mathematics, an ordinary differential equation (ODE) is a differential equation (DE) dependent on only a single independent variable. As with any other DE, its unknown(s) consists of one (or more) function(s) and involves the derivatives ...
* computations with a wide variety of
special functions
Special functions are particular mathematical functions that have more or less established names and notations due to their importance in mathematical analysis, functional analysis, geometry, physics, or other applications.
The term is defined by ...
* general
matrix
Matrix (: matrices or matrixes) or MATRIX may refer to:
Science and mathematics
* Matrix (mathematics), a rectangular array of numbers, symbols or expressions
* Matrix (logic), part of a formula in prenex normal form
* Matrix (biology), the m ...
and
non-commutative algebra
* plotting in 2 and 3 dimensions of
**
graphs of functions
** arbitrary
points
A point is a small dot or the sharp tip of something. Point or points may refer to:
Mathematics
* Point (geometry), an entity that has a location in space or on a plane, but has no extent; more generally, an element of some abstract topologica ...
,
lines and
curves
A curve is a geometrical object in mathematics.
Curve(s) may also refer to:
Arts, entertainment, and media Music
* Curve (band), an English alternative rock music group
* Curve (album), ''Curve'' (album), a 2012 album by Our Lady Peace
* Curve ( ...
*
Dirac matrix calculations of interest in
high energy physics
Particle physics or high-energy physics is the study of fundamental particles and forces that constitute matter and radiation. The field also studies combinations of elementary particles up to the scale of protons and neutrons, while the stu ...
*
quantifier elimination
Quantifier elimination is a concept of simplification used in mathematical logic, model theory, and theoretical computer science. Informally, a quantified statement "\exists x such that ..." can be viewed as a question "When is there an x such ...
and decision for interpreted
first-order logic
First-order logic, also called predicate logic, predicate calculus, or quantificational logic, is a collection of formal systems used in mathematics, philosophy, linguistics, and computer science. First-order logic uses quantified variables over ...
* powerful intuitive user-level
programming language
A programming language is a system of notation for writing computer programs.
Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
.
Syntax
The REDUCE language is a
high-level structured
Structuring, also known as smurfing in banking jargon, is the practice of executing financial transactions such as making bank deposits in a specific pattern, calculated to avoid triggering financial institutions to file reports required by law ...
programming language based on
ALGOL 60
ALGOL 60 (short for ''Algorithmic Language 1960'') is a member of the ALGOL family of computer programming languages. It followed on from ALGOL 58 which had introduced code blocks and the begin and end pairs for delimiting them, representing a ...
(but with Standard Lisp
semantics
Semantics is the study of linguistic Meaning (philosophy), meaning. It examines what meaning is, how words get their meaning, and how the meaning of a complex expression depends on its parts. Part of this process involves the distinction betwee ...
), although it does not support all ALGOL 60 syntax. It is similar to
Pascal, which evolved from ALGOL 60, and
Modula
The Modula programming language is a descendant of the Pascal language. It was developed in Switzerland, at ETH Zurich, in the mid-1970s by Niklaus Wirth, the same person who designed Pascal. The main innovation of Modula over Pascal is a mo ...
, which evolved from Pascal.
REDUCE is a
free-form language, meaning that spacing and line breaks are not significant, but consequently input statements must be separated from each other and all input must be terminated with either a semi-colon (
;
) or a dollar sign (
$
). The difference is that if the input results in a useful (non-
nil
) value then it will be output if the separator is a semi-colon (
;
) but hidden if it is a dollar sign (
$
). The assignment operator is colon-equal (
:=
), which in its simplest usage assigns to the variable on its left the value of the expression on its right. However, a REDUCE variable can have no value, in which case it is displayed as its name, in order to allow mathematical expressions involving indeterminates to be constructed and manipulated. The simplest way to use REDUCE is interactively: type input after the last input
prompt, terminate it with semi-colon and press the ''
Return
Return may refer to:
In business, economics, and finance
* Return on investment (ROI), the financial gain after an expense.
* Rate of return, the financial term for the profit or loss derived from an investment
* Tax return, a blank document or t ...
'' or ''
Enter'' key; REDUCE processes the input and displays the result. This is illustrated in the
screenshot
A screenshot (also known as screen capture or screen grab) is an analog or digital image that shows the contents of a computer display. A screenshot is created by a (film) camera shooting the screen or the operating system
An operating sys ...
.
Identifiers and strings
Programming languages use
identifiers
An identifier is a name that identifies (that is, labels the identity of) either a unique object or a unique ''class'' of objects, where the "object" or class may be an idea, person, physical countable object (or class thereof), or physical mass ...
to name constructs such as variables and functions, and
strings to store text. A REDUCE identifier must begin with a letter and can be followed by letters, digits and underscore characters (
_
). A REDUCE identifier can also include any character anywhere if it is input preceded by an exclamation mark (
!
). A REDUCE string is any sequence of characters delimited when input by double quote characters (
"
). A double quote can be included in a string by entering two double quotes; no other escape mechanism is implemented within strings. An identifier can be used instead of a string in most situations in REDUCE, such as to represent a file name.
REDUCE source code was originally written in all
upper-case letters, as were all programming languages in the 1960s. (Hence, the name REDUCE is normally written in all upper-case.) However, modern REDUCE is
case-insensitive
In computers, case sensitivity defines whether uppercase and lowercase letters are treated as distinct (case-sensitive) or equivalent (case-insensitive). For instance, when users interested in learning about dogs search an e-book, "dog" and "Dog ...
(by default), which means that it ignores the case of letters, and it is normally written in lower-case. (The REDUCE source code has been converted to lower case.) The exceptions to this rule are that case is preserved within strings and when letters in identifiers are preceded by an exclamation mark (
!
). Hence, it is conventional to use
snake-case (e.g.
long_name
) rather than
camel-case (e.g.
longName
) for REDUCE identifiers, because camel-case gets lost without also using exclamation marks.
Hello World programs
Below is a REDUCE
"Hello, World!" program
A "Hello, World!" program is usually a simple computer program that emits (or displays) to the screen (often the Console application, console) a message similar to "Hello, World!". A small piece of code in most general-purpose programming languag ...
, which is almost as short as such a program could possibly be!
"Hello, World!";
REDUCE displays the output
Hello, World!
Another REDUCE "Hello, World!" program, which is slightly longer than the version above, uses an identifier as follows
!Hello!,! !World!!;
CSL REDUCE displays the same output as shown above. (Other REDUCE GUIs may italicise this output on the grounds that it is an identifier rather than a string.)
Statements and expressions
Because REDUCE inherits Lisp semantics, all programming constructs have values. Therefore, the only distinction between statements and expressions is that the value of an expression is used but the value of a statement is not. The terms ''statement'' and ''expression'' are interchangeable, although a few constructs always return the Lisp value
nil
and so are always used as statements.
There are two ways to group several statements or expressions into a single unit that is syntactically equivalent to a single statement or expression, which is necessary to facilitate
structured programming Structured programming is a programming paradigm aimed at improving the clarity, quality, and development time of a computer program by making specific disciplined use of the structured control flow constructs of selection ( if/then/else) and repet ...
. One is the
begin
...
end
construct inherited from ALGOL 60, which is called a ''block'' or ''compound'' statement. Its value is the value of the expression following the (optional) keyword
return
. The other uses the bracketing syntax
<<
...
>>
, which is called a ''group'' statement. Its value is the value of the last (unterminated) expression in it. Both are illustrated below in the
procedural programming example below.
Structured programming
REDUCE supports
conditional and repetition statements, some of which are controlled by a ''boolean expression'', which is any expression whose value can be either ''true'' or ''false'', such as
. (The REDUCE user-level language does not explicitly support constants representing ''true'' or ''false'' although, as in
C and related languages, 0 has the boolean value ''false'', whereas 1 and many other non-zero values have the boolean value ''true''.)
Conditional statements: if ... then ... else
The conditional statement has the form
if
''boolean expression'' then
''statement''
which can optionally be followed by
else
''statement''
For example, the following conditional statement ensures that the value of
, assumed to be numerical, is positive. (It effectively implements the
absolute value
In mathematics, the absolute value or modulus of a real number x, is the non-negative value without regard to its sign. Namely, , x, =x if x is a positive number, and , x, =-x if x is negative (in which case negating x makes -x positive), ...
function.)
if n < 0 then n := -n
The following conditional statement, used as an expression, avoids an error that would be caused by dividing by 0.
recip_x := if x = 0 then infinity else 1/x
Repetition statements: for ...
The
for
statement is a flexible loop construct that executes ''statement'' repeatedly a number of times that must be known in advance. One version has the form
for
''variable'' := ''initial'' step
''increment'' until
''final'' do
''statement''
where ''variable'' names a variable whose value can be used within ''statement'', and ''initial, increment'' and ''final'' are numbers (preferably integers). The value of ''variable'' is initialized to ''initial'' and ''statement'' is executed, then the value of ''variable'' is repeatedly increased by ''increment'' and the ''statement'' executed again, provided the value of ''variable'' is not greater than ''final''. The common special case "''initial''
step 1 until
''final''" can be abbreviated as "''initial'' : ''final''".
The following
for
statement computes the value of
as the value of the variable
fac
.
n := 5;
fac := 1$ for r := 2 : n do fac := fac*r; fac;
Another version of the
for
statement iterates over a list, and the keyword
do
can be replaced by
product
,
sum
,
collect
or
join
, in which case the
for
statement becomes an expression and the controlled ''statement'' is treated as an expression. With
product
, the value is the product of the values of the controlled ''statement''; with
sum
, the value is the sum of the values of the controlled ''statement''; with
collect
, the value is the values of the controlled ''statement'' collected into a list; with
join
, the value is the values of the controlled ''statement'', which must be lists, joined into one list.
The following
for
statement computes the value of
much more succinctly and elegantly than the previous example.
n := 5;
for r := 2 : n product r;
Repetition statements: while ... do; repeat ... until
The two loop statements
while
''boolean expression'' do
''statement''
repeat
''statement'' until
''boolean expression''
are closely related to the conditional statement and execute ''statement'' repeatedly a number of times that need not be known in advance. Their difference is that
while
repetition stops when ''boolean expression'' becomes false whereas
repeat
repetition stops when ''boolean expression'' becomes true. Also,
repeat
always executes ''statement'' at least once and it can be used to initialize ''boolean expression'', whereas when using
while
''boolean expression'' must be initialized before entering the loop.
The following
while
statement computes the value of
as the value of the variable
fac
. Note that this code treats the assignment
n := n - 1
as an expression and uses its value.
n := 5;
fac := n$ while n > 1 do fac := fac*(n := n - 1); fac;
Comments
REDUCE has three comment conventions. It inherits the ''comment statement'' from ALGOL 60, which looks like this:
comment This is a multi-line comment
that ends at the next separator,
so it cannot contain separators;
Comment statements mostly appear in older code.
It inherits the
%
... comment from Standard Lisp, which looks like this:
% This is a single-line comment that ends at the end of the line.
% It can appear on a line after code and
% can contain the separators ";" and "$".
%
... comments are analogous to
C++ //
... comments and are the most commonly used form of comment.
REDUCE also supports a
C-style
/*
...
*/
comment that looks like this:
/* This is a multi-line comment that can
appear anywhere a space could and
can contain the separators ";" and "$".
*/
Programming paradigms
REDUCE's user-level language supports several
programming paradigms
A programming paradigm is a relatively high-level way to conceptualize and structure the implementation of a computer program. A programming language can be classified as supporting one or more paradigms.
Paradigms are separated along and descri ...
, as illustrated in the
algebraic programming examples below.
Since it is based on Lisp, which is a
functional programming
In computer science, functional programming is a programming paradigm where programs are constructed by Function application, applying and Function composition (computer science), composing Function (computer science), functions. It is a declarat ...
language, REDUCE supports functional programming and all statements have values (although they are not always useful). REDUCE also supports
procedural programming
Procedural programming is a programming paradigm, classified as imperative programming, that involves implementing the behavior of a computer program as Function (computer programming), procedures (a.k.a. functions, subroutines) that call each o ...
by ignoring statement values. Algebraic computation usually proceeds by transforming a mathematical expression into an equivalent but different form. This is called ''simplification'', even though the result might be much longer. (The name ''REDUCE'' is a
pun
A pun, also known as a paronomasia in the context of linguistics, is a form of word play that exploits multiple meanings of a term, or of similar-sounding words, for an intended humorous or rhetorical effect. These ambiguities can arise from t ...
on this problem of ''intermediate expression swell''!) In REDUCE, simplification occurs automatically when an expression is entered or computed, controlled by ''simplification rules'' and ''switches''. In this way, REDUCE supports
rule-based programming
In computer science, a rule-based system is a computer system in which domain-specific knowledge is represented in the form of rules and general-purpose reasoning is used to solve problems in the domain.
Two different kinds of rule-based systems ...
, which is the classic REDUCE programming paradigm. In early versions of REDUCE, rules and switches could only be set globally, but modern REDUCE also supports local setting of rules and switches, meaning that they control the simplification of only one expression. REDUCE programs often contain a mix of programming paradigms.
Algebraic programming examples
The
screenshot
A screenshot (also known as screen capture or screen grab) is an analog or digital image that shows the contents of a computer display. A screenshot is created by a (film) camera shooting the screen or the operating system
An operating sys ...
shows simple interactive use.
As a simple programming example, consider the problem of computing the
th Taylor polynomial of the function
about the point
, which is given by the formula
. Here,
denotes the
th derivative
In mathematics, the derivative is a fundamental tool that quantifies the sensitivity to change of a function's output with respect to its input. The derivative of a function of a single variable at a chosen input value, when it exists, is t ...
of
evaluated at the point
and
denotes the
factorial
In mathematics, the factorial of a non-negative denoted is the Product (mathematics), product of all positive integers less than or equal The factorial also equals the product of n with the next smaller factorial:
\begin
n! &= n \times ...
of
. (However, note that REDUCE include
sophisticated facilitiesfor
power-series expansion.)
As an ''example of functional programming'' in REDUCE, here is an easy way to compute the 5th Taylor polynomial of
about 0. In the following code, the control variable
r
takes values from 0 through 5 in steps of 1,
df
is the REDUCE
differentiation operator and the operator
sub
performs substitution of its first argument into its second. Note that this code is very similar to the mathematical formula above (with
and
).
for r := 0:5 sum sub(x = 0, df(sin x, x, r))*x^r/factorial r;
produces by default the output
This is correct, but it doesn't look much like a Taylor series. That can be fixed by changing a few output-control switches and then evaluating the special variable
ws
, which stands for
work
space and holds the last non-empty output expression:
off allfac; on revpri, div; ws;
As an ''example of procedural programming'' in REDUCE, here is a procedure to compute the general Taylor polynomial, which works for functions that are well-behaved at the expansion point
.
procedure my_taylor(f, x, x0, n);
% Return the nth Taylor polynomial of f
% as a function of x about x0.
begin scalar result := sub(x = x0, f), mul := 1;
for r := 1:n do <<
f := df(f, x);
mul := mul*(x - x0)/r;
result := result + sub(x = x0, f)*mul
>>;
return result
end;
The procedure is called
my_taylor
because REDUCE already includes an operator called
taylor
. All the text following a
%
sign up to the end of the line is a comment. The keyword
scalar
introduces and initializes two
local variables,
result
and
mul
. The keywords
begin
and
end
delimit a block of code that may include local variables and may return a value, whereas the symbols
<<
and
>>
delimit a group of statements without introducing local variables.
The procedure may be called as follows to compute the same Taylor polynomial as above.
my_taylor(sin x, x, 0, 5);
File and package handling
REDUCE GUIs provide menu support for some or all of the file and package handling described below.
File handling
In order to develop non-trivial computations, it is convenient to store source code in a file and have REDUCE read it instead of interactive input. REDUCE input should be
plain text
In computing, plain text is a loose term for data (e.g. file contents) that represent only characters of readable material but not its graphical representation nor other objects ( floating-point numbers, images, etc.). It may also include a lim ...
(not
rich text as produced by
word-processing applications). REDUCE filenames are arbitrary. The REDUCE source code uses the
filename extension
A filename extension, file name extension or file extension is a suffix to the name of a computer file (for example, .txt, .mp3, .exe) that indicates a characteristic of the file contents or its intended use. A filename extension is typically d ...
.red
for the main source code and
.tst
for the test files, and for that reason REDUCE GUIs such as CSL REDUCE normally offer to input files with those extensions by default, but on platforms such as Microsoft Windows the extension
.txt
may be more convenient. It is recommended to end a REDUCE input file with the line
;end;
as an end-of-file marker. This is something of a historical quirk but it avoids potential warning messages. Apart from that, an input file can contain whatever might be entered interactively into REDUCE. The command
in
''file1''
,
''file2''
,
...
inputs each of the named files in succession into REDUCE, essentially as if their contents had been entered interactively, after which REDUCE waits for further interactive input. If the separator used to terminate this command is a semi-colon (
;
) then the file content is
echoed as output; if the separator is a dollar sign (
$
) then the file content is not echoed.
REDUCE filenames can be either absolute or relative to the current directory; when using a REDUCE GUI absolute filenames are safer because it is not obvious what the current directory is! Filenames can be specified as either
strings or identifiers; strings (in double quotes) are usually more convenient because otherwise filename elements such as directory separators and dots must be escaped with an exclamation mark (
!
). Note that the
Microsoft Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
directory or folder separator,
backslash
The backslash is a mark used mainly in computing and mathematics. It is the mirror image of the common slash (punctuation), slash . It is a relatively recent mark, first documented in the 1930s. It is sometimes called a hack, whack, Escape c ...
(
\
), does not need to be doubled in REDUCE strings because backslash is not an escape character in REDUCE, but REDUCE on Microsoft Windows also accepts
forward slash
The slash is a slanting line punctuation mark . It is also known as a stroke, a solidus, a forward slash and several other historical or technical names. Once used as the equivalent of the modern period and comma, the slash is now used to r ...
(
/
) as the directory separator.
REDUCE output can be directed to a file instead of the interactive display by executing the command
out
''file''
;
Output redirection can be terminated permanenty by executing the command
shut
''file''
;
or temporarily by executing the command
out t;
There are similar mechanisms for directing a compiled version of the REDUCE input to a file and loading compiled code, which is the basis for building REDUCE and can be used to extend it.
Loading packages
REDUCE is composed of a number of packages; some are pre-loaded, some are auto-loaded when needed, and some must be explicitly loaded before they can be used. The command
load_package
''package1''
,
''package2''
,
...
loads each of the named packages in succession into REDUCE. Package names are ''not'' filenames; they are simple identifiers that do not need any exclamation marks, so they are normally input as identifiers, although they can be input as strings. A package consists of one or more files of compiled Lisp code, and the
load_package
command ensures that the right files are loaded in the right order. The precise filenames and locations depend on the version of Lisp on which REDUCE is built, but the package names are always the same.
Types and variable scope
REDUCE inherits
dynamic scoping from Lisp, which means that data have types but variables themselves do not: the type of a variable is the type of the data assigned to it. The simplest REDUCE data types are Standard Lisp
atomic types such as identifiers, machine numbers (i.e. "small" integers and floating-point numbers supported directly by the computer hardware), and strings. Most other REDUCE data types are represented internally as Lisp lists whose first element (
car
) indicates the data type. For example, the REDUCE input
mat((1, 2), (3, 4));
produces the display
and the internal representation of this matrix is the Lisp list
(mat (1 2) (3 4))
The main algebraic objects used in REDUCE are quotients of two possibly-multivariate polynomials, the indeterminates of which, called ''kernels'', may in fact be functions of one or more variables, e.g. the input
z := (x + y^2)/f(x,y);
produces the display
REDUCE uses two representations for such algebraic objects. One is called ''prefix form'', which is just the Standard Lisp code for the expression and is convenient for operations such as input and output; e.g. for
it is
(quotient (plus x (expt y 2)) (f x y))
The other is called ''standard quotient'' form, which is better for performing algebraic manipulations such as addition; e.g. for
it is
(!*sq ((((x . 1) . 1) ((y . 2) . 1)) (((f x y) . 1) . 1)) t)
REDUCE converts between these two representations as necessary, but tries to retain ''standard quotient'' form as much as possible to avoid the conversion overhead.
Because variables have no types there are no variable type
declarations in REDUCE, but there are
variable scope declarations. The scope of a variable refers to the range of a program throughout which it has the same significance. By default, REDUCE variables are automatically
global
Global may refer to:
General
*Globe, a spherical model of celestial bodies
*Earth, the third planet from the Sun
Entertainment
* ''Global'' (Paul van Dyk album), 2003
* ''Global'' (Bunji Garlin album), 2007
* ''Global'' (Humanoid album), 198 ...
in scope, meaning that they have the same significance everywhere, i.e. once a variable has been assigned a value, it will evaluate to that same value everywhere. Variables can be declared to have scope limited to a particular block of code by delimiting that block of code by the keywords
begin
and
end
, and declaring the variables
scalar
at the start of the block, using the following syntax (as illustrated in the
algebraic programming examples above):
begin
scalar
''variable1'', ''variable2'', ...;
''statements''
end
Each variable so declared can optionally be followed by an assignment operator (
:=
) and an initial value. The keyword
scalar
should be read as meaning ''
local
Local may refer to:
Geography and transportation
* Local (train), a train serving local traffic demand
* Local, Missouri, a community in the United States
Arts, entertainment, and media
* ''Local'' (comics), a limited series comic book by Bria ...
''. (The reason for the name ''
scalar'' is buried in the history of REDUCE, but it was probably chosen to distinguish local variables from the
relativistic 4-vectors and
Dirac gamma matrices defined in the
high-energy physics
Particle physics or high-energy physics is the study of fundamental particles and forces that constitute matter and radiation. The field also studies combinations of elementary particles up to the scale of protons and neutrons, while the stu ...
package, which was the original core of REDUCE.
[)
The ]scalar
keyword can be replaced by integer
or real
. The difference is that integer
variables are initialized by default to 0, whereas scalar
and real
variables are initialized by default to the Lisp value nil
(which has the algebraic value 0 anyway). This distinction is more significant in the REDUCE implementation language, RLISP, also known as ''symbolic'' or ''lisp mode''. Otherwise, it is useful as documentation of the intended use of local variables.
There are two other variable declarations that are used only in the implementation of REDUCE, i.e. in symbolic mode. The REDUCE begin
...end
block described above is translated into a Standard Lisp prog
form by the REDUCE parser
Parsing, syntax analysis, or syntactic analysis is a process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar by breaking it into parts. The term '' ...
, and all Standard Lisp variables should either be bound in prog
forms, or declared global
or fluid
. In RLISP, these declarations look like this:
fluid '(
''variable1'' ''variable2'' ...)
global '(
''variable1'' ''variable2'' ...)
A global
variable cannot be rebound in a prog
form, whereas a fluid
variable can. This distinction is normally only significant to a Lisp compiler and is used to maximize efficiency; in interpreted code these declarations can be skipped and undeclared variables are effectively fluid
.
Graphics
REDUCE supports graphical display via gnuplot, which is an independent portable open-source graphics package that is included in all REDUCE binary distributions. The REDUCE GNUPLOT package supports the display of curves or surfaces defined by formulas and/or data sets via the command plot(
...)
. This command exposes some, but not all, of the capabilities of gnuplot. The REDUCE TURTLE and LOGOTURTLE packages are built on the REDUCE GNUPLOT package and support turtle graphics
In computer graphics, turtle graphics are vector graphics using a relative cursor (the "turtle") upon a Cartesian plane (x and y axis). Turtle graphics is a key feature of the Logo programming language. It is also a simple and didactic way of d ...
in two dimensions; the LOGOTURTLE package also exposes additional capabilities of gnuplot, such as control of colour and line thickness, filling and text annotations.
Available implementations and supported platforms
REDUCE is available from SourceForge
SourceForge is a web service founded by Geoffrey B. Jeffery, Tim Perdue, and Drew Streib in November 1999. SourceForge provides a centralized software discovery platform, including an online platform for managing and hosting open-source soft ...
. Binary distributions are released[ a few times a year with no fixed schedule as snapshots of the ]Subversion
Subversion () refers to a process by which the values and principles of a system in place are contradicted or reversed in an attempt to sabotage the established social order and its structures of Power (philosophy), power, authority, tradition, h ...
repository, and also offer compressed archive snapshots of the full source code. SourceForge can be set up to notify users when a new release is available. In 2024, binary distributions were released for 64-bit versions of macOS
macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
, Linux
Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
(Debian
Debian () is a free and open-source software, free and open source Linux distribution, developed by the Debian Project, which was established by Ian Murdock in August 1993. Debian is one of the oldest operating systems based on the Linux kerne ...
and Red Hat
Red Hat, Inc. (formerly Red Hat Software, Inc.) is an American software company that provides open source software products to enterprises and is a subsidiary of IBM. Founded in 1993, Red Hat has its corporate headquarters in Raleigh, North ...
based systems) and Microsoft Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
. The installers either include or are available for both CSL- and PSL-REDUCE, and may include the REDUCE source code. REDUCE can be built from the source code on a larger range of platforms and on other Lisp systems, such as Common Lisp
Common Lisp (CL) is a dialect of the Lisp programming language, published in American National Standards Institute (ANSI) standard document ''ANSI INCITS 226-1994 (S2018)'' (formerly ''X3.226-1994 (R1999)''). The Common Lisp HyperSpec, a hyperli ...
.
Other software that uses REDUCE
The following projects use REDUCE:
* ALLTYPES (ALgebraic Language and TYPe System) is a computer algebra type system with particular emphasis on differential algebra and differential equations;
* DAISY (Differential Algebra for Identifiability of SYstems) is a software tool to perform structural identifiability analysis for linear and nonlinear dynamic models described by polynomial or rational ODE equations;
* MTT (Model Transformation Tools) is a set of tools for modeling dynamic physical systems using the bond-graph methodology;
* Reduce.jl is a symbolic parser for Julia language term rewriting using REDUCE algebra;
* Redlog (REDUCE Logic System) provides more than 100 functions on first-order formulas and was originally independent but is now available as a REDUCE package;
* Pure is a programming language, which has bindings for REDUCE, providing a very interesting environment for doing computer-powered science.
See also
* List of computer algebra systems
* ALTRAN
* REDUCE Meets CAMAL - J. P. Fitc
References
External links
*
* Anthony C. Hearn at al., REDUCE User's Manual
HTML
PDF
].
* Anthony C. Hearn
"REDUCE: The First Forty Years"
Invited paper presented at the A3L Conference in Honor of the 60th Birthday of Volker Weispfenning, April 2005.
* Andrey Grozin
"TeXmacs-Reduce interface"
April 2012.
{{DEFAULTSORT:Reduce (computer algebra system)
Computer algebra system software for Linux
Computer algebra systems
Formerly proprietary software
Free computer algebra systems
Free software programmed in Lisp
Software using the BSD license