1\chapter{Introductory Information}
2
3\index{Introduction}{\REDUCE} is a system for carrying out algebraic
4operations accurately, no matter how complicated the expressions become.
5It can manipulate polynomials in a variety of forms, both expanding and
6factoring them, and extract various parts of them as required.  {\REDUCE} can
7also do differentiation and integration, but we shall only show trivial
8examples of this in this introduction.  Other topics not
9considered include the use of arrays, the definition of procedures and
10operators, the specific routines for high energy physics calculations, the
11use of files to eliminate repetitious typing and for saving results, and
12the editing of the input text.
13
14Also not considered in any detail in this introduction are the many options
15that are available for varying computational procedures, output forms,
16number systems used, and so on.
17
18{\REDUCE} is designed to be an interactive system, so that the user can input
19an algebraic expression and see its value before moving on to the next
20calculation.  For those systems that do not support interactive use, or
21for those calculations, especially long ones, for which a standard script
22can be defined, {\REDUCE} can also be used in batch mode. In this case,
23a sequence of commands can be given to {\REDUCE} and results obtained
24without any user interaction during the computation.
25
26In this introduction, we shall limit ourselves to the interactive use of
27{\REDUCE}, since this illustrates most completely the capabilities of the
28system. When {\REDUCE} is called, it begins by printing a banner message
29like:
30\begin{verbatim}
31     Reduce (Free CSL version), 25-Oct-14 ...
32\end{verbatim}
33where the version number and the system release date will change from time
34to time. It proceeds to execute the commands in \hyperlink{startup file}{user's startup (\texttt{reducerc}\ttindextype{reducerc}{file}) file}, if such a file is present,
35then prompts the user for input by:
36\begin{verbatim}
37     1:
38\end{verbatim}
39You can now type a {\REDUCE} statement, terminated by a semicolon to indicate
40the end of the expression, for example:
41\begin{verbatim}
42     (x+y+z)^2;
43\end{verbatim}
44This expression would normally be followed by another character (a
45\key{Return} on an ASCII keyboard) to ``wake up'' the system, which would
46then input the expression, evaluate it, and return the result:
47\begin{verbatim}
48       2                    2            2
49      X  + 2*X*Y + 2*X*Z + Y  + 2*Y*Z + Z
50\end{verbatim}
51Let us review this simple example to learn a little more about the way that
52{\REDUCE} works. First, we note that {\REDUCE} deals with variables, and
53constants like other computer languages, but that in evaluating the former,
54a variable can stand for itself. Expression evaluation normally follows
55the rules of high school algebra, so the only surprise in the above example
56might be that the expression was expanded. {\REDUCE} normally expands
57expressions where possible, collecting like terms and ordering the
58variables in a specific manner. However, expansion, ordering of variables,
59format of output and so on is under control of the user, and various
60declarations are available to manipulate these.
61
62Another characteristic of the above example is the use of lower case on
63input and upper case on output.  In fact, input may be in either mode, but
64output is usually in lower case.  To make the difference between input and
65output more distinct in this manual, all expressions intended for input
66will be shown in lower case and output in upper case.  However, for
67stylistic reasons, we represent all single identifiers in the text in
68upper case.
69
70Finally, the numerical prompt can be used to reference the result in a
71later computation.
72
73As a further illustration of the system features, the user should try:
74\begin{verbatim}
75     for i:= 1:40 product i;
76\end{verbatim}
77The result in this case is the value of 40!,
78\begin{verbatim}
79     815915283247897734345611269596115894272000000000
80\end{verbatim}
81You can also get the same result by saying
82\begin{verbatim}
83     factorial 40;
84\end{verbatim}
85Since we want exact results in algebraic calculations, it is essential that
86integer arithmetic be performed to arbitrary precision, as in the above
87example. Furthermore, the {\tt FOR} statement in the above is illustrative of a
88whole range of combining forms that {\REDUCE} supports for the convenience of
89the user.
90
91Among the many options in {\REDUCE} is the use of other number systems, such
92as multiple precision floating point with any specified number of digits ---
93of use if roundoff in, say, the $100^{th}$ digit is all that can be tolerated.
94
95In many cases, it is necessary to use the results of one calculation in
96succeeding calculations. One way to do this is via an assignment for a
97variable, such as
98\begin{verbatim}
99     u := (x+y+z)^2;
100\end{verbatim}
101If we now use \var{U} in later calculations, the value of the right-hand
102side of the above will be used.
103
104The results of a given calculation are also saved in the variable
105\var{WS}\ttindex{WS} (for WorkSpace), so this can be used in the next
106calculation for further processing.
107
108For example, the expression
109\begin{verbatim}
110     df(ws,x);
111\end{verbatim}
112following the previous evaluation will calculate the derivative of
113\texttt{(x+y+z)\textasciicircum2} with respect to \var{X}. Alternatively,
114\begin{verbatim}
115     int(ws,y);
116\end{verbatim}
117would calculate the integral of the same expression with respect to \var{y}.
118
119{\REDUCE} is also capable of handling symbolic matrices. For example,
120\begin{verbatim}
121     matrix m(2,2);
122\end{verbatim}
123declares \var{m} to be a two by two matrix, and
124\begin{verbatim}
125     m := mat((a,b),(c,d));
126\end{verbatim}
127gives its elements values.  Expressions that include \var{M} and make
128algebraic sense may now be evaluated, such as \texttt{1/m} to give the
129inverse, \texttt{2*m - u*m\textasciicircum2} to give us another matrix
130and \texttt{det(m)} to give us the determinant of \var{M}.
131
132{\REDUCE} has a wide range of substitution capabilities. The system knows
133about elementary functions, but does not automatically invoke many of their
134well-known properties. For example, products of trigonometrical functions
135are not converted automatically into multiple angle expressions, but if the
136user wants this, he can say, for example:
137\begin{verbatim}
138     (sin(a+b)+cos(a+b))*(sin(a-b)-cos(a-b))
139         where cos(~x)*cos(~y) = (cos(x+y)+cos(x-y))/2,
140               cos(~x)*sin(~y) = (sin(x+y)-sin(x-y))/2,
141               sin(~x)*sin(~y) = (cos(x-y)-cos(x+y))/2;
142\end{verbatim}
143where the tilde in front of the variables \var{X} and \var{Y} indicates
144that the rules apply for all values of those variables.
145The result of this calculation is
146\begin{verbatim}
147        -(COS(2*A) + SIN(2*B))
148\end{verbatim}
149\extendedmanual{See also the user-contributed packages ASSIST
150(chapter~\ref{ASSIST}), CAMAL (chapter~\ref{CAMAL}) and TRIGSIMP
151(chapter~\ref{TRIGSIMP}).}
152
153Another very commonly used capability of the system, and an illustration
154of one of the many output modes of {\REDUCE}, is the ability to output
155results in a FORTRAN compatible form.  Such results can then be used in a
156FORTRAN based numerical calculation.  This is particularly useful as a way
157of generating algebraic formulas to be used as the basis of extensive
158numerical calculations.
159
160For example, the statements
161\begin{verbatim}
162     on fort;
163     df(log(x)*(sin(x)+cos(x))/sqrt(x),x,2);
164\end{verbatim}
165will result in the output
166\begin{small}
167\begin{verbatim}
168      ANS=(-4.*LOG(X)*COS(X)*X**2-4.*LOG(X)*COS(X)*X+3.*
169      . LOG(X)*COS(X)-4.*LOG(X)*SIN(X)*X**2+4.*LOG(X)*
170      . SIN(X)*X+3.*LOG(X)*SIN(X)+8.*COS(X)*X-8.*COS(X)-8.
171      . *SIN(X)*X-8.*SIN(X))/(4.*SQRT(X)*X**2)
172\end{verbatim}
173\end{small}
174These algebraic manipulations illustrate the algebraic mode of {\REDUCE}.
175{\REDUCE} is based on Standard Lisp. A symbolic mode is also available for
176executing Lisp statements. These statements follow the syntax of Lisp,
177e.g.
178\begin{verbatim}
179  symbolic car '(a);
180\end{verbatim}
181Communication between the two modes is possible.
182
183With this simple introduction, you are now in a position to study the
184material in the full {\REDUCE} manual in order to learn just how extensive
185the range of facilities really is.  If further tutorial material is
186desired, the seven {\REDUCE} Interactive Lessons by David R. Stoutemyer are
187recommended.  These are normally distributed with the system.
188
189