1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN"
2 "http://www.w3.org/TR/REC-html40/loose.dtd">
4 <meta name=
"GENERATOR" content=
"TtH 3.85">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8">
6 <style type=
"text/css"> div
.p
{ margin-top: 7pt;}</style>
7 <style type=
"text/css"><!--
8 td div
.comp
{ margin-top: -0.6ex; margin-bottom: -1ex;}
9 td div
.comb
{ margin-top: -0.6ex; margin-bottom: -.6ex;}
10 td div
.hrcomp
{ line-height: 0.9; margin-top: -0.8ex; margin-bottom: -1ex;}
11 td div
.norm
{line-height:normal
;}
14 border: 1px solid gray
;
19 background-color: #F1F5F9; /* light blue-gray */
21 span
.roman
{font-family: serif
; font-style: normal
; font-weight: normal
;}
22 span
.overacc2
{position: relative
; left: .8em; top: -1.2ex;}
23 span
.overacc1
{position: relative
; left: .6em; top: -1.2ex;} --></style>
27 <title> Introduction to Maxima
</title>
29 <h1 align=
"center">Introduction to Maxima
</h1>
31 <h3 align=
"center">Richard H. Rand
<br />
32 Dept. of Theoretical and Applied Mechanics, Cornell University
33 <a href=
"#tthFtNtAAB" name=
"tthFrefAAB"><sup>1</sup></a> </h3>
35 <h3 align=
"center"> </h3>
37 <div class=
"p"><!----></div>
38 Copyright (c)
1988-
2010 Richard H. Rand.
40 <div class=
"p"><!----></div>
41 This document is free; you can redistribute it and/or modify it under
42 the terms of the GNU General Public License as published by the Free
43 Software Foundation. See the GNU General Public License for more
44 details at http://www.gnu.org/copyleft/gpl.html
46 <div class=
"p"><!----></div>
48 <h1>Contents
</h1><a href=
"#tth_sEc1"
49 >1 Introduction
</a><br />
51 >2 Special keys and symbols
</a><br />
53 >3 Arithmetic
</a><br />
55 >4 Algebra
</a><br />
57 >5 Calculus
</a><br />
59 >6 Matrix calculations
</a><br />
61 >7 Programming in Maxima
</a><br />
63 >8 A partial list of Maxima functions
</a><br />
66 <div class=
"p"><!----></div>
67 <h2><a name=
"tth_sEc1">
68 1</a> Introduction
<a name=
"sec:introduction">
71 <div class=
"p"><!----></div>
72 To invoke Maxima in a console, type
75 maxima
<enter
>
79 <div class=
"p"><!----></div>
80 The computer will display a greeting of the sort:
83 Distributed
under
the
GNU
Public
License.
See
the
file
COPYING.
84 Dedicated
to
the
memory
of
William
Schelter.
85 This
is
a
development
version
of
Maxima.
The
function
bug_report()
86 provides
bug
reporting
information.
91 <div class=
"p"><!----></div>
92 The
<tt>(%i1)
</tt> is a
"label". Each input or output line is
93 labelled and can be referred to by its own label for the rest of the
94 session.
<tt>i
</tt> labels denote your commands and
<tt>o
</tt> labels
95 denote displays of the machine's response.
<em>Never use variable
96 names like
<tt>%i1
</tt> or
<tt>%o5
</tt>, as these will be confused with
97 the lines so labeled
</em>.
99 <div class=
"p"><!----></div>
100 Maxima distinguishes lower and upper case. All built-in functions
101 have names which are lowercase only (
<tt>sin
</tt>,
<tt>cos
</tt>,
<tt>save
</tt>,
102 <tt>load
</tt>, etc). Built-in constants have lowercase names (
<tt>%e
</tt>,
103 <tt>%pi
</tt>,
<tt>inf
</tt>, etc). If you type
<tt>SIN(x)
</tt> or
<tt>
104 Sin(x)
</tt>, Maxima assumes you mean something other than the built-in
105 <tt>sin
</tt> function. User-defined functions and variables can have
106 names which are lower or upper case or both.
<tt>foo(XY)
</tt>,
<tt>
107 Foo(Xy)
</tt>,
<tt>FOO(xy)
</tt> are all different.
109 <div class=
"p"><!----></div>
110 <h2><a name=
"tth_sEc2">
111 2</a> Special keys and symbols
<a name=
"sec:keys">
114 <div class=
"p"><!----></div>
117 <li> To end a Maxima session, type
<tt>quit();
</tt>.
118 <div class=
"p"><!----></div>
121 <li> To abort a computation without leaving Maxima, type
<tt>^C
</tt>.
122 (Here
<tt>^
</tt> stands for the control key, so
123 that
<tt>^C
</tt> means first press the key marked control and hold it down while pressing the C key.)
124 It is important for you to
125 know how to do this in case, for example, you begin a computation which is taking too long.
129 (%i1)
sum
(
1/x^
2,
x,
1,
100000)$
131 Maxima
encountered
a
Lisp
error:
133 Interactive
interrupt
at
#x7FFFF74A43C3.
135 Automatically
continuing.
136 To
enable
the
Lisp
debugger
set
*debugger-hook*
to
nil.
140 <div class=
"p"><!----></div>
143 <li> In order to tell Maxima that you have finished your command, use
144 the semicolon (
<tt>;
</tt>), followed by a return. Note that the return
145 key alone does not signal that you are done with your input.
146 <div class=
"p"><!----></div>
149 <li> An alternative input terminator to the semicolon (
<tt>;
</tt>) is
150 the dollar sign (
<tt>$
</tt>), which, however, supresses the display of
151 Maxima's computation. This is useful if you are computing some long
152 intermediate result, and you don't want to waste time having it
153 displayed on the screen.
154 <div class=
"p"><!----></div>
157 <li> If you wish to repeat a command which you have already given,
158 say on line
<tt>(%i5)
</tt>, you may do so without typing it over again
159 by preceding its label with two single quotes (
<tt>"</tt>), i.e., <tt>
160 "%i5
</tt>. (Note that simply inputing
<tt>%i5
</tt> will not do the job
162 <div class=
"p"><!----></div>
165 <li> If you want to refer to the immediately preceding result
166 computed by Maxima, you can either use its
<tt>o
</tt> label, or you can
167 use the special symbol percent (
<tt>%
</tt>).
168 <div class=
"p"><!----></div>
171 <li> The standard quantities e (natural log base), i (square root
172 of
<font face=
"symbol">-
</font
173 >1) and
<font face=
"symbol">p
</font
174 > (
3.14159<font face=
"symbol">¼
</font
175 >) are respectively referred to as
176 <tt>%e
</tt>,
<tt>%i
</tt>,
177 and
<tt>%pi
</tt>. Note that the use of
<tt>%
</tt> here as a prefix
178 is completely unrelated to the use of
<tt>%
</tt> to refer to the
179 preceding result computed.
180 <div class=
"p"><!----></div>
183 <li> In order to assign a value to a variable, Maxima uses the colon
184 (
<tt>:
</tt>), not the equal sign. The equal sign is used for
185 representing equations.
186 <div class=
"p"><!----></div>
190 <div class=
"p"><!----></div>
191 <h2><a name=
"tth_sEc3">
192 3</a> Arithmetic
<a name=
"sec:arithmetic">
195 <div class=
"p"><!----></div>
196 The common arithmetic operations are
198 <dl compact=
"compact">
199 <dt><b><tt>+
</tt></b></dt>
201 <dt><b><tt>-
</tt></b></dt>
202 <dd> subtraction
</dd>
203 <dt><b><tt>*
</tt></b></dt>
204 <dd> scalar multiplication
</dd>
205 <dt><b><tt>/
</tt></b></dt>
207 <dt><b><tt>^
</tt></b></dt>
208 <dd> or
<tt>**
</tt> exponentiation
</dd>
209 <dt><b><tt>.
</tt></b></dt>
210 <dd> matrix multiplication
</dd>
211 <dt><b><tt>sqrt(x)
</tt></b></dt>
212 <dd> square root of
<tt>x
</tt>.
</dd>
214 Maxima's output is characterized by exact (rational) arithmetic. For example,
217 (%i1)
1/
100 +
1/
101;
218 201
219 (%o1)
-----
220 10100
223 If irrational numbers are involved in a computation, they are kept in symbolic form:
226 (%i2)
(
1 +
sqrt(
2))^
5;
227 5
228 (%o2)
(sqrt(
2)
+
1)
229 (%i3)
expand
(%);
230 7/
2
231 (%o3)
3 2 +
5 sqrt(
2)
+
41
234 However, it is often useful to express a result in decimal notation.
235 This may be accomplished by following the expression you want expanded
236 by
"<tt>,numer</tt>":
239 (%i4)
%,
numer;
240 (%o4)
82.01219330881977
243 Note the use here of
<tt>%
</tt>
244 to refer to the previous result. In this version of Maxima,
<tt>
245 numer
</tt> gives
16 significant figures, of which the last is often
246 unreliable. However, Maxima can offer
<em>arbitrarily high
247 precision
</em> by using the
<tt>bfloat
</tt> function:
250 (%i5)
bfloat
(%o3);
251 (%o5)
8.201219330881976b1
254 The number of significant figures displayed is controlled by the
255 Maxima variable
<tt>fpprec
</tt>, which has the default value of
16:
259 (%o6)
16
262 Here we reset
<tt>fpprec
</tt> to yield
100 digits:
265 (%i7)
fpprec:
100;
266 (%o7)
100
268 (%o8)
8.20121933088197564152489730020812442785204843859314941221\
269 2371240173124187540110412666123849550160561b1
272 Note the use of two single quotes (
<tt>"</tt>) in <tt>(%i8)</tt> to repeat
273 command <tt>(%i5)</tt>. Maxima can handle very large numbers without
278 (%o9) 9332621544394415268169923885626670049071596826438162146859\
279 2963895217599993229915608941463976156518286253697920827223758251\
280 185210916864000000000000000000000000
284 <div class="p
"><!----></div>
285 <h2><a name="tth_sEc4
">
286 4</a> Algebra <a name="sec:algebra
">
289 <div class="p
"><!----></div>
290 Maxima's importance as a computer tool to facilitate analytical
291 calculations becomes more evident when we see how easily it does
292 algebra for us. Here's an example in which a polynomial is expanded:
295 (%i1) (x + 3*y + x^2*y)^3;
296 2 3
297 (%o1) (x y + 3 y + x)
298 (%i2) expand (%);
299 6 3 4 3 2 3 3 5 2 3 2
300 (%o2) x y + 9 x y + 27 x y + 27 y + 3 x y + 18 x y
301 2 4 2 3
302 + 27 x y + 3 x y + 9 x y + x
305 Now suppose we wanted to substitute <tt>5/z</tt> for <tt>x</tt> in the above
308 <div class="p
"><!----></div>
309 <table border="0"><tr><td></td><td><table border="0"><tr><td></td><td width="1000">
312 (%i3) %o2, x=5/z;
313 2 3 2 3
314 135 y 675 y 225 y 2250 y 125 5625 y 1875 y
315 (%o3) ------ + ------ + ----- + ------- + --- + ------- + ------
316 z 2 2 3 3 4 4
317 z z z z z z
318 2 3
319 9375 y 15625 y 3
320 + ------- + -------- + 27 y
321 5 6
322 z z
326 </td></tr></table><!--vbox-->
327 </td><td></td></tr></table><!--hboxt-->The Maxima function <tt>ratsimp</tt> will place this over a common denominator:
330 (%i4) ratsimp (%);
331 3 6 2 5 3 4
332 (%o4) (27 y z + 135 y z + (675 y + 225 y) z
333 2 3 3 2 2
334 + (2250 y + 125) z + (5625 y + 1875 y) z + 9375 y z
335 3 6
336 + 15625 y )/z
339 Expressions may also be <tt>factor</tt>ed:
342 (%i5) factor (%);
343 2 3
344 (3 y z + 5 z + 25 y)
345 (%o5) ----------------------
346 6
347 z
350 Maxima can obtain exact solutions to systems of nonlinear algebraic
351 equations. In this example we <tt>solve</tt> three equations in the
352 three unknowns <tt>a</tt>, <tt>b</tt>, <tt>c</tt>:
355 (%i6) a + b*c = 1;
356 (%o6) b c + a = 1
357 (%i7) b - a*c = 0;
358 (%o7) b - a c = 0
359 (%i8) a + b = 5;
360 (%o8) b + a = 5
361 (%i9) solve ([%o6, %o7, %o8], [a, b, c]);
362 25 sqrt(79) %i + 25 5 sqrt(79) %i + 5
363 (%o9) [[a = -------------------, b = -----------------,
364 6 sqrt(79) %i - 34 sqrt(79) %i + 11
365 sqrt(79) %i + 1 25 sqrt(79) %i - 25
366 c = ---------------], [a = -------------------,
367 10 6 sqrt(79) %i + 34
368 5 sqrt(79) %i - 5 sqrt(79) %i - 1
369 b = -----------------, c = - ---------------]]
370 sqrt(79) %i - 11 10
373 Note that the display consists of a "list
", i.e., some expression
374 contained between two brackets <tt>[ ... ]</tt>, which itself contains
375 two lists. Each of the latter contain a distinct solution to the
376 simultaneous equations.
378 <div class="p
"><!----></div>
379 Trigonometric identities are easy to manipulate in Maxima. The
380 function <tt>trigexpand</tt> uses the sum-of-angles formulas to make the
381 argument inside each trig function as simple as possible:
384 (%i10) sin(u + v) * cos(u)^3;
385 3
386 (%o10) cos (u) sin(v + u)
387 (%i11) trigexpand (%);
388 3
389 (%o11) cos (u) (cos(u) sin(v) + sin(u) cos(v))
392 The function <tt>trigreduce</tt>, on the other hand, converts an
393 expression into a form which is a sum of terms, each of which contains
394 only a single <tt>sin</tt> or <tt>cos</tt>:
397 (%i12) trigreduce (%o10);
398 sin(v + 4 u) + sin(v - 2 u) 3 sin(v + 2 u) + 3 sin(v)
399 (%o12) --------------------------- + -------------------------
400 8 8
403 The functions <tt>realpart</tt> and <tt>imagpart</tt> will return the real
404 and imaginary parts of a complex expression:
407 (%i13) w: 3 + k*%i;
408 (%o13) %i k + 3
409 (%i14) w^2 * %e^w;
410 2 %i k + 3
411 (%o14) (%i k + 3) %e
412 (%i15) realpart (%);
413 3 2 3
414 (%o15) %e (9 - k ) cos(k) - 6 %e k sin(k)
418 <div class="p
"><!----></div>
419 <h2><a name="tth_sEc5
">
420 5</a> Calculus <a name="sec:calculus
">
423 <div class="p
"><!----></div>
424 Maxima can compute derivatives and integrals, expand in Taylor series,
425 take limits, and obtain exact solutions to ordinary differential
426 equations. We begin by defining the symbol <tt>f</tt> to be the
427 following function of <tt>x</tt>:
430 (%i1) f: x^3 * %e^(k*x) * sin(w*x);
431 3 k x
432 (%o1) x %e sin(w x)
435 We compute the derivative of <tt>f</tt> with respect to <tt>x</tt>:
438 (%i2) diff (f, x);
439 3 k x 2 k x
440 (%o2) k x %e sin(w x) + 3 x %e sin(w x)
441 3 k x
442 + w x %e cos(w x)
445 Now we find the indefinite integral of <tt>f</tt> with respect to <tt>x</tt>:
448 (%i3) integrate (f, x);
449 6 3 4 5 2 7 3
450 (%o3) (((k w + 3 k w + 3 k w + k ) x
451 6 2 4 4 2 6 2
452 + (3 w + 3 k w - 3 k w - 3 k ) x
453 4 3 2 5 4 2 2 4
454 + (- 18 k w - 12 k w + 6 k ) x - 6 w + 36 k w - 6 k )
455 k x 7 2 5 4 3 6 3
456 %e sin(w x) + ((- w - 3 k w - 3 k w - k w) x
457 5 3 3 5 2
458 + (6 k w + 12 k w + 6 k w) x
459 5 2 3 4 3 3 k x
460 + (6 w - 12 k w - 18 k w) x - 24 k w + 24 k w) %e
461 8 2 6 4 4 6 2 8
462 cos(w x))/(w + 4 k w + 6 k w + 4 k w + k )
465 A slight change in syntax gives definite integrals:
468 (%i4) integrate (1/x^2, x, 1, inf);
469 (%o4) 1
470 (%i5) integrate (1/x, x, 0, inf);
472 defint: integral is divergent.
473 -- an error. To debug this try: debugmode(true);
476 Next we define the simbol <tt>g</tt> in terms of <tt>f</tt> (previously
477 defined in <tt>%i1</tt>) and the hyperbolic sine function, and find its
478 Taylor series expansion (up to, say, order 3 terms) about the point
481 <div class="p
"><!----></div>
482 <table border="0"><tr><td></td><td><table border="0"><tr><td></td><td width="1000">
485 (%i6) g: f / sinh(k*x)^4;
486 3 k x
487 x %e sin(w x)
488 (%o6) -----------------
489 4
490 sinh (k x)
491 (%i7) taylor (g, x, 0, 3);
492 2 3 2 2 3 3
493 w w x (w k + w ) x (3 w k + w ) x
494 (%o7)/T/ -- + --- - -------------- - ---------------- + . . .
495 4 3 4 3
496 k k 6 k 6 k
500 </td></tr></table><!--vbox-->
501 </td><td></td></tr></table><!--hboxt-->The limit of <tt>g</tt> as <tt>x</tt> goes to 0 is computed as follows:
504 (%i8) limit (g, x, 0);
505 w
506 (%o8) --
507 4
508 k
511 Maxima also permits derivatives to be represented in unevaluated form
515 (%i9) 'diff (y, x);
516 dy
517 (%o9) --
518 dx
521 The quote operator in <tt>(%i9)</tt> means "do not evaluate
". Without
522 it, Maxima would have obtained 0:
525 (%i10) diff (y, x);
526 (%o10) 0
529 Using the quote operator we can write differential equations:
532 (%i11) 'diff (y, x, 2) + 'diff (y, x) + y;
533 2
534 d y dy
535 (%o11) --- + -- + y
536 2 dx
537 dx
540 Maxima's <tt>ode2</tt> function can solve first and second order ODE's:
543 (%i12) ode2 (%o11, y, x);
544 - x/2 sqrt(3) x sqrt(3) x
545 (%o12) y = %e (%k1 sin(---------) + %k2 cos(---------))
546 2 2
550 <div class="p
"><!----></div>
551 <h2><a name="tth_sEc6
">
552 6</a> Matrix calculations <a name="sec:matrix
">
555 <div class="p
"><!----></div>
556 Maxima can compute the determinant, inverse and eigenvalues and
557 eigenvectors of matrices which have symbolic elements (i.e., elements
558 which involve algebraic variables.) We begin by entering a matrix <tt>
559 m</tt> element by element:
562 (%i1) m: entermatrix (3, 3);
564 Is the matrix 1. Diagonal 2. Symmetric 3. Antisymmetric 4. General
565 Answer 1, 2, 3 or 4 :
567 Row 1 Column 1:
569 Row 1 Column 2:
571 Row 1 Column 3:
573 Row 2 Column 1:
575 Row 2 Column 2:
577 Row 2 Column 3:
579 Row 3 Column 1:
581 Row 3 Column 2:
583 Row 3 Column 3:
587 [ 0 1 a ]
588 [ ]
589 (%o1) [ 1 0 1 ]
590 [ ]
591 [ 1 1 0 ]
594 Next we find its transpose, determinant and inverse:
597 (%i2) transpose (m);
598 [ 0 1 1 ]
599 [ ]
600 (%o2) [ 1 0 1 ]
601 [ ]
602 [ a 1 0 ]
603 (%i3) determinant (m);
604 (%o3) a + 1
605 (%i4) invert (m), detout;
606 [ - 1 a 1 ]
607 [ ]
608 [ 1 - a a ]
609 [ ]
610 [ 1 1 - 1 ]
611 (%o4) -----------------
612 a + 1
615 In <tt>(%i4)</tt>, the modifier <tt>detout</tt> keeps the determinant
616 outside the inverse. As a check, we multiply <tt>m</tt> by its inverse
617 (note the use of the period to represent matrix multiplication):
620 (%i5) m . %o4;
621 [ - 1 a 1 ]
622 [ ]
623 [ 1 - a a ]
624 [ 0 1 a ] [ ]
625 [ ] [ 1 1 - 1 ]
626 (%o5) [ 1 0 1 ] . -----------------
627 [ ] a + 1
628 [ 1 1 0 ]
629 (%i6) expand (%);
630 [ a 1 ]
631 [ ----- + ----- 0 0 ]
632 [ a + 1 a + 1 ]
633 [ ]
634 [ a 1 ]
635 (%o6) [ 0 ----- + ----- 0 ]
636 [ a + 1 a + 1 ]
637 [ ]
638 [ a 1 ]
639 [ 0 0 ----- + ----- ]
640 [ a + 1 a + 1 ]
641 (%i7) factor (%);
642 [ 1 0 0 ]
643 [ ]
644 (%o7) [ 0 1 0 ]
645 [ ]
646 [ 0 0 1 ]
649 In order to find the eigenvalues and eigenvectors of <tt>m</tt>, we use the function <tt>
652 <div class="p
"><!----></div>
653 <table border="0"><tr><td></td><td><table border="0"><tr><td></td><td width="1000">
656 (%i8) eigenvectors (m);
657 sqrt(4 a + 5) - 1 sqrt(4 a + 5) + 1
658 (%o8) [[[- -----------------, -----------------, - 1],
659 2 2
660 sqrt(4 a + 5) - 1 sqrt(4 a + 5) - 1
661 [1, 1, 1]], [[[1, - -----------------, - -----------------]],
662 2 a + 2 2 a + 2
663 sqrt(4 a + 5) + 1 sqrt(4 a + 5) + 1
664 [[1, -----------------, -----------------]], [[1, - 1, 0]]]]
665 2 a + 2 2 a + 2
668 In <tt>%o8</tt>, the first triple gives the eigenvalues of <tt>m</tt> and
669 the next gives their respective multiplicities (here each is
670 unrepeated). The next three triples give the corresponding
671 eigenvectors of <tt>m</tt>. In order to extract from this expression
672 one of these eigenvectors, we may use the <tt>part</tt> function:
675 (%i9) part (%o23, 2, 1, 1);
676 sqrt(4 a + 5) - 1 sqrt(4 a + 5) - 1
677 (%o9) [1, - -----------------, - -----------------]
678 2 a + 2 2 a + 2
682 </td></tr></table><!--vbox-->
683 </td><td></td></tr></table><!--hboxt--> <h2><a name="tth_sEc7
">
684 7</a> Programming in Maxima <a name="sec:programming
">
687 <div class="p
"><!----></div>
688 So far, we have used Maxima in the interactive mode, rather like a
689 calculator. However, for computations which involve a repetitive
690 sequence of commands, it is better to execute a program. Here we
691 present a short sample program to calculate the critical points of a
692 function <tt>f</tt> of two variables <tt>x</tt> and <tt>y</tt>. The program
693 cues the user to enter the function <tt>f</tt>, then it computes the
694 partial derivatives <tt>f</tt><sub><tt>x</tt></sub> and <tt>f</tt><sub><tt>y</tt></sub>, and then it
695 uses the Maxima command <tt>solve</tt> to obtain solutions to
696 <tt>f</tt><sub><tt>x</tt></sub><tt> = </tt><tt>f</tt><sub><tt>y</tt></sub><tt> = </tt><tt>0</tt>. The program is written outside of Maxima
697 with a text editor, and then loaded into Maxima with the <tt>batch</tt>
698 command. Here is the program listing:
701 /* --------------------------------------------------------------------------
702 this is file critpts.max:
703 as you can see, comments in maxima are like comments in C
705 Nelson Luis Dias, nldias@simepar.br
706 created 20000707
707 updated 20000707
708 --------------------------------------------------------------------------- */
710 print("program
to
find
critical
points
"),
711 /* ---------------------------------------------------------------------------
712 asks for a function
713 --------------------------------------------------------------------------- */
714 f:read("enter
f(x,y)
"),
715 /* ---------------------------------------------------------------------------
716 echoes it, to make sure
717 --------------------------------------------------------------------------- */
718 print("f
=
",f),
719 /* ---------------------------------------------------------------------------
720 produces a list with the two partial derivatives of f
721 --------------------------------------------------------------------------- */
722 eqs:[diff(f,x),diff(f,y)],
723 /* ---------------------------------------------------------------------------
724 produces a list of unknowns
725 --------------------------------------------------------------------------- */
726 unk:[x,y],
727 /* ---------------------------------------------------------------------------
728 solves the system
729 --------------------------------------------------------------------------- */
730 solve(eqs,unk)
734 The program (which is actually a function with no argument) is called
735 <tt>critpts</tt>. Each line is a valid Maxima command which could be
736 executed from the keyboard, and which is separated by the next command
737 by a comma. The partial derivatives are stored in a variable named
738 <tt>eqs</tt>, and the unknowns are stored in <tt>unk</tt>. Here is a sample
742 (%i1) batch ("critpts.max
");
744 batching #p/home/robert/tmp/maxima-clean/maxima/critpts.max
745 (%i2) critpts() := (print("program
to
find
critical
points
"),
746 f : read("enter
f(x,y)
"), print("f
=
", f),
747 eqs : [diff(f, x), diff(f, y)], unk : [x, y], solve(eqs, unk))
748 (%i3) critpts ();
749 program to find critical points
750 enter f(x,y)
751 %e^(x^3 + y^2)*(x + y);
752 2 3
753 y + x
754 f = (y + x) %e
755 (%o3) [[x = .4588955685487001 %i + .3589790871086935,
756 y = .4942017368275118 %i - .1225787367783657],
757 [x = .3589790871086935 - .4588955685487001 %i,
758 y = - .4942017368275118 %i - .1225787367783657],
759 [x = .4187542327234816 %i - .6923124204420268,
760 y = 0.455912070111699 - .8697262692814121 %i],
761 [x = - .4187542327234816 %i - .6923124204420268,
762 y = .8697262692814121 %i + 0.455912070111699]]
766 <div class="p
"><!----></div>
767 <h2><a name="tth_sEc8
">
768 8</a> A partial list of Maxima functions</h2>
770 <div class="p
"><!----></div>
771 See the Maxima reference manual <tt>doc/html/maxima_toc.html</tt> (under
772 the main Maxima installation directory). From Maxima itself, you can
773 use <tt>describe(<i>function name</i>)</tt>.
775 <div class="p
"><!----></div>
777 <dl compact="compact
">
778 <dt><b><tt>allroots(a)</tt></b></dt>
779 <dd> Finds all the (generally complex) roots of
780 the polynomial equation <tt>A</tt>, and lists them in <tt>numer</tt>ical
781 format (i.e. to 16 significant figures).</dd>
782 <dt><b><tt>append(a,b)</tt></b></dt>
783 <dd> Appends the list <tt>b</tt> to the list <tt>a</tt>,
784 resulting in a single list.</dd>
785 <dt><b><tt>batch(a)</tt></b></dt>
786 <dd> Loads and runs a program with filename <tt>a</tt>.</dd>
787 <dt><b><tt>coeff(a,b,c)</tt></b></dt>
788 <dd> Gives the coefficient of <tt>b</tt> raised to
789 the power <tt>c</tt> in expression <tt>a</tt>.</dd>
790 <dt><b><tt>concat(a,b)</tt></b></dt>
791 <dd> Creates the symbol <tt>ab</tt>.</dd>
792 <dt><b><tt>cons(a,b)</tt></b></dt>
793 <dd> Adds <tt>a</tt> to the list <tt>b</tt> as its first element.</dd>
794 <dt><b><tt>demoivre(a)</tt></b></dt>
795 <dd> Transforms all complex exponentials in <tt>
796 a</tt> to their trigonometric equivalents.</dd>
797 <dt><b><tt>denom(a)</tt></b></dt>
798 <dd> Gives the denominator of <tt>a</tt>.</dd>
799 <dt><b><tt>depends(a,b)</tt></b></dt>
800 <dd> Declares <tt>a</tt> to be a function of <tt>
801 b</tt>. This is useful for writing unevaluated derivatives, as in
802 specifying differential equations.</dd>
803 <dt><b><tt>desolve(a,b)</tt></b></dt>
804 <dd> Attempts to solve a linear system <tt>a</tt> of
805 ODE's for unknowns <tt>b</tt> using Laplace transforms.</dd>
806 <dt><b><tt>determinant(a)</tt></b></dt>
807 <dd> Returns the determinant of the square
808 matrix <tt>a</tt>.</dd>
809 <dt><b><tt>diff(a,b1,c1,b2,c2,...,bn,cn)</tt></b></dt>
810 <dd> Gives the mixed partial
811 derivative of <tt>a</tt> with respect to each <tt>bi</tt>, <tt>ci</tt> times.
812 For brevity, <tt>diff(a,b,1)</tt> may be represented by <tt>
813 diff(a,b)</tt>. <tt>'diff(...)</tt> represents the unevaluated
814 derivative, useful in specifying a differential equation.</dd>
815 <dt><b><tt>eigenvalues(a)</tt></b></dt>
816 <dd> Returns two lists, the first being the
817 eigenvalues of the square matrix <tt>a</tt>, and the second being their
818 respective multiplicities.</dd>
819 <dt><b><tt>eigenvectors(a)</tt></b></dt>
820 <dd> Does everything that <tt>eigenvalues</tt>
821 does, and adds a list of the eigenvectors of <tt>a</tt>.</dd>
822 <dt><b><tt>entermatrix(a,b)</tt></b></dt>
823 <dd> Cues the user to enter an <tt>a</tt> × <tt>b</tt> matrix, element by element.</dd>
824 <dt><b><tt>ev(a,b1,b2,...,bn)</tt></b></dt>
825 <dd> Evaluates <tt>a</tt> subject to the
826 conditions <tt>bi</tt>. In particular the <tt>bi</tt> may be equations,
827 lists of equations (such as that returned by <tt>solve</tt>), or
828 assignments, in which cases <tt>ev</tt> "plugs
" the <tt>bi</tt> into
829 <tt>a</tt>. The <tt>Bi</tt> may also be words such as <tt>numer</tt> (in
830 which case the result is returned in numerical format), <tt>detout</tt>
831 (in which case any matrix inverses in <tt>a</tt> are performed with the
832 determinant factored out), or <tt>diff</tt> (in which case all
833 differentiations in <tt>a</tt> are evaluated, i.e., <tt>'diff</tt> in <tt>
834 a</tt> is replaced by <tt>diff</tt>). For brevity in a manual command
835 (i.e., not inside a user-defined function), the <tt>ev</tt> may be
836 dropped, shortening the syntax to <tt>a,b1,b2,...,bn</tt>.</dd>
837 <dt><b><tt>expand(a)</tt></b></dt>
838 <dd> Algebraically expands <tt>a</tt>. In particular
839 multiplication is distributed over addition.</dd>
840 <dt><b><tt>exponentialize(a)</tt></b></dt>
841 <dd> Transforms all trigonometric functions
842 in <tt>a</tt> to their complex exponential equivalents.</dd>
843 <dt><b><tt>factor(a)</tt></b></dt>
844 <dd> Factors <tt>a</tt>.</dd>
845 <dt><b><tt>freeof(a,b)</tt></b></dt>
846 <dd> Is true if the variable <tt>a</tt> is not part
847 of the expression <tt>b</tt>.</dd>
848 <dt><b><tt>grind(a)</tt></b></dt>
849 <dd> Displays a variable or function <tt>a</tt> in a
850 compact format. When used with <tt>writefile</tt> and an editor
851 outside of Maxima, it offers a scheme for producing <tt>batch</tt>
852 files which include Maxima-generated expressions.</dd>
853 <dt><b><tt>ident(a)</tt></b></dt>
854 <dd> Returns an <tt>a</tt> × <tt>a</tt>
855 identity matrix.</dd>
856 <dt><b><tt>imagpart(a)</tt></b></dt>
857 <dd> Returns the imaginary part of <tt>a</tt>.</dd>
858 <dt><b><tt>integrate(a,b)</tt></b></dt>
859 <dd> Attempts to find the indefinite integral
860 of <tt>a</tt> with respect to <tt>b</tt>.</dd>
861 <dt><b><tt>integrate(a,b,c,d)</tt></b></dt>
862 <dd> Attempts to find the indefinite
863 integral of <tt>a</tt> with respect to <tt>b</tt>. taken from
864 <tt>b</tt><tt>=</tt><tt>c</tt> to <tt>b</tt><tt>=</tt><tt>d</tt>. The limits of integration <tt>c</tt>
865 and <tt>d</tt> may be taken is <tt>inf</tt> (positive infinity) of <tt>
866 minf</tt> (negative infinity).</dd>
867 <dt><b><tt>invert(a)</tt></b></dt>
868 <dd> Computes the inverse of the square matrix <tt>
870 <dt><b><tt>kill(a)</tt></b></dt>
871 <dd> Removes the variable <tt>a</tt> with all its
872 assignments and properties from the current Maxima environment.</dd>
873 <dt><b><tt>limit(a,b,c)</tt></b></dt>
874 <dd> Gives the limit of expression <tt>a</tt> as
875 variable <tt>b</tt> approaches the value <tt>c</tt>. The latter may be
876 taken as <tt>inf</tt> of <tt>minf</tt> as in <tt>integrate</tt>.</dd>
877 <dt><b><tt>lhs(a)</tt></b></dt>
878 <dd> Gives the left-hand side of the equation <tt>a</tt>.</dd>
879 <dt><b><tt>loadfile(a)</tt></b></dt>
880 <dd> Loads a disk file with filename <tt>a</tt> from
881 the current default directory. The disk file must be in the proper
882 format (i.e. created by a <tt>save</tt> command).</dd>
883 <dt><b><tt>makelist(a,b,c,d)</tt></b></dt>
884 <dd> Creates a list of <tt>a</tt>'s (each of
885 which presumably depends on <tt>b</tt>), concatenated from
886 <tt>b</tt><tt>=</tt><tt>c</tt> to <tt>b</tt><tt>=</tt><tt>d</tt></dd>
887 <dt><b><tt>map(a,b)</tt></b></dt>
888 <dd> Maps the function <tt>a</tt> onto the
889 subexpressions of <tt>b</tt>.</dd>
890 <dt><b><tt>matrix(a1,a2,...,an)</tt></b></dt>
891 <dd> Creates a matrix consisting of the rows <tt>ai</tt>, where each
892 row <tt>ai</tt> is a list of <tt>m</tt> elements, <tt>[b1, b2, ..., bm]</tt>.</dd>
893 <dt><b><tt>num(a)</tt></b></dt>
894 <dd> Gives the numerator of <tt>a</tt>.</dd>
895 <dt><b><tt>ode2(a,b,c)</tt></b></dt>
896 <dd> Attempts to solve the first- or second-order
897 ordinary differential equation <tt>a</tt> for <tt>b</tt> as a function of
899 <dt><b><tt>part(a,b1,b2,...,bn)</tt></b></dt>
900 <dd> First takes the <tt>b1</tt>th part
901 of <tt>a</tt>, then the <tt>b2</tt>th part of that, and so on.</dd>
902 <dt><b><tt>playback(a)</tt></b></dt>
903 <dd> Displays the last <tt>a</tt> (an integer)
904 labels and their associated expressions. If <tt>a</tt> is omitted,
905 all lines are played back. See the Manual for other options.</dd>
906 <dt><b><tt>ratsimp(a)</tt></b></dt>
907 <dd> Simplifies <tt>a</tt> and returns a quotient of
908 two polynomials.</dd>
909 <dt><b><tt>realpart(a)</tt></b></dt>
910 <dd> Returns the real part of <tt>a</tt>.</dd>
911 <dt><b><tt>rhs(a)</tt></b></dt>
912 <dd> Gives the right-hand side of the equation <tt>a</tt>.</dd>
913 <dt><b><tt>save(a,b1,b2,..., bn)</tt></b></dt>
914 <dd> Creates a disk file with
915 filename <tt>a</tt> in the current default directory, of variables,
916 functions, or arrays <tt>bi</tt>. The format of the file permits it to
917 be reloaded into Maxima using the <tt>loadfile</tt> command.
918 Everything (including labels) may be <tt>save</tt>d by taking <tt>b1</tt>
919 equal to <tt>all</tt>.</dd>
920 <dt><b><tt>solve(a,b)</tt></b></dt>
921 <dd> Attempts to solve the algebraic equation <tt>
922 a</tt> for the unknown <tt>b</tt>. A list of solution equations is
923 returned. For brevity, if <tt>a</tt> is an equation of the form
924 <tt>c</tt><tt> = </tt><tt>0</tt>, it may be abbreviated simply by the expression
926 <dt><b><tt>string(a)</tt></b></dt>
927 <dd> Converts <tt>a</tt> to Maxima's linear notation
928 (similar to Fortran's) just as if it had been typed in and puts <tt>
929 a</tt> into the buffer for possible editing. The <tt>string</tt>'ed
930 expression should not be used in a computation.</dd>
931 <dt><b><tt>stringout(a,b1,b2,...,bn)</tt></b></dt>
932 <dd> Creates a disk file with
933 filename <tt>a</tt> in the current default directory, of variables
934 (e.g. labels) <tt>bi</tt>. The file is in a text format and is not
935 reloadable into Maxima. However the strungout expressions can be
936 incorporated into a Fortran, Basic or C program with a minimum of
938 <dt><b><tt>subst(a,b,c)</tt></b></dt>
939 <dd> Substitutes <tt>a</tt> for <tt>b</tt> in <tt>c</tt>.</dd>
940 <dt><b><tt>taylor(a,b,c,d)</tt></b></dt>
941 <dd> Expands <tt>a</tt> in a Taylor series in
942 <tt>b</tt> about <tt>b</tt><tt>=</tt><tt>c</tt>, up to and including the term
943 <tt>(</tt><tt>b</tt><font face="symbol
">-</font
944 ><tt>c</tt><tt>)</tt><sup><tt>d</tt></sup>. Maxima also supports Taylor expansions in more
945 than one independent variable; see the Manual for details.</dd>
946 <dt><b><tt>transpose(a)</tt></b></dt>
947 <dd> Gives the transpose of the matrix <tt>a</tt>.</dd>
948 <dt><b><tt>trigexpand(a)</tt></b></dt>
949 <dd> Is a trig simplification function which
950 uses the sum-of-angles formulas to simplify the arguments of
951 individual <tt>sin</tt>'s or <tt>cos</tt>'s. For example, <tt>
952 trigexpand(sin(x+y))</tt> gives <tt>cos(x) sin(y) + sin(x) cos(y)</tt>.</dd>
953 <dt><b><tt>trigreduce(a)</tt></b></dt>
954 <dd> Is a trig simplification function which
955 uses trig identities to convert products and powers of <tt>sin</tt> and
956 <tt>cos</tt> into a sum of terms, each of which contains only a single
957 <tt>sin</tt> or <tt>cos</tt>. For example, <tt>trigreduce(sin(x)^2)</tt>
958 gives <tt>(1 - cos(2x))/2</tt>.</dd>
959 <dt><b><tt>trigsimp(a)</tt></b></dt>
960 <dd> Is a trig simplification function which
961 replaces <tt>tan</tt>, <tt>sec</tt>, etc., by their <tt>sin</tt> and <tt>
962 cos</tt> equivalents. It also uses the identity <tt>sin</tt><tt>(</tt><tt>)</tt><sup><tt>2</tt></sup> <tt>+</tt> <tt>cos</tt><tt>(</tt><tt>)</tt><sup><tt>2</tt></sup><tt> = </tt><tt>1</tt>.</dd>
965 <div class="p
"><!----></div>
966 <hr /><h3>Footnotes:</h3>
968 <div class="p
"><!----></div>
969 <a name="tthFtNtAAB
"></a><a href="#tthFrefAAB
"><sup>1</sup></a>Adapted from "Perturbation Methods, Bifurcation Theory and Computer Algebra
"
970 by Rand and Armbruster, Springer, 1987.
971 Adapted to <span class="roman
">L</span><sup><span class="roman
">A</span></sup><span class="roman
">T</span><sub><span class="roman
">E</span></sub><span class="roman
">X</span> and HTML by Nelson L. Dias (nldias@simepar.br),
972 SIMEPAR Technological Institute and Federal University of ParanĂ¡, Brazil.
973 Updated by Robert Dodier, August 2005.
974 <br /><br /><hr /><small>File translated from
975 T<sub><font size="-
1">E</font></sub>X
976 by <a href="http://hutchinson.belmont.ma.us/tth/
">
977 T<sub><font size="-
1">T</font></sub>H</a>,
978 version 3.85.<br />On 26 Apr 2010, 00:45.</small>