This document was uploaded by user and they confirmed that they have the permission to share
it. If you are author or own the copyright of this book, please report to us by using this DMCA
report form. Report DMCA
Maxima is a computer algebra system, implemented in Lisp. Maxima is derived from the Macsyma system, developed at MIT in the years 1968 through 1982 as part of Project MAC. MIT turned over a copy of the Macsyma source code to the Department of Energy in 1982; that version is now known as DOE Macsyma. A copy of DOE Macsyma was maintained by Professor William F. Schelter of the University of Texas from 1982 until his death in 2001. In 1998, Schelter obtained permission from the Department of Energy to release the DOE Macsyma source code under the GNU Public License, and in 2000 he initiated the Maxima project at SourceForge to maintain and develop DOE Macsyma, now called Maxima.
1 Introduction to Maxima Start Maxima with the command "maxima". Maxima will display version information and a prompt. End each Maxima command with a semicolon. End the session with the command "quit();". Here’s a sample session: [wfs@chromium]$ maxima Maxima 5.9.1 http://maxima.sourceforge.net Using Lisp CMU Common Lisp 19a Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. This is a development version of Maxima. The function bug_report() provides bug reporting information. (%i1) factor(10!); 8 4 2 (%o1) 2 3 5 7 (%i2) expand ((x + y)^6); 6 5 2 4 3 3 4 2 5 6 (%o2) y + 6 x y + 15 x y + 20 x y + 15 x y + 6 x y + x (%i3) factor (x^6 - 1); 2 2 (%o3) (x - 1) (x + 1) (x - x + 1) (x + x + 1) (%i4) quit(); [wfs@chromium]$ Maxima can search the info pages. Use the describe command to show information about the command or all the commands and variables containing a string. The question mark ? (exact search) and double question mark ?? (inexact search) are abbreviations for describe: (%i1) ?? integ 0: Functions and Variables for Elliptic Integrals 1: Functions and Variables for Integration 2: Introduction to Elliptic Functions and Integrals 3: Introduction to Integration 4: askinteger (Functions and Variables for Simplification) 5: integerp (Functions and Variables for Miscellaneous Options) 6: integer_partitions (Functions and Variables for Sets) 7: integrate (Functions and Variables for Integration) 8: integrate_use_rootsof (Functions and Variables for Integration) 9: integration_constant_counter (Functions and Variables for Integration) 10: nonnegintegerp (Functions and Variables for linearalgebra) Enter space-separated numbers, ‘all’ or ‘none’: 5 4 -- Function: integerp (<expr>) Returns ‘true’ if <expr> is a literal numeric integer, otherwise ‘false’. ‘integerp’ returns false if its argument is a symbol, even if the argument is declared integer.
Function: askinteger (<expr>, integer) Function: askinteger (<expr>) Function: askinteger (<expr>, even) Function: askinteger (<expr>, odd) ‘askinteger (<expr>, integer)’ attempts to determine from the ‘assume’ database whether <expr> is an integer. ‘askinteger’ prompts the user if it cannot tell otherwise, and attempt to install the information in the database if possible. ‘askinteger (<expr>)’ is equivalent to ‘askinteger (<expr>, integer)’. ‘askinteger (<expr>, even)’ and ‘askinteger (<expr>, odd)’ likewise attempt to determine if <expr> is an even integer or odd integer, respectively.
(%o1)
true
To use a result in later calculations, you can assign it to a variable or refer to it by its automatically supplied label. In addition, % refers to the most recent calculated result: (%i1) u: expand ((x + y)^6); 6 5 2 4 3 3 4 2 5 6 (%o1) y + 6 x y + 15 x y + 20 x y + 15 x y + 6 x y + x (%i2) diff (u, x); 5 4 2 3 3 2 4 5 (%o2) 6 y + 30 x y + 60 x y + 60 x y + 30 x y + 6 x (%i3) factor (%o2); 5 (%o3) 6 (y + x)
Chapter 1: Introduction to Maxima
3
Maxima knows about complex numbers and numerical constants: (%i1) cos(%pi); (%o1) - 1 (%i2) exp(%i*%pi); (%o2) - 1 Maxima can do differential and integral calculus: (%i1) u: expand ((x + y)^6); 6 5 2 4 3 3 4 2 5 6 (%o1) y + 6 x y + 15 x y + 20 x y + 15 x y + 6 x y + x (%i2) diff (%, x); 5 4 2 3 3 2 4 5 (%o2) 6 y + 30 x y + 60 x y + 60 x y + 30 x y + 6 x (%i3) integrate (1/(1 + x^3), x); 2 x - 1 2 atan(-------) log(x - x + 1) sqrt(3) log(x + 1) (%o3) - --------------- + ------------- + ---------6 sqrt(3) 3 Maxima can solve linear systems and cubic equations: (%i1) linsolve ([3*x + 4*y = 7, 2*x + a*y = 13], [x, y]); 7 a - 52 25 (%o1) [x = --------, y = -------] 3 a - 8 3 a - 8 (%i2) solve (x^3 - 3*x^2 + 5*x = 15, x); (%o2) [x = - sqrt(5) %i, x = sqrt(5) %i, x = 3] Maxima can solve nonlinear sets of equations. Note that if you don’t want a result printed, you can finish your command with $ instead of ;. (%i1) eq_1: x^2 + 3*x*y + y^2 = 0$ (%i2) eq_2: 3*x + y = 1$ (%i3) solve ([eq_1, eq_2]); 3 sqrt(5) + 7 sqrt(5) + 3 (%o3) [[y = - -------------, x = -----------], 2 2 3 sqrt(5) - 7 sqrt(5) - 3 [y = -------------, x = - -----------]] 2 2 Maxima can generate plots of one or more functions: (%i1) eq_1: x^2 + 3*x*y + y^2 = 0$ (%i2) eq_2: 3*x + y = 1$ (%i3) solve ([eq_1, eq_2]); 3 sqrt(5) + 7 sqrt(5) + 3 (%o3) [[y = - -------------, x = -----------], 2 2 3 sqrt(5) - 7 sqrt(5) - 3 [y = -------------, x = - -----------]]
2 Bug Detection and Reporting 2.1 Functions and Variables for Bug Detection and Reporting run run run run
testsuite testsuite testsuite testsuite
() Function (boolean) Function (boolean, boolean) Function (boolean, boolean, list) Function Run the Maxima test suite. Tests producing the desired answer are considered “passes,” as are tests that do not produce the desired answer, but are marked as known bugs. run_testsuite () displays only tests that do not pass. run_testsuite (true) displays tests that are marked as known bugs, as well as failures. run_testsuite (true, true) displays all tests. If the optional third argument is given, a subset of the tests is run. The subset of the tests to run is given as a list of the names of the tests. The complete set of tests is specified by testsuite_files. run_testsuite changes the Maxima environment. Typically a test script executes kill to establish a known environment (namely one without user-defined functions and variables) and then defines functions and variables appropriate to the test. run_testsuite returns done.
testsuite files
Option variable testsuite_files is the set of tests to be run by run_testsuite. It is a list of names of the files containing the tests to run. If some of the tests in a file are known to fail, then instead of listing the name of the file, a list containing the file name and the test numbers that fail is used. For example, this is a part of the default set of tests: ["rtest13s", ["rtest14", 57, 63]] This specifies the testsuite consists of the files "rtest13s" and "rtest14", but "rtest14" contains two tests that are known to fail: 57 and 63.
bug report ()
Function Prints out Maxima and Lisp version numbers, and gives a link to the Maxima project bug report web page. The version information is the same as reported by build_info. When a bug is reported, it is helpful to copy the Maxima and Lisp version information into the bug report. bug_report returns an empty string "".
build info () Prints out a summary of the parameters of the Maxima build. build_info returns an empty string "".
Function
6
Maxima Manual
Chapter 3: Help
7
3 Help 3.1 Lisp and Maxima Maxima is written in Lisp, and it is easy to access Lisp functions and variables from Maxima and vice versa. Lisp and Maxima symbols are distinguished by a naming convention. A Lisp symbol which begins with a dollar sign $ corresponds to a Maxima symbol without the dollar sign. A Maxima symbol which begins with a question mark ? corresponds to a Lisp symbol without the question mark. For example, the Maxima symbol foo corresponds to the Lisp symbol $foo, while the Maxima symbol ?foo corresponds to the Lisp symbol foo, Note that ?foo is written without a space between ? and foo; otherwise it might be mistaken for describe ("foo"). Hyphen -, asterisk *, or other special characters in Lisp symbols must be escaped by backslash \ where they appear in Maxima code. For example, the Lisp identifier *foo-bar* is written ?\*foo\-bar\* in Maxima. Lisp code may be executed from within a Maxima session. A single line of Lisp (containing one or more forms) may be executed by the special command :lisp. For example, (%i1) :lisp (foo $x $y) calls the Lisp function foo with Maxima variables x and y as arguments. The :lisp construct can appear at the interactive prompt or in a file processed by batch or demo, but not in a file processed by load, batchload, translate_file, or compile_file. The function to_lisp() opens an interactive Lisp session. Entering (to-maxima) closes the Lisp session and returns to Maxima. Lisp functions and variables which are to be visible in Maxima as functions and variables with ordinary names (no special punctuation) must have Lisp names beginning with the dollar sign $. Maxima is case-sensitive, distinguishing between lowercase and uppercase letters in identifiers, while Lisp is not. There are some rules governing the translation of names between Lisp and Maxima. 1. A Lisp identifier not enclosed in vertical bars corresponds to a Maxima identifier in lowercase. Whether the Lisp identifier is uppercase, lowercase, or mixed case, is ignored. E.g., Lisp $foo, $FOO, and $Foo all correspond to Maxima foo. 2. A Lisp identifier which is all uppercase or all lowercase and enclosed in vertical bars corresponds to a Maxima identifier with case reversed. That is, uppercase is changed to lowercase and lowercase to uppercase. E.g., Lisp |$FOO| and |$foo| correspond to Maxima foo and FOO, respectively. 3. A Lisp identifier which is mixed uppercase and lowercase and enclosed in vertical bars corresponds to a Maxima identifier with the same case. E.g., Lisp |$Foo| corresponds to Maxima Foo. The #$ Lisp macro allows the use of Maxima expressions in Lisp code. #$expr$ expands to a Lisp expression equivalent to the Maxima expression expr. (msetq $foo #$[x, y]$) This has the same effect as entering
8
Maxima Manual
(%i1) foo: [x, y]; The Lisp function displa prints an expression in Maxima format. (%i1) :lisp #$[x, y, z]$ ((MLIST SIMP) $X $Y $Z) (%i1) :lisp (displa ’((MLIST SIMP) $X $Y $Z)) [x, y, z] NIL Functions defined in Maxima are not ordinary Lisp functions. The Lisp function mfuncall calls a Maxima function. For example: (%i1) foo(x,y) := x*y$ (%i2) :lisp (mfuncall ’$foo ’a ’b) ((MTIMES SIMP) A B) Some Lisp functions are shadowed in the Maxima package, namely the following. complement, continue, //, float, functionp, array, exp, listen, signum, atan, asin, acos, asinh, acosh, atanh, tanh, cosh, sinh, tan, break, and gcd.
3.2 Garbage Collection Symbolic computation tends to create a good deal of garbage, and effective handling of this can be crucial to successful completion of some programs. Under GCL, on UNIX systems where the mprotect system call is available (including SUN OS 4.0 and some variants of BSD) a stratified garbage collection is available. This limits the collection to pages which have been recently written to. See the GCL documentation under ALLOCATE and GBC. At the Lisp level doing (setq si::*notify-gbc* t) will help you determine which areas might need more space.
3.3 Documentation The Maxima on-line user’s manual can be viewed in different forms. From the Maxima interactive prompt, the user’s manual is viewed as plain text by the ? command (i.e., the describe function). The user’s manual is viewed as info hypertext by the info viewer program and as a web page by any ordinary web browser. example displays examples for many Maxima functions. For example, (%i1) example (integrate); yields (%i2) test(f):=block([u],u:integrate(f,x),ratsimp(f-diff(u,x))) (%o2) test(f) := block([u], u : integrate(f, x), ratsimp(f - diff(u, x))) (%i3) test(sin(x)) (%o3) (%i4) test(1/(x+1)) (%o4) (%i5) test(1/(x^2+1)) (%o5) and additional output.
0 0 0
Chapter 3: Help
9
3.4 Functions and Variables for Help demo (filename)
Function Evaluates Maxima expressions in filename and displays the results. demo pauses after evaluating each expression and continues after the user enters a carriage return. (If running in Xmaxima, demo may need to see a semicolon ; followed by a carriage return.) demo searches the list of directories file_search_demo to find filename. If the file has the suffix dem, the suffix may be omitted. See also file_search. demo evaluates its argument. demo returns the name of the demonstration file. Example: (%i1) demo ("disol"); batching /home/wfs/maxima/share/simplification/disol.dem At the _ prompt, type ’;’ followed by enter to get next demo (%i2) load(disol) _ (%i3) (%o3)
exp1 : a (e (g + f) + b (d + c)) a (e (g + f) + b (d + c))
_ (%i4) (%t4)
disolate(exp1, a, b, e) d + c
(%t5)
g + f
(%o5)
a (%t5 e + %t4 b)
_ (%i5) demo ("rncomb"); batching /home/wfs/maxima/share/simplification/rncomb.dem At the _ prompt, type ’;’ followed by enter to get next demo (%i6) load(rncomb) _ (%i7)
(%o7)
_ (%i8)
z x exp1 : ----- + --------y + x 2 (y + x) z x ----- + --------y + x 2 (y + x)
combine(exp1) z x
10
Maxima Manual
(%o8)
_ (%i9) (%o9)
----- + --------y + x 2 (y + x)
rncombine(%) 2 z + x --------2 (y + x)
_ (%i10)
(%o10)
_ (%i11) (%o11)
_ (%i12) (%o12)
d c b a exp2 : - + - + - + 3 3 2 2 d c b a - + - + - + 3 3 2 2
combine(exp2) 2 d + 2 c + 3 (b + a) --------------------6
rncombine(exp2) 2 d + 2 c + 3 b + 3 a --------------------6
describe(string) is equivalent to describe(string, exact). describe(string, exact) finds an item with title equal (case-insensitive) to string, if there is any such item. describe(string, inexact) finds all documented items which contain string in their titles. If there is more than one such item, Maxima asks the user to select an item or items to display. At the interactive prompt, ? foo (with a space between ? and foo) is equivalent to describe("foo", exact), and ?? foo is equivalent to describe("foo", inexact). describe("", inexact) yields a list of all topics documented in the on-line manual. describe quotes its argument. describe returns true if some documentation is found, otherwise false. See also Section 3.3 [Documentation], page 8.