34
35
\section{Introduction \label{sec:introduction}}
36
To invoke MAXIMA in Linux, type
37
To invoke Maxima in Linux, type
42
43
The computer will display a greeting of the sort:
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)
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.
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}.
57
MAXIMA is pragmatic about lower and upper case: regardless of your typing {\tt sin(x)} or {\tt
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.)}
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}.
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.
68
67
\section{Special keys and symbols \label{sec:keys}}
71
\item To end a MAXIMA session, type {\tt quit();}. If you type \verb+^C+, here is what happens:
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.
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();}.
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.)
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:
78
% sum (1/x^2, x, 1, 10000);
91
(C1) sum(1/x^2,x,1,1000);
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.
81
(%i1) sum (1/x^2, x, 1, 10000);
83
Maxima encountered a Lisp error:
87
Automatically continuing.
88
To reenable the Lisp debugger set *debugger-hook* to nil.
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
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.
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 ??}).
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.)
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 \%}).
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.
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.
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.,
150
139
If irrational numbers are involved in a computation, they are kept in symbolic form:
143
(%i2) (1 + sqrt(2))^5;
147
(%o3) 29 sqrt(2) + 41
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}'':
165
(D4) 82.01219330881976
154
(%o4) 82.01219330881976
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:
174
(D5) 8.201219330881976B1 \end{verbatim}
175
The number of significant figures displayed is controlled by the MAXIMA variable {\tt FPPREC}, which
163
(%o5) 8.201219330881976B1
165
The number of significant figures displayed is controlled by the Maxima variable {\tt fpprec}, which
176
166
has the default value of 16:
182
Here we reset {\tt FPPREC} to yield 100 digits:
189
(D8) 8.20121933088197564152489730020812442785204843859314941221237124017312418#
191
7540110412666123849550160561B1
193
Note the use of two single quotes ({\tt ''}) in {\tt (C8)} to repeat command {\tt (C5)}. MAXIMA can
172
Here we reset {\tt fpprec} to yield 100 digits:
179
(%o8) 8.20121933088197564152489730020812442785204843859314941221#
180
2371240173124187540110412666123849550160561B1
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:
198
(D9) 9332621544394415268169923885626670049071596826438162146859296389521759999#
200
322991560894146397615651828625369792082722375825118521091686400000000000000000#
202
0000000 \end{verbatim}
187
(%o9) 9332621544394415268169923885626670049071596826438162146859#
188
2963895217599993229915608941463976156518286253697920827223758251#
189
185210916864000000000000000000000000
204
192
\section{Algebra \label{sec:algebra}}
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;
209
(C1) (x+3*y+x^2*y)^3;
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
199
(%i1) (x + 3*y + x^2*y)^3;
201
(%o1) (x y + 3 y + x)
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
206
+ 27 x y + 3 x y + 9 x y + x
221
208
Now suppose we wanted to substitute {\tt 5/z} for {\tt x} in the above expression:
223
210
\noindent\begin{minipage}{\textwidth}
228
135 y 675 y 225 y 2250 y 125 5625 y 1875 y 9375 y
229
(D3) ------ + ------ + ----- + ------- + --- + ------- + ------ + -------
215
135 y 675 y 225 y 2250 y 125 5625 y 1875 y
216
(%o3) ------ + ------ + ----- + ------- + --- + ------- + ------
221
+ ------- + -------- + 27 y
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:
245
(D4) (27 y z + 135 y z + (675 y + 225 y) z + (2250 y + 125) z
248
+ (5625 y + 1875 y) z + 9375 y z + 15625 y )/z
231
(%o4) (27 y z + 135 y z + (675 y + 225 y) z
233
+ (2250 y + 125) z + (5625 y + 1875 y) z + 9375 y z
250
237
Expressions may also be {\tt factor}ed:
256
(D5) ----------------------
243
(%o5) ----------------------
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}:
252
% solve ([%o6, %o7, %o8], [a, b, c]);
272
(C9) solve([d6,d7,d8],[a,b,c]);
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
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
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 = - ---------------]]
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.
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;
289
(C10) sin(u+v)*cos(u)^3;
292
(D10) COS (u) SIN(v + u)
296
(D11) COS (u) (COS(u) SIN(v) + SIN(u) COS(v))
280
(%i10) sin(u + v) * cos(u)^3;
282
(%o10) cos (u) sin(v + u)
283
(%i11) trigexpand (%);
285
(%o11) cos (u) (cos(u) sin(v) + sin(u) cos(v))
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}:
302
(C12) trigreduce(d10);
304
SIN(v + 4 u) + SIN(v - 2 u) 3 SIN(v + 2 u) + 3 SIN(v)
305
(D12) --------------------------- + -------------------------
291
(%i12) trigreduce (%o10);
292
sin(v + 4 u) + sin(v - 2 u) 3 sin(v + 2 u) + 3 sin(v)
293
(%o12) --------------------------- + -------------------------
308
296
The functions {\tt realpart} and {\tt imagpart} will return the real and imaginary parts of a
309
297
complex expression:
322
(D15) %E (9 - k ) COS(k) - 6 %E k SIN(k)
309
(%o15) %e (9 - k ) cos(k) - 6 %e k sin(k)
325
312
\section{Calculus \label{sec:calculus}}
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);
331
(C1) f:x^3*%E^(k*x)*sin(w*x);
319
(%i1) f: x^3 * %e^(k*x) * sin(w*x);
336
323
We compute the derivative of {\tt f} with respect to {\tt x}:
341
(D2) k x %E SIN(w x) + 3 x %E SIN(w x) + w x %E COS(w x)
328
(%o2) k x %e sin(w x) + 3 x %e sin(w x)
343
332
Now we find the indefinite integral of {\tt f} with respect to {\tt x}:
348
(D3) (((k w + 3 k w + 3 k w + k ) x
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
354
- 6 w + 36 k w - 6 k ) %E SIN(w x)
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
335
(%i3) integrate (f, x);
337
(%o3) (((k w + 3 k w + 3 k w + k ) x
339
+ (3 w + 3 k w - 3 k w - 3 k ) x
341
+ (- 18 k w - 12 k w + 6 k ) x - 6 w + 36 k w - 6 k )
343
%e sin(w x) + ((- w - 3 k w - 3 k w - k w) x
345
+ (6 k w + 12 k w + 6 k w) x
360
+ (6 w - 12 k w - 18 k w) x - 24 k w + 24 k w) %E COS(w x))
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
349
cos(w x))/(w + 4 k w + 6 k w + 4 k w + k )
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);
367
(C4) integrate(1/x^2,x,1,inf);
370
(C5) integrate(1/x,x,0,inf);
355
(%i4) integrate (1/x^2, x, 1, inf);
357
(%i5) integrate (1/x, x, 0, inf);
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);
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}:
379
366
\noindent\begin{minipage}{\textwidth}
367
% g: f / sinh(k*x)^4;
368
% taylor (g, x, 0, 3);
381
(C6) g:f/sinh(k*x)^4;
385
(D6) -----------------
388
(C7) taylor(g,x,0,3);
391
w w x (w k + w ) x (3 w k + w ) x
392
(D7)/T/ -- + --- - -------------- - ---------------- + . . .
370
(%i6) g: f / sinh(k*x)^4;
373
(%o6) -----------------
376
(%i7) taylor (g, x, 0, 3);
378
w w x (w k + w ) x (3 w k + w ) x
379
(%o7)/T/ -- + --- - -------------- - ---------------- + . . .
397
384
The limit of {\tt g} as {\tt x} goes to 0 is computed as follows:
405
MAXIMA also permits derivatives to be represented in unevaluated form (note the quote):
413
The quote operator in {\tt (C9)} means ``do not evaluate''. Without it, MAXIMA would have obtained
387
(%i8) limit (g, x, 0);
393
Maxima also permits derivatives to be represented in unevaluated form (note the quote):
401
The quote operator in {\tt (\%i9)} means ``do not evaluate''. Without it, Maxima would have obtained
420
408
Using the quote operator we can write differential equations:
409
% 'diff (y, x, 2) + 'diff (y, x) + y;
422
(C11) 'diff(y,x,2) + 'diff(y,x) + y;
411
(%i11) 'diff (y, x, 2) + 'diff (y, x) + y;
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:
434
- x/2 SQRT(3) x SQRT(3) x
435
(D12) y = %E (%K1 SIN(---------) + %K2 COS(---------))
421
(%i12) ode2 (%o11, y, x);
422
- x/2 sqrt(3) x sqrt(3) x
423
(%o12) y = %e (%k1 sin(---------) + %k2 cos(---------))
441
429
\section{Matrix calculations \label{sec:matrix}}
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);
447
(C1) m:entermatrix(3,3);
436
(%i1) m: entermatrix (3, 3);
450
438
Is the matrix 1. Diagonal 2. Symmetric 3. Antisymmetric 4. General
451
Answer 1, 2, 3 or 4 : 4;
439
Answer 1, 2, 3 or 4 :
469
467
Next we find its transpose, determinant and inverse:
481
(C4) invert(m),detout;
470
% invert (m), detout;
478
(%i3) determinant (m);
480
(%i4) invert (m), detout;
486
(%o4) -----------------
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):
488
(D4) -----------------
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):
501
(D5) [ 1 0 1 ] . -----------------
507
[ ----- + ----- 0 0 ]
511
(D6) [ 0 ----- + ----- 0 ]
515
[ 0 0 ----- + ----- ]
501
(%o5) [ 1 0 1 ] . -----------------
506
[ ----- + ----- 0 0 ]
510
(%o6) [ 0 ----- + ----- 0 ]
514
[ 0 0 ----- + ----- ]
525
523
In order to find the eigenvalues and eigenvectors of {\tt m}, we use the function {\tt
528
526
\noindent\begin{minipage}{\textwidth}
530
(C8) eigenvectors(m);
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]],
538
SQRT(4 a + 5) - 1 SQRT(4 a + 5) - 1
539
[1, - -----------------, - -----------------],
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],
533
sqrt(4 a + 5) - 1 sqrt(4 a + 5) - 1
534
[1, 1, 1]], [1, - -----------------, - -----------------],
536
sqrt(4 a + 5) + 1 sqrt(4 a + 5) + 1
543
537
[1, -----------------, -----------------], [1, - 1, 0]]
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:
553
SQRT(4 a + 5) - 1 SQRT(4 a + 5) - 1
554
(D9) [1, - -----------------, - -----------------]
547
sqrt(4 a + 5) - 1 sqrt(4 a + 5) - 1
548
(%o9) [1, - -----------------, - -----------------]
559
\section{Programming in MAXIMA \label{sec:programming}}
553
\section{Programming in Maxima \label{sec:programming}}
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
570
564
/* --------------------------------------------------------------------------
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");
607
(C1) batch("critpts.max");
610
batching #/home/nldias/work/papers2000/intromax/critpts.max
612
(C2) critpts() := (PRINT("program to find critical points"),
614
f : READ("enter f(x,y)"), PRINT("f = ", f), eqs : [DIFF(f, x), DIFF(f, y)],
616
unk : [x, y], SOLVE(eqs, unk))
619
program to find critical points
603
(%i1) batch ("critpts.max");
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))
610
program to find critical points
612
%e^(x^3 + y^2)*(x + y);
625
(D3) [[x = 0.4588955685487 %I + 0.35897908710869,
627
y = 0.49420173682751 %I - 0.12257873677837],
629
[x = 0.35897908710869 - 0.4588955685487 %I,
631
y = - 0.49420173682751 %I - 0.12257873677837],
633
[x = 0.41875423272348 %I - 0.69231242044203,
635
y = 0.4559120701117 - 0.86972626928141 %I],
637
[x = - 0.41875423272348 %I - 0.69231242044203,
639
y = 0.86972626928141 %I + 0.4559120701117]]
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]]
642
\section{A partial list of MAXIMA functions}
626
\section{A partial list of Maxima functions}
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})}.
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
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
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
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
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
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
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
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}