Reduce (computer algebra system)
Developer(s) | Anthony C. Hearn et al. |
---|---|
Initial release | 1968 |
Stable release | August 2024[1]
|
Repository | sourceforge |
Written in | Standard Lisp |
Operating system | Cross-platform |
Type | Computer algebra system |
License | Modified BSD license |
Website | reduce-algebra |
REDUCE is a general-purpose computer algebra system 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[2] have contributed to its development. REDUCE was open-sourced in December 2008[3] and is available for free under a modified BSD license on SourceForge. Previously it had cost $695.
REDUCE is written entirely in its own Lisp dialect called Standard Lisp[4], expressed in an ALGOL-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, Linux, Microsoft Windows, or Apple Macintosh systems by using an underlying Portable Standard Lisp (PSL) or Codemist Standard Lisp (CSL) implementation. CSL REDUCE offers a graphical user interface. REDUCE can also be built on other Lisps, such as Common Lisp. The Julia package Reduce.jl[5] uses REDUCE as a backend and implements its semantics in Julia style.
Programming paradigms
[edit]REDUCE's user-level language supports several programming paradigms, as illustrated in the programming examples below.
Since it is based on Lisp, which is a functional programming language, REDUCE supports functional programming and all statements have values (although they are not always useful). REDUCE also supports procedural programming 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 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, 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.
Programming examples
[edit]The screenshot 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 of evaluated at the point and denotes the factorial of . (However, note that REDUCE includes sophisticated facilities for 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[6]
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 workspace 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);
See also
[edit]- List of computer algebra systems
- ALTRAN
- REDUCE Meets CAMAL - J. P. Fitch [1]
References
[edit]- ^ "Files on SourceForge".
- ^ "REDUCE History and Contributors". REDUCE Computer Algebra System. Retrieved 2024-12-27.
- ^ "REDUCE History and Contributors". REDUCE Computer Algebra System. Retrieved 2024-12-27.
- ^ "The Standard Lisp Report" (PDF). REDUCE Computer Algebra System. Retrieved 2024-12-27.
- ^ chakravala (April 9, 2019). "chakravala/Reduce.jl". GitHub. Retrieved June 16, 2019.
- ^ The typeset REDUCE output shown assumes the use of CSL REDUCE.
External links
[edit]- Reduce (computer algebra system) on SourceForge
- 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.