~ubuntu-branches/debian/squeeze/maxima/squeeze

« back to all changes in this revision

Viewing changes to doc/intromax/intromax.ltx

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2006-10-18 14:52:42 UTC
  • mto: (1.1.5 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20061018145242-vzyrm5hmxr8kiosf
ImportĀ upstreamĀ versionĀ 5.10.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
 
19
19
 
20
 
\title{Introduction to MACSYMA%
21
 
\thanks{Adapted from ``Perturbation Methods, Bifurcation Theory and Computer Algebra'' by Rand and
22
 
Armbruster, Springer, 1987}
23
 
}
24
 
\author{Richard H. Rand\\ Dept. of Theoretical and Applied Mechanics, Cornell University%
25
 
\thanks{Adapted to \LaTeX\ and HTML by Nelson L. Dias (nldias@simepar.br), SIMEPAR Technological Institute and Federal University of Paranļæ½, Brazil}}
26
 
\date{\today}
 
20
\title{Introduction to Maxima}
 
21
\author{Richard H. Rand\\ Dept. of Theoretical and Applied Mechanics, Cornell University
 
22
\thanks{Adapted from ``Perturbation Methods, Bifurcation Theory and Computer Algebra''
 
23
by Rand and Armbruster, Springer, 1987.
 
24
Adapted to \LaTeX\ and HTML by Nelson L. Dias (nldias@simepar.br), 
 
25
SIMEPAR Technological Institute and Federal University of Paranļæ½, Brazil.
 
26
Updated by Robert Dodier, August 2005.}}
 
27
\date{\empty}
27
28
 
28
29
 
29
30
\begin{document}
33
34
 
34
35
\section{Introduction \label{sec:introduction}}
35
36
 
36
 
To invoke MAXIMA in Linux, type
 
37
To invoke Maxima in Linux, type
37
38
\begin{verbatim}
38
 
maxima<ret>
 
39
maxima <enter>
39
40
\end{verbatim}
40
41
 
41
42
 
42
43
The computer will display a greeting of the sort:
43
44
\begin{verbatim}
44
 
GCL (GNU Common Lisp)  Version(2.3) ter jun 27 14:16:29 BRT 2000                                        
45
 
Licensed under GNU Library General Public License
46
 
Contains Enhancements by W. Schelter
47
 
Maxima 5.4 ter jun 27 14:16:11 BRT 2000 (with enhancements by W. Schelter).
48
 
Licensed under the GNU Public License (see file COPYING)
49
 
(C1)                                                                                                    
 
45
Distributed under the GNU Public License. See the file COPYING.
 
46
Dedicated to the memory of William Schelter.
 
47
This is a development version of Maxima. The function bug_report()
 
48
provides bug reporting information.
 
49
(%i1)
50
50
\end{verbatim}
51
51
 
52
 
The {\tt (C1)} is a ``label''.  Each input or output line is labelled and can be referred to by its
53
 
own label for the rest of the session.  {\tt C} labels denote your commands and {\tt D} labels
54
 
denote Displays of the machine's response.  \emph{Never use variable names like {\tt C1} or {\tt
55
 
D5}, as these will be confused with the lines so labeled}.
56
 
 
57
 
MAXIMA is pragmatic about lower and upper case: regardless of your typing {\tt sin(x)} or {\tt
58
 
SIN(x)},
59
 
{\tt \verb+%e^x+} or {\tt \verb+%E^x+}, it will understand that you mean the sine and exponential
60
 
functions, and will echo in standard uppercase {\tt SIN} and {\tt \verb+%E+}.
61
 
\emph{That doesn't apply to user variables, though: {\tt x} and {\tt X} are \emph{different}
62
 
variables for MAXIMA ! (Try it.)}
63
 
 
64
 
 
65
 
 
 
52
The {\tt (\%i1)} is a ``label''.  Each input or output line is labelled and can be referred to by its
 
53
own label for the rest of the session.  {\tt i} labels denote your commands and {\tt o} labels
 
54
denote displays of the machine's response.  \emph{Never use variable names like {\tt \%i1} or {\tt
 
55
\%o5}, as these will be confused with the lines so labeled}.
 
56
 
 
57
Maxima distinguishes lower and upper case.
 
58
All built-in functions have names which are lowercase only
 
59
({\tt sin}, {\tt cos}, {\tt save}, {\tt load}, etc).
 
60
Built-in constants have lowercase names ({\tt \%e}, {\tt \%pi}, {\tt inf}, etc).
 
61
If you type {\tt SIN(x)} or {\tt Sin(x)},
 
62
Maxima assumes you mean something other than the built-in {\tt sin} function.
 
63
User-defined functions and variables can have names which are lower or upper case or both.
 
64
{\tt foo(XY)}, {\tt Foo(Xy)}, {\tt FOO(xy)} are all different.
66
65
 
67
66
 
68
67
\section{Special keys and symbols \label{sec:keys}}
69
68
 
70
69
\begin{enumerate}
71
 
\item To end a MAXIMA session, type {\tt quit();}.  If you type \verb+^C+, here is what happens:
72
 
\begin{verbatim}
73
 
Correctable error: Console interrupt.
74
 
Signalled by MACSYMA-TOP-LEVEL.
75
 
If continued: Type :r to resume execution, or :q to quit to top level.
76
 
Broken at SYSTEM:TERMINAL-INTERRUPT.  Type :H for Help.
77
 
MAXIMA>>:q
78
 
 
79
 
(C1)     
80
 
\end{verbatim}
81
 
Notice that typing {\tt :q} or {\tt :t} (for \emph{top level}) after the {\tt MAXIMA>>} prompt gets
82
 
you back to the MAXIMA level.
83
 
\verb+^Y+, on the other hand, won't have any effect but being echoed on the screen; finally 
84
 
\verb+^Z+ will have the same effect as {\tt quit();}. (Here \verb+^+ stands for the control key, so
 
70
\item To end a Maxima session, type {\tt quit();}.
 
71
 
 
72
\item To abort a computation without leaving Maxima, type \verb+^C+.
 
73
(Here \verb+^+ stands for the control key, so
85
74
that \verb+^C+ means first press the key marked control and hold it down while pressing the C key.)
86
 
 
87
 
\item To abort a computation without leaving MAXIMA, type \verb+^C+.  It is important for you to
 
75
It is important for you to
88
76
know how to do this in case, for example, you begin a computation which is taking too long.
89
 
Remember to type {\tt :q} at the {\tt MAXIMA>>} prompt to return to MAXIMA. For example:
 
77
For example:
 
78
% sum (1/x^2, x, 1, 10000);
 
79
% ^C
90
80
\begin{verbatim}
91
 
(C1) sum(1/x^2,x,1,1000);
92
 
 
93
 
 
94
 
Correctable error: Console interrupt.
95
 
Signalled by MACSYMA-TOP-LEVEL.
96
 
If continued: Type :r to resume execution, or :q to quit to top level.
97
 
Broken at SYSTEM:TERMINAL-INTERRUPT.  Type :H for Help.
98
 
MAXIMA>>:q
99
 
 
100
 
(C2)                                                                                                    
 
81
(%i1) sum (1/x^2, x, 1, 10000);
 
82
 
 
83
Maxima encountered a Lisp error:
 
84
 
 
85
 Console interrupt.
 
86
 
 
87
Automatically continuing.
 
88
To reenable the Lisp debugger set *debugger-hook* to nil.
 
89
(%i2)
101
90
\end{verbatim}
102
91
 
103
 
\item In order to tell MAXIMA that you have finished your command, use the semicolon ({\tt ;}),
 
92
\item In order to tell Maxima that you have finished your command, use the semicolon ({\tt ;}),
104
93
followed by a return.  Note that the return key alone does not signal that you are done with your
105
94
input.
106
95
 
107
96
\item An alternative input terminator to the semicolon ({\tt ;}) is the dollar sign ({\tt \$}),
108
 
which, however, supresses the display of MAXIMA's computation.  This is useful if you are computing
 
97
which, however, supresses the display of Maxima's computation.  This is useful if you are computing
109
98
some long intermediate result, and you don't want to waste time having it displayed on the screen.
110
99
 
111
100
%\item If you want to completely delete the current input line (and start this line fresh from the
112
101
%beginning), type a double question mark ({\tt ??}).
113
102
 
114
 
\item If you wish to repeat a command which you have already given, say on line {\tt (C5)}, you may
 
103
\item If you wish to repeat a command which you have already given, say on line {\tt (\%i5)}, you may
115
104
do so without typing it over again by preceding its label with two single quotes ({\tt ''}), i.e., {\tt
116
 
''C5}. (Note that simply inputing {\tt C5} will not do the job --- try it.)
 
105
''\%i5}. (Note that simply inputing {\tt \%i5} will not do the job --- try it.)
117
106
 
118
 
\item If you want to refer to the immediately preceding result computed my MAXIMA, you can either
119
 
use its {\tt D} label, or you can use the special symbol percent   ({\tt \%}).
 
107
\item If you want to refer to the immediately preceding result computed my Maxima, you can either
 
108
use its {\tt o} label, or you can use the special symbol percent   ({\tt \%}).
120
109
 
121
110
\item The standard quantities $e$ (natural log base), $i$ (square root of $-1$) and $\pi$
122
 
($3.14159\ldots$) are respectively referred to as \verb+%e+ (or \verb+%E+), \verb+%i+ 
123
 
(or \verb+%I+), and \verb+%pi+ (or \verb+%PI+).  Note that the use of {\tt \%} here as a prefix
 
111
($3.14159\ldots$) are respectively referred to as \verb+%e+, \verb+%i+,
 
112
and \verb+%pi+.  Note that the use of {\tt \%} here as a prefix
124
113
is completely unrelated to the use of {\tt \%} to refer to the preceding result computed.
125
114
 
126
 
\item In order to assign a value to a variable, MAXIMA uses the colon ({\tt :}), not the equal
 
115
\item In order to assign a value to a variable, Maxima uses the colon ({\tt :}), not the equal
127
116
sign.  The equal sign is used for representing equations.
128
117
\end{enumerate}
129
118
 
139
128
   \item [{\tt .}] matrix multiplication
140
129
   \item [{\tt sqrt(x)}] square root of {\tt x}.
141
130
\end{description}
142
 
MAXIMA's output is characterized by exact (rational) arithmetic.  E.g.,
 
131
Maxima's output is characterized by exact (rational) arithmetic.  E.g.,
 
132
% 1/100 + 1/101;
143
133
\begin{verbatim}
144
 
(C1) 1/100+1/101;
145
 
 
146
 
                                      201
147
 
(D1)                                 -----
148
 
                                     10100                                                              
 
134
(%i1) 1/100 + 1/101;
 
135
                               201
 
136
(%o1)                         -----
 
137
                              10100
149
138
\end{verbatim}
150
139
If irrational numbers are involved in a computation, they are kept in symbolic form:
 
140
% (1 + sqrt(2))^5;
 
141
% expand (%);
151
142
\begin{verbatim}
152
 
(C2) (1+sqrt(2))^5;
153
 
 
154
 
                                             5
155
 
(D2)                            (SQRT(2) + 1)
156
 
(C3) expand(%);
157
 
 
158
 
(D3)                            29 SQRT(2) + 41                                                              
 
143
(%i2) (1 + sqrt(2))^5;
 
144
                                      5
 
145
(%o2)                    (sqrt(2) + 1)
 
146
(%i3) expand (%);
 
147
(%o3)                    29 sqrt(2) + 41
159
148
\end{verbatim}
160
149
However, it is often useful to express a result in decimal notation.  This may be accomplished by
161
150
following the expression you want expanded by ``{\tt ,numer}'':
 
151
% %, numer;
162
152
\begin{verbatim}
163
 
(C4) %,numer;
164
 
 
165
 
(D4)                           82.01219330881976                                                             
 
153
(%i4) %, numer;
 
154
(%o4)                   82.01219330881976
166
155
\end{verbatim}
167
156
Note the use here of \verb+%+ 
168
 
to refer to the previous result.  In this version of MAXIMA, {\tt numer} gives 16 significant
169
 
figures, of which the last is often unreliable.  However, MAXIMA can offer \emph{arbitrarily high
 
157
to refer to the previous result.  In this version of Maxima, {\tt numer} gives 16 significant
 
158
figures, of which the last is often unreliable.  However, Maxima can offer \emph{arbitrarily high
170
159
precision} by using the {\tt bfloat} function:
 
160
% bfloat (%o3);
171
161
\begin{verbatim}
172
 
(C5) bfloat(d3);
173
 
 
174
 
(D5)                          8.201219330881976B1                                                            \end{verbatim}
175
 
The number of significant figures displayed is controlled by the MAXIMA variable {\tt FPPREC}, which
 
162
(%i5) bfloat (%o3);
 
163
(%o5)                  8.201219330881976B1
 
164
\end{verbatim}
 
165
The number of significant figures displayed is controlled by the Maxima variable {\tt fpprec}, which
176
166
has the default value of 16:
177
 
\begin{verbatim}
178
 
(C6) fpprec;
179
 
 
180
 
(D6)                                  16                                                                     
181
 
\end{verbatim}
182
 
Here we reset {\tt FPPREC} to yield 100 digits:
183
 
\begin{verbatim}
184
 
(C7) fpprec:100;
185
 
 
186
 
(D7)                                  100
187
 
(C8) ''c5;
188
 
 
189
 
(D8) 8.20121933088197564152489730020812442785204843859314941221237124017312418#
190
 
 
191
 
7540110412666123849550160561B1
192
 
\end{verbatim}
193
 
Note the use of two single quotes ({\tt ''}) in {\tt (C8)} to repeat command {\tt (C5)}.  MAXIMA can
 
167
% fpprec;
 
168
\begin{verbatim}
 
169
(%i6) fpprec;
 
170
(%o6)                          16
 
171
\end{verbatim}
 
172
Here we reset {\tt fpprec} to yield 100 digits:
 
173
% fpprec: 100;
 
174
% ''%i5;
 
175
\begin{verbatim}
 
176
(%i7) fpprec: 100;
 
177
(%o7)                          100
 
178
(%i8) ''%i5;
 
179
(%o8) 8.20121933088197564152489730020812442785204843859314941221#
 
180
2371240173124187540110412666123849550160561B1
 
181
\end{verbatim}
 
182
Note the use of two single quotes ({\tt ''}) in {\tt (\%i8)} to repeat command {\tt (\%i5)}.  Maxima can
194
183
handle very large numbers without approximation:
 
184
% 100!;
195
185
\begin{verbatim}
196
 
(C9) 100!;
197
 
 
198
 
(D9) 9332621544394415268169923885626670049071596826438162146859296389521759999#
199
 
 
200
 
322991560894146397615651828625369792082722375825118521091686400000000000000000#
201
 
 
202
 
0000000                                                                                                      \end{verbatim}
 
186
(%i9) 100!;
 
187
(%o9) 9332621544394415268169923885626670049071596826438162146859#
 
188
2963895217599993229915608941463976156518286253697920827223758251#
 
189
185210916864000000000000000000000000
 
190
\end{verbatim}
203
191
 
204
192
\section{Algebra \label{sec:algebra}}
205
193
 
206
 
MAXIMA's importance as a computer tool to facilitate analytical calculations becomes more evident
 
194
Maxima's importance as a computer tool to facilitate analytical calculations becomes more evident
207
195
when we see how easily it does algebra for us.  Here's an example in which a polynomial is expanded:
 
196
% (x + 3*y + x^2*y)^3;
 
197
% expand (%);
208
198
\begin{verbatim}
209
 
(C1) (x+3*y+x^2*y)^3;
210
 
 
211
 
                                 2             3
212
 
(D1)                           (x  y + 3 y + x)
213
 
(C2) expand(%);
214
 
 
215
 
      6  3      4  3       2  3       3      5  2       3  2         2      4
216
 
(D2) x  y  + 9 x  y  + 27 x  y  + 27 y  + 3 x  y  + 18 x  y  + 27 x y  + 3 x  y
217
 
 
218
 
                                                                       2      3
219
 
                                                                  + 9 x  y + x  
 
199
(%i1) (x + 3*y + x^2*y)^3;
 
200
                          2             3
 
201
(%o1)                   (x  y + 3 y + x)
 
202
(%i2) expand (%);
 
203
       6  3      4  3       2  3       3      5  2       3  2
 
204
(%o2) x  y  + 9 x  y  + 27 x  y  + 27 y  + 3 x  y  + 18 x  y
 
205
                                         2      4        2      3
 
206
                                 + 27 x y  + 3 x  y + 9 x  y + x
220
207
\end{verbatim}
221
208
Now suppose we wanted to substitute {\tt 5/z} for {\tt x} in the above expression:
222
209
 
223
210
\noindent\begin{minipage}{\textwidth}
 
211
% %o2, x=5/z;
224
212
\begin{verbatim}
225
 
(C3) d2,x=5/z;
226
 
 
227
 
          2        3                 2               3                  2
228
 
     135 y    675 y    225 y   2250 y    125   5625 y    1875 y   9375 y
229
 
(D3) ------ + ------ + ----- + ------- + --- + ------- + ------ + -------
230
 
       z         2       2        3       3       4         4        5
231
 
                z       z        z       z       z         z        z
232
 
 
233
 
                                                                      3
234
 
                                                               15625 y        3
235
 
                                                             + -------- + 27 y
236
 
                                                                   6
237
 
                                                                  z                                          
 
213
(%i3) %o2, x=5/z;
 
214
           2        3                 2               3
 
215
      135 y    675 y    225 y   2250 y    125   5625 y    1875 y
 
216
(%o3) ------ + ------ + ----- + ------- + --- + ------- + ------
 
217
        z         2       2        3       3       4         4
 
218
                 z       z        z       z       z         z
 
219
                                             2          3
 
220
                                       9375 y    15625 y        3
 
221
                                     + ------- + -------- + 27 y
 
222
                                          5          6
 
223
                                         z          z
238
224
\end{verbatim}
239
225
\end{minipage}
240
 
The MAXIMA function RATSIMP will place this over a common denominator:
 
226
The Maxima function {\tt ratsimp} will place this over a common denominator:
 
227
% ratsimp (%);
241
228
\begin{verbatim}
242
 
(C4) ratsimp(%);
243
 
 
244
 
          3  6        2  5         3           4          2         3
245
 
(D4) (27 y  z  + 135 y  z  + (675 y  + 225 y) z  + (2250 y  + 125) z
246
 
 
247
 
                                      3            2         2            3   6
248
 
                             + (5625 y  + 1875 y) z  + 9375 y  z + 15625 y )/z    
 
229
(%i4) ratsimp (%);
 
230
           3  6        2  5         3           4
 
231
(%o4) (27 y  z  + 135 y  z  + (675 y  + 225 y) z
 
232
          2         3          3            2         2
 
233
 + (2250 y  + 125) z  + (5625 y  + 1875 y) z  + 9375 y  z
 
234
          3   6
 
235
 + 15625 y )/z
249
236
\end{verbatim}
250
237
Expressions may also be {\tt factor}ed:
 
238
% factor (%);
251
239
\begin{verbatim}
252
 
(C5) factor(%);
253
 
 
254
 
                                  2              3
255
 
                            (3 y z  + 5 z + 25 y)
256
 
(D5)                        ----------------------
257
 
                                       6
258
 
                                      z                                                                      
 
240
(%i5) factor (%);
 
241
                           2              3
 
242
                     (3 y z  + 5 z + 25 y)
 
243
(%o5)                ----------------------
 
244
                                6
 
245
                               z
259
246
\end{verbatim}
260
 
MAXIMA can obtain exact solutions to systems of nonlinear algebraic equations.  In this example we
261
 
{\tt solve} three equations in the three unknowns {\tt A}, {\tt B}, {\tt C}:
 
247
Maxima can obtain exact solutions to systems of nonlinear algebraic equations.  In this example we
 
248
{\tt solve} three equations in the three unknowns {\tt a}, {\tt b}, {\tt c}:
 
249
% a + b*c = 1;
 
250
% b - a*c = 0;
 
251
% a + b = 5;
 
252
% solve ([%o6, %o7, %o8], [a, b, c]);
262
253
\begin{verbatim}
263
 
(C6) a + b*c=1;
264
 
 
265
 
(D6)                              b C + a = 1
266
 
(C7) b - a*c=0;
267
 
 
268
 
(D7)                              b - a C = 0
269
 
(C8) a+b=5;
270
 
 
271
 
(D8)                               b + a = 5
272
 
(C9) solve([d6,d7,d8],[a,b,c]);
273
 
 
274
 
           25 SQRT(79) %I + 25      5 SQRT(79) %I + 5      SQRT(79) %I + 1
275
 
(D9) [[a = -------------------, b = -----------------, C = ---------------],
276
 
           6 SQRT(79) %I - 34       SQRT(79) %I + 11             10
277
 
 
278
 
            25 SQRT(79) %I - 25      5 SQRT(79) %I - 5        SQRT(79) %I - 1
279
 
       [a = -------------------, b = -----------------, C = - ---------------]]
280
 
            6 SQRT(79) %I + 34       SQRT(79) %I - 11               10                     
 
254
(%i6) a + b*c = 1;
 
255
(%o6)                      b c + a = 1
 
256
(%i7) b - a*c = 0;
 
257
(%o7)                      b - a c = 0
 
258
(%i8) a + b = 5;
 
259
(%o8)                       b + a = 5
 
260
(%i9) solve ([%o6, %o7, %o8], [a, b, c]);
 
261
            25 sqrt(79) %i + 25      5 sqrt(79) %i + 5
 
262
(%o9) [[a = -------------------, b = -----------------, 
 
263
            6 sqrt(79) %i - 34       sqrt(79) %i + 11
 
264
    sqrt(79) %i + 1        25 sqrt(79) %i - 25
 
265
c = ---------------], [a = -------------------, 
 
266
          10               6 sqrt(79) %i + 34
 
267
    5 sqrt(79) %i - 5        sqrt(79) %i - 1
 
268
b = -----------------, c = - ---------------]]
 
269
    sqrt(79) %i - 11               10
281
270
\end{verbatim}
282
271
Note that the display consists of a ``list'', i.e., some expression contained between two brackets
283
272
{\tt [ \ldots ]}, which itself contains two lists.  Each of the latter contain a distinct solution
284
273
to the simultaneous equations.
285
274
 
286
 
Trigonometric identities are easy to manipulate in MAXIMA.  The function {\tt trigexpand} uses the
 
275
Trigonometric identities are easy to manipulate in Maxima.  The function {\tt trigexpand} uses the
287
276
sum-of-angles formulas to make the argument inside each trig function as simple as possible:
 
277
% sin(u + v) * cos(u)^3;
 
278
% trigexpand (%);
288
279
\begin{verbatim}
289
 
(C10) sin(u+v)*cos(u)^3;
290
 
 
291
 
                                 3
292
 
(D10)                         COS (u) SIN(v + u)
293
 
(C11) trigexpand(%);
294
 
 
295
 
                       3
296
 
(D11)               COS (u) (COS(u) SIN(v) + SIN(u) COS(v))       
 
280
(%i10) sin(u + v) * cos(u)^3;
 
281
                          3
 
282
(%o10)                 cos (u) sin(v + u)
 
283
(%i11) trigexpand (%);
 
284
                3
 
285
(%o11)       cos (u) (cos(u) sin(v) + sin(u) cos(v))
297
286
\end{verbatim}
298
287
The function {\tt trigreduce}, on the other hand, converts an expression into a form which is a sum
299
288
of terms, each of which contains only a single {\tt sin} or {\tt cos}:
 
289
% trigreduce (%o10);
300
290
\begin{verbatim}
301
 
 
302
 
(C12) trigreduce(d10);
303
 
 
304
 
            SIN(v + 4 u) + SIN(v - 2 u)   3 SIN(v + 2 u) + 3 SIN(v)
305
 
(D12)       --------------------------- + -------------------------
306
 
                         8                            8                               
 
291
(%i12) trigreduce (%o10);
 
292
       sin(v + 4 u) + sin(v - 2 u)   3 sin(v + 2 u) + 3 sin(v)
 
293
(%o12) --------------------------- + -------------------------
 
294
                    8                            8
307
295
\end{verbatim}
308
296
The functions {\tt realpart} and {\tt imagpart} will return the real and imaginary parts of a
309
297
complex expression:
 
298
% w: 3 + k*%i;
 
299
% w^2 * %e^w;
 
300
% realpart (%);
310
301
\begin{verbatim}
311
 
 
312
 
(C13) w:3+k*%i;
313
 
 
314
 
(D13)                              %I k + 3
315
 
(C14) w^2*%e^w;
316
 
 
317
 
                                      2   %I k + 3
318
 
(D14)                       (%I k + 3)  %E
319
 
(C15) realpart(%);
320
 
 
321
 
                       3       2               3
322
 
(D15)                %E  (9 - k ) COS(k) - 6 %E  k SIN(k)                     
 
302
(%i13) w: 3 + k*%i;
 
303
(%o13)                      %i k + 3
 
304
(%i14) w^2 * %e^w;
 
305
                               2   %i k + 3
 
306
(%o14)               (%i k + 3)  %e
 
307
(%i15) realpart (%);
 
308
                3       2               3
 
309
(%o15)        %e  (9 - k ) cos(k) - 6 %e  k sin(k)
323
310
\end{verbatim}
324
311
 
325
312
\section{Calculus \label{sec:calculus}}
326
313
 
327
 
MAXIMA can compute derivatives and integrals, expand in Taylor series, take limits, and obtain exact
 
314
Maxima can compute derivatives and integrals, expand in Taylor series, take limits, and obtain exact
328
315
solutions to ordinary differential equations.  We begin by defining the symbol {\tt f} to be the
329
316
following function of {\tt x}:
 
317
% f: x^3 * %e^(k*x) * sin(w*x);
330
318
\begin{verbatim}
331
 
(C1) f:x^3*%E^(k*x)*sin(w*x);
332
 
 
333
 
                                3   k x
334
 
(D1)                           x  %E    SIN(w x)    
 
319
(%i1) f: x^3 * %e^(k*x) * sin(w*x);
 
320
                         3   k x
 
321
(%o1)                   x  %e    sin(w x)
335
322
\end{verbatim}
336
323
We compute the derivative of {\tt f} with respect to {\tt x}:
 
324
% diff (f, x);
337
325
\begin{verbatim}
338
 
(C2) diff(f,x);
339
 
 
340
 
           3   k x               2   k x               3   k x
341
 
(D2)    k x  %E    SIN(w x) + 3 x  %E    SIN(w x) + w x  %E    COS(w x)             
 
326
(%i2) diff (f, x);
 
327
         3   k x               2   k x
 
328
(%o2) k x  %e    sin(w x) + 3 x  %e    sin(w x)
 
329
                                                 3   k x
 
330
                                            + w x  %e    cos(w x)
342
331
\end{verbatim}
343
332
Now we find the indefinite integral of {\tt f} with respect to {\tt x}:
 
333
% integrate (f, x);
344
334
\begin{verbatim}
345
 
(C3) integrate(f,x);
346
 
 
347
 
           6      3  4      5  2    7   3
348
 
(D3) (((k w  + 3 k  w  + 3 k  w  + k ) x
349
 
 
350
 
       6      2  4      4  2      6   2            4       3  2      5
351
 
 + (3 w  + 3 k  w  - 3 k  w  - 3 k ) x  + (- 18 k w  - 12 k  w  + 6 k ) x
352
 
 
353
 
      4       2  2      4    k x
354
 
 - 6 w  + 36 k  w  - 6 k ) %E    SIN(w x)
355
 
 
356
 
        7      2  5      4  3    6     3         5       3  3      5     2
357
 
 + ((- w  - 3 k  w  - 3 k  w  - k  w) x  + (6 k w  + 12 k  w  + 6 k  w) x
358
 
 
 
335
(%i3) integrate (f, x);
 
336
            6      3  4      5  2    7   3
 
337
(%o3) (((k w  + 3 k  w  + 3 k  w  + k ) x
 
338
       6      2  4      4  2      6   2
 
339
 + (3 w  + 3 k  w  - 3 k  w  - 3 k ) x
 
340
            4       3  2      5         4       2  2      4
 
341
 + (- 18 k w  - 12 k  w  + 6 k ) x - 6 w  + 36 k  w  - 6 k )
 
342
   k x                 7      2  5      4  3    6     3
 
343
 %e    sin(w x) + ((- w  - 3 k  w  - 3 k  w  - k  w) x
 
344
         5       3  3      5     2
 
345
 + (6 k w  + 12 k  w  + 6 k  w) x
359
346
       5       2  3       4              3       3      k x
360
 
 + (6 w  - 12 k  w  - 18 k  w) x - 24 k w  + 24 k  w) %E    COS(w x))
361
 
 
362
 
   8      2  6      4  4      6  2    8
363
 
/(w  + 4 k  w  + 6 k  w  + 4 k  w  + k )                                                                     
 
347
 + (6 w  - 12 k  w  - 18 k  w) x - 24 k w  + 24 k  w) %e
 
348
             8      2  6      4  4      6  2    8
 
349
 cos(w x))/(w  + 4 k  w  + 6 k  w  + 4 k  w  + k )
364
350
\end{verbatim}
365
351
A slight change in syntax gives definite integrals:
 
352
% integrate (1/x^2, x, 1, inf);
 
353
% integrate (1/x, x, 0, inf);
366
354
\begin{verbatim}
367
 
(C4) integrate(1/x^2,x,1,inf);
368
 
 
369
 
(D4)                                   1                                                                     
370
 
(C5) integrate(1/x,x,0,inf);
371
 
 
 
355
(%i4) integrate (1/x^2, x, 1, inf);
 
356
(%o4)                           1
 
357
(%i5) integrate (1/x, x, 0, inf);
 
358
 
372
359
Integral is divergent
373
 
 -- an error.  Quitting.  To debug this try DEBUGMODE(TRUE);)
 
360
 -- an error.  Quitting.  To debug this try debugmode(true);
374
361
\end{verbatim}
375
 
Next we define the simbol {\tt g} in terms of {\tt f} (previously defined in {\tt C1}) and the
 
362
Next we define the simbol {\tt g} in terms of {\tt f} (previously defined in {\tt \%i1}) and the
376
363
hyperbolic sine function, and find its Taylor series expansion (up to, say, order 3 terms) about the
377
364
point {\tt x = 0}:
378
365
 
379
366
\noindent\begin{minipage}{\textwidth}
 
367
% g: f / sinh(k*x)^4;
 
368
% taylor (g, x, 0, 3);
380
369
\begin{verbatim}
381
 
(C6) g:f/sinh(k*x)^4;
382
 
 
383
 
                                3   k x
384
 
                               x  %E    SIN(w x)
385
 
(D6)                           -----------------
386
 
                                      4
387
 
                                  SINH (k x)
388
 
(C7) taylor(g,x,0,3);
389
 
 
390
 
                            2    3   2         2    3   3
391
 
             w    w x   (w k  + w ) x    (3 w k  + w ) x
392
 
(D7)/T/      -- + --- - -------------- - ---------------- + . . .
393
 
              4    3            4                 3
394
 
             k    k          6 k               6 k                                                           
 
370
(%i6) g: f / sinh(k*x)^4;
 
371
                         3   k x
 
372
                        x  %e    sin(w x)
 
373
(%o6)                   -----------------
 
374
                               4
 
375
                           sinh (k x)
 
376
(%i7) taylor (g, x, 0, 3);
 
377
                        2    3   2         2    3   3
 
378
         w    w x   (w k  + w ) x    (3 w k  + w ) x
 
379
(%o7)/T/ -- + --- - -------------- - ---------------- + . . .
 
380
          4    3            4                 3
 
381
         k    k          6 k               6 k
395
382
\end{verbatim}
396
383
\end{minipage}
397
384
The limit of {\tt g} as {\tt x} goes to 0 is computed as follows:
398
 
\begin{verbatim}
399
 
(C8) limit(g,x,0);
400
 
 
401
 
                                      w
402
 
(D8)                                  --
403
 
                                       4
404
 
                                      k                                                                      \end{verbatim}
405
 
MAXIMA also permits derivatives to be represented in unevaluated form (note the quote):
406
 
\begin{verbatim}
407
 
(C9) 'diff(y,x);
408
 
 
409
 
                                      dy
410
 
(D9)                                  --
411
 
                                      dx                                                                     
412
 
\end{verbatim}
413
 
The quote operator in {\tt (C9)} means ``do not evaluate''.  Without it, MAXIMA would have obtained
 
385
% limit (g, x, 0);
 
386
\begin{verbatim}
 
387
(%i8) limit (g, x, 0);
 
388
                               w
 
389
(%o8)                          --
 
390
                                4
 
391
                               k
 
392
\end{verbatim}
 
393
Maxima also permits derivatives to be represented in unevaluated form (note the quote):
 
394
% 'diff (y, x);
 
395
\begin{verbatim}
 
396
(%i9) 'diff (y, x);
 
397
                               dy
 
398
(%o9)                          --
 
399
                               dx
 
400
\end{verbatim}
 
401
The quote operator in {\tt (\%i9)} means ``do not evaluate''.  Without it, Maxima would have obtained
414
402
0:
 
403
% diff (y, x);
415
404
\begin{verbatim}
416
 
(C10) diff(y,x);
417
 
 
418
 
(D10)                                  0                
 
405
(%i10) diff (y, x);
 
406
(%o10)                          0
419
407
\end{verbatim}
420
408
Using the quote operator we can write differential equations:
 
409
% 'diff (y, x, 2) + 'diff (y, x) + y;
421
410
\begin{verbatim}
422
 
(C11) 'diff(y,x,2) + 'diff(y,x) + y;
423
 
 
424
 
                                  2
425
 
                                 d y   dy
426
 
(D11)                            --- + -- + y
427
 
                                   2   dx
428
 
                                 dx                                                                          
 
411
(%i11) 'diff (y, x, 2) + 'diff (y, x) + y;
 
412
                           2
 
413
                          d y   dy
 
414
(%o11)                    --- + -- + y
 
415
                            2   dx
 
416
                          dx
429
417
\end{verbatim}
430
 
MAXIMA's {\tt ODE2} function can solve first and second order ODE's:
 
418
Maxima's {\tt ode2} function can solve first and second order ODE's:
 
419
% ode2 (%o11, y, x);
431
420
\begin{verbatim}
432
 
(C12) ode2(d11,y,x);
433
 
 
434
 
                   - x/2          SQRT(3) x            SQRT(3) x
435
 
(D12)        y = %E      (%K1 SIN(---------) + %K2 COS(---------))
436
 
                                      2                    2       
 
421
(%i12) ode2 (%o11, y, x);
 
422
             - x/2          sqrt(3) x            sqrt(3) x
 
423
(%o12) y = %e      (%k1 sin(---------) + %k2 cos(---------))
 
424
                                2                    2
437
425
\end{verbatim}
438
426
 
439
427
 
440
428
\newpage
441
429
\section{Matrix calculations \label{sec:matrix}}
442
430
 
443
 
MAXIMA can compute the determinant, inverse and eigenvalues and eigenvectors of matrices which have
 
431
Maxima can compute the determinant, inverse and eigenvalues and eigenvectors of matrices which have
444
432
symbolic elements (i.e., elements which involve algebraic variables.) We begin by entering a matrix
445
433
{\tt m} element by element:
 
434
% m: entermatrix (3, 3);
446
435
\begin{verbatim}
447
 
(C1) m:entermatrix(3,3);
448
 
 
 
436
(%i1) m: entermatrix (3, 3);
449
437
 
450
438
Is the matrix  1. Diagonal  2. Symmetric  3. Antisymmetric  4. General
451
 
Answer 1, 2, 3 or 4 : 4;
452
 
Row 1 Column 1:  0;
453
 
Row 1 Column 2:  1;
454
 
Row 1 Column 3:  a;
455
 
Row 2 Column 1:  1;
456
 
Row 2 Column 2:  0;
457
 
Row 2 Column 3:  1;
458
 
Row 3 Column 1:  1;
459
 
Row 3 Column 2:  1;
460
 
Row 3 Column 3:  0;
461
 
 
 
439
Answer 1, 2, 3 or 4 : 
 
440
4;
 
441
Row 1 Column 1: 
 
442
0;
 
443
Row 1 Column 2: 
 
444
1;
 
445
Row 1 Column 3: 
 
446
a;
 
447
Row 2 Column 1: 
 
448
1;
 
449
Row 2 Column 2: 
 
450
0;
 
451
Row 2 Column 3: 
 
452
1;
 
453
Row 3 Column 1: 
 
454
1;
 
455
Row 3 Column 2: 
 
456
1;
 
457
Row 3 Column 3: 
 
458
0;
 
459
 
462
460
Matrix entered.
463
 
                                  [ 0  1  a ]
464
 
                                  [         ]
465
 
(D1)                              [ 1  0  1 ]
466
 
                                  [         ]
467
 
                                  [ 1  1  0 ]                                                           
 
461
                           [ 0  1  a ]
 
462
                           [         ]
 
463
(%o1)                      [ 1  0  1 ]
 
464
                           [         ]
 
465
                           [ 1  1  0 ]
468
466
\end{verbatim}
469
467
Next we find its transpose, determinant and inverse:
470
 
\begin{verbatim}
471
 
(C2) transpose(m);
472
 
 
473
 
                                  [ 0  1  1 ]
474
 
                                  [         ]
475
 
(D2)                              [ 1  0  1 ]
476
 
                                  [         ]
477
 
                                  [ a  1  0 ]
478
 
(C3) determinant(m);
479
 
 
480
 
(D3)                                 a + 1
481
 
(C4) invert(m),detout;
482
 
 
 
468
% transpose (m);
 
469
% determinant (m);
 
470
% invert (m), detout;
 
471
\begin{verbatim}
 
472
(%i2) transpose (m);
 
473
                           [ 0  1  1 ]
 
474
                           [         ]
 
475
(%o2)                      [ 1  0  1 ]
 
476
                           [         ]
 
477
                           [ a  1  0 ]
 
478
(%i3) determinant (m);
 
479
(%o3)                         a + 1
 
480
(%i4) invert (m), detout;
 
481
                        [ - 1   a    1  ]
 
482
                        [               ]
 
483
                        [  1   - a   a  ]
 
484
                        [               ]
 
485
                        [  1    1   - 1 ]
 
486
(%o4)                   -----------------
 
487
                              a + 1
 
488
\end{verbatim}
 
489
In {\tt (\%i4)}, the modifier {\tt detout} keeps the determinant outside the inverse.  As a check, we
 
490
multiply {\tt m} by its inverse (note the use of the period to represent matrix multiplication):
 
491
% m . %o4;
 
492
% expand (%);
 
493
% factor (%);
 
494
\begin{verbatim}
 
495
(%i5) m . %o4;
483
496
                               [ - 1   a    1  ]
484
497
                               [               ]
485
498
                               [  1   - a   a  ]
486
 
                               [               ]
487
 
                               [  1    1   - 1 ]
488
 
(D4)                           -----------------
489
 
                                     a + 1                                                              
490
 
\end{verbatim}
491
 
In {\tt (C4)}, the modifier {\tt DETOUT} keeps the determinant outside the inverse.  As a check, we
492
 
multiply {\tt m} by its inverse (note the use of the period to represent matrix multiplication):
493
 
\begin{verbatim}
494
 
(C5) m.d4;
495
 
 
496
 
                                      [ - 1   a    1  ]
497
 
                                      [               ]
498
 
                                      [  1   - a   a  ]
499
 
                        [ 0  1  a ]   [               ]
500
 
                        [         ]   [  1    1   - 1 ]
501
 
(D5)                    [ 1  0  1 ] . -----------------
502
 
                        [         ]         a + 1
503
 
                        [ 1  1  0 ]
504
 
(C6) expand(%);
505
 
 
506
 
                [   a       1                                 ]
507
 
                [ ----- + -----        0              0       ]
508
 
                [ a + 1   a + 1                               ]
509
 
                [                                             ]
510
 
                [                  a       1                  ]
511
 
(D6)            [       0        ----- + -----        0       ]
512
 
                [                a + 1   a + 1                ]
513
 
                [                                             ]
514
 
                [                                 a       1   ]
515
 
                [       0              0        ----- + ----- ]
516
 
                [                               a + 1   a + 1 ]
517
 
(C7) factor(%);
518
 
 
519
 
                                  [ 1  0  0 ]
520
 
                                  [         ]
521
 
(D7)                              [ 0  1  0 ]
522
 
                                  [         ]
523
 
                                  [ 0  0  1 ]                                                                
 
499
                 [ 0  1  a ]   [               ]
 
500
                 [         ]   [  1    1   - 1 ]
 
501
(%o5)            [ 1  0  1 ] . -----------------
 
502
                 [         ]         a + 1
 
503
                 [ 1  1  0 ]
 
504
(%i6) expand (%);
 
505
         [   a       1                                 ]
 
506
         [ ----- + -----        0              0       ]
 
507
         [ a + 1   a + 1                               ]
 
508
         [                                             ]
 
509
         [                  a       1                  ]
 
510
(%o6)    [       0        ----- + -----        0       ]
 
511
         [                a + 1   a + 1                ]
 
512
         [                                             ]
 
513
         [                                 a       1   ]
 
514
         [       0              0        ----- + ----- ]
 
515
         [                               a + 1   a + 1 ]
 
516
(%i7) factor (%);
 
517
                           [ 1  0  0 ]
 
518
                           [         ]
 
519
(%o7)                      [ 0  1  0 ]
 
520
                           [         ]
 
521
                           [ 0  0  1 ]
524
522
\end{verbatim}
525
523
In order to find the eigenvalues and eigenvectors of {\tt m}, we use the function {\tt
526
 
EIGENVECTORS}:
 
524
eigenvectors}:
527
525
 
528
526
\noindent\begin{minipage}{\textwidth}
 
527
% eigenvectors (m);
529
528
\begin{verbatim}
530
 
(C8) eigenvectors(m);
531
 
 
532
 
Warning - you are redefining the MACSYMA function EIGENVALUES
533
 
Warning - you are redefining the MACSYMA function EIGENVECTORS
534
 
          SQRT(4 a + 5) - 1  SQRT(4 a + 5) + 1
535
 
(D8) [[[- -----------------, -----------------, - 1], [1, 1, 1]],
536
 
                  2                  2
537
 
 
538
 
      SQRT(4 a + 5) - 1    SQRT(4 a + 5) - 1
539
 
[1, - -----------------, - -----------------],
540
 
           2 a + 2              2 a + 2
541
 
 
542
 
    SQRT(4 a + 5) + 1  SQRT(4 a + 5) + 1
 
529
(%i8) eigenvectors (m);
 
530
           sqrt(4 a + 5) - 1  sqrt(4 a + 5) + 1
 
531
(%o8) [[[- -----------------, -----------------, - 1], 
 
532
                   2                  2
 
533
                  sqrt(4 a + 5) - 1    sqrt(4 a + 5) - 1
 
534
[1, 1, 1]], [1, - -----------------, - -----------------], 
 
535
                       2 a + 2              2 a + 2
 
536
    sqrt(4 a + 5) + 1  sqrt(4 a + 5) + 1
543
537
[1, -----------------, -----------------], [1, - 1, 0]]
544
 
         2 a + 2            2 a + 2                                               
 
538
         2 a + 2            2 a + 2
545
539
\end{verbatim}
546
 
In {\tt D8}, the first triple gives the eigenvalues of {\tt m} and the next gives their respective
 
540
In {\tt \%o8}, the first triple gives the eigenvalues of {\tt m} and the next gives their respective
547
541
multiplicities (here each is unrepeated).  The next three triples give the corresponding
548
542
eigenvectors of {\tt m}.  In order to extract from this expression one of these eigenvectors, we may
549
 
use the {\tt PART} function:
 
543
use the {\tt part} function:
 
544
% part (%, 2);
550
545
\begin{verbatim}
551
 
(C9) part(%,2);
552
 
 
553
 
                       SQRT(4 a + 5) - 1    SQRT(4 a + 5) - 1
554
 
(D9)             [1, - -----------------, - -----------------]
555
 
                            2 a + 2              2 a + 2                               
 
546
(%i9) part (%, 2);
 
547
                sqrt(4 a + 5) - 1    sqrt(4 a + 5) - 1
 
548
(%o9)     [1, - -----------------, - -----------------]
 
549
                     2 a + 2              2 a + 2
556
550
\end{verbatim}
557
551
\end{minipage}
558
552
 
559
 
\section{Programming in MAXIMA \label{sec:programming}}
 
553
\section{Programming in Maxima \label{sec:programming}}
560
554
 
561
 
So far, we have used MAXIMA in the interactive mode, rather like a calculator.  However, for
 
555
So far, we have used Maxima in the interactive mode, rather like a calculator.  However, for
562
556
computations which involve a repetitive sequence of commands, it is better to execute a program.
563
557
Here we present a short sample program to calculate the critical points of a function {\tt f} of two
564
558
variables {\tt x} and {\tt y}.  The program cues the user to enter the function {\tt f}, then it
565
 
computes the partial derivatives $\mathtt{f_x}$ and $\mathtt{f_y}$, and then it uses the MAXIMA
566
 
command {\tt SOLVE} to obtain solutions to $\mathtt{f_x = f_y = 0}$.  The program is written outside
567
 
of MAXIMA with a text editor, and then loaded into MAXIMA with the {\tt BATCH} command.  Here is the
 
559
computes the partial derivatives $\mathtt{f_x}$ and $\mathtt{f_y}$, and then it uses the Maxima
 
560
command {\tt solve} to obtain solutions to $\mathtt{f_x = f_y = 0}$.  The program is written outside
 
561
of Maxima with a text editor, and then loaded into Maxima with the {\tt batch} command.  Here is the
568
562
program listing:
569
563
\begin{verbatim}
570
564
/* -------------------------------------------------------------------------- 
600
594
)$
601
595
\end{verbatim}
602
596
The program (which is actually a function with no argument) is called {\tt critpts}. Each line is a
603
 
valid MAXIMA command which could be executed from the keyboard, and which is separated by the next
 
597
valid Maxima command which could be executed from the keyboard, and which is separated by the next
604
598
command by a comma.  The partial derivatives are stored in a variable named {\tt eqs}, and the
605
599
unknowns are stored in {\tt unk}.  Here is a sample run:
 
600
% batch ("critpts.max");
 
601
% critpts ();
606
602
\begin{verbatim} 
607
 
(C1) batch("critpts.max");
608
 
 
609
 
 
610
 
batching #/home/nldias/work/papers2000/intromax/critpts.max
611
 
(C2)
612
 
(C2) critpts() := (PRINT("program to find critical points"),
613
 
 
614
 
f : READ("enter f(x,y)"), PRINT("f = ", f), eqs : [DIFF(f, x), DIFF(f, y)],
615
 
 
616
 
unk : [x, y], SOLVE(eqs, unk))
617
 
(C3) critpts();
618
 
 
619
 
program to find critical points
620
 
enter f(x,y)
621
 
%e^(x^3+y^2)*(x+y);
 
603
(%i1) batch ("critpts.max");
 
604
 
 
605
batching #p/home/robert/tmp/maxima-clean/maxima/critpts.max
 
606
(%i2) critpts() := (print("program to find critical points"), 
 
607
f : read("enter f(x,y)"), print("f = ", f), 
 
608
eqs : [diff(f, x), diff(f, y)], unk : [x, y], solve(eqs, unk))
 
609
(%i3) critpts ();
 
610
program to find critical points 
 
611
enter f(x,y) 
 
612
%e^(x^3 + y^2)*(x + y);
622
613
                2    3
623
614
               y  + x
624
 
f =  (y + x) %E
625
 
(D3) [[x = 0.4588955685487 %I + 0.35897908710869,
626
 
 
627
 
y = 0.49420173682751 %I - 0.12257873677837],
628
 
 
629
 
[x = 0.35897908710869 - 0.4588955685487 %I,
630
 
 
631
 
y = - 0.49420173682751 %I - 0.12257873677837],
632
 
 
633
 
[x = 0.41875423272348 %I - 0.69231242044203,
634
 
 
635
 
y = 0.4559120701117 - 0.86972626928141 %I],
636
 
 
637
 
[x = - 0.41875423272348 %I - 0.69231242044203,
638
 
 
639
 
y = 0.86972626928141 %I + 0.4559120701117]]                                     
 
615
f =  (y + x) %e        
 
616
(%o3) [[x = 0.4588955685487 %i + 0.35897908710869, 
 
617
y = 0.49420173682751 %i - 0.12257873677837], 
 
618
[x = 0.35897908710869 - 0.4588955685487 %i, 
 
619
y = - 0.49420173682751 %i - 0.12257873677837], 
 
620
[x = 0.41875423272348 %i - 0.69231242044203, 
 
621
y = 0.4559120701117 - 0.86972626928141 %i], 
 
622
[x = - 0.41875423272348 %i - 0.69231242044203, 
 
623
y = 0.86972626928141 %i + 0.4559120701117]]
640
624
\end{verbatim}
641
625
 
642
 
\section{A partial list of MAXIMA functions}
 
626
\section{A partial list of Maxima functions}
643
627
 
644
 
See the MAXIMA Manual in the {\tt maxima-5.4/info/} directory in texinfo or html format.  From
645
 
MAXIMA itself, you can use {\tt DESCRIBE(\textit{function name})}.
 
628
See the Maxima reference manual {\tt doc/html/maxima\_toc.html} (under the main Maxima installation directory).
 
629
From Maxima itself, you can use {\tt describe(\textit{function name})}.
646
630
 
647
631
\begin{description}
648
 
   \item[{\tt ALLROOTS(A)}] Finds all the (generally complex) roots of the polynomial equation {\tt
649
 
   A}, and lists them in {\tt NUMER}ical format (i.e. to 16 significant figures).
650
 
   \item[{\tt APPEND(A,B)}] Appends the list {\tt B} to the list {\tt A}, resulting in a single
 
632
   \item[{\tt allroots(a)}] Finds all the (generally complex) roots of the polynomial equation {\tt
 
633
   A}, and lists them in {\tt numer}ical format (i.e. to 16 significant figures).
 
634
   \item[{\tt append(a,b)}] Appends the list {\tt b} to the list {\tt a}, resulting in a single
651
635
   list.
652
 
   \item[{\tt BATCH(A)}] Loads and runs a BATCH program with filename {\tt A}.
653
 
   \item[{\tt COEFF(A,B,C)}] Gives the coefficient of {\tt B} raised to the power {\tt C} in
654
 
   expression {\tt A}.
655
 
   \item[{\tt CONCAT(A,B)}] Creates the symbol {\tt AB}.
656
 
   \item[{\tt CONS(A,B)}] Adds {\tt A} to the list {\tt B} as its first element.
657
 
   \item[{\tt DEMOIVRE(A)}] Transforms all complex exponentials in {\tt A} to their trigonometric
 
636
   \item[{\tt batch(a)}] Loads and runs a program with filename {\tt a}.
 
637
   \item[{\tt coeff(a,b,c)}] Gives the coefficient of {\tt b} raised to the power {\tt c} in
 
638
   expression {\tt a}.
 
639
   \item[{\tt concat(a,b)}] Creates the symbol {\tt ab}.
 
640
   \item[{\tt cons(a,b)}] Adds {\tt a} to the list {\tt b} as its first element.
 
641
   \item[{\tt demoivre(a)}] Transforms all complex exponentials in {\tt a} to their trigonometric
658
642
   equivalents. 
659
 
   \item[{\tt DENOM(A)}] Gives the denominator of {\tt A}.
660
 
   \item[{\tt DEPENDS(A,B)}] Declares {\tt A} to be a function of {\tt B}.  This is useful for
 
643
   \item[{\tt denom(a)}] Gives the denominator of {\tt a}.
 
644
   \item[{\tt depends(a,b)}] Declares {\tt a} to be a function of {\tt b}.  This is useful for
661
645
   writing unevaluated derivatives, as in specifying differential equations.
662
 
   \item[{\tt DESOLVE(A,B)}] Attempts to solve a linear system {\tt A} of ODE's for unknowns {\tt B}
 
646
   \item[{\tt desolve(a,b)}] Attempts to solve a linear system {\tt a} of ODE's for unknowns {\tt b}
663
647
   using Laplace transforms.
664
 
   \item[{\tt DETERMINANT(A)}] Returns the determinant of the square matrix {\tt A}.
665
 
   \item[{\tt DIFF(A,B1,C1,B2,C2,\ldots,Bn,Cn)}] Gives the mixed partial derivative of {\tt A} with
666
 
   respect to each {\tt Bi}, {\tt Ci} times.  For brevity, {\tt DIFF(A,B,1)} may be represented by
667
 
   {\tt DIFF(A,B)}.  {\tt 'DIFF(\ldots)} represents the unevaluated derivative, useful in specifying
 
648
   \item[{\tt determinant(a)}] Returns the determinant of the square matrix {\tt a}.
 
649
   \item[{\tt diff(a,b1,c1,b2,c2,\ldots,bn,cn)}] Gives the mixed partial derivative of {\tt a} with
 
650
   respect to each {\tt bi}, {\tt ci} times.  For brevity, {\tt diff(a,b,1)} may be represented by
 
651
   {\tt diff(a,b)}.  {\tt 'diff(\ldots)} represents the unevaluated derivative, useful in specifying
668
652
   a differential equation.
669
 
   \item[{\tt EIGENVALUES(A)}] Returns two lists, the first being the eigenvalues of the square
670
 
   matrix {\tt A}, and the second being their respective multiplicities.
671
 
   \item[{\tt EIGENVECTORS(A)}] Does everything that {\tt EIGENVALUES} does, and adds a list of the
672
 
   eigenvectors of {\tt A}.
673
 
   \item[{\tt ENTERMATRIX(A,B)}] Cues the user to enter an $\mathtt{A} \times\, \mathtt{B}$ matrix,
 
653
   \item[{\tt eigenvalues(a)}] Returns two lists, the first being the eigenvalues of the square
 
654
   matrix {\tt a}, and the second being their respective multiplicities.
 
655
   \item[{\tt eigenvectors(a)}] Does everything that {\tt eigenvalues} does, and adds a list of the
 
656
   eigenvectors of {\tt a}.
 
657
   \item[{\tt entermatrix(a,b)}] Cues the user to enter an $\mathtt{a} \times\, \mathtt{b}$ matrix,
674
658
   element by element.
675
 
   \item[{\tt EV(A,B1,B2,\ldots,Bn)}] Evaluates {\tt A} subject to the conditions {\tt Bi}.  In
676
 
   particular the {\tt Bi} may be equations, lists of equations (such as that returned by {\tt
677
 
   SOLVE}), or assignments, in which cases {\tt EV} ``plugs'' the {\tt Bi} into {\tt A}.  The {\tt
678
 
   Bi} may also be words such as {\tt NUMER} (in which case the result is returned in numerical
679
 
   format), {\tt DETOUT} (in which case any matrix inverses in {\tt A} are performed with the
680
 
   determinant factored out), or {\tt DIFF} (in which case all differentiations in {\tt A} are
681
 
   evaluated, i.e., {\tt 'DIFF} in {\tt A} is replaced by {\tt DIFF}).  For brevity in a manual
682
 
   command (i.e., not inside a user-defined function), the {\tt EV} may be dropped, shortening the
683
 
   syntax to {\tt A,B1,B2,\ldots,Bn}.
684
 
   \item[{\tt EXPAND(A)}] Algebraically expands {\tt A}.  In particular multiplication is
 
659
   \item[{\tt ev(a,b1,b2,\ldots,bn)}] Evaluates {\tt a} subject to the conditions {\tt bi}.  In
 
660
   particular the {\tt bi} may be equations, lists of equations (such as that returned by {\tt
 
661
   solve}), or assignments, in which cases {\tt ev} ``plugs'' the {\tt bi} into {\tt a}.  The {\tt
 
662
   Bi} may also be words such as {\tt numer} (in which case the result is returned in numerical
 
663
   format), {\tt detout} (in which case any matrix inverses in {\tt a} are performed with the
 
664
   determinant factored out), or {\tt diff} (in which case all differentiations in {\tt a} are
 
665
   evaluated, i.e., {\tt 'diff} in {\tt a} is replaced by {\tt diff}).  For brevity in a manual
 
666
   command (i.e., not inside a user-defined function), the {\tt ev} may be dropped, shortening the
 
667
   syntax to {\tt a,b1,b2,\ldots,bn}.
 
668
   \item[{\tt expand(a)}] Algebraically expands {\tt a}.  In particular multiplication is
685
669
   distributed over addition.
686
 
   \item[{\tt EXPONENTIALIZE(A)}] Transforms all trigonometric functions in {\tt A} to their complex
 
670
   \item[{\tt exponentialize(a)}] Transforms all trigonometric functions in {\tt a} to their complex
687
671
   exponential equivalents.
688
 
   \item[{\tt FACTOR(A)}] Factors {\tt A}.
689
 
   \item[{\tt FREEOF(A,B)}] Is true if the variable {\tt A} is not part of the expression {\tt B}.
690
 
   \item[{\tt GRIND(A)}] Displays a variable or function {\tt A} in a compact format.  When used
691
 
   with {\tt WRITEFILE} and an editor outside of MAXIMA, it offers a scheme for producing {\tt
692
 
   BATCH} files which include MAXIMA-generated expressions.
693
 
   \item[{\tt IDENT(A)}] Returns an $\mathtt{A} \times\, \mathtt{A}$ identity matrix.
694
 
   \item[{\tt IMAGPART(A)}] Returns the imaginary part of {\tt A}.
695
 
   \item[{\tt INTEGRATE(A,B)}] Attempts to find the indefinite integral of {\tt A} with respect to
696
 
   {\tt B}.
697
 
   \item[{\tt INTEGRATE(A,B,C,D)}] Attempts to find the indefinite integral of {\tt A} with respect to
698
 
   {\tt B}. taken from $\mathtt{B=C}$ to $\mathtt{B=D}$.  The limits of integration {\tt C} and {\tt
699
 
   D} may be taken is {\tt INF} (positive infinity) of {\tt MINF} (negative infinity).
700
 
   \item[{\tt INVERT(A)}] Computes the inverse of the square matrix {\tt A}.
701
 
   \item[{\tt KILL(A)}] Removes the variable {\tt A} with all its assignments and properties from
702
 
   the current MAXIMA environment.
703
 
   \item[{\tt LIMIT(A,B,C)}] Gives the limit of expression {\tt A} as variable {\tt B} approaches
704
 
   the value {\tt C}.  The latter may be taken as {\tt INF} of {\tt MINF} as in {\tt INTEGRATE}.
705
 
   \item[{\tt LHS(A)}] Gives the left-hand side of the equation {\tt A}.
706
 
   \item[{\tt LOADFILE(A)}] Loads a disk file with filename {\tt A} from the current default
707
 
   directory.  The disk file must be in the proper format (i.e. created by a {\tt SAVE} command).
708
 
   \item[{\tt MAKELIST(A,B,C,D)}] Creates a list of {\tt A}'s (each of which presumably depends on
709
 
   {\tt B}), concatenated from $\mathtt{B=C}$ to $\mathtt{B=D}$
710
 
   \item[{\tt MAP(A,B)}] Maps the function {\tt A} onto the subexpressions of {\tt B}.
711
 
   \item[{\tt MATRIX(A1,A2,\ldots,An)}] Creates a matrix consisting of the rows {\tt Ai}, where each
712
 
   row {\tt Ai} is a list of {\tt m} elements, {\tt [B1, B2, \ldots, Bm]}.
713
 
   \item[{\tt NUM(A)}] Gives the numerator of {\tt A}.
714
 
   \item[{\tt ODE2(A,B,C)}] Attempts to solve the first- or second-order ordinary differential
715
 
   equation {\tt A} for {\tt B} as a function of {\tt C}.
716
 
   \item[{\tt PART(A,B1,B2,\ldots,Bn)}] First takes the {\tt B1}th part of {\tt A}, then the {\tt
 
672
   \item[{\tt factor(a)}] Factors {\tt a}.
 
673
   \item[{\tt freeof(a,b)}] Is true if the variable {\tt a} is not part of the expression {\tt b}.
 
674
   \item[{\tt grind(a)}] Displays a variable or function {\tt a} in a compact format.  When used
 
675
   with {\tt writefile} and an editor outside of Maxima, it offers a scheme for producing {\tt
 
676
   batch} files which include Maxima-generated expressions.
 
677
   \item[{\tt ident(a)}] Returns an $\mathtt{a} \times\, \mathtt{a}$ identity matrix.
 
678
   \item[{\tt imagpart(a)}] Returns the imaginary part of {\tt a}.
 
679
   \item[{\tt integrate(a,b)}] Attempts to find the indefinite integral of {\tt a} with respect to
 
680
   {\tt b}.
 
681
   \item[{\tt integrate(a,b,c,d)}] Attempts to find the indefinite integral of {\tt a} with respect to
 
682
   {\tt b}. taken from $\mathtt{b=c}$ to $\mathtt{b=d}$.  The limits of integration {\tt c} and {\tt
 
683
   D} may be taken is {\tt inf} (positive infinity) of {\tt minf} (negative infinity).
 
684
   \item[{\tt invert(a)}] Computes the inverse of the square matrix {\tt a}.
 
685
   \item[{\tt kill(a)}] Removes the variable {\tt a} with all its assignments and properties from
 
686
   the current Maxima environment.
 
687
   \item[{\tt limit(a,b,c)}] Gives the limit of expression {\tt a} as variable {\tt b} approaches
 
688
   the value {\tt c}.  The latter may be taken as {\tt inf} of {\tt minf} as in {\tt integrate}.
 
689
   \item[{\tt lhs(a)}] Gives the left-hand side of the equation {\tt a}.
 
690
   \item[{\tt loadfile(a)}] Loads a disk file with filename {\tt a} from the current default
 
691
   directory.  The disk file must be in the proper format (i.e. created by a {\tt save} command).
 
692
   \item[{\tt makelist(a,b,c,d)}] Creates a list of {\tt a}'s (each of which presumably depends on
 
693
   {\tt b}), concatenated from $\mathtt{b=c}$ to $\mathtt{b=d}$
 
694
   \item[{\tt map(a,b)}] Maps the function {\tt a} onto the subexpressions of {\tt b}.
 
695
   \item[{\tt matrix(a1,a2,\ldots,an)}] Creates a matrix consisting of the rows {\tt ai}, where each
 
696
   row {\tt ai} is a list of {\tt m} elements, {\tt [b1, b2, \ldots, bm]}.
 
697
   \item[{\tt num(a)}] Gives the numerator of {\tt a}.
 
698
   \item[{\tt ode2(a,b,c)}] Attempts to solve the first- or second-order ordinary differential
 
699
   equation {\tt a} for {\tt b} as a function of {\tt c}.
 
700
   \item[{\tt part(a,b1,b2,\ldots,bn)}] First takes the {\tt b1}th part of {\tt a}, then the {\tt
717
701
   B2}th part of that, and so on.
718
 
   \item[{\tt PLAYBACK(A)}] Displays the last {\tt A} (an integer) labels and their associated
719
 
   expressions.  If {\tt A} is omitted, all lines are played back.  See the Manual for other
 
702
   \item[{\tt playback(a)}] Displays the last {\tt a} (an integer) labels and their associated
 
703
   expressions.  If {\tt a} is omitted, all lines are played back.  See the Manual for other
720
704
   options.
721
 
   \item[{\tt RATSIMP(A)}] Simplifies {\tt A} and returns a quotient of two polynomials.
722
 
   \item[{\tt REALPART(A)}] Returns the real part of {\tt A}.
723
 
   \item[{\tt RHS(A)}] Gives the right-hand side of the equation {\tt A}.
724
 
   \item[{\tt SAVE(A,B1,B2,\ldots, Bn)}] Creates a disk file with filename {\tt A} in the current
725
 
   default directory, of variables, functions, or arrays {\tt Bi}.  The format of the file permits
726
 
   it to be reloaded into MAXIMA using the {\tt LOADFILE} command.  Everything (including labels)
727
 
   may be {\tt SAVE}d by taking {\tt B1} equal to {\tt ALL}.
728
 
   \item[{\tt SOLVE(A,B)}] Attempts to solve the algebraic equation {\tt A} for the unknown {\tt B}.  A
729
 
   list of solution equations is returned.  For brevity, if {\tt A} is an equation of the form
730
 
   $\mathtt{C = 0}$, it may be abbreviated simply by the expression {\tt C}.
731
 
   \item[{\tt STRING(A)}] Converts {\tt A} to MACSYMA's linear notation (similar to FORTRAN's) just as if
732
 
   it had been typed in and puts {\tt A} into the
733
 
    buffer for possible editing.  The STRING'ed expression should not be used in a computation. 
734
 
   \item[{\tt STRINGOUT(A,B1,B2,\ldots,Bn)}] Creates a disk file with filename {\tt A} in the current
735
 
   default directory, of variables (e.g. labels) {\tt Bi}.  The file is in a text format and is not
736
 
   reloadable into MAXIMA. However the strungout expressions can be incorporated into a FORTRAN,
737
 
   BASIC or C program with a minimum of editing.
738
 
   \item[{\tt SUBST(A,B,C)}] Substitutes {\tt A} for {\tt B} in {\tt C}.
739
 
   \item[{\tt TAYLOR(A,B,C,D)}] Expands {\tt A} in a Taylor series in {\tt B} about $\mathtt{B=C}$,
740
 
   up to and including the term $\mathtt{(B-C)^D}$.  MAXIMA also supports Taylor expansions in more
 
705
   \item[{\tt ratsimp(a)}] Simplifies {\tt a} and returns a quotient of two polynomials.
 
706
   \item[{\tt realpart(a)}] Returns the real part of {\tt a}.
 
707
   \item[{\tt rhs(a)}] Gives the right-hand side of the equation {\tt a}.
 
708
   \item[{\tt save(a,b1,b2,\ldots, bn)}] Creates a disk file with filename {\tt a} in the current
 
709
   default directory, of variables, functions, or arrays {\tt bi}.  The format of the file permits
 
710
   it to be reloaded into Maxima using the {\tt loadfile} command.  Everything (including labels)
 
711
   may be {\tt save}d by taking {\tt b1} equal to {\tt all}.
 
712
   \item[{\tt solve(a,b)}] Attempts to solve the algebraic equation {\tt a} for the unknown {\tt b}.  A
 
713
   list of solution equations is returned.  For brevity, if {\tt a} is an equation of the form
 
714
   $\mathtt{c = 0}$, it may be abbreviated simply by the expression {\tt c}.
 
715
   \item[{\tt string(a)}] Converts {\tt a} to Maxima's linear notation (similar to Fortran's) just as if
 
716
   it had been typed in and puts {\tt a} into the
 
717
    buffer for possible editing.  The {\tt string}'ed expression should not be used in a computation. 
 
718
   \item[{\tt stringout(a,b1,b2,\ldots,bn)}] Creates a disk file with filename {\tt a} in the current
 
719
   default directory, of variables (e.g. labels) {\tt bi}.  The file is in a text format and is not
 
720
   reloadable into Maxima. However the strungout expressions can be incorporated into a Fortran,
 
721
   Basic or C program with a minimum of editing.
 
722
   \item[{\tt subst(a,b,c)}] Substitutes {\tt a} for {\tt b} in {\tt c}.
 
723
   \item[{\tt taylor(a,b,c,d)}] Expands {\tt a} in a Taylor series in {\tt b} about $\mathtt{b=c}$,
 
724
   up to and including the term $\mathtt{(b-c)^d}$.  Maxima also supports Taylor expansions in more
741
725
   than one independent variable; see the Manual for details.
742
 
   \item[{\tt TRANSPOSE(A)}] Gives the transpose of the matrix {\tt A}.
743
 
   \item[{\tt TRIGEXPAND(A)}] Is a trig simplification function which uses the sum-of-angles
744
 
   formulas to simplify the arguments of individual {\tt SIN}'s or {\tt COS}'s.  For example, 
745
 
   {\tt trigexpand(sin(x+y))} gives {\tt COS(x) SIN(y) + SIN(x) COS(y)}.
746
 
   \item[{\tt TRIGREDUCE(A)}] Is a trig simplification function which uses trig identities to
747
 
   convert products and powers of {\tt SIN} and {\tt COS} into a sum of terms, each of which
748
 
   contains only a single {\tt SIN} or {\tt COS}.  For example, \verb+trigreduce(sin(x)^2)+ gives
749
 
   {\tt (1 - COS(2x))/2}.
750
 
   \item[{\tt TRIGSIMP(A)}] Is a trig simplification function which replaces {\tt TAN}, {\tt SEC},
751
 
   etc., by their {\tt SIN} and {\tt COS} equivalents.  It also uses the identity 
752
 
   $\mathtt{SIN()^2 +   COS()^2 = 1}$.
 
726
   \item[{\tt transpose(a)}] Gives the transpose of the matrix {\tt a}.
 
727
   \item[{\tt trigexpand(a)}] Is a trig simplification function which uses the sum-of-angles
 
728
   formulas to simplify the arguments of individual {\tt sin}'s or {\tt cos}'s.  For example, 
 
729
   {\tt trigexpand(sin(x+y))} gives {\tt cos(x) sin(y) + sin(x) cos(y)}.
 
730
   \item[{\tt trigreduce(a)}] Is a trig simplification function which uses trig identities to
 
731
   convert products and powers of {\tt sin} and {\tt cos} into a sum of terms, each of which
 
732
   contains only a single {\tt sin} or {\tt cos}.  For example, \verb+trigreduce(sin(x)^2)+ gives
 
733
   {\tt (1 - cos(2x))/2}.
 
734
   \item[{\tt trigsimp(a)}] Is a trig simplification function which replaces {\tt tan}, {\tt sec},
 
735
   etc., by their {\tt sin} and {\tt cos} equivalents.  It also uses the identity 
 
736
   $\mathtt{sin()^2 +   cos()^2 = 1}$.
753
737
\end{description}
754
738
 
755
739