Maxima
Maxima
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 all the com-
mands and variables containing a string, and optionally their documentation. The question
mark ? is an abbreviation for describe:
(%i1) ? integ
(%o1) false
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)
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);
Chapter 1: Introduction to Maxima 5
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 2
(%i4) kill(labels);
(%o0) done
(%i1) plot2d (sin(x)/x, [x, -20, 20]);
(%o1)
(%i2) plot2d ([atan(x), erf(x), tanh(x)], [x, -5, 5]);
(%o2)
(%i3) plot3d (sin(sqrt(x^2 + y^2))/sqrt(x^2 + y^2), [x, -12, 12], [y, -12, 12]);
(%o3)
6 Maxima Manual
Chapter 2: Bug Detection and Reporting 7
3 Help
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
(%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.
Chapter 3: Help 11
3.4 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),
batching /home/wfs/maxima/share/simplification/disol.dem
12 Maxima Manual
_
(%i3) exp1 : a (e (g + f) + b (d + c))
(%o3) a (e (g + f) + b (d + c))
_
(%i4) disolate(exp1, a, b, e)
(%t4) d + c
(%t5) g + f
_
(%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)
_
z x
(%i7) exp1 : ----- + ---------
y + x 2 (y + x)
z x
(%o7) ----- + ---------
y + x 2 (y + x)
_
(%i8) combine(exp1)
z x
(%o8) ----- + ---------
y + x 2 (y + x)
_
(%i9) rncombine(%)
2 z + x
(%o9) ---------
2 (y + x)
_
d c b a
(%i10) exp2 : - + - + - + -
3 3 2 2
d c b a
(%o10) - + - + - + -
3 3 2 2
Chapter 3: Help 13
_
(%i11) combine(exp2)
2 d + 2 c + 3 (b + a)
(%o11) ---------------------
6
_
(%i12) rncombine(exp2)
2 d + 2 c + 3 b + 3 a
(%o12) ---------------------
6
_
(%i13)
4 Command Line
"’" operator
The single quote operator ’ prevents evaluation.
E.g., ’(f(x)) means do not evaluate the expression f(x). ’f(x) (with the single
quote applied to f instead of f(x)) means return the noun form of f applied to [x].
The single quote does not prevent simplification.
"’’" operator
The ’’ (double single quotes) operator causes an extra evaluation to occur. E.g.,
’’%i4 will re-evaluate input line %i4. ’’(f(x)) means evaluate the expression f(x)
an extra time. ’’f(x) (with the double single quotes applied to f instead of f(x))
means return the verb form of f applied to [x].
alias (new name 1, old name 1, ..., new name n, old name n) Function
provides an alternate name for a (user or system) function, variable, array, etc. Any
even number of arguments may be used.
debugmode Variable
Default value: false
When a Maxima error occurs, Maxima will start the debugger if debugmode is true.
The user may enter commands to examine the call stack, set breakpoints, step through
Maxima code, and so on. See debugging for a list of debugger commands.
Enabling debugmode will not catch Lisp errors.
1
(%t7) y = - -
5
6
(%t8) x = -
5
(%o8) [[%t7, %t8]]
(%i8) %o6, %o8;
18 Maxima Manual
(%o8) - 4 = - 4
(%i9) x + 1/x > gamma (1/2);
1
(%o9) x + - > sqrt(%pi)
x
(%i10) %, numer, x=1/2;
(%o10) 2.5 > 1.772453850905516
(%i11) %, pred;
(%o11) true
evflag property
Some Boolean flags have the evflag property. ev treats such flags specially. A flag
with the evflag property will be bound to true during the execution of ev if it is
mentioned in the call to ev. For example, demoivre and ratfac are bound to true
during the call ev (%, demoivre, ratfac).
The flags which have the evflag property are: algebraic, cauchysum, demoivre,
dotscrules, %emode, %enumer, exponentialize, exptisolate, factorflag, float,
halfangles, infeval, isolate_wrt_times, keepfloat, letrat, listarith,
logabs, logarc, logexpand, lognegint, lognumer, m1pbranch, numer_pbranch,
programmode, radexpand, ratalgdenom, ratfac, ratmx, ratsimpexpons, simp,
simpsum, sumexpand, and trigexpand.
The construct :lisp (putprop ’|$foo| t ’evflag) gives the evflag property to the
variable foo, so foo is bound to true during the call ev (%, foo). Equivalently, ev
(%, foo:true) has the same effect.
evfun property
Some functions have the evfun property. ev treats such functions specially. A func-
tion with the evfun property will be applied during the execution of ev if it is men-
tioned in the call to ev. For example, ratsimp and radcan will be applied during the
call ev (%, ratsimp, radcan).
The functions which have the evfun property are: bfloat, factor, fullratsimp,
logcontract, polarform, radcan, ratexpand, ratsimp, rectform, rootscontract,
trigexpand, and trigreduce.
The construct :lisp (putprop ’|$foo| t ’evfun) gives the evfun property to the
function foo, so that foo is applied during the call ev (%, foo). Equivalently, foo
(ev (%)) has the same effect.
The variable labels is the list of input, output, and intermediate expression labels,
including all previous labels if inchar, outchar, or linechar were redefined.
By default, Maxima displays the result of each user input expression, giving the result
an output label. The output display is suppressed by terminating the input with $
(dollar sign) instead of ; (semicolon). An output label is generated, but not displayed,
and the label may be referenced in the same way as displayed output labels. See also
%, %%, and %th.
Intermediate expression labels can be generated by some functions. The flag
programmode controls whether solve and some other functions generate intermediate
expression labels instead of returning a list of expressions. Some other functions,
such as ldisplay, always generate intermediate expression labels.
first (rest (labels (’’inchar))) returns the most recent input label.
See also inchar, outchar, linechar, and infolists.
linenum Variable
The line number of the current pair of input and output expressions.
myoptions Variable
Default value: []
myoptions is the list of all options ever reset by the user, whether or not they get
reset to their default value.
nolabels Variable
Default value: false
When nolabels is true, input and output labels are generated but not appended to
labels, the list of all input and output labels. kill (labels) kills the labels on the
labels list, but does not kill any labels generated since nolabels was assigned true.
It seems likely this behavior is simply broken.
See also batch, batchload, and labels.
optionset Variable
Default value: false
When optionset is true, Maxima prints out a message whenever a Maxima option
is reset. This is useful if the user is doubtful of the spelling of some option and wants
to make sure that the variable he assigned a value to was truly an option variable.
playback () Function
playback (n) Function
playback ([m, n]) Function
playback ([m]) Function
playback (input) Function
playback (slow) Function
playback (time) Function
playback (grind) Function
Displays input, output, and intermediate expressions, without recomputing them.
playback only displays the expressions bound to labels; any other output (such as
Chapter 4: Command Line 21
text printed by print or describe, or error messages) is not displayed. See also
labels.
playback quotes its arguments. The double single quotes operator, ’’, defeats quo-
tation. playback always returns done.
playback () (with no arguments) displays all input, output, and intermediate expres-
sions generated so far. An output expression is displayed even if it was suppressed by
the $ terminator when it was originally computed.
playback (n) displays the most recent n expressions. Each input, output, and inter-
mediate expression counts as one.
playback ([m, n]) displays input, output, and intermediate expressions with num-
bers from m through n, inclusive.
playback ([m]) is equivalent to playback ([m, m]); this usually prints one pair
of input and output expressions.
playback (input) displays all input expressions generated so far.
playback (slow) pauses between expressions and waits for the user to press enter.
This behavior is similar to demo. playback (slow) is useful in conjunction with
save or stringout when creating a secondary-storage file in order to pick out useful
expressions.
playback (time) displays the computation time for each expression.
playback (grind) displays input expressions in the same format as the grind func-
tion. Output expressions are not affected by the grind option. See grind.
Arguments may be combined, e.g., playback ([5, 10], grind, time, slow).
prompt Variable
Default value: _
prompt is the prompt symbol of the demo function, playback (slow) mode, and the
Maxima break loop (as invoked by break).
quit () Function
Terminates the Maxima session. Note that the function must be invoked as quit();
or quit()$, not quit by itself.
To stop a lengthy computation, type control-C. The default action is to return to the
Maxima prompt. If *debugger-hook* is nil, control-C opens the Lisp debugger.
See also debugging.
22 Maxima Manual
reset () Function
Resets many global variables and options, and some other variables, to their default
values.
reset processes the variables on the Lisp list *variable-initial-values*. The
Lisp macro defmvar puts variables on this list (among other actions). Many, but not
all, global variables and options are defined by defmvar, and some variables defined
by defmvar are not global variables or options.
showtime Variable
Default value: false
When showtime is true, the computation time and elapsed time is printed with each
output expression.
See also time, timer, and playback.
to lisp () Function
Enters the Lisp system under Maxima. (to-maxima) returns to Maxima.
values Variable
Initial value: []
values is a list of all bound user variables (not Maxima options or switches). The
list comprises symbols bound by : , ::, or :=.
Chapter 5: Operators 23
5 Operators
5.1 nary
An nary operator is used to denote a function of any number of arguments, each of
which is separated by an occurrence of the operator, e.g. A+B or A+B+C. The nary("x")
function is a syntax extension function to declare x to be an nary operator. Functions may
be declared to be nary. If declare(j,nary); is done, this tells the simplifier to simplify,
e.g. j(j(a,b),j(c,d)) to j(a, b, c, d).
See also syntax.
5.2 nofix
nofix operators are used to denote functions of no arguments. The mere presence of
such an operator in a command will cause the corresponding function to be evaluated. For
example, when one types "exit;" to exit from a Maxima break, "exit" is behaving similar to
a nofix operator. The function nofix("x") is a syntax extension function which declares
x to be a nofix operator.
See also syntax.
5.3 operator
See operators.
5.4 postfix
postfix operators like the prefix variety denote functions of a single argument, but
in this case the argument immediately precedes an occurrence of the operator in the input
string, e.g. 3! . The postfix("x") function is a syntax extension function to declare x to
be a postfix operator.
See also syntax.
5.5 prefix
A prefix operator is one which signifies a function of one argument, which argument
immediately follows an occurrence of the operator. prefix("x") is a syntax extension
function to declare x to be a prefix operator.
See also syntax.
24 Maxima Manual
"!" operator
The factorial operator. For any complex number x (including integer, rational, and
real numbers) except for negative integers, x! is defined as gamma(x+1).
For an integer x, x! simplifies to the product of the integers from 1 to x inclusive.
0! simplifies to 1. For a floating point number x, x! simplifies to the value of gamma
(x+1). For x equal to n/2 where n is an odd integer, x! simplifies to a rational factor
times sqrt (%pi) (since gamma (1/2) is equal to sqrt (%pi)). If x is anything else,
x! is not simplified.
The variables factlim, minfactorial, and factcomb control the simplification of
expressions containing factorials.
The functions gamma, bffac, and cbffac are varieties of the gamma function.
makegamma substitutes gamma for factorials and related functions.
See also binomial.
• The factorial of an integer, half-integer, or floating point argument is simplified
unless the operand is greater than factlim.
(%i1) factlim: 10$
(%i2) [0!, (7/2)!, 4.77!, 8!, 20!];
105 sqrt(%pi)
(%o2) [1, -------------, 81.44668037931193, 40320, 20!]
16
• The factorial of a complex number, known constant, or general expression is not
simplified. Even so it may be possible simplify the factorial after evaluating the
operand.
(%i1) [(%i + 1)!, %pi!, %e!, (cos(1) + sin(1))!];
(%o1) [(%i + 1)!, %pi!, %e!, (sin(1) + cos(1))!]
(%i2) ev (%, numer, %enumer);
(%o2) [(%i + 1)!, 7.188082728976031, 4.260820476357003,
1.227580202486819]
• The factorial of an unbound symbol is not simplified.
(%i1) kill (foo)$
(%i2) foo!;
(%o2) foo!
• Factorials are simplified, not evaluated. Thus x! may be replaced even in a
quoted expression.
(%i1) ’([0!, (7/2)!, 4.77!, 8!, 20!]);
105 sqrt(%pi)
(%o1) [1, -------------, 81.44668037931193, 40320, 20!]
16
"!!" operator
The double factorial operator.
Chapter 5: Operators 25
For an integer, float, or rational number n, n!! evaluates to the product n (n-2) (n-
4) (n-6) ... (n - 2 (k-1)) where k is equal to entier (n/2), that is, the largest
integer less than or equal to n/2. Note that this definition does not coincide with
other published definitions for arguments which are not integers.
For an even (or odd) integer n, n!! evaluates to the product of all the consecutive
even (or odd) integers from 2 (or 1) through n inclusive.
For an argument n which is not an integer, float, or rational, n!! yields a noun form
genfact (n, n/2, 2).
"#" operator
The logical operator "Not equals".
"." operator
The dot operator, for matrix (non-commutative) multiplication. When "." is used in
this way, spaces should be left on both sides of it, e.g. A . B. This distinguishes it
plainly from a decimal point in a floating point number.
See also dot, dot0nscsimp, dot0simp, dot1simp, dotassoc, dotconstrules,
dotdistrib, dotexptsimp, dotident, and dotscrules.
":" operator
The assignment operator. E.g. A:3 sets the variable A to 3.
"::" operator
Assignment operator. :: assigns the value of the expression on its right to the value
of the quantity on its left, which must evaluate to an atomic variable or subscripted
variable.
"::=" operator
The "::=" is used instead of ":=" to indicate that what follows is a macro definition,
rather than an ordinary functional definition. See macros.
":=" operator
The function definition operator. E.g. f(x):=sin(x) defines a function f.
"=" operator
denotes an equation to Maxima. To the pattern matcher in Maxima it denotes a
total relation that holds between two expressions if and only if the expressions are
syntactically identical.
and operator
The logical conjunction operator. and is an n-ary infix operator; its operands are
Boolean expressions, and its result is a Boolean value.
and forces evaluation (like is) of one or more operands, and may force evaluation of
all operands.
26 Maxima Manual
Operands are evaluated in the order in which they appear. and evaluates only as
many of its operands as necessary to determine the result. If any operand is false,
the result is false and no further operands are evaluated.
The global flag prederror governs the behavior of and when an evaluated operand
cannot be determined to be true or false. and prints an error message when
prederror is true. Otherwise, and returns unknown.
and is not commutative: a and b might not be equal to b and a due to the treatment
of indeterminate operands.
or operator
The logical disjunction operator. or is an n-ary infix operator; its operands are
Boolean expressions, and its result is a Boolean value.
or forces evaluation (like is) of one or more operands, and may force evaluation of
all operands.
Operands are evaluated in the order in which they appear. or evaluates only as many
of its operands as necessary to determine the result. If any operand is true, the result
is true and no further operands are evaluated.
The global flag prederror governs the behavior of or when an evaluated operand can-
not be determined to be true or false. or prints an error message when prederror
is true. Otherwise, or returns unknown.
or is not commutative: a or b might not be equal to b or a due to the treatment of
indeterminate operands.
not operator
The logical negation operator. not is a prefix operator; its operand is a Boolean
expression, and its result is a Boolean value.
not forces evaluation (like is) of its operand.
The global flag prederror governs the behavior of not when its operand cannot be
determined to be true or false. not prints an error message when prederror is
true. Otherwise, not returns unknown.
allbut keyword
works with the part commands (i.e. part, inpart, substpart, substinpart, dpart,
and lpart). For example,
(%i1) expr: e+d+c+b+a$
(%i2) part (expr, [2, 5]);
(%o2) d + a
while
(%i3) part (expr, allbut (2, 5));
(%o3) e + c + b
It also works with the kill command,
kill (allbut (name_1, ..., name_k))
will do a kill (all) except it will not kill the names specified. Note: name_i
means a name such as function name such as u, f, foo, or g, not an infolist such as
functions.
antisymmetric declaration
If declare(h,antisymmetric) is done, this tells the simplifier that h is antisymmet-
ric. E.g. h(x,z,y) will simplify to - h(x, y, z). That is, it will give (-1)^n times the
result given by symmetric or commutative, where n is the number of interchanges of
two arguments necessary to convert it to that form.
commutative declaration
If declare(h,commutative) is done, this tells the simplifier that h is a commutative
function. E.g. h(x,z,y) will simplify to h(x, y, z). This is the same as symmetric.
eval operator
As an argument in a call to ev (expr), eval causes an extra evaluation of expr. See
ev.
is (expr) Function
Attempts to determine whether expr (which must evaluate to a predicate) is provable
from the facts in the current data base. is returns true if the predicate is true for all
values of its variables consistent with the data base and returns false if it is false for
all such values. Otherwise, its action depends on the setting of the switch prederror.
is errs out if the value of prederror is true and returns unknown if prederror is
false.
pred operator
As an argument in a call to ev (expr), pred causes predicates (expressions which
evaluate to true or false) to be evaluated. See ev.
sqrtdispflag Variable
Default value: true
When sqrtdispflag is false, causes sqrt to display with exponent 1/2.
exptsubst if true permits substitutions like y for %e^x in %e^(a*x) to take place.
When opsubst is false, subst will not attempt to substitute into the operator of an
expression. E.g. (opsubst: false, subst (x^2, r, r+r[0])) will work.
Examples:
(%i1) subst (a, x+y, x + (x+y)^2 + y);
2
(%o1) y + x + a
(%i2) subst (-%i, %i, a + b*%i);
(%o2) a - %i b
For further examples, do example (subst).
z x x
(%i6) substpart (xthru (piece), expr, [2, 3]);
y + 1 1
(%o6) ----- - -
x z
Also, setting the option inflag to true and calling part or substpart is the same
as calling inpart or substinpart.
unorder () Function
Disables the aliasing created by the last use of the ordering commands ordergreat
and orderless. ordergreat and orderless may not be used more than one time
each without calling unorder. See also ordergreat and orderless.
(%i1) unorder();
(%o1) []
(%i2) b*x + a^2;
2
(%o2) b x + a
(%i3) ordergreat (a);
34 Maxima Manual
(%o3) done
(%i4) b*x + a^2;
2
(%o4) a + b x
(%i5) %th(1) - %th(3);
2 2
(%o5) a - a
(%i6) unorder();
(%o6) [a]
4. The algorithm uses evaluation at randomly chosen points for carefully selected
subexpressions. This is always a somewhat hazardous business, although the
algorithm tries to minimize the potential for error.
For example zeroequiv (sin(2*x) - 2*sin(x)*cos(x), x) returns true and
zeroequiv (%e^x + x, x) returns false. On the other hand zeroequiv (log(a*b)
- log(a) - log(b), a) returns dontknow because of the presence of an extra
parameter b.
36 Maxima Manual
Chapter 6: Expressions 37
6 Expressions
6.2 Assignment
There are two assignment operators in Maxima, : and ::. E.g., a: 3 sets the variable a
to 3. :: assigns the value of the expression on its right to the value of the quantity on its
left, which must evaluate to an atomic variable or subscripted variable.
6.3 Complex
A complex expression is specified in Maxima by adding the real part of the expression
to %i times the imaginary part. Thus the roots of the equation x^2 - 4*x + 13 = 0 are 2
+ 3*%I and 2 - 3*%i. Note that simplification of products of complex expressions can be
effected by expanding the product. Simplification of quotients, roots, and other functions
38 Maxima Manual
6.4 Inequality
Maxima has the usual inequality operators:
less than: <
greater than: >
greater than or equal to: >=
less than or equal to: <=
6.5 Syntax
It is possible to add new operators to Maxima (infix, prefix, postfix, unary, or matchfix
with given precedences), to remove existing operators, or to redefine the precedence of exist-
ing operators. While Maxima’s syntax should be adequate for most ordinary applications,
it is possible to define new operators or eliminate predefined ones that get in the user’s
way. The extension mechanism is rather straightforward and should be evident from the
examples below.
(%i1) prefix ("ddx")$
(%i2) ddx y$ /* equivalent to "ddx"(y) */
(%i3) infix ("<-")$
(%i4) a <- ddx y$ /* equivalent to "<-"(a, "ddx"(y)) */
For each of the types of operator except special, there is a corresponding creation
function that will give the lexeme specified the corresponding parsing properties. Thus
prefix ("ddx") will make ddx a prefix operator just like - or not. Of course, certain
extension functions require additional information such as the matching keyword for a
matchfix operator. In addition, binding powers and parts of speech must be specified for all
keywords defined. This is done by passing additional arguments to the extension functions.
If a user does not specify these additional parameters, Maxima will assign default values.
The six extension functions with binding powers and parts of speech defaults (enclosed in
brackets) are summarized below.
prefix (operator, rbp[180], rpos[any], pos[any])
postfix (operator, lbp[180], lpos[any], pos[any])
infix (operator, lbp[180], rbp[180], lpos[any], rpos[any], pos[any])
nary (operator, bp[180], argpos[any], pos[any])
nofix (operator, pos[any])
matchfix (operator, match, argpos[any], pos[any])
The defaults have been provided so that a user who does not wish to concern himself
with parts of speech or binding powers may simply omit those arguments to the extension
functions. Thus the following are all equivalent.
prefix ("ddx", 180, any, any)$
prefix ("ddx", 180)$
prefix ("ddx")$
It is also possible to remove the syntax properties of an operator by using the functions
remove or kill. Specifically, remove ("ddx", op) or kill ("ddx") will return ddx to
operand status; but in the second case all the other properties of ddx will also be removed.
Chapter 6: Expressions 39
boxchar Variable
Default value: "
boxchar is the character used to draw the box in the box and in the dpart and lpart
functions.
%emode Variable
Default value: true
When %emode is true, %e^(%pi %i x) is simplified as follows: it is expressed as cos
(%pi x) + %i sin (%pi x) if x is an integer or a multiple of 1/2, 1/3, 1/4, or 1/6,
and thus further simplified. For other numerical x, it is expressed as %e^(%pi %i y)
where y is x - 2 k for some integer k such that abs(y) < 1.
When %emode is false, no special simplification of %e^(%pi %i x) is carried out.
42 Maxima Manual
%enumer Variable
Default value: false
When %enumer is true, %e is replaced by its numeric value 2.718... whenever numer
is true.
When %enumer is false, this substitution is carried out only if the exponent in %e^x
evaluates to a number.
See also ev and numer.
exptisolate Variable
Default value: false
When exptisolate is true, will cause isolate (expr, var) to examine exponents
of atoms (like %e) which contain var.
exptsubst Variable
Default value: false
When exptsubst is true, permits substitutions such as y for %e^x in %e^(a x) to
take place.
(%i5) 1 + a@b + 2;
(%o5) (a+1,b+2)
• Greater lbp makes op right-associative, while greater rbp makes op
left-associative.
(%i1) "@"(a, b) := sconcat("(", a, ",", b, ")")$
(%i2) infix ("@", 100, 99)$
(%i3) foo @ bar @ baz;
(%o3) (foo,(bar,baz))
(%i4) infix ("@", 100, 101)$
(%i5) foo @ bar @ baz;
(%o5) ((foo,bar),baz)
inflag Variable
Default value: false
When inflag is true, the functions for part extraction will look at the internal
form of expr. Note that the simplifier re-orders expressions. Thus first (x+y) will
be x if inflag is true and Y if inflag is false. (first (y+x) gives the same
results). Also, setting inflag to true and calling part/substpart is the same as
calling inpart/substinpart. Functions affected by the setting of inflag are: part,
substpart, first, rest, last, length, the for ... in construct, map, fullmap,
maplist, reveal and pickapart.
(%t2) 2 a
(%t3) 2 b
2 2
(%t4) b + 2 a b + a
2
(%o4) c + %t3 c + %t2 c + %t4
(%i4) isolate_wrt_times: false$
(%i5) isolate (expand ((a+b+c)^2), c);
2
(%o5) c + 2 b c + 2 a c + %t4
listconstvars Variable
Default value: false
When listconstvars is true, it will cause listofvars to include %e, %pi, %i, and
any variables declared constant in the list it returns if they appear in the expression
listofvars is called on. The default is to omit these.
listdummyvars Variable
Default value: true
When listdummyvars is false, "dummy variables" in the expression will not be
included in the list returned by listofvars. (The meaning of "dummy variables" is
Chapter 6: Expressions 47
as given in freeof. "Dummy variables" are mathematical things like the index of a
sum or product, the limit variable, and the definite integration variable.) Example:
(%i1) listdummyvars: true$
(%i2) listofvars (’sum(f(i), i, 0, n));
(%o2) [i, n]
(%i3) listdummyvars: false$
(%i4) listofvars (’sum(f(i), i, 0, n));
(%o4) [n]
x - y 2 3
(x - y) (x - y)
(%i2) multthru ((x-y)^3, %);
2
(%o2) - (x - y) + x (x - y) - f(x)
(%i3) ratexpand (%);
2
(%o3) - y + x y - f(x)
(%i4) ((a+b)^10*s^2 + 2*a*b*s + (a*b)^2)/(a*b*s^2);
10 2 2 2
(b + a) s + 2 a b s + a b
(%o4) ------------------------------
2
a b s
(%i5) multthru (%); /* note that this does not expand (b+a)^10 */
10
2 a b (b + a)
(%o5) - + --- + ---------
s 2 a b
s
(%i6) multthru (a.(b+c.(d+e)+f));
(%o6) a . f + a . c . (e + d) + a . b
(%i7) expand (a.(b+c.(d+e)+f));
(%o7) a . f + a . c . e + a . c . d + a . b
nounify (f ) Function
Returns the noun form of the function name f. This is needed if one wishes to refer
to the name of a verb function as if it were a noun. Note that some verb functions
will return their noun forms if they can’t be evaluated for certain arguments. This is
also the form returned if a function call is preceded by a quote.
op (expr) Function
Returns the operator of the expression, and functions the same way as part (expr,
0). It observes the setting of the inpart flag.
optimprefix Variable
Default value: %
optimprefix is the prefix used for generated symbols by the optimize command.
partswitch Variable
Default value: false
When partswitch is true, end is returned when a selected part of an expression
doesn’t exist, otherwise an error message is given.
2
sin(x ) b + a
(%t2) - log(sqrt(x + 1) + 1) + ------- + -----
3 2
(%o2) %t2
(%i3) pickapart (expr, 1);
(%t3) - log(sqrt(x + 1) + 1)
2
sin(x )
(%t4) -------
Chapter 6: Expressions 51
b + a
(%t5) -----
2
(%t6) log(sqrt(x + 1) + 1)
2
(%t7) sin(x )
(%t8) b + a
%t8 %t7
(%o8) --- + --- - %t6
2 3
(%i8) pickapart (expr, 3);
(%t9) sqrt(x + 1) + 1
2
(%t10) x
b + a sin(%t10)
(%o10) ----- - log(%t9) + ---------
2 3
(%i10) pickapart (expr, 4);
(%t11) sqrt(x + 1)
2
sin(x ) b + a
(%o11) ------- + ----- - log(%t11 + 1)
3 2
(%i11) pickapart (expr, 5);
(%t12) x + 1
2
sin(x ) b + a
(%o12) ------- + ----- - log(sqrt(%t12) + 1)
3 2
52 Maxima Manual
piece Variable
Holds the last expression selected when using the part functions. It is set during the
execution of the function and thus may be referred to in the function itself.
verbify (f ) Function
Returns the function name f in its verb form.
See also verb, noun, and nounify.
54 Maxima Manual
Chapter 7: Simplification 55
7 Simplification
askexp Variable
When asksign is called, askexp is the expression asksign is testing.
At one time, it was possible for a user to inspect askexp by entering a Maxima break
with control-A.
domain Variable
Default value: real
When domain is set to complex, sqrt (x^2) will remain sqrt (x^2) instead of re-
turning abs(x).
56 Maxima Manual
expon Variable
Default value: 0
expon is the exponent of the largest negative power which is automatically expanded
(independent of calls to expand). For example, if expon is 4 then (x+1)^(-5) will
not be automatically expanded.
expop Variable
Default value: 0
expop is the highest positive exponent which is automatically expanded. Thus (x +
1)^3, when typed, will be automatically expanded only if expop is greater than or
equal to 3. If it is desired to have (x + 1)^n expanded where n is greater than expop
then executing expand ((x + 1)^n) will work only if maxposex is not less than n.
factlim Variable
Default value: -1
factlim specifies the highest factorial which is automatically expanded. If it is -1
then all integers are expanded.
lassociative declaration
declare (g, lassociative) tells the Maxima simplifier that g is left-associative.
E.g., g (g (a, b), g (c, d)) will simplify to g (g (g (a, b), c), d).
58 Maxima Manual
linear declaration
One of Maxima’s operator properties. For univariate f so declared, "expansion" f(x
+ y) yields f(x) + f(y), f(a*x) yields a*f(x) takes place where a is a "constant".
For functions of two or more arguments, "linearity" is defined to be as in the case of
sum or integrate, i.e., f (a*x + b, x) yields a*f(x,x) + b*f(1,x) for a and b free
of x.
linear is equivalent to additive and outative. See also opproperties.
mainvar declaration
You may declare variables to be mainvar. The ordering scale for atoms is essentially:
numbers < constants (e.g., %e, %pi) < scalars < other variables < mainvars. E.g., com-
pare expand ((X+Y)^4) with (declare (x, mainvar), expand ((x+y)^4)). (Note:
Care should be taken if you elect to use the above feature. E.g., if you subtract an
expression in which x is a mainvar from one in which x isn’t a mainvar, resimplifica-
tion e.g. with ev (expr, simp) may be necessary if cancellation is to occur. Also, if
you save an expression in which x is a mainvar, you probably should also save x.)
maxapplydepth Variable
Default value: 10000
maxapplydepth is the maximum depth to which apply1 and apply2 will delve.
maxapplyheight Variable
Default value: 10000
maxapplyheight is the maximum height to which applyb1 will reach before giving
up.
maxnegex Variable
Default value: 1000
maxnegex is the largest negative exponent which will be expanded by the expand
command (see also maxposex).
maxposex Variable
Default value: 1000
maxposex is the largest exponent which will be expanded with the expand command
(see also maxnegex).
multiplicative declaration
declare (f, multiplicative) tells the Maxima simplifier that f is multiplicative.
1. If f is univariate, whenever the simplifier encounters f applied to a product, f
distributes over that product. E.g., f(x*y) simplifies to f(x)*f(y).
2. If f is a function of 2 or more arguments, multiplicativity is defined as multiplica-
tivity in the first argument to f, e.g., f (g(x) * h(x), x) simplifies to f (g(x)
,x) * f (h(x), x).
This simplification does not occur when f is applied to expressions of the form product
(x[i], i, m, n).
Chapter 7: Simplification 59
negdistrib Variable
Default value: true
When negdistrib is true, -1 distributes over an expression. E.g., -(x + y) becomes
- y - x. Setting it to false will allow - (x + y) to be displayed like that. This is
sometimes useful but be very careful: like the simp flag, this is one flag you do not
want to set to false as a matter of course or necessarily for other than local use in
your Maxima.
negsumdispflag Variable
Default value: true
When negsumdispflag is true, x - y displays as x - y instead of as - y + x. Setting
it to false causes the special check in display for the difference of two expressions
to not be done. One application is that thus a + %i*b and a - %i*b may both be
displayed the same way.
noun declaration
noun is one of the options of the declare command. It makes a function so declared
a "noun", meaning that it won’t be evaluated automatically.
noundisp Variable
Default value: false
When noundisp is true, nouns display with a single quote. This switch is always
true when displaying function definitions.
opproperties Variable
opproperties is the list of the special operator properties recognized by the Max-
ima simplifier: linear, additive, multiplicative, outative, evenfun, oddfun,
commutative, symmetric, antisymmetric, nary, lassociative, rassociative.
opsubst Variable
Default value: true
When opsubst is false, subst does not attempt to substitute into the operator of
an expression. E.g., (opsubst: false, subst (x^2, r, r+r[0])) will work.
outative declaration
declare (f, outative) tells the Maxima simplifier that constant factors in the ar-
gument of f can be pulled out.
1. If f is univariate, whenever the simplifier encounters f applied to a product, that
product will be partitioned into factors that are constant and factors that are not
and the constant factors will be pulled out. E.g., f(a*x) will simplify to a*f(x)
where a is a constant. Non-atomic constant factors will not be pulled out.
2. If f is a function of 2 or more arguments, outativity is defined as in the case of
sum or integrate, i.e., f (a*g(x), x) will simplify to a * f(g(x), x) for a free
of x.
sum, integrate, and limit are all outative.
posfun declaration
declare (f, posfun) declares f to be a positive function. is (f(x) > 0) yields true.
prodhack Variable
Default value: false
When prodhack is true, the identity product (f(i), i, a, b) = 1/product (f(i),
i, b+1, a-1) is applied if a is greater than b. For example, product (f(i), i, 3,
1) yields 1/f(2).
When radexpand is false, certain transformations are inhibited. radcan (sqrt (1-
x)) remains sqrt (1-x) and is not simplified to %i sqrt (x-1). radcan (sqrt (x^2
- 2*x + 11)) remains sqrt (x^2 - 2*x + 1) and is not simplified to x - 1.
example (radcan) displays some examples.
radexpand Variable
Default value: true
radexpand controls some simplifications of radicals.
When radexpand is all, causes nth roots of factors of a product which are powers
of n to be pulled outside of the radical. E.g. if radexpand is all, sqrt (16*x^2)
simplifies to 4*x.
More particularly, consider sqrt (x^2).
• If radexpand is all or assume (x > 0) has been executed, sqrt(x^2) simplifies
to x.
• If radexpand is true and domain is real (its default), sqrt(x^2) simplifies to
abs(x).
• If radexpand is false, or radexpand is true and domain is complex, sqrt(x^2)
is not simplified.
Note that domain only matters when radexpand is true.
radsubstflag Variable
Default value: false
radsubstflag, if true, permits ratsubst to make substitutions such as u for sqrt
(x) in x.
rassociative declaration
declare (g, rassociative) tells the Maxima simplifier that g is right-associative.
E.g., g(g(a, b), g(c, d)) simplifies to g(a, g(b, g(c, d))).
simpsum Variable
Default value: false
When simpsum is true, the result of a sum is simplified. This simplification may
sometimes be able to produce a closed form. If simpsum is false or if the quoted
form ’sum is used, the value is a sum noun form which is a representation of the sigma
notation used in mathematics.
62 Maxima Manual
sumexpand Variable
Default value: false
When sumexpand is true, products of sums and exponentiated sums simplify to nested
sums.
See also cauchysum.
Examples:
(%i1) sumexpand: true$
(%i2) sum (f (i), i, 0, m) * sum (g (j), j, 0, n);
m n
==== ====
\ \
(%o2) > > f(i1) g(i2)
/ /
==== ====
i1 = 0 i2 = 0
(%i3) sum (f (i), i, 0, m)^2;
m m
==== ====
\ \
(%o3) > > f(i3) f(i4)
/ /
==== ====
i3 = 0 i4 = 0
sumhack Variable
Default value: false
When sumhack is true, the identity sum (f(i), i, a, b) = - sum (f(i), i, b+1,
a-1) is applied if a is greater than b. For example, (sumhack: true, sum (f(i), i,
3, 1)) yields -f(2).
sumsplitfact Variable
Default value: true
When sumsplitfact is false, minfactorial is applied after a factcomb.
symmetric declaration
declare (h, symmetric) tells the Maxima simplifier that h is a symmetric function.
E.g., h (x, z, y) simplifies to h (x, y, z).
commutative is synonymous with symmetric.
Chapter 7: Simplification 63
8 Plotting
in netmath Variable
Default value: false
When in_netmath is true, plot3d prints OpenMath output to the console if plot_
format is openmath; otherwise in_netmath (even if true) has no effect.
in_netmath has no effect on plot2d.
options are assumed to have default values unless otherwise specified by set_plot_
options.
plot2d ([expr 1, ..., expr n], x range) plots expr 1, ..., expr n as a function of
the variable named in x range, over the range specified in x range. If the vertical
range is not otherwise specified by set_plot_options, it is chosen automatically. All
options are assumed to have default values unless otherwise specified by set_plot_
options.
plot2d ([expr 1, ..., expr n], x range, y range) plots expr 1, ..., expr n as a
function of the variable named in x range, over the range specified in x range. The
vertical range is set to y range. All options are assumed to have default values unless
otherwise specified by set_plot_options.
Examples:
(%i1) plot2d (sin(x), [x, -5, 5])$
(%i2) plot2d (sec(x), [x, -2, 2], [y, -20, 20], [nticks, 200])$
Anywhere there may be an ordinary expression, there may be a parametric expres-
sion: parametric expr is a list of the form [parametric, x expr, y expr, t range,
options]. Here x expr and y expr are expressions of 1 variable var which is the first
element of the range trange. The plot is of the path traced out by the pair [x expr,
y expr] as var varies in trange.
In the following example, we plot a circle, then we do the plot with only a few points
used, so that we get a star, and finally we plot this together with an ordinary function
of X.
Examples:
• Plot a circle with a parametric plot.
(%i1) plot2d ([parametric, cos(t), sin(t), [t, -%pi*2, %pi*2],
[nticks, 80]])$
• Plot a star: join eight points on the circumference of a circle.
(%i2) plot2d ([parametric, cos(t), sin(t), [t, -%pi*2, %pi*2],
[nticks, 8]])$
• Plot a cubic polynomial with an ordinary plot and a circle with a parametric
plot.
(%i3) plot2d ([x^3 + 2, [parametric, cos(t), sin(t), [t, -5, 5],
[nticks, 80]]], [x, -3, 3])$
See also plot_options, which describes plotting options and has more examples.
plot3d ([expr_1, expr_2, expr_3], [x, -%pi, %pi], [y, -%pi, %pi], [’grid, 40, 4
or a torus
expr_1: cos(y)*(10.0+6*cos(x));
expr_2: sin(y)*(10.0+6*cos(x));
expr_3: -6*sin(x);
plot3d ([expr_1, expr_2, expr_3], [x, 0, 2*%pi], [y, 0, 2*%pi], [’grid, 40, 40]
We can output to gnuplot too:
plot3d (2^(x^2 - y^2), [x, -1, 1], [y, -2, 2], [plot_format, gnuplot]);
Sometimes you may need to define a function to plot the expression. All the arguments
to plot3d are evaluated before being passed to plot3d, and so trying to make an
expression which does just what you want may be difficult, and it is just easier to
make a function.
M: matrix([1, 2, 3, 4], [1, 2, 3, 2], [1, 2, 3, 4], [1, 2, 3, 3])$
f(x, y) := float (M [?round(x), ?round(y)])$
plot3d (f, [x, 1, 4], [y, 1, 4], [’grid, 4, 4])$
See plot_options for more examples.
72 Maxima Manual
closeps () Function
This should usually becalled at the end of a sequence of plotting commands. It closes
the current output stream pstream, and sets it to nil. It also may be called at the start
of a plot, to ensure pstream is closed if it was open. All commands which write to
pstream, open it if necessary. closeps is separate from the other plotting commands,
since we may want to plot 2 ranges or superimpose several plots, and so must keep
the stream open.
9.2 Files
A file is simply an area on a particular storage device which contains data or text. Files
on the disks are figuratively grouped into "directories". A directory is just a list of files.
Commands which deal with files are: save, load, loadfile, stringout, batch, demo,
writefile, closefile, and appendfile.
% Variable
% is the output expression (e.g., %o1, %o2, %o3, ...) most recently computed by
Maxima, whether or not it was displayed. See also %% and %th.
%% Variable
In a compound statement comprising two or more statements, %% is the value of the
previous statement. For example,
block (integrate (x^5, x), ev (%%, x=2) - ev (%%, x=1));
block ([prev], prev: integrate (x^5, x), ev (prev, x=2) - ev (prev, x=1));
yield the same result, namely 21/2.
A compound statement may comprise other compound statements. Whether a state-
ment be simple or compound, %% is the value of the previous statement. For example,
block (block (a^n, %%*42), %%/6)
yields 7*a^n.
Within a compound statement, the value of %% may be inspected at a break prompt,
which is opened by executing the break function. For example, at the break prompt
opened by
block (a: 42, break ())$
entering %%; yields 42.
At the first statement in a compound statement, or outside of a compound statement,
%% is undefined.
%edispflag Variable
Default value: false
When %edispflag is true, Maxima displays %e to a negative exponent as a quotient.
For example, %e^-x is displayed as 1/%e^x.
74 Maxima Manual
absboxchar Variable
Default value: !
absboxchar is the character used to draw absolute value signs around expressions
which are more than one line tall.
closefile () Function
Closes the transcript file opened by writefile or appendfile.
display2d Variable
Default value: true
When display2d is false, the console display is a string (1-dimensional) form rather
than a display (2-dimensional) form.
A - 1
a/b; - A B
B
1/2
sqrt(x); sqrt(X) X
4 X 4
X*4/3; --- - X
3 3
E
D
C + B + A
Example expression is --------------
cos(X - 1) + 1
-- an error. Quitting. To debug this try debugmode(true);
exptdispflag Variable
Default value: true
When exptdispflag is true, Maxima displays expressions with negative exponents
using quotients, e.g., X^(-1) as 1/X.
The argument filename can be a path and file name, or just a file name, or, if a file
search directory includes a file search pattern, just the base of the file name (without
an extension). For example,
file_search ("/home/wfs/special/zeta.mac");
file_search ("zeta.mac");
file_search ("zeta");
all find the same file, assuming the file exists and /home/wfs/special/###.mac is in
file_search_maxima.
file_search (filename, pathlist) searches only in the directories specified by path-
list, which is a list of strings. The argument pathlist supersedes the default search
directories, so if the path list is given, file_search searches only the ones specified,
and not any of the default search directories. Even if there is only one directory in
pathlist, it must still be given as a one-element list.
The user may modify the default search directories. See file_search_maxima.
file_search is invoked by load with file_search_maxima and file_search_lisp
as the search directories.
The return value is a symbol, either object, lisp, or maxima. If the extension starts
with m or d, file_type returns maxima. If the extension starts with l, file_type
returns lisp. If none of the above, file_type returns object.
ibase Variable
Default value: 10
Integers entered into Maxima are interpreted with respect to the base ibase.
ibase may be assigned any integer between 2 and 35 (decimal), inclusive. When
ibase is greater than 10, the numerals comprise the decimal numerals 0 through 9
plus capital letters of the alphabet A, B, C, ..., as needed. The numerals for base 35,
the largest acceptable base, comprise 0 through 9 and A through Y.
See also obase.
inchar Variable
Default value: %i
inchar is the prefix of the labels of expressions entered by the user. Maxima auto-
matically constructs a label for each input expression by concatenating inchar and
linenum. inchar may be assigned any string or symbol, not necessarily a single
character.
(%i1) inchar: "input";
(%o1) input
(input1) expand ((a+b)^3);
3 2 2 3
(%o1) b + 3 a b + 3 a b + a
(input2)
See also labels.
(%i1) e: (a+b)^3;
3
(%o1) (b + a)
(%i2) f: expand (e);
3 2 2 3
(%o2) b + 3 a b + 3 a b + a
(%i3) ldisp (e, f);
3
(%t3) (b + a)
3 2 2 3
(%t4) b + 3 a b + 3 a b + a
3 2 2 3
(%t4) f = b + 3 a b + 3 a b + a
linechar Variable
Default value: %t
linechar is the prefix of the labels of intermediate expressions generated by Maxima.
Maxima constructs a label for each intermediate expression (if displayed) by concate-
nating linechar and linenum. linechar may be assigned any string or symbol, not
necessarily a single character.
Intermediate expressions might or might not be displayed. See programmode and
labels.
linel Variable
Default value: 79
linel is the assumed width (in characters) of the console display for the purpose
of displaying expressions. linel may be assigned any value by the user, although
very small or very large values may be impractical. Text printed by built-in Maxima
functions, such as error messages and the output of describe, is not affected by
linel.
loadprint Variable
Default value: true
loadprint tells whether to print a message when a file is loaded.
Chapter 9: Input and Output 83
obase Variable
Default value: 10
obase is the base for integers displayed by Maxima.
obase may be assigned any integer between 2 and 35 (decimal), inclusive. When
obase is greater than 10, the numerals comprise the decimal numerals 0 through 9
plus capital letters of the alphabet A, B, C, ..., as needed. The numerals for base 35,
the largest acceptable base, comprise 0 through 9, and A through Y.
See also ibase.
outchar Variable
Default value: %o
outchar is the prefix of the labels of expressions computed by Maxima. Maxima auto-
matically constructs a label for each computed expression by concatenating outchar
and linenum. outchar may be assigned any string or symbol, not necessarily a single
character.
(%i1) outchar: "output";
(output1) output
(%i2) expand ((a+b)^3);
3 2 2 3
(output2) b + 3 a b + 3 a b + a
(%i3)
See also labels.
packagefile Variable
Default value: false
Package designers who use save or translate to create packages (files) for others to
use may want to set packagefile: true to prevent information from being added to
Maxima’s information-lists (e.g. values, functions) except where necessary when
the file is loaded in. In this way, the contents of the package will not get in the user’s
way when he adds his own data. Note that this will not solve the problem of possible
name conflicts. Also note that the flag simply affects what is output to the package
file. Setting the flag to true is also useful for creating Maxima init files.
pfeformat Variable
Default value: false
When pfeformat is true, a ratio of integers is displayed with the solidus (forward
slash) character, and an integer denominator n is displayed as a leading multiplicative
term 1/n.
84 Maxima Manual
10 log(a) - log(b)
(%i2) r;
(%o2) 10 log(a) - log(b)
(%i3) disp ("(a+b)^3 is", expand ((a+b)^3), "log (a^10/b) is", radcan (log (a^1
(a+b)^3 is
3 2 2 3
b + 3 a b + 3 a b + a
log (a^10/b) is
10 log(a) - log(b)
{1.000000000 4.000000000
}
(%i2) tcl_output ([1, 2, 3, 4, 5, 6], 2, 3)$
{2.000000000 5.000000000
}
(%i3) tcl_output ([3/7, 5/9, 11/13, 13/17], 1)$
2 %e + %e + %e
(%i7) reveal (e, 6);
2 2
b - 2 a b + a
(%o7) -------------------------
b + a 2 b 2 a
2 %e + %e + %e
rmxchar Variable
Default value: ]
rmxchar is the character drawn on the right-hand side of a matrix.
See also lmxchar.
save quotes its arguments. filename must be a string, not a string variable. The first
and last labels to save, if specified, must be integers. The double quote operator eval-
uates a string variable to its string value, e.g., s: "foo.1"$ save (’’s, all)$, and
integer variables to their integer values, e.g., m: 5$ n: 12$ save ("foo.1", [’’m,
’’n])$.
savedef Variable
Default value: true
When savedef is true, the Maxima version of a user function is preserved when the
function is translated. This permits the definition to be displayed by dispfun and
allows the function to be edited.
When savedef is false, the names of translated functions are removed from the
functions list.
stardisp Variable
Default value: false
When stardisp is true, multiplication is displayed with an asterisk * between
operands.
If grind is true, stringout formats the output using the grind format. Otherwise
the string format is used. See grind and string.
The special form stringout (filename, [m, n]) writes the values of input labels m
through n, inclusive.
The special form stringout (filename, input) writes all input labels to the file.
The special form stringout (filename, functions) writes all user-defined functions
(named by the global list functions) to the file.
The special form stringout (filename, values) writes all user-assigned variables
(named by the global list values) to the file. Each variable is printed as an assignment
statement, with the name of the variable, a colon, and its value. Note that the general
form of stringout does not print variables as assignment statements.
ttyoff Variable
Default value: false
When ttyoff is true, output expressions are not displayed. Output expressions are
still computed and assigned labels. See labels.
Text printed by built-in Maxima functions, such as error messages and the output of
describe, is not affected by ttyoff.
10 Floating Point
algepsilon Variable
Default value: 10^8
algepsilon is used by algsys.
bftorat Variable
Default value: false
bftorat controls the conversion of bfloats to rational numbers. When bftorat is
false, ratepsilon will be used to control the conversion (this results in relatively
small rational numbers). When bftorat is true, the rational number generated will
accurately represent the bfloat.
bftrunc Variable
Default value: true
bftrunc causes trailing zeroes in non-zero bigfloat numbers not to be displayed. Thus,
if bftrunc is false, bfloat (1) displays as 1.000000000000000B0. Otherwise, this
is displayed as 1.0B0.
92 Maxima Manual
float2bf Variable
Default value: false
When float2bf is false, a warning message is printed when a floating point number
is converted into a bigfloat number (since this may lead to loss of precision).
fpprec Variable
Default value: 16
fpprec is the Maxima floating point precision. fpprec can be set to an integer
representing the desired precision.
fpprintprec Variable
Default value: 0
fpprintprec is the number of digits to print when printing a bigfloat number, making
it possible to compute with a large number of digits of precision, but have the answer
printed out with a smaller number of digits.
When fpprintprec is 0, or greater than or equal to fpprec, then the value of fpprec
controls the number of digits used for printing.
When fpprintprec has a value between 2 and fpprec - 1, then it controls the num-
ber of digits used. (The minimal number of digits used is 2, one to the left of the
point and one to the right.
The value 1 for fpprintprec is illegal.
11 Contexts
activecontexts Variable
Default value: []
activecontexts is a list of the contexts which are active by way of the activate
function, as opposed to being active because they are subcontexts of the current
context.
assumescalar Variable
Default value: true
assumescalar helps govern whether expressions expr for which nonscalarp (expr)
is false are assumed to behave like scalars for certain transformations.
Let expr represent any expression other than a list or a matrix, and let [1, 2, 3]
represent any list or matrix. Then expr . [1, 2, 3] yields [expr, 2 expr, 3 expr]
if assumescalar is true, or scalarp (expr) is true, or constantp (expr) is true.
If assumescalar is true, such expressions will behave like scalars only for commuta-
tive operators, but not for noncommutative multiplication ..
When assumescalar is false, such expressions will behave like non-scalars.
When assumescalar is all, such expressions will behave like scalars for all the op-
erators listed above.
By default, a parameter is x such that symbolp (x) or subvarp (x). The class of
expressions considered parameters can be modified to some extent via the variable
assume_pos_pred.
sign and asksign attempt to deduce the sign of expressions from the sign of operands
within the expression. For example, if a and b are both positive, then a + b is also
positive.
However, there is no way to bypass all asksign queries. In particular, when the
asksign argument is a difference x - y or a logarithm log(x), asksign always re-
quests an input from the user, even when assume_pos is true and assume_pos_pred
is a function which returns true for all arguments.
(%o6) pos
(%i7) asksign (a[1]);
x = a
1
(%o7) pos
(%i8) asksign (foo (a));
x = foo(a)
(%o8) pos
(%i9) asksign (foo (a) + bar (b));
x = foo(a)
Chapter 11: Contexts 97
x = bar(b)
(%o9) pos
(%i10) asksign (log (a));
x = a
p;
(%o10) pos
(%i11) asksign (a - b);
x = a
x = b
x = a
x = b
p;
(%o11) neg
context Variable
Default value: initial
context names the collection of facts maintained by assume and forget. assume
adds facts to the collection named by context, while forget removes facts.
Binding context to a name foo changes the current context to foo. If the specified
context foo does not yet exist, it is created automatically by a call to newcontext.
The specified context is activated automatically.
See context for a general description of the context mechanism.
contexts Variable
Default value: [initial, global]
contexts is a list of the contexts which currently exist, including the currently active
context.
The context mechanism makes it possible for a user to bind together and name a
selected portion of his database, called a context. Once this is done, the user can have
Maxima assume or forget large numbers of facts merely by activating or deactivating
their context.
Any symbolic atom can be a context, and the facts contained in that context will be
retained in storage until destroyed one by one by calling forget or destroyed as a
whole by calling kill to destroy the context to which they belong.
Contexts exist in a hierarchy, with the root always being the context global, which
contains information about Maxima that some functions need. When in a given
98 Maxima Manual
context, all the facts in that context are "active" (meaning that they are used in
deductions and retrievals) as are all the facts in any context which is a subcontext of
the active context.
When a fresh Maxima is started up, the user is in a context called initial, which
has global as a subcontext.
See also facts, newcontext, supcontext, killcontext, activate, deactivate,
assume, and forget.
features declaration
Maxima recognizes certain mathematical properties of functions and variables. These
are called "features".
declare (x, foo) gives the property foo to the function or variable x.
declare (foo, feature) declares a new feature foo. For example, declare ([red,
green, blue], feature) declares three new features, red, green, and blue.
The predicate featurep (x, foo) returns true if x has the foo property, and false
otherwise.
The infolist features is a list of known features. These are integer, noninteger,
even, odd, rational, irrational, real, imaginary, complex, analytic,
increasing, decreasing, oddfun, evenfun, posfun, commutative, lassociative,
rassociative, symmetric, and antisymmetric, plus any user-defined features.
features is a list of mathematical features. There is also a list of non-mathematical,
system-dependent features. See status.
If one of the contexts is the current context, the new current context will become the
first available subcontext of the current context which has not been killed. If the first
available unkilled context is global then initial is used instead. If the initial
context is killed, a new, empty initial context is created.
killcontext refuses to kill a context which is currently active, either because it is a
subcontext of the current context, or by use of the function activate.
12 Polynomials
algebraic Variable
Default value: false
algebraic must be set to true in order for the simplification of algebraic integers to
take effect.
102 Maxima Manual
berlefact Variable
Default value: true
When berlefact is false then the Kronecker factoring algorithm will be used oth-
erwise the Berlekamp algorithm, which is the default, will be used.
3 2
- 5154 x - 1291 x + 7688 x + 15376]
facexpand Variable
Default value: true
facexpand controls whether the irreducible factors returned by factor are in ex-
panded (the default) or recursive (normal CRE) form.
104 Maxima Manual
2
(%o7) - (y + x) (z - x) (z + x)
(%i8) (2 + x)/(3 + x)/(b + x)/(c + x)^2;
x + 2
(%o8) ------------------------
2
(x + 3) (x + b) (x + c)
(%i9) ratsimp (%);
4 3
(%o9) (x + 2)/(x + (2 c + b + 3) x
2 2 2 2
+ (c + (2 b + 6) c + 3 b) x + ((b + 3) c + 6 b c) x + 3 b c )
(%i10) partfrac (%, x);
2 4 3
(%o10) - (c - 4 c - b + 6)/((c + (- 2 b - 6) c
2 2 2 2
+ (b + 12 b + 9) c + (- 6 b - 18 b) c + 9 b ) (x + c))
c - 2
- ---------------------------------
2 2
(c + (- b - 3) c + 3 b) (x + c)
b - 2
+ -------------------------------------------------
2 2 3 2
((b - 3) c + (6 b - 2 b ) c + b - 3 b ) (x + b)
1
- ----------------------------------------------
2
((b - 3) c + (18 - 6 b) c + 9 b - 27) (x + 3)
(%i11) map (’factor, %);
2
c - 4 c - b + 6 c - 2
(%o11) - ------------------------- - ------------------------
2 2 2
(c - 3) (c - b) (x + c) (c - 3) (c - b) (x + c)
b - 2 1
+ ------------------------ - ------------------------
2 2
(b - 3) (c - b) (x + b) (b - 3) (c - 3) (x + 3)
(%i12) ratsimp ((x^5 - 1)/(x - 1));
4 3 2
(%o12) x + x + x + x + 1
(%i13) subst (a, x, %);
106 Maxima Manual
4 3 2
(%o13) a + a + a + a + 1
(%i14) factor (%th(2), %);
2 3 3 2
(%o14) (x - a) (x - a ) (x - a ) (x + a + a + a + 1)
(%i15) factor (1 + x^12);
4 8 4
(%o15) (x + 1) (x - x + 1)
(%i16) factor (1 + x^99);
2 6 3
(%o16) (x + 1) (x - x + 1) (x - x + 1)
10 9 8 7 6 5 4 3 2
(x - x + x - x + x - x + x - x + x - x + 1)
20 19 17 16 14 13 11 10 9 7 6
(x + x - x - x + x + x - x - x - x + x + x
4 3 60 57 51 48 42 39 33
- x - x + x + 1) (x + x - x - x + x + x - x
30 27 21 18 12 9 3
- x - x + x + x - x - x + x + 1)
factorflag Variable
Default value: false
When factorflag is false, suppresses the factoring of integer factors of rational
expressions.
2 2 2 2
+ 2 u v x + u x + a w + v + 2 u v + u
(%i2) factorsum (%);
2 2
(%o2) (x + 1) (a (z + w) + (v + u) )
Chapter 12: Polynomials 107
fasttimes (p 1, p 2) Function
Returns the product of the polynomials p 1 and p 2 by using a special algorithm for
multiplication of polynomials. p_1 and p_2 should be multivariate, dense, and nearly
the same size. Classical multiplication is of order n_1 n_2 where n_1 is the degree of
p_1 and n_2 is the degree of p_2. fasttimes is of order max (n_1, n_2)^1.585.
hipow does not consider expressions equivalent to expr. In particular, hipow does not
expand expr, so hipow (expr, x) and hipow (expand (expr, x)) may yield different
results.
Examples:
(%i1) hipow (y^3 * x^2 + x * y^4, x);
(%o1) 2
(%i2) hipow ((x + y)^5, x);
(%o2) 1
(%i3) hipow (expand ((x + y)^5), x);
(%o3) 5
(%i4) hipow ((x + y)^5, x + y);
(%o4) 5
(%i5) hipow (expand ((x + y)^5), x + y);
(%o5) 0
intfaclim Variable
Default value: 1000
intfaclim is the largest divisor which will be tried when factoring a bignum integer.
When intfaclim is false (this is the case when the user calls factor explicitly),
or if the integer is a fixnum (i.e., fits in one machine word), factors of any size are
considered. intfaclim is set to false when factors are computed in divsum, totient,
and primep.
Internal calls to factor respect the user-specified value of intfaclim. Setting
intfaclim to a smaller value may reduce the time spent factoring large integers.
keepfloat Variable
Default value: false
When keepfloat is true, prevents floating point numbers from being rationalized
when expressions which contain them are converted to canonical rational expression
(CRE) form.
• If only one substitution is desired, then a single equation may be given as first
argument.
(%i4) lratsubst (a^2 = b, a^3);
(%o4) a b
modulus Variable
Default value: false
When modulus is a positive number p, operations on rational numbers (as returned by
rat and related functions) are carried out modulo p, using the so-called "balanced"
modulus system in which n modulo p is defined as an integer k in [-(p-1)/2, ...,
0, ..., (p-1)/2] when p is odd, or [-(p/2 - 1), ..., 0, ...., p/2] when p is
even, such that a p + k equals n for some integer a.
If expr is already in canonical rational expression (CRE) form when modulus is reset,
then you may need to re-rat expr, e.g., expr: rat (ratdisrep (expr)), in order to
get correct results.
Typically modulus is set to a prime number. If modulus is set to a positive non-prime
integer, this setting is accepted, but a warning message is displayed. Maxima will
allow zero or a negative integer to be assigned to modulus, although it is not clear if
that has any useful consequences.
quotient (p 1, p 2) Function
quotient (p 1, p 2, x 1, ..., x n) Function
Returns the polynomial p 1 divided by the polynomial p 2. The arguments x 1, ...,
x n are interpreted as in ratvars.
quotient returns the first element of the two-element list returned by divide.
time in some computations. The numerator and denominator are still made rela-
tively prime (e.g. rat ((x^2 - 1)^4/(x + 1)^2) yields (x - 1)^4 (x + 1)^2), but
the factors within each part may not be relatively prime.
ratprint if false suppresses the printout of the message informing the user of the
conversion of floating point numbers to rational numbers.
keepfloat if true prevents floating point numbers from being converted to rational
numbers.
See also ratexpand and ratsimp.
Examples:
(%i1) ((x - 2*y)^4/(x^2 - 4*y^2)^2 + 1)*(y + a)*(2*y + x) /(4*y^2 + x^2);
4
(x - 2 y)
(y + a) (2 y + x) (------------ + 1)
2 2 2
(x - 4 y )
(%o1) ------------------------------------
2 2
4 y + x
(%i2) rat (%, y, a, x);
2 a + 2 y
(%o2)/R/ ---------
x + 2 y
ratalgdenom Variable
Default value: true
When ratalgdenom is true, allows rationalization of denominators with respect to
radicals to take effect. ratalgdenom has an effect only when canonical rational ex-
pressions (CRE) are used in algebraic mode.
ratdenomdivide Variable
Default value: true
When ratdenomdivide is true, ratexpand expands a ratio in which the numerator is
a sum into a sum of ratios, all having a common denominator. Otherwise, ratexpand
collapses a sum of ratios into a single ratio, the numerator of which is the sum of the
numerators of each ratio.
Examples:
(%i1) expr: (x^2 + x + 1)/(y^2 + 7);
2
x + x + 1
(%o1) ----------
2
y + 7
(%i2) ratdenomdivide: true$
(%i3) ratexpand (expr);
2
x x 1
(%o3) ------ + ------ + ------
2 2 2
y + 7 y + 7 y + 7
(%i4) ratdenomdivide: false$
(%i5) ratexpand (expr);
2
x + x + 1
(%o5) ----------
2
y + 7
(%i6) expr2: a^2/(b^2 + 3) + b/(b^2 + 3);
2
b a
(%o6) ------ + ------
2 2
b + 3 b + 3
114 Maxima Manual
ratepsilon Variable
Default value: 2.0e-8
ratepsilon is the tolerance used in the conversion of floating point numbers to ra-
tional numbers.
3 2 3 2
x + x - x - 1 x + x - x - 1
ratfac Variable
Default value: false
When ratfac is true, canonical rational expressions (CRE) are manipulated in a
partially factored form.
During rational operations the expression is maintained as fully factored as possi-
ble without calling factor. This should always save space and may save time in
some computations. The numerator and denominator are made relatively prime, for
example rat ((x^2 - 1)^4/(x + 1)^2) yields (x - 1)^4 (x + 1)^2), but the factors
within each part may not be relatively prime.
In the ctensr (Component Tensor Manipulation) package, Ricci, Einstein, Riemann,
and Weyl tensors and the scalar curvature are factored automatically when ratfac is
true. ratfac should only be set for cases where the tensorial components are known
to consist of few terms.
The ratfac and ratweight schemes are incompatible and may not both be used at
the same time.
ratprint Variable
Default value: true
When ratprint is true, a message informing the user of the conversion of floating
point numbers to rational numbers is displayed.
Chapter 12: Polynomials 117
ratsimpexpons Variable
Default value: false
When ratsimpexpons is true, ratsimp is applied to the exponents of expressions
during simplification.
118 Maxima Manual
ratweights Variable
Default value: []
ratweights is the list of weights assigned by ratweight. The list is cumulative: each
call to ratweight places additional items in the list.
kill (ratweights) and save (ratweights) both work as expected.
ratwtlvl Variable
Default value: false
ratwtlvl is used in combination with the ratweight function to control the trun-
cation of canonical rational expressions (CRE). For the default value of false, no
truncation occurs.
remainder (p 1, p 2) Function
remainder (p 1, p 2, x 1, ..., x n) Function
Returns the remainder of the polynomial p 1 divided by the polynomial p 2. The
arguments x 1, ..., x n are interpreted as in ratvars.
remainder returns the second element of the two-element list returned by divide.
resultant (p 1, p 2, x) Function
resultant Variable
Computes the resultant of the two polynomials p 1 and p 2, eliminating the variable
x. The resultant is a determinant of the coefficients of x in p 1 and p 2, which equals
zero if and only if p 1 and p 2 have a non-constant factor in common.
120 Maxima Manual
savefactors Variable
Default value: false
When savefactors is true, causes the factors of an expression which is a product
of factors to be saved by certain functions in order to speed up later factorizations of
expressions containing some of the same factors.
13 Constants
%e Constant
- The base of natural logarithms, e, is represented in Maxima as %e.
false Constant
- the Boolean constant, false. (NIL in Lisp)
%inf Constant
- real positive infinity.
%infinity Constant
- complex infinity.
%minf Constant
- real minus infinity.
pi Constant
- "pi" is represented in Maxima as %pi.
true Constant
- the Boolean constant, true. (T in Lisp)
124 Maxima Manual
Chapter 14: Logarithms 125
14 Logarithms
15 Trigonometric
atrig1 Package
The atrig1 package contains several additional simplification rules for inverse trigono-
metric functions. Together with rules already known to Maxima, the following angles
are fully implemented: 0, %pi/6, %pi/4, %pi/3, and %pi/2. Corresponding angles in
the other three quadrants are also available. Do load(atrig1); to use them.
ntrig Package
The ntrig package contains a set of simplification rules that are used to simplify
trigonometric function whose arguments are of the form f (n %pi/10) where f is any
of the functions sin, cos, tan, csc, sec and cot.
The trigonometric simplification routines will use declared information in some simple
cases. Declarations about variables are used as follows, e.g.
(%i1) declare(j, integer, e, even, o, odd)$
(%i2) sin(x + (e + 1/2)*%pi);
(%o2) cos(x)
(%i3) sin(x + (o + 1/2)*%pi);
(%o3) - cos(x)
The following example is taken from Davenport, Siret, and Tournier, Calcul Formel,
Masson (or in English, Addison-Wesley), section 1.5.5, Morley theorem.
(%i1) c: %pi/3 - a - b;
%pi
(%o1) - b - a + ---
3
(%i2) bc: sin(a)*sin(3*c)/sin(a+b);
sin(a) sin(3 b + 3 a)
(%o2) ---------------------
sin(b + a)
(%i3) ba: bc, c=a, a=c$
(%i4) ac2: ba^2 + bc^2 - 2*bc*ba*cos(b);
2 2
sin (a) sin (3 b + 3 a)
(%o4) -----------------------
2
sin (b + a)
%pi
2 sin(a) sin(3 a) cos(b) sin(b + a - ---) sin(3 b + 3 a)
3
- --------------------------------------------------------
%pi
sin(a - ---) sin(b + a)
3
2 2 %pi
sin (3 a) sin (b + a - ---)
3
+ ---------------------------
2 %pi
sin (a - ---)
3
(%i5) trigrat (ac2);
(%o5) - (sqrt(3) sin(4 b + 4 a) - cos(4 b + 4 a)
- 9)/4
Chapter 16: Special Functions 133
16 Special Functions
16.2 specint
hypgeo is a package for handling Laplace transforms of special functions. hyp is a package
for handling generalized Hypergeometric functions.
specint attempts to compute the definite integral (over the range from zero to infinity)
of an expression containing special functions. When the integrand contains a factor exp
(-s t), the result is a Laplace transform.
The syntax is as follows:
specint (exp (-s*t) * expr, t);
where t is the variable of integration and expr is an expression containing special func-
tions.
If specint cannot compute the integral, the return value may contain various Lisp sym-
bols, including other-defint-to-follow-negtest, other-lt-exponential-to-follow,
product-of-y-with-nofract-indices, etc.; this is a bug.
Special function notation follows:
bessel_j (index, expr) Bessel function, 1st kind
bessel_y (index, expr) Bessel function, 2nd kind
bessel_i (index, expr) Modified Bessel function, 1st kind
bessel_k (index, expr) Modified Bessel function, 2nd kind
%he[n] (z) Hermite polynomial (Nota bene: he, not h. See A&S 22.
%p[u,v] (z) Legendre function
%q[u,v] (z) Legendre function, 2nd kind
hstruve[n] (z) Struve H function
lstruve[n] (z) Struve L function
%f[p,q] ([], [], expr) Generalized Hypergeometric function
gamma() Gamma function
gammagreek(a,z) Incomplete gamma function
gammaincomplete(a,z) Tail of incomplete gamma function
slommel
%m[u,k] (z) Whittaker function, 1st kind
%w[u,k] (z) Whittaker function, 2nd kind
erfc (z) Complement of the erf function
ei (z) Exponential integral (?)
kelliptic (z) Complete elliptic integral of the first kind (K)
%d [n] (z) Parabolic cylinder function
demo ("hypgeo") displays several examples of Laplace transforms computed by specint.
This is a work in progress. Some of the function names may change.
134 Maxima Manual
asympa Function
asympa is a package for asymptotic analysis. The package contains simplification
functions for asymptotic analysis, including the “big O” and “little o” functions that
are widely used in complexity analysis and numerical analysis.
load ("asympa") loads this package.
∞ k z v+2 k
X (−1) 2
k=0
k! Γ (v + k + 1)
∞ v+2 k
X 1 z
k=0
k! Γ (v + k + 1) 2
besselexpand Variable
Default value: false
Controls expansion of the Bessel functions when the order is half of an odd integer. In
this case, the Bessel functions can be expanded in terms of other elementary functions.
When besselexpand is true, the Bessel function is expanded.
136 Maxima Manual
j0 (x) Function
The Bessel function of the first kind of order 0.
This function is deprecated. Write bessel_j (0, x) instead.
j1 (x) Function
The Bessel function of the first kind of order 1.
This function is deprecated. Write bessel_j (1, x) instead.
jn (x, n) Function
The Bessel function of the first kind of order n.
This function is deprecated. Write bessel_j (n, x) instead.
i0 (x) Function
The modified Bessel function of the first kind of order 0.
This function is deprecated. Write bessel_i (0, x) instead.
i1 (x) Function
The modified Bessel function of the first kind of order 1.
This function is deprecated. Write bessel_i (1, x) instead.
gammalim Variable
Default value: 1000000
gammalim controls simplification of the gamma function for integral and rational num-
ber arguments. If the absolute value of the argument is not greater than gammalim,
then simplification will occur. Note that the factlim switch controls simplification
of the result of gamma of an integer argument as well.
Chapter 16: Special Functions 137
poislim Variable
Default value: 5
poislim determines the domain of the coefficients in the arguments of the trig func-
tions. The initial value of 5 corresponds to the interval [-2^(5-1)+1,2^(5-1)], or [-15,16],
but it can be set to [-2^(n-1)+1, 2^(n-1)].
138 Maxima Manual
poistrim () Function
is a reserved function name which (if the user has defined it) gets applied during Pois-
son multiplication. It is a predicate function of 6 arguments which are the coefficients
of the u, v, ..., z in a term. Terms for which poistrim is true (for the coefficients of
that term) are eliminated during multiplication.
17 Orthogonal Polynomials
not bigfloats), many functions in specfun call a float modedeclared version of the Jacobi
function. This greatly speeds floating point evaluation of the orthogonal polynomials.
specfun handles most domain errors by returning an unevaluated function. No sim-
plification rules (based on recursion relations) are defined for unevaluated functions. It is
possible for an expression involving sums of unevaluated special functions to vanish, yet
Maxima is unable to reduce it to zero.
load ("specfun") loads the specfun package. Alternatively, setup_autoload causes
the package to be loaded when one of the specfun functions appears in an expression.
setup_autoload may appear at the command line or in the maxima-init.mac file. See
setup_autoload.
An example use of specfun is
(%i1) load ("specfun")$
(%i2) [hermite (0, x), hermite (1, x), hermite (2, x)];
2
(%o2) [1, 2 x, - 2 (1 - 2 x )]
(%i3) diff (hermite (n, x), x);
(%o3) 2 n hermite(n - 1, x)
Generally, compiled code runs faster than translated code; however, translated code may
be better for program development.
Some functions (namely jacobi_p, ultraspherical, chebyshev_t, chebyshev_u, and
legendre_p), return a series representation when the order is a symbolic integer. The
series representation is not used by specfun for any computations, but it may be simplified
by Maxima automatically, or it may be possible to use the series to evaluate the function
through further manipulations. For example:
(%i1) load ("specfun")$
(%i2) legendre_p (n, x);
(%o2) legendre_p(n, x)
(%i3) ultraspherical (n, 3/2, 2);
genfact(3, n, - 1) jacobi_p(n, 1, 1, 2)
(%o3) ---------------------------------------
genfact(2, n, - 1)
(%i4) declare (n, integer)$
(%i5) legendre_p (n, x);
n - 1
====
\ n - i%
(%o5) ( > binomial(n, i%) binomial(n, n - i%) (x - 1)
/
====
i% = 1
i% n n n
(x + 1) + (x + 1) + (x - 1) )/2
(%i6) ultraspherical (n, 3/2, 2);
n - 1
====
\ i%
Chapter 17: Orthogonal Polynomials 141
n
binomial(n + 1, n - i%) + (n + 1) 3 + n + 1)
n
/(genfact(2, n, - 1) 2 )
The first and last terms of the sum are added outside the summation. Removing these
two terms avoids Maxima bugs associated with 00 terms in a sum that should evaluate to
1, but evaluate to 0 in a Maxima summation. Because the sum index runs from 1 to n − 1,
the lower sum index will exceed the upper sum index when n = 0; setting sumhack to true
provides a fix. For example:
(%i1) load ("specfun")$
(%i2) declare (n, integer)$
(%i3) e: legendre_p(n,x)$
(%i4) ev (e, sum, n=0);
Lower bound to sum: 1
is greater than the upper bound: - 1
-- an error. Quitting. To debug this try debugmode(true);
(%i5) ev (e, sum, n=0, sumhack=true);
(%o5) 1
Most functions in specfun have a gradef property; derivatives with respect to the order
or other function parameters are undefined, and an attempt to compute such a derivative
yields an error message.
The specfun package and its documentation were written by Barton Willis of the Uni-
versity of Nebraska at Kearney. It is released under the terms of the General Public License
(GPL). Send bug reports and comments on this package to willisb@unk.edu. In your report,
please include the Maxima version, as reported by build_info(), and the specfun version,
as reported by get (’specfun, ’version).
18 Elliptic Functions
The elliptic functions and integrals are primarily intended to support symbolic compu-
tation. Therefore, most of derivatives of the functions and integrals are known. However,
if floating-point values are given, a floating-point result is returned.
Support for most of the other properties of elliptic functions and integrals other than
derivatives has not yet been written.
Some examples of elliptic functions:
(%i1) jacobi_sn (u, m);
(%o1) jacobi_sn(u, m)
(%i2) jacobi_sn (u, 1);
(%o2) tanh(u)
(%i3) jacobi_sn (u, 0);
(%o3) sin(u)
(%i4) diff (jacobi_sn (u, m), u);
(%o4) jacobi_cn(u, m) jacobi_dn(u, m)
(%i5) diff (jacobi_sn (u, m), m);
(%o5) jacobi_cn(u, m) jacobi_dn(u, m)
elliptic_e(asin(jacobi_sn(u, m)), m)
(u - ------------------------------------)/(2 m)
1 - m
2
jacobi_cn (u, m) jacobi_sn(u, m)
+ --------------------------------
2 (1 - m)
Some examples of elliptic integrals:
(%i1) elliptic_f (phi, m);
(%o1) elliptic_f(phi, m)
146 Maxima Manual
cos(phi) sin(phi)
- ---------------------)/(2 (1 - m))
2
sqrt(1 - m sin (phi))
Support for elliptic functions and integrals was written by Raymond Toy. It is placed
under the terms of the General Public License (GPL) that governs the distribution of
Maxima.
φ
dθ
Z
p
0 1 − m sin2 θ
See also [elliptic e], page 148 and [elliptic kc], page 149.
where τ = sn(u, m)
This is related to elliptice by
E(u, m) = E(φ, m)
where φ = sin−1 sn(u, m), m) See also [elliptic e], page 148.
Chapter 18: Elliptic Functions 149
For certain values of m, the value of the integral is known in terms of Gamma func-
tions. Use makegamma to evaluate them.
150 Maxima Manual
Chapter 19: Limits 151
19 Limits
20 Differentiation
atomgrad property
atomgrad is the atomic gradient property of an expression. This property is assigned
by gradef.
Chapter 20: Differentiation 155
2
f(0, 1) = a
(%o3) done
(%i4) diff (4*f(x,y)^2 - u(x,y)^2, x);
d d
(%o4) 8 f(x, y) (-- (f(x, y))) - 2 u(x, y) (-- (u(x, y)))
dx dx
(%i5) at (%, [x = 0, y = 1]);
!
2 d !
(%o5) 16 a - 2 u(0, 1) (-- (u(x, y))! )
dx !
!x = 0, y = 1
156 Maxima Manual
cartan - Function
The exterior calculus of differential forms is a basic tool of differential geometry
developed by Elie Cartan and has important applications in the theory of partial
differential equations. The cartan package implements the functions ext_diff and
lie_diff, along with the operators ~ (wedge product) and | (contraction of a form
with a vector.) Type demo (tensor) to see a brief description of these commands
along with examples.
cartan was implemented by F.B. Estabrook and H.D. Wahlquist.
p;
- a s
(%o1) sin(a b) %e
dependencies Variable
Default value: []
dependencies is the list of atoms which have functional dependencies, assigned by
depends or gradef. The dependencies list is cumulative: each call to depends or
gradef appends additional items.
See depends and gradef.
depends (f, x) is declared, diff (f, x) yields a symbolic derivative (that is, a
diff noun).
Each argument f 1, x 1, etc., can be the name of a variable or array, or a list of names.
Every element of f i (perhaps just a single element) is declared to depend on every
element of x i (perhaps just a single element). If some f i is the name of an array or
contains the name of an array, all elements of the array depend on x i.
diff recognizes indirect dependencies established by depends and applies the chain
rule in these cases.
remove (f, dependency) removes all dependencies declared for f.
depends returns a list of the dependencies established. The dependencies are ap-
pended to the global variable dependencies. depends evaluates its arguments.
diff is the only Maxima command which recognizes dependencies established by
depends. Other functions (integrate, laplace, etc.) only recognize dependencies
explicitly represented by their arguments. For example, integrate does not recognize
the dependence of f on x unless explicitly represented as integrate (f(x), x).
(%i1) depends ([f, g], x);
(%o1) [f(x), g(x)]
(%i2) depends ([r, s], [u, v, w]);
(%o2) [r(u, v, w), s(u, v, w)]
(%i3) depends (u, t);
(%o3) [u(t)]
(%i4) dependencies;
(%o4) [f(x), g(x), r(u, v, w), s(u, v, w), u(t)]
(%i5) diff (r.s, u);
dr ds
(%o5) -- . s + r . --
du du
(%i6) diff (r.s, t);
dr du ds du
(%o6) -- -- . s + r . -- --
du dt du dt
(%i7) remove (r, dependency);
(%o7) done
(%i8) diff (r.s, t);
ds du
(%o8) r . -- --
du dt
derivabbrev Variable
Default value: false
When derivabbrev is true, symbolic derivatives (that is, diff nouns) are displayed
as subscripts. Otherwise, derivatives are displayed in the Leibniz notation dy/dx.
Example:
(%i1) ’diff (y, x, 2) + ’diff (y, z, 3) + ’diff (y, x) * x^2;
3 2
d y d y 2 dy
(%o1) --- + --- + x --
3 2 dx
dz dx
(%i2) derivdegree (%, y, x);
(%o2) 2
derivsubst Variable
Default value: false
When derivsubst is true, a non-syntactic substitution such as subst (x, ’diff (y,
t), ’diff (y, t, 2)) yields ’diff (x, t).
dscalar (f ) Function
Applies the scalar d’Alembertian to the scalar function f.
load ("ctensor") loads this function.
gradefs Variable
Default value: []
gradefs is the list of the functions for which partial derivatives have been defined by
gradef. gradefs does not include any variables for which partial derivatives have
been defined by gradef.
21 Integration
erfflag Variable
Default value: true
When erfflag is false, prevents risch from introducing the erf function in the
answer if there were none in the integrand to begin with.
pos;
166 Maxima Manual
sqrt(a b (a b - 1)) t
2 cosh(---------------------) 2
b a t
(%o4) - ----------------------------- + -------
3 2 2 a b - 1
a b - 2 a b + a
2
+ ------------------
3 2 2
a b - 2 a b + a
If none of the preceding heuristics find the indefinite integral, the Risch algorithm is
executed. The flag risch may be set as an evflag, in a call to ev or on the com-
mand line, e.g., ev (integrate (expr, x), risch) or integrate (expr, x), risch.
If risch is present, integrate calls the risch function without attempting heuristics
first. See also risch.
integrate works only with functional relations represented explicitly with the f(x)
notation. integrate does not respect implicit dependencies established by the
depends function.
integrate may need to know some property of a parameter in the integrand.
integrate will first consult the assume database, and, if the variable of interest
is not there, integrate will ask the user. Depending on the question, suitable
responses are yes; or no;, or pos;, zero;, or neg;.
integrate is not, by default, declared to be linear. See declare and linear.
integrate attempts integration by parts only in a few special cases.
Examples:
• Elementary indefinite and definite integrals.
(%i1) integrate (sin(x)^3, x);
3
cos (x)
(%o1) ------- - cos(x)
3
(%i2) integrate (x/ sqrt (b^2 - x^2), x);
2 2
(%o2) - sqrt(b - x )
(%i3) integrate (cos(x)^2 * exp(x), x, 0, %pi);
%pi
3 %e 3
(%o3) ------- - -
5 5
(%i4) integrate (x^2 * exp(-x^2), x, minf, inf);
sqrt(%pi)
(%o4) ---------
2
• Use of assume and interactive query.
(%i1) assume (a > 1)$
(%i2) integrate (x**a/(x+1)**(5/2), x, 0, inf);
2 a + 2
Is ------- an integer?
5
no;
Is 2 a - 3 positive, negative, or zero?
neg;
3
(%o2) beta(a + 1, - - a)
2
168 Maxima Manual
• Change of variable. There are two changes of variable in this example: one using
a derivative established by gradef, and one using the derivation diff(r(x)) of
an unspecified function r(x).
(%i3) gradef (q(x), sin(x**2));
(%o3) q(x)
(%i4) diff (log (q (r (x))), x);
d 2
(-- (r(x))) sin(r (x))
dx
(%o4) ----------------------
q(r(x))
(%i5) integrate (%, x);
(%o5) log(q(r(x)))
• Return value contains the ’integrate noun form. In this example, Maxima can
extract one factor of the denominator of a rational function, but cannot factor the
remainder or otherwise find its integral. grind shows the noun form ’integrate
in the result. See also integrate_use_rootsof for more on integrals of rational
functions.
(%i1) expand ((x-4) * (x^3+2*x+1));
4 3 2
(%o1) x - 4 x + 2 x - 7 x - 4
(%i2) integrate (1/%, x);
/ 2
[ x + 4 x + 18
I ------------- dx
] 3
log(x - 4) / x + 2 x + 1
(%o2) ---------- - ------------------
73 73
(%i3) grind (%);
log(x-4)/73-(’integrate((x^2+4*x+18)/(x^3+2*x+1),x))/73$
• Defining a function in terms of an integral. The body of a function is not evalu-
ated when the function is defined. Thus the body of f_1 in this example contains
the noun form of integrate. The double-single-quotes operator ’’ causes the
integral to be evaluated, and the result becomes the body of f_2.
(%i1) f_1 (a) := integrate (x^3, x, 1, a);
3
(%o1) f_1(a) := integrate(x , x, 1, a)
(%i2) ev (f_1 (7), nouns);
(%o2) 600
(%i3) /* Note parentheses around integrate(...) here */
f_2 (a) := ’’(integrate (x^3, x, 1, a));
4
a 1
(%o3) f_2(a) := -- - -
4 4
(%i4) f_2 (7);
(%o4) 600
Chapter 21: Integration 169
2 x + 1
2 5 atan(-------)
log(x + x + 1) sqrt(3)
- --------------- + ---------------
14 7 sqrt(3)
Alternatively the user may compute the roots of the denominator separately, and
then express the integrand in terms of these roots, e.g., 1/((x - a)*(x - b)*(x -
c)) or 1/((x^2 - (a+b)*x + a*b)*(x - c)) if the denominator is a cubic polynomial.
Sometimes this will help Maxima obtain a more useful result.
170 Maxima Manual
qq Function
The package qq (which may be loaded with load ("qq")) contains a function quanc8
which can take either 3 or 4 arguments. The 3 arg version computes the integral
of the function specified as the first argument over the interval from lo to hi as in
quanc8 (’function, lo, hi). The function name should be quoted. The 4 arg
version will compute the integral of the function or expression (first arg) with respect
to the variable (second arg) over the interval from lo to hi as in quanc8(<f(x) or
expression in x>, x, lo, hi). The method used is the Newton-Cotes 8th order
polynomial quadrature, and the routine is adaptive. It will thus spend time dividing
the interval only when necessary to achieve the error conditions specified by the
global variables quanc8_relerr (default value=1.0e-4) and quanc8_abserr (default
value=1.0e-8) which give the relative error test:
|integral(function) - computed value| < quanc8_relerr*|integral(function)|
and the absolute error test:
|integral(function) - computed value| < quanc8_abserr
printfile ("qq.usg") yields additional information.
the geometric information thrown away by expressing multiple integrals this way can
be incredible. The user should be sure to understand and use the rombergtol and
rombergit switches.
rombergabs Variable
Default value: 0.0
Assuming that successive estimates produced by romberg are y[0], y[1], y[2], etc.,
then romberg will return after n iterations if (roughly speaking)
(abs(y[n]-y[n-1]) <= rombergabs or
abs(y[n]-y[n-1])/(if y[n]=0.0 then 1.0 else y[n]) <= rombergtol)
is true. (The condition on the number of iterations given by rombergmin must also
be satisfied.) Thus if rombergabs is 0.0 (the default) you just get the relative error
test. The usefulness of the additional variable comes when you want to perform an
integral, where the dominant contribution comes from a small region. Then you can
do the integral over the small dominant region first, using the relative accuracy check,
followed by the integral over the rest of the region using the absolute accuracy check.
Example: Suppose you want to compute
’integrate (exp(-x), x, 0, 50)
(numerically) with a relative accuracy of 1 part in 10000000. Define the function. n
is a counter, so we can see how many function evaluations were needed. First of all
try doing the whole integral at once.
(%i1) f(x) := (mode_declare (n, integer, x, float), n:n+1, exp(-x))$
(%i2) translate(f)$
Warning-> n is an undefined global variable.
(%i3) block ([rombergtol: 1.e-6, romberabs: 0.0], n:0, romberg (f, 0, 50));
(%o3) 1.000000000488271
(%i4) n;
(%o4) 257
That approach required 257 function evaluations. Now do the integral intelligently, by
first doing ’integrate (exp(-x), x, 0, 10) and then setting rombergabs to 1.E-6
times (this partial integral). This approach takes only 130 function evaluations.
(%i5) block ([rombergtol: 1.e-6, rombergabs:0.0, sum:0.0],
n: 0, sum: romberg (f, 0, 10), rombergabs: sum*rombergtol, rombergtol:0.0,
sum + romberg (f, 10, 50));
(%o5) 1.000000001234793
(%i6) n;
(%o6) 130
So if f(x) were a function that took a long time to compute, the second method
would be about 2 times quicker.
rombergit Variable
Default value: 11
The accuracy of the romberg integration command is governed by the global variables
rombergtol and rombergit. romberg will return a result if the relative difference in
successive approximations is less than rombergtol. It will try halving the stepsize
rombergit times before it gives up.
174 Maxima Manual
rombergmin Variable
Default value: 0
rombergmin governs the minimum number of function evaluations that romberg will
make. romberg will evaluate its first arg. at least 2^(rombergmin+2)+1 times. This
is useful for integrating oscillatory functions, when the normal converge test might
sometimes wrongly pass.
rombergtol Variable
Default value: 1e-4
The accuracy of the romberg integration command is governed by the global variables
rombergtol and rombergit. romberg will return a result if the relative difference in
successive approximations is less than rombergtol. It will try halving the stepsize
rombergit times before it gives up.
Z a
f (x)dx
∞
176 Maxima Manual
Z ∞
f (x)dx
∞
using the Quadpack QAGI routine. The function to be integrated is f(x), with de-
pendent variable x, and the function is to be integrated over an infinite range.
The parameter inftype determines the integration interval as follows:
inf The interval is from a to positive infinity.
minf The interval is from negative infinity to a.
both The interval is the entire real line.
The optional arguments epsrel and limit are the desired relative error and the maxi-
mum number of subintervals, respectively. epsrel defaults to 1e-8 and limit is 200.
quad_qagi returns a list of four elements:
an approximation to the integral,
the estimated absolute error of the approximation,
the number integrand evaluations,
an error code.
The error code (fourth element of the return value) can have the values:
0 no problems were encountered;
1 too many sub-intervals were done;
2 excessive roundoff error is detected;
3 extremely bad integrand behavior occurs;
4 failed to converge
5 integral is probably divergent or slowly convergent
6 if the input is invalid.
Examples:
(%i1) quad_qagi (x^2*exp(-4*x), x, 0, inf);
(%o1) [0.03125, 2.95916102995002E-11, 105, 0]
(%i2) integrate (x^2*exp(-4*x), x, 0, inf);
1
(%o2) --
32
The optional arguments epsrel and limit are the desired relative error and the maxi-
mum number of subintervals, respectively. epsrel defaults to 1e-8 and limit is 200.
quad_qawc returns a list of four elements:
an approximation to the integral,
the estimated absolute error of the approximation,
the number integrand evaluations,
an error code.
The error code (fourth element of the return value) can have the values:
0 no problems were encountered;
1 too many sub-intervals were done;
2 excessive roundoff error is detected;
3 extremely bad integrand behavior occurs;
6 if the input is invalid.
Examples:
(%i1) quad_qawc (2^(-5)*((x-1)^2+4^(-5))^(-1), x, 2, 0, 5);
(%o1) [- 3.130120337415925, 1.306830140249558E-8, 495, 0]
(%i2) integrate (2^(-alpha)*(((x-1)^2 + 4^(-alpha))*(x-2))^(-1), x, 0, 5);
Principal Value
alpha
alpha 9 4 9
4 log(------------- + -------------)
alpha alpha
64 4 + 4 64 4 + 4
(%o2) (-----------------------------------------
alpha
2 4 + 2
3 alpha 3 alpha
------- -------
2 alpha/2 2 alpha/2
2 4 atan(4 4 ) 2 4 atan(4 ) alpha
- --------------------------- - -------------------------)/2
alpha alpha
2 4 + 2 2 4 + 2
(%i3) ev (%, alpha=5, numer);
(%o3) - 3.130120337415917
quad qawf (f(x), x, a, omega, trig, epsabs, limit, maxp1, limlst) Function
Numerically compute the a Fourier-type integral using the Quadpack QAWF routine.
The integral is
Z ∞
f (x)w(x)dx
a
quad qawo (f(x), x, a, b, omega, trig, epsabs, limit, maxp1, limlst) Function
Numerically compute the integral using the Quadpack QAWO routine:
Z b
f (x)w(x)dx
a
pos;
alpha alpha
2 %pi 2 sqrt(2 2 + 1)
(%o2) -------------------------------
alpha
4 2 + 2
(%i3) ev (%, alpha=4, numer);
(%o3) 8.750097361672829
Chapter 22: Equations 181
22 Equations
algexact Variable
Default value: false
algexact affects the behavior of algsys as follows:
If algexact is true, algsys always calls solve and then uses realroots on solve’s
failures.
If algexact is false, solve is called only if the eliminant was not univariate, or if it
was a quadratic or biquadratic.
Thus algexact: true doesn’t guarantee only exact solutions, just that algsys will
first try as hard as it can to give exact solutions, and only yield approximations when
all else fails.
In some cases, solve is not be able to find a solution, or if it does the solution may
be a very large expression.
If the equation is univariate and is either linear, quadratic, or biquadratic, then again
solve is called if no approximations have been introduced. If approximations have
been introduced or the equation is not univariate and neither linear, quadratic, or
biquadratic, then if the switch realonly is true, the function realroots is called to
find the real-valued solutions. If realonly is false, then allroots is called which
looks for real and complex-valued solutions.
If algsys produces a solution which has fewer significant digits than required, the
user can change the value of algepsilon to a higher value.
If algexact is set to true, solve will always be called.
(4) Finally, the solutions obtained in step (3) are substituted into previous levels and
the solution process returns to (1).
When algsys encounters a multivariate equation which contains floating point ap-
proximations (usually due to its failing to find exact solutions at an earlier stage),
then it does not attempt to apply exact methods to such equations and instead prints
the message: "algsys cannot solve - system too complicated."
Interactions with radcan can produce large or complicated expressions. In that case,
it may be possible to isolate parts of the result with pickapart or reveal.
Occasionally, radcan may introduce an imaginary unit %i into a solution which is
actually real-valued.
Examples:
(%i1) e1: 2*x*(1 - a1) - 2*(x - 1)*a2;
(%o1) 2 (1 - a1) x - 2 a2 (x - 1)
(%i2) e2: a2 - a1;
(%o2) a2 - a1
(%i3) e3: a1*(-y - x^2 + 1);
2
(%o3) a1 (- y - x + 1)
(%i4) e4: a2*(y - (x - 1)^2);
2
(%o4) a2 (y - (x - 1) )
(%i5) algsys ([e1, e2, e3, e4], [x, y, a1, a2]);
(%o5) [[x = 0, y = %r1, a1 = 0, a2 = 0],
[x = 1, y = 0, a1 = 1, a2 = 1]]
(%i6) e1: x^2 - y^2;
2 2
(%o6) x - y
(%i7) e2: -1 - y + 2*y^2 - x + x^2;
2 2
(%o7) 2 y - y + x - x - 1
(%i8) algsys ([e1, e2], [x, y]);
1 1
(%o8) [[x = - -------, y = -------],
sqrt(3) sqrt(3)
Chapter 22: Equations 183
1 1 1 1
[x = -------, y = - -------], [x = - -, y = - -], [x = 1, y = 1]]
sqrt(3) sqrt(3) 3 3
x = .9659625152196369 %i - .4069597231924075,
- 5.32907051820075E-15
4.44089209850063E-15 %i - 4.88498130835069E-15
- 4.44089209850063E-15 %i - 4.88498130835069E-15
3.5527136788005E-15
(%o3) done
(%i4) polyfactor: true$
(%i5) allroots (eqn);
184 Maxima Manual
2
(x + 1.015755543828121) (x + .8139194463848151 x
+ 1.098699797110288)
backsubst Variable
Default value: true
When backsubst is false, prevents back substitution after the equations have been
triangularized. This may be helpful in very big problems where back substitution
would cause the generation of extremely large expressions.
breakup Variable
Default value: true
When breakup is true, solve expresses solutions of cubic and quartic equations in
terms of common subexpressions, which are assigned to intermediate expression labels
(%t1, %t2, etc.). Otherwise, common subexpressions are not identified.
breakup: true has an effect only when programmode is false.
Examples:
(%i1) programmode: false$
(%i2) breakup: true$
(%i3) solve (x^3 + x^2 - 1);
sqrt(23) 25 1/3
(%t3) (--------- + --)
6 sqrt(3) 54
Solution:
sqrt(3) %i 1
---------- - -
sqrt(3) %i 1 2 2 1
(%t4) x = (- ---------- - -) %t3 + -------------- - -
2 2 9 %t3 3
sqrt(3) %i 1
- ---------- - -
sqrt(3) %i 1 2 2 1
(%t5) x = (---------- - -) %t3 + ---------------- - -
2 2 9 %t3 3
1 1
(%t6) x = %t3 + ----- - -
9 %t3 3
(%o6) [%t4, %t5, %t6]
(%i6) breakup: false$
(%i7) solve (x^3 + x^2 - 1);
Chapter 22: Equations 185
Solution:
sqrt(3) %i 1
---------- - -
2 2 sqrt(23) 25 1/3
(%t7) x = --------------------- + (--------- + --)
sqrt(23) 25 1/3 6 sqrt(3) 54
9 (--------- + --)
6 sqrt(3) 54
sqrt(3) %i 1 1
(- ---------- - -) - -
2 2 3
sqrt(3) %i 1
- ---------- - -
2 2 1
+ --------------------- - -
sqrt(23) 25 1/3 3
9 (--------- + --)
6 sqrt(3) 54
sqrt(23) 25 1/3 1 1
(%t9) x = (--------- + --) + --------------------- - -
6 sqrt(3) 54 sqrt(23) 25 1/3 3
9 (--------- + --)
6 sqrt(3) 54
(%o9) [%t7, %t8, %t9]
dispflag Variable
Default value: true
If set to false within a block will inhibit the display of output generated by the
solve functions called from within the block. Termination of the block with a dollar
sign, $, sets dispflag to false.
globalsolve Variable
Default value: false
When globalsolve is true, solved-for variables are assigned the solution values found
by solve.
Examples:
(%i1) globalsolve: true$
(%i2) solve ([x + 3*y = 2, 2*x - y = 5], [x, y]);
Solution
17
(%t2) x : --
7
1
(%t3) y : - -
7
(%o3) [[%t2, %t3]]
(%i3) x;
17
(%o3) --
7
(%i4) y;
1
(%o4) - -
7
(%i5) globalsolve: false$
(%i6) kill (x, y)$
(%i7) solve ([x + 3*y = 2, 2*x - y = 5], [x, y]);
Solution
17
(%t7) x = --
7
1
Chapter 22: Equations 187
(%t8) y = - -
7
(%o8) [[%t7, %t8]]
(%i8) x;
(%o8) x
(%i9) y;
(%o9) y
ieqnprint Variable
Default value: true
ieqnprint governs the behavior of the result returned by the ieqn command. When
ieqnprint is false, the lists returned by the ieqn function are of the form
[solution, technique used, nterms, flag]
where flag is absent if the solution is exact.
Otherwise, it is the word approximate or incomplete corresponding to an inexact
or non-closed form solution, respectively. If a series method was used, nterms gives
the number of terms taken (which could be less than the n given to ieqn if an error
prevented generation of further terms).
linsolvewarn Variable
Default value: true
When linsolvewarn is true, linsolve prints a message "Dependent equations elim-
inated".
multiplicities Variable
Default value: not_set_yet
multiplicities is set to a list of the multiplicities of the individual solutions returned
by solve or realroots.
Chapter 22: Equations 189
programmode Variable
Default value: true
When programmode is true, solve, realroots, allroots, and linsolve return
solutions as elements in a list. (Except when backsubst is set to false, in which
case programmode: false is assumed.)
When programmode is false, solve, etc. create intermediate expression labels %t1,
t2, etc., and assign the solutions to them.
realonly Variable
Default value: false
When realonly is true, algsys returns only those solutions which are free of %i.
2 2
(%o2) y + x
(%i3) rhs (e);
2
(%o3) z
rootsconmode Variable
Default value: true
rootsconmode governs the behavior of the rootscontract command. See
rootscontract for details.
rootsepsilon Variable
Default value: 1.0e-7
rootsepsilon is the tolerance which establishes the confidence interval for the roots
found by the realroots function.
solve ([eqn 1, ..., eqn n], [x 1, ..., x n]) solves a system of simultaneous (lin-
ear or non-linear) polynomial equations by calling linsolve or algsys and returns
a list of the solution lists in the variables. In the case of linsolve this list would
contain a single list of solutions. It takes two lists as arguments. The first list rep-
resents the equations to be solved; the second list is a list of the unknowns to be
determined. If the total number of variables in the equations is equal to the number
of equations, the second argument-list may be omitted. For linear systems if the given
equations are not compatible, the message inconsistent will be displayed (see the
solve_inconsistent_error switch); if no unique solution exists, then singular will
be displayed.
Examples:
(%i1) solve (asin (cos (3*x))*(f(x) - 1), x);
- .1331240357358706, y = .0767837852378778
- .1331240357358706, y = 3.608003221870287 %i
+ .0767837852378778], [x = - 1.733751846381093,
y = - .1535675710019696]]
(%i5) solve (1 + a*x + x^3, x);
3
sqrt(3) %i 1 sqrt(4 a + 27) 1 1/3
(%o5) [x = (- ---------- - -) (--------------- - -)
2 2 6 sqrt(3) 2
sqrt(3) %i 1
(---------- - -) a
2 2
- --------------------------, x =
3
Chapter 22: Equations 193
3
sqrt(3) %i 1 sqrt(4 a + 27) 1 1/3
(---------- - -) (--------------- - -)
2 2 6 sqrt(3) 2
sqrt(3) %i 1
(- ---------- - -) a
2 2
- --------------------------, x =
3
sqrt(4 a + 27) 1 1/3
3 (--------------- - -)
6 sqrt(3) 2
3
sqrt(4 a + 27) 1 1/3 a
(--------------- - -) - --------------------------]
6 sqrt(3) 2 3
sqrt(4 a + 27) 1 1/3
3 (--------------- - -)
6 sqrt(3) 2
(%i6) solve (x^3 - 1);
sqrt(3) %i - 1 sqrt(3) %i + 1
(%o6) [x = --------------, x = - --------------, x = 1]
2 2
(%i7) solve (x^6 - 1);
sqrt(3) %i + 1 sqrt(3) %i - 1
(%o7) [x = --------------, x = --------------, x = - 1,
2 2
sqrt(3) %i + 1 sqrt(3) %i - 1
x = - --------------, x = - --------------, x = 1]
2 2
(%i8) ev (x^6 - 1, %[1]);
6
(sqrt(3) %i + 1)
(%o8) ----------------- - 1
64
(%i9) expand (%);
(%o9) 0
(%i10) x^2 - 1;
2
(%o10) x - 1
(%i11) solve (%, x);
(%o11) [x = - 1, x = 1]
194 Maxima Manual
solvedecomposes Variable
Default value: true
When solvedecomposes is true, solve calls polydecomp if asked to solve polynomi-
als.
solveexplicit Variable
Default value: false
When solveexplicit is true, inhibits solve from returning implicit solutions, that
is, solutions of the form F(x) = 0 where F is some function.
solvefactors Variable
Default value: true
When solvefactors is false, solve does not try to factor the expression. The
false setting may be desired in some cases where factoring is not necessary.
solvenullwarn Variable
Default value: true
When solvenullwarn is true, solve prints a warning message if called with either
a null equation list or a null variable list. For example, solve ([], []) would print
two warning messages and return [].
solveradcan Variable
Default value: false
When solveradcan is true, solve calls radcan which makes solve slower but will
allow certain problems containing exponentials and logarithms to be solved.
solvetrigwarn Variable
Default value: true
When solvetrigwarn is true, solve may print a message saying that it is using
inverse trigonometric functions to solve the equation, and thereby losing solutions.
23 Differential Equations
x
cos(x) + a %e - a + g(0) - 1]
196 Maxima Manual
(%i6) [%o1,%o2],%o5,diff;
x x x x
(%o6) [a %e = a %e , a %e - cos(x) = a %e - cos(x)]
(%o1) x -- + 3 x y = ------
dx x
(%i2) ode2(%,y,x);
%c - cos(x)
(%o2) y = -----------
3
x
(%i3) ic1(%o2,x=%pi,y=0);
cos(x) + 1
(%o3) y = - ----------
3
x
(%i4) ’diff(y,x,2) + y*’diff(y,x)^3 = 0;
2
d y dy 3
(%o4) --- + y (--) = 0
2 dx
dx
(%i5) ode2(%,y,x);
3
y + 6 %k1 y
(%o5) ------------ = x + %k2
6
(%i6) ratsimp(ic2(%o5,x=0,y=0,’diff(y,x)=2));
3
2 y - 3 y
(%o6) - ---------- = x
6
(%i7) bc2(%o5,x=0,y=1,x=1,y=3);
3
y - 10 y 3
(%o7) --------- = x - -
6 2
198 Maxima Manual
Chapter 24: Numerical 199
24 Numerical
fortindent Variable
Default value: 0
fortindent controls the left margin indentation of expressions printed out by the
fortran command. 0 gives normal printout (i.e., 6 spaces), and positive values will
causes the expressions to be printed farther to the right.
fortspaces Variable
Default value: false
When fortspaces is true, fortran fills out each printed line with spaces to 80
columns.
Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
(%i4) ev (expr2, x=1e155);
(%o4) 7.0E+154
answer as is possible with the single precision arithmetic we have. The first arg may
be an equation. The order of the last two args is irrelevant. Thus
interpolate (sin(x) = x/2, x, %pi, 0.1);
is equivalent to
interpolate (sin(x) = x/2, x, 0.1, %pi);
The method used is a binary search in the range specified by the last two args. When it
thinks the function is close enough to being linear, it starts using linear interpolation.
(%i1) f(x) := sin(x) - x/2;
x
(%o1) f(x) := sin(x) - -
2
(%i2) interpolate (sin(x) - x/2, x, 0.1, %pi);
(%o2) 1.895494267033981
(%i3) interpolate (sin(x) = x/2, x, 0.1, %pi);
(%o3) 1.895494267033981
(%i4) interpolate (f(x), x, 0.1, %pi);
(%o4) 1.895494267033981
(%i5) interpolate (f, 0.1, %pi);
(%o5) 1.895494267033981
There is also a Newton method interpolation routine. See newton.
intpolabs Variable
Default value: 0.0
intpolabs is the accuracy of the interpolate command is governed by intpolabs
and intpolrel which must be non-negative floating point numbers. interpolate
will stop when the first arg evaluates to something less than or equal to intpolabs
or if successive approximants to the root differ by no more than intpolrel * <one
of the approximants>. The default values of intpolabs and intpolrel are 0.0 so
interpolate gets as good an answer as is possible with the single precision arithmetic
we have.
intpolerror Variable
Default value: true
intpolerror governs the behavior of interpolate. When interpolate is called, it
determines whether or not the function to be interpolated satisfies the condition that
the values of the function at the endpoints of the interpolation interval are opposite
in sign. If they are of opposite sign, the interpolation proceeds. If they are of like
sign, and intpolerror is true, then an error is signaled. If they are of like sign and
intpolerror is not true, the value of intpolerror is returned. Thus for plotting,
intpolerror might be set to 0.0.
intpolrel Variable
Default value: 0.0
intpolrel is the accuracy of the interpolate command is governed by intpolabs
and intpolrel which must be non-negative floating point numbers. interpolate
204 Maxima Manual
will stop when the first arg evaluates to something less than or equal to intpolabs
or if successive approximants to the root differ by no more than intpolrel * <one
of the approximants>. The default values of intpolabs and intpolrel are 0.0 so
interpolate gets as good an answer as is possible with the single precision arithmetic
we have.
sinnpiflag Variable
Default value: true
See foursimp.
cosnpiflag Variable
Default value: true
See foursimp.
25 Statistics
27.1.1 Dot
The operator . represents noncommutative multiplication and scalar product. When
the operands are 1-column or 1-row matrices a and b, the expression a.b is equivalent to
sum (a[i]*b[i], i, 1, length(a)). If a and b are not complex, this is the scalar product,
also called the inner product or dot product, of a and b. The scalar product is defined as
conjugate(a).b when a and b are complex; innerproduct in the eigen package provides
the complex scalar product.
When the operands are more general matrices, the product is the matrix product a and
b. The number of rows of b must equal the number of columns of a, and the result has
number of rows equal to the number of rows of a and number of columns equal to the
number of columns of b.
To distinguish . as an arithmetic operator from the decimal point in a floating point
number, it may be necessary to leave spaces on either side. For example, 5.e3 is 5000.0
but 5 . e3 is 5 times e3.
There are several flags which govern the simplification of expressions involving .,
namely dot, dot0nscsimp, dot0simp, dot1simp, dotassoc, dotconstrules, dotdistrib,
dotexptsimp, dotident, and dotscrules.
27.1.2 Vectors
vect is a package of functions for vector analysis. load ("vect") loads this package,
and demo ("vect") displays a demonstration.
The vector analysis package can combine and simplify symbolic expressions including dot
products and cross products, together with the gradient, divergence, curl, and Laplacian
operators. The distribution of these operators over sums or products is governed by several
flags, as are various other expansions, including expansion into components in any specific
orthogonal coordinate systems. There are also functions for deriving the scalar or vector
potential of a field.
The vect package contains these functions: vectorsimp, scalefactors, express,
potential, and vectorpotential.
Warning: the vect package declares the dot operator . to be a commutative operator.
27.1.3 eigen
The package eigen contains several functions devoted to the symbolic computation
of eigenvalues and eigenvectors. Maxima loads the package automatically if one of the
functions eigenvalues or eigenvectors is invoked. The package may be loaded explicitly
as load ("eigen").
214 Maxima Manual
adjoint (M ) Function
Returns the adjoint of the matrix M.
1 2
[x1 = -------, x2 = -------]]
sqrt(5) sqrt(5)
copymatrix (M ) Function
Returns a copy of the matrix M. This is the only way to make a copy aside from
copying M element by element.
Note that an assignment of one matrix to another, as in m2: m1, does not copy m1. An
assignment m2 [i,j]: x or setelmx (x, i, j, m2 also modifies m1 [i,j]. Creating
a copy with copymatrix and then using assignment creates a separate, modified copy.
determinant (M ) Function
Computes the determinant of M by a method similar to Gaussian elimination.
The form of the result depends upon the setting of the switch ratmx.
There is a special routine for computing sparse determinants which is called when the
switches ratmx and sparse are both true.
detout Variable
Default value: false
When detout is true, the determinant of a matrix whose inverse is computed is
factored out of the inverse.
For this switch to have an effect DOALLMXOPS and DOSCMXOPS should be false
(see their descriptions). Alternatively this switch can be given to EV which causes
the other two to be set correctly.
Example:
(%i1) m: matrix ([a, b], [c, d]);
[ a b ]
(%o1) [ ]
[ c d ]
(%i2) detout: true$
(%i3) doallmxops: false$
(%i4) doscmxops: false$
(%i5) invert (m);
[ d - b ]
[ ]
[ - c a ]
(%o5) ------------
a d - b c
doallmxops Variable
Default value: true
When doallmxops is true, all operations relating to matrices are carried out. When
it is false then the setting of the individual dot switches govern which operations
are performed.
domxexpt Variable
Default value: true
When domxexpt is true, a matrix exponential, exp (M ) where M is a matrix, is
interpreted as a matrix with element [i,j equal to exp (m[i,j]). Otherwise exp
(M ) evaluates to exp (ev(M).
domxexpt affects all expressions of the form base^power where base is an expression
assumed scalar or constant, and power is a list or matrix.
Example:
(%i1) m: matrix ([1, %i], [a+b, %pi]);
[ 1 %i ]
(%o1) [ ]
[ b + a %pi ]
(%i2) domxexpt: false$
(%i3) (1 - c)^m;
[ 1 %i ]
[ ]
[ b + a %pi ]
(%o3) (1 - c)
(%i4) domxexpt: true$
(%i5) (1 - c)^m;
[ %i ]
[ 1 - c (1 - c) ]
(%o5) [ ]
[ b + a %pi ]
[ (1 - c) (1 - c) ]
domxmxops Variable
Default value: true
When domxmxops is true, all matrix-matrix or matrix-list operations are carried out
(but not scalar-matrix operations); if this switch is false such operations are not
carried out.
domxnctimes Variable
Default value: false
When domxnctimes is true, non-commutative products of matrices are carried out.
218 Maxima Manual
dontfactor Variable
Default value: []
dontfactor may be set to a list of variables with respect to which factoring is not to
occur. (The list is initially empty.) Factoring also will not take place with respect to
any variables which are less important, according the variable ordering assumed for
canonical rational expression (CRE) form, than those on the dontfactor list.
doscmxops Variable
Default value: false
When doscmxops is true, scalar-matrix operations are carried out.
doscmxplus Variable
Default value: false
When doscmxplus is true, scalar-matrix operations yield a matrix result. This switch
is not subsumed under doallmxops.
dot0nscsimp Variable
Default value: true
When dot0nscsimp is true, a non-commutative product of zero and a nonscalar term
is simplified to a commutative product.
dot0simp Variable
Default value: true
When dot0simp is true, a non-commutative product of zero and a scalar term is
simplified to a commutative product.
dot1simp Variable
Default value: true
When dot1simp is true, a non-commutative product of one and another term is
simplified to a commutative product.
dotassoc Variable
Default value: true
When dotassoc is true, an expression (A.B).C simplifies to A.(B.C).
dotconstrules Variable
Default value: true
When dotconstrules is true, a non-commutative product of a constant and another
term is simplified to a commutative product. Turning on this flag effectively turns on
dot0simp, dot0nscsimp, and dot1simp as well.
dotdistrib Variable
Default value: false
When dotdistrib is true, an expression A.(B + C) simplifies to A.B + A.C.
Chapter 27: Matrices and Linear Algebra 219
dotexptsimp Variable
Default value: true
When dotexptsimp is true, an expression A.A simplifies to A^^2.
dotident Variable
Default value: 1
dotident is the value returned by X^^0.
dotscrules Variable
Default value: false
When dotscrules is true, an expression A.SC or SC.A simplifies to SC*A and
A.(SC*B) simplifies to SC*(A.B).
echelon (M ) Function
Returns the echelon form of the matrix M. The echelon form is computed from M
by elementary row operations such that the first non-zero element in each row in the
resulting matrix is a one and the column elements under the first one in each row are
all zero.
(%i1) m: matrix ([2, 1-a, -5*b], [a, b, c]);
[ 2 1 - a - 5 b ]
(%o1) [ ]
[ a b c ]
(%i2) echelon (m);
[ a - 1 5 b ]
[ 1 - ----- - --- ]
[ 2 2 ]
(%o2)/R/ [ ]
[ 2 c + 5 a b ]
[ 0 1 ------------ ]
[ 2 ]
[ 2 b + a - a ]
eigenvalues (M ) Function
eivals (M ) Function
Returns a list of two lists containing the eigenvalues of the matrix M. The first sublist
of the return value is the list of eigenvalues of the matrix, and the second sublist is
the list of the multiplicities of the eigenvalues in the corresponding order.
eivals is a synonym for eigenvalues.
eigenvalues calls the function solve to find the roots of the characteristic polynomial
of the matrix. Sometimes solve may not be able to find the roots of the polynomial;
in that case some other functions in this package (except conjugate, innerproduct,
unitvector, columnvector and gramschmidt) will not work.
In some cases the eigenvalues found by solve may be complicated expressions. (This
may happen when solve returns a not-so-obviously real expression for an eigenvalue
which is known to be real.) It may be possible to simplify the eigenvalues using some
other functions.
220 Maxima Manual
eigenvectors (M ) Function
eivects (M ) Function
takes a matrix M as its argument and returns a list of lists the first sublist of which is
the output of eigenvalues and the other sublists of which are the eigenvectors of the
matrix corresponding to those eigenvalues respectively. The calculated eigenvectors
and the unit eigenvectors of the matrix are the right eigenvectors and the right unit
eigenvectors respectively.
eivects is a synonym for eigenvectors.
The package eigen.mac is loaded automatically when eigenvalues or eigenvectors
is referenced. If eigen.mac is not already loaded, load ("eigen") loads it. After
loading, all functions and variables in the package are available.
The flags that affect this function are:
nondiagonalizable is set to true or false depending on whether the matrix is
nondiagonalizable or diagonalizable after eigenvectors returns.
hermitianmatrix when true, causes the degenerate eigenvectors of the Hermitian
matrix to be orthogonalized using the Gram-Schmidt algorithm.
knowneigvals when true causes the eigen package to assume the eigenvalues of
the matrix are known to the user and stored under the global name listeigvals.
listeigvals should be set to a list similar to the output eigenvalues.
The function algsys is used here to solve for the eigenvectors. Sometimes if the
eigenvalues are messy, algsys may not be able to find a solution. In some cases, it
may be possible to simplify the eigenvalues by first finding them using eigenvalues
command and then using other functions to reduce them to something simpler. Fol-
lowing simplification, eigenvectors can be called again with the knowneigvals flag
set to true.
Matrix entered.
(%i3) m;
[ 3 ]
[ (b + a) 0 0 ]
[ ]
(%o3) [ 4 ]
[ 0 (b + a) 0 ]
[ ]
[ 5 ]
[ 0 0 (b + a) ]
invert (M ) Function
Returns the inverse of the matrix M. The inverse is computed by the adjoint method.
This allows a user to compute the inverse of a matrix with bfloat entries or polynomials
with floating pt. coefficients without converting to cre-form.
Cofactors are computed by the determinant function, so if ratmx is false the inverse
is computed without changing the representation of the elements.
The current implementation is inefficient for matrices of high order.
When detout is true, the determinant is factored out of the inverse.
The elements of the inverse are not automatically expanded. If M has polynomial ele-
ments, better appearing output can be generated by expand (invert (m)), detout.
If it is desirable to then divide through by the determinant this can be accomplished
by xthru (%) or alternatively from scratch by
expand (adjoint (m)) / expand (determinant (m))
invert (m) := adjoint (m) / determinant (m)
See ^^ (noncommutative exponent) for another method of inverting a matrix.
lmxchar Variable
Default value: [
lmxchar is the character displayed as the left delimiter of a matrix. See also rmxchar.
Example:
(%i1) lmxchar: "|"$
(%i2) matrix ([a, b, c], [d, e, f], [g, h, i]);
| a b c ]
| ]
(%o2) | d e f ]
| ]
| g h i ]
[ --- 3 %e ]
[ %pi ]
(%o6) [ ]
[ 8 11 ]
[ - - -- ]
[ a b ]
• Matrix to a scalar exponent, element by element.
(%i7) x ^ 3;
[ 4913 27 ]
(%o7) [ ]
[ - 512 1331 ]
• Scalar base to a matrix exponent, element by element.
(%i8) exp(y);
[ %pi %e ]
[ %e %e ]
(%o8) [ ]
[ a b ]
[ %e %e ]
• Matrix base to a matrix exponent. This is not carried out element by element.
(%i9) x ^ y;
[ %pi %e ]
[ ]
[ a b ]
[ 17 3 ]
(%o9) [ ]
[ - 8 11 ]
• Noncommutative matrix multiplication.
(%i10) x . y;
[ 3 a + 17 %pi 3 b + 17 %e ]
(%o10) [ ]
[ 11 a - 8 %pi 11 b - 8 %e ]
(%i11) y . x;
[ 17 %pi - 8 %e 3 %pi + 11 %e ]
(%o11) [ ]
[ 17 a - 8 b 11 b + 3 a ]
• Noncommutative matrix exponentiation. A scalar base b to a matrix power M
is carried out element by element and so b^^m is the same as b^m.
(%i12) x ^^ 3;
[ 3833 1719 ]
(%o12) [ ]
[ - 4584 395 ]
(%i13) %e ^^ y;
[ %pi %e ]
[ %e %e ]
(%o13) [ ]
[ a b ]
[ %e %e ]
226 Maxima Manual
[ 2 2 2 ]
[ sqrt((c - z) + (b - y) + (a - x) ) ]
Col 2 = [ ]
[ 2 2 2 ]
[ sqrt((f - z) + (e - y) + (d - x) ) ]
mattrace (M ) Function
Returns the trace (that is, the sum of the elements on the main diagonal) of the
square matrix M.
mattrace is called by ncharpoly, an alternative to Maxima’s charpoly.
load ("nchrpl") loads this function.
ncharpoly works by computing traces of powers of the given matrix, which are known
to be equal to sums of powers of the roots of the characteristic polynomial. From
these quantities the symmetric functions of the roots can be calculated, which are
nothing more than the coefficients of the characteristic polynomial. charpoly works
by forming the determinant of x * ident [n] - a. Thus ncharpoly wins, for example,
in the case of large dense matrices filled with integers, since it avoids polynomial
arithmetic altogether.
load ("nchrpl") loads this file.
nonscalar declaration
Makes atoms behave as does a list or matrix with respect to the dot operator.
rank (M ) Function
Computes the rank of the matrix M. That is, the order of the largest non-singular
subdeterminant of M.
rank may return the wrong answer if it cannot determine that a matrix element that
is equivalent to zero is indeed so.
ratmx Variable
Default value: false
When ratmx is false, determinant and matrix addition, subtraction, and multiplica-
tion are performed in the representation of the matrix elements and cause the result
of matrix inversion to be left in general representation.
When ratmx is true, the 4 operations mentioned above are performed in CRE form
and the result of matrix inverse is in CRE form. Note that this may cause the elements
to be expanded (depending on the setting of ratfac) which might not always be
desired.
scalarmatrixp Variable
Default value: true
When scalarmatrixp is true, then whenever a 1 x 1 matrix is produced as a result
of computing the dot product of matrices it is simplified to a scalar, namely the sole
element of the matrix.
When scalarmatrixp is all, then all 1 x 1 matrices are simplified to scalars.
When scalarmatrixp is false, 1 x 1 matrices are not simplified to scalars.
similaritytransform (M ) Function
simtran (M ) Function
similaritytransform computes a similarity transform of the matrix M. It returns a
list which is the output of the uniteigenvectors command. In addition if the flag
nondiagonalizable is false two global matrices leftmatrix and rightmatrix are
computed. These matrices have the property that leftmatrix . M . rightmatrix is
a diagonal matrix with the eigenvalues of M on the diagonal. If nondiagonalizable
is true the left and right matrices are not computed.
If the flag hermitianmatrix is true then leftmatrix is the complex conjugate of
the transpose of rightmatrix. Otherwise leftmatrix is the inverse of rightmatrix.
rightmatrix is the matrix the columns of which are the unit eigenvectors of M.
The other flags (see eigenvalues and eigenvectors) have the same effects since
similaritytransform calls the other functions in the package in order to be able to
form rightmatrix.
load ("eigen") loads this function.
simtran is a synonym for similaritytransform.
sparse Variable
Default value: false
When sparse is true, and if ratmx is true, then determinant will use special routines
for computing sparse determinants.
Chapter 27: Matrices and Linear Algebra 231
transpose (M ) Function
Returns the transpose of M.
If M is a matrix, the return value is another matrix N such that N[i,j] = M[j,i].
Otherwise M is a list, and the return value is a matrix N of length (m) rows and 1
column, such that N[i,1] = M[i].
triangularize (M ) Function
Returns the upper triangular form of the matrix M.
M need not be square.
uniteigenvectors (M ) Function
ueivects (M ) Function
Computes unit eigenvectors of the matrix M. The return value is a list of lists, the first
sublist of which is the output of the eigenvalues command, and the other sublists
of which are the unit eigenvectors of the matrix corresponding to those eigenvalues
respectively.
The flags mentioned in the description of the eigenvectors command have the same
effects in this one as well.
When knowneigvects is true, the eigen package assumes that the eigenvectors of the
matrix are known to the user and are stored under the global name listeigvects.
listeigvects should be set to a list similar to the output of the eigenvectors
command.
If knowneigvects is set to true and the list of eigenvectors is given the setting of the
flag nondiagonalizable may not be correct. If that is the case please set it to the
correct value. The author assumes that the user knows what he is doing and will not
try to diagonalize a matrix the eigenvectors of which do not span the vector space of
the appropriate dimension.
load ("eigen") loads this function.
ueivects is a synonym for uniteigenvectors.
28 Affine
dotsimp (f ) Function
Returns 0 if and only if f is in the ideal generated by the equations, i.e., if and only
if f is a polynomial combination of the elements of the equations.
236 Maxima Manual
(%i81) create_list([i,j],i,[1,2,3],j,1,i);
(%o81) [[1,1],[2,1],[2,2],[3,1],[3,2],[3,3]]
Note that the limits or list for the j variable can depend on the current value of i.
29 itensor
i j
(%i4) ishow(contract(%))$
k l
(%t4) a
This result is incorrect unless a happens to be a symmetric tensor. The reason why this
happens is that although itensor correctly maintains the order within the set of covariant
and contravariant indices, once an index is raised or lowered, its position relative to the
other set of indices is lost.
To avoid this problem, a new notation has been developed that remains fully compatible
with the existing notation and can be used interchangeably. In this notation, contravariant
indices are inserted in the appropriate positions in the covariant index list, but with a
minus sign prepended. Functions like contract and ishow are now aware of this new index
notation and can process tensors appropriately.
In this new notation, the previous example yields a correct result:
(%i5) ishow(g([-j,-k],[])*g([-i,-l],[])*a([i,j],[]))$
i l j k
(%t5) g a g
i j
(%i6) ishow(contract(%))$
l k
(%t6) a
Presently, the only code that makes use of this notation is the lc2kdt function. Through
this notation, it achieves consistent results as it applies the metric tensor to resolve Levi-
Civita symbols without resorting to numeric indices.
Since this code is brand new, it probably contains bugs. While it has been tested to make
sure that it doesn’t break anything using the "old" tensor notation, there is a considerable
chance that "new" tensors will fail to interoperate with certain functions or features. These
bugs will be fixed as they are encountered... until then, caveat emptor!
%3 %3
(%t10) v w + v w
i,%3 ,i %3
(%i11) ishow(covdiff(v([i],[]),j))$
%4
(%t11) v - v ichr2
i,j %4 i j
(%i12) ishow(ev(%,ichr2))$
%4 %5
(%t12) v - g v (e p + e p - e p - e p
i,j %4 j %5,i ,i j %5 i j,%5 ,%5 i j
+ e p + e p )/2
i %5,j ,j i %5
(%i13) iframe_flag:true;
(%o13) true
(%i14) ishow(covdiff(v([i],[]),j))$
%6
(%t14) v - v icc2
i,j %6 i j
(%i15) ishow(ev(%,icc2))$
%6
(%t15) v - v ifc2
i,j %6 i j
(%i16) ishow(radcan(ev(%,ifc2,ifc1)))$
%6 %8 %6 %8
(%t16) - (ifg v ifb + ifg v ifb - 2 v
%6 j %8 i %6 i j %8 i,j
%6 %8
- ifg v ifb )/2
%6 %8 i j
(%i17) ishow(canform(s([i,j],[])-s([j,i])))$
(%t17) s - s
i j j i
(%i18) decsym(s,2,0,[sym(all)],[]);
(%o18) done
(%i19) ishow(canform(s([i,j],[])-s([j,i])))$
(%t19) 0
(%i20) ishow(canform(a([i,j],[])+a([j,i])))$
(%t20) a + a
j i i j
(%i21) decsym(a,2,0,[anti(all)],[]);
(%o21) done
(%i22) ishow(canform(a([i,j],[])+a([j,i])))$
(%t22) 0
listoftens Function
Lists all tensors in a tensorial expression, complete with their indices. E.g.,
(%i6) ishow(a([i,j],[k])*b([u],[],v)+c([x,y],[])*d([],[])*e)$
k
(%t6) d e c + a b
x y i j u,v
(%i7) ishow(listoftens(%))$
k
(%t7) [a , b , c , d]
i j u,v x y
(%i1) load(itensor);
(%o1) /share/tensor/itensor.lisp
(%i2) ishow(a([i,j],[k,l],m,n)*b([k,o],[j,m,p],q,r))$
k l j m p
(%t2) a b
i j,m n k o,q r
(%i3) indices(%);
(%o3) [[l, p, i, n, o, q, r], [k, j, m]]
244 Maxima Manual
A tensor product containing the same index more than twice is syntactically illegal.
indices attempts to deal with these expressions in a reasonable manner; however,
when it is called to operate upon such an illegal expression, its behavior should be
considered undefined.
(%i1) load(itensor);
(%o1) /share/tensor/itensor.lisp
(%i2) allsym:true;
(%o2) true
(%i3) g([],[%4,%5])*g([],[%6,%7])*ichr2([%1,%4],[%3])*
ichr2([%2,%3],[u])*ichr2([%5,%6],[%1])*ichr2([%7,r],[%2])-
g([],[%4,%5])*g([],[%6,%7])*ichr2([%1,%2],[u])*
ichr2([%3,%5],[%1])*ichr2([%4,%6],[%3])*ichr2([%7,r],[%2]),noeval$
(%i4) expr:ishow(%)$
%4 %5 %6 %7 %3 u %1 %2
(%t4) g g ichr2 ichr2 ichr2 ichr2
%1 %4 %2 %3 %5 %6 %7 r
%4 %5 %6 %7 u %1 %3 %2
- g g ichr2 ichr2 ichr2 ichr2
%1 %2 %3 %5 %4 %6 %7 r
(%i5) flipflag:true;
(%o5) true
(%i6) ishow(rename(expr))$
%2 %5 %6 %7 %4 u %1 %3
(%t6) g g ichr2 ichr2 ichr2 ichr2
%1 %2 %3 %4 %5 %6 %7 r
%4 %5 %6 %7 u %1 %3 %2
- g g ichr2 ichr2 ichr2 ichr2
%1 %2 %3 %4 %5 %6 %7 r
(%i7) flipflag:false;
Chapter 29: itensor 245
(%o7) false
(%i8) rename(%th(2));
(%o8) 0
(%i9) ishow(rename(expr))$
%1 %2 %3 %4 %5 %6 %7 u
(%t9) g g ichr2 ichr2 ichr2 ichr2
%1 %6 %2 %3 %4 r %5 %7
%1 %2 %3 %4 %6 %5 %7 u
- g g ichr2 ichr2 ichr2 ichr2
%1 %3 %2 %6 %4 r %5 %7
flipflag Variable
Default: false. if false then the indices will be renamed according to the order of the
contravariant indices, otherwise according to the order of the covariant indices. The
function influences rename in the following way: If flipflag is false then rename
forms a list of the contravariant indices as they are encountered from left to right (if
true then of the covariant indices). The first dummy index in the list is renamed to
%1, the next to %2, etc. Then sorting occurs after the rename-ing (see the example
under rename).
(%i2) components(g([],[i,j]),e([],[i])*p([],[j]))$
(%i3) ishow(g([],[i,j]))$
i j
(%t3) e p
2) As a matrix:
(%i6) components(g([i,j],[]),lg);
(%o6) done
(%i7) ishow(g([i,j],[]))$
(%t7) g
i j
(%i8) g([3,3],[]);
(%o8) 1
(%i9) g([4,4],[]);
(%o9) - 1
j
(%t5) kdelta
i
(%i6) ishow(h([i,j],[k],l))$
k
(%t6) g
i j,l
(%i1) load(itensor);
(%o1) /share/tensor/itensor.lisp
(%i2) matchdeclare(l1,listp);
(%o2) done
(%i3) defrule(r1,m(l1,[]),(i1:idummy(),
g([l1[1],l1[2]],[])*q([i1],[])*e([],[i1])))$
(%i4) defrule(r2,m([],l1),(i1:idummy(),
w([],[l1[1],l1[2]])*e([i1],[])*q([],[i1])))$
(%i5) ishow(m([i,n],[])*m([],[i,m]))$
i m
(%t5) m m
i n
(%i6) ishow(rename(applyb1(%,r1,r2)))$
%1 %2 %3 m
(%t6) e q w q e g
%1 %2 %3 n
showcomps Function
Shows component assignments of a tensor, as made using the components command.
This function can be particularly useful when a matrix is assigned to an indicial tensor
using components, as demonstrated by the following example:
(%i1) load(ctensor);
(%o1) /share/tensor/ctensor.mac
(%i2) load(itensor);
(%o2) /share/tensor/itensor.lisp
(%i3) lg:matrix([sqrt(r/(r-2*m)),0,0,0],[0,r,0,0],
[0,0,sin(theta)*r,0],[0,0,0,sqrt((r-2*m)/r)]);
[ r ]
[ sqrt(-------) 0 0 0 ]
248 Maxima Manual
[ r - 2 m ]
[ ]
[ 0 r 0 0 ]
(%o3) [ ]
[ 0 0 r sin(theta) 0 ]
[ ]
[ r - 2 m ]
[ 0 0 0 sqrt(-------) ]
[ r ]
(%i4) components(g([i,j],[]),lg);
(%o4) done
(%i5) showcomps(g([i,j],[]));
[ r ]
[ sqrt(-------) 0 0 0 ]
[ r - 2 m ]
[ ]
[ 0 r 0 0 ]
(%t5) g = [ ]
i j [ 0 0 r sin(theta) 0 ]
[ ]
[ r - 2 m ]
[ 0 0 0 sqrt(-------) ]
[ r ]
(%o5) false
The showcomps command can also display components of a tensor of rank higher than
2.
idummy () Function
Increments icounter and returns as its value an index of the form %n where n is
a positive integer. This guarantees that dummy indices which are needed in form-
ing expressions will not conflict with indices already in use (see the example under
indices).
idummyx Variable
Is the prefix for dummy indices (see the example under indices).
icounter Variable
default: [1] determines the numerical suffix to be used in generating the next dummy
index in the tensor package. The prefix is determined by the option idummy (default:
%).
In what amounts to an abuse of this notation, itensor also allows kdelta to have 2
covariant and no contravariant, or 2 contravariant and no covariant indices, in effect
providing a co(ntra)variant "unit matrix" capability. This is strictly considered a
programming aid and not meant to imply that kdelta([i,j],[]) is a valid tensorial
object.
(%i1) load(itensor);
(%o1) /share/tensor/itensor.lisp
(%i2) kdelta([1,2],[2,1]);
(%o2) - 1
(%i3) kdels([1,2],[2,1]);
(%o3) 1
(%i4) ishow(kdelta([a,b],[c,d]))$
c d d c
(%t4) kdelta kdelta - kdelta kdelta
a b a b
(%i4) ishow(kdels([a,b],[c,d]))$
c d d c
(%t4) kdelta kdelta + kdelta kdelta
a b a b
(%i1) load(itensor);
(%o1) /share/tensor/itensor.lisp
(%i2) expr:ishow(’levi_civita([],[i,j])*’levi_civita([k,l],[])*a([j],[k]))$
i j k
(%t2) levi_civita a levi_civita
j k l
(%i3) ishow(ev(expr,levi_civita))$
i j k 1 2
250 Maxima Manual
1 2 2 1
(kdelta kdelta - kdelta kdelta )
k l k l
(%i5) ishow(lc2kdt(expr))$
k i j k j i
(%t5) a kdelta kdelta - a kdelta kdelta
j k l j k l
(%i6) ishow(contract(expand(%)))$
i i
(%t6) a - a kdelta
l l
The lc2kdt function sometimes makes use of the metric tensor. If the metric tensor
was not defined previously with imetric, this results in an error.
(%i7) expr:ishow(’levi_civita([],[i,j])*’levi_civita([],[k,l])*a([j,k],[]))$
i j k l
(%t7) levi_civita levi_civita a
j k
(%i8) ishow(lc2kdt(expr))$
Maxima encountered a Lisp error:
Error in $IMETRIC [or a callee]: $IMETRIC [or a callee] requires less than two
Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
(%i9) imetric(g);
(%o9) done
(%i10) ishow(lc2kdt(expr))$
%3 i k %4 j l %3 i l %4 j k
(%t10) (g kdelta g kdelta - g kdelta g kdelta ) a
%3 %4 %3 %4 j k
(%i11) ishow(contract(expand(%)))$
l i l i
(%t11) a - a g
lc l Function
Simplification rule used for expressions containing the unevaluated Levi-Civita symbol
(levi_civita). Along with lc_u, it can be used to simplify many expressions more
efficiently than the evaluation of levi_civita. For example:
Chapter 29: itensor 251
(%i1) load(itensor);
(%o1) /share/tensor/itensor.lisp
(%i2) el1:ishow(’levi_civita([i,j,k],[])*a([],[i])*a([],[j]))$
i j
(%t2) a a levi_civita
i j k
(%i3) el2:ishow(’levi_civita([],[i,j,k])*a([i])*a([j]))$
i j k
(%t3) levi_civita a a
i j
(%i4) ishow(canform(contract(expand(applyb1(el1,lc_l,lc_u)))))$
(%t4) 0
(%i5) ishow(canform(contract(expand(applyb1(el2,lc_l,lc_u)))))$
(%t5) 0
lc u Function
Simplification rule used for expressions containing the unevaluated Levi-Civita symbol
(levi_civita). Along with lc_u, it can be used to simplify many expressions more
efficiently than the evaluation of levi_civita. For details, see lc_l.
allsym Variable
Default: false. if true then all indexed objects are assumed symmetric in all of
their covariant and contravariant indices. If false then no symmetries of any kind
are assumed in these indices. Derivative indices are always taken to be symmetric
unless iframe_flag is set to true.
cyclic in all of its contravariant indices. Either list of symmetry declarations may
be null. The function which performs the simplifications is canform as the example
below illustrates.
(%i1) load(itensor);
(%o1) /share/tensor/itensor.lisp
(%i2) expr:contract(expand(a([i1,j1,k1],[])*kdels([i,j,k],[i1,j1,k1])))$
(%i3) ishow(expr)$
(%t3) a + a + a + a + a + a
k j i k i j j k i j i k i k j i j k
(%i4) decsym(a,3,0,[sym(all)],[]);
(%o4) done
(%i5) ishow(canform(expr))$
(%t5) 6 a
i j k
(%i6) remsym(a,3,0);
(%o6) done
(%i7) decsym(a,3,0,[anti(all)],[]);
(%o7) done
(%i8) ishow(canform(expr))$
(%t8) 0
(%i9) remsym(a,3,0);
(%o9) done
(%i10) decsym(a,3,0,[cyc(all)],[]);
(%o10) done
(%i11) ishow(canform(expr))$
(%t11) 3 a + 3 a
i k j i j k
(%i12) dispsym(a,3,0);
(%o12) [[cyc, [[1, 2, 3]], []]]
(%i1) load(itensor);
(%o1) /share/tensor/itensor.lisp
(%i2) ishow(liediff(v,a([i,j],[])*b([],[k],l)))$
k %2 %2 %2
(%t2) b (v a + v a + v a )
,l i j,%2 ,j i %2 ,i %2 j
%1 k %1 k %1 k
+ (v b - b v + v b ) a
,%1 l ,l ,%1 ,l ,%1 i j
evundiff Function
Equivalent to the execution of undiff, followed by ev and rediff.
The point of this operation is to easily evalute expressions that cannot be directly
evaluated in derivative form. For instance, the following causes an error:
(%i1) load(itensor);
(%o1) /share/tensor/itensor.lisp
(%i2) icurvature([i,j,k],[l],m);
Maxima encountered a Lisp error:
Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
However, if icurvature is entered in noun form, it can be evaluated using evundiff:
(%i3) ishow(’icurvature([i,j,k],[l],m))$
l
(%t3) icurvature
i j k,m
(%i4) ishow(evundiff(%))$
l l %1 l %1
(%t4) - ichr2 - ichr2 ichr2 - ichr2 ichr2
i k,j m %1 j i k,m %1 j,m i k
l l %1 l %1
+ ichr2 + ichr2 ichr2 + ichr2 ichr2
i j,k m %1 k i j,m %1 k,m i j
Note: In earlier versions of Maxima, derivative forms of the Christoffel-symbols also
could not be evaluated. This has been fixed now, so evundiff is no longer necessary
for expressions like this:
(%i5) imetric(g);
(%o5) done
(%i6) ishow(ichr2([i,j],[k],l))$
k %3
g (g - g + g )
j %3,i l i j,%3 l i %3,j l
(%t6) -----------------------------------------
2
k %3
g (g - g + g )
,l j %3,i i j,%3 i %3,j
+ -----------------------------------
2
(%i1) load(itensor);
(%o1) /share/tensor/itensor.lisp
(%i2) ishow(a([i],[J,r],k,r)+a([i],[j,r,s],k,r,s))$
J r j r s
(%t2) a + a
i,k r i,k r s
(%i3) ishow(flushnd(%,a,3))$
J r
(%t3) a
i,k r
(%i1) load(itensor);
(%o1) /share/tensor/itensor.lisp
(%i2) ishow(g([],[a,b],c))$
a b
(%t2) g
,c
256 Maxima Manual
(%i3) ishow(conmetderiv(%,g))$
%1 b a %1 a b
(%t3) - g ichr2 - g ichr2
%1 c %1 c
(%i1) load(itensor);
(%o1) /share/tensor/itensor.lisp
(%i2) entertensor()$
Enter tensor name: a;
Enter a list of the covariant indices: [i,j];
Enter a list of the contravariant indices: [k];
Enter a list of the derivative indices: [];
k
(%t2) a
i j
(%i3) ishow(covdiff(%,s))$
k %1 k %1 k k %1
(%t3) - a ichr2 - a ichr2 + a + ichr2 a
i %1 j s %1 j i s i j,s %1 s i j
(%i1) load(itensor);
(%o1) /share/tensor/itensor.lisp
(%i2) ishow(icurvature([r,s,t],[u]))$
u u %1 u u %1
(%t2) - ichr2 - ichr2 ichr2 + ichr2 + ichr2 ichr2
r t,s %1 s r t r s,t %1 t r s
(%i3) ishow(igeodesic_coords(%,ichr2))$
u u
(%t3) ichr2 - ichr2
r s,t r t,s
(%i4) ishow(igeodesic_coords(icurvature([r,s,t],[u]),ichr2)+
igeodesic_coords(icurvature([s,t,r],[u]),ichr2)+
igeodesic_coords(icurvature([t,r,s],[u]),ichr2))$
u u u u u
(%t4) - ichr2 + ichr2 + ichr2 - ichr2 - ichr2
t s,r t r,s s t,r s r,t r t,s
u
+ ichr2
258 Maxima Manual
r s,t
(%i5) canform(%);
(%o5) 0
(%i1) load(itensor);
(%o1) /share/tensor/itensor.lisp
(%i2) iframe_flag:true;
(%o2) true
(%i3) ishow(covdiff(v([],[i]),j))$
i i %1
(%t3) v + icc2 v
,j %1 j
(%i4) ishow(ev(%,icc2))$
%1 i i i
(%t4) v (ifc2 + ichr2 ) + v
%1 j %1 j ,j
(%i5) ishow(ev(%,ifc2))$
%1 i %2
v ifg (ifb - ifb + ifb )
j %2 %1 %2 %1 j %1 j %2 i
(%t5) -------------------------------------------------- + v
2 ,j
(%i6) ishow(ifb([a,b,c]))$
Chapter 29: itensor 259
%5 %4
(%t6) ifr ifr (ifri - ifri )
a b c %4,%5 c %5,%4
An alternate method is used to compute the frame bracket (ifb) if the iframe_bracket_
form flag is set to false:
(%i8) block([iframe_bracket_form:false],ishow(ifb([a,b,c])))$
%7 %6 %6 %7
(%t8) (ifr ifr - ifr ifr ) ifri
a b,%7 a,%7 b c %6
iframes () Function
Since in this version of Maxima, contraction identities for ifr and ifri are always
defined, as is the frame bracket (ifb), this function does nothing.
ifb Variable
The frame bracket. The contribution of the frame metric to the connection coefficients
is expressed using the frame bracket:
The frame bracket itself is defined in terms of the frame field and frame metric.
Two alternate methods of computation are used depending on the value of frame_
bracket_form. If true (the default) or if the itorsion_flag is true:
d e f
ifb = ifr ifr (ifri - ifri - ifri itr )
abc b c a d,e a e,d a f d e
Otherwise:
e d d e
ifb = (ifr ifr - ifr ifr ) ifri
abc b c,e b,e c a d
icc1 Variable
Connection coefficients of the first kind. In itensor, defined as
icc2 Variable
Connection coefficients of the second kind. In itensor, defined as
c c c c
icc2 = ichr2 - ikt2 - inmc2
ab ab ab ab
ifc1 Variable
Frame coefficient of the first kind (also known as Ricci-rotation coefficients.) This
tensor represents the contribution of the frame metric to the connection coefficient of
the first kind. Defined as:
ifc2 Variable
Frame coefficient of the first kind. This tensor represents the contribution of the frame
metric to the connection coefficient of the first kind. Defined as a permutation of the
frame bracket (ifb) with the appropriate indices raised and lowered as necessary:
c cd
ifc2 = ifg ifc1
ab abd
ifr Variable
The frame field. Contracts with the inverse frame field (ifri) to form the frame
metric (ifg).
Chapter 29: itensor 261
ifri Variable
The inverse frame field. Specifies the frame base (basis vectors). Along with the
frame metric, it forms the basis of all calculations based on frames.
ifg Variable
The frame metric. Defaults to kdelta, but can be changed using components.
ifgi Variable
The inverse frame metric. Contracts with the frame metric (ifg) to kdelta.
inm Variable
The nonmetricity vector. Conformal nonmetricity is defined through the covariant
derivative of the metric tensor. Normally zero, the metric tensor’s covariant derivative
will evaluate to the following when inonmet_flag is set to true:
g =- g nm
ij;k ij k
inmc1 Variable
Covariant permutation of the nonmetricity vector components. Defined as
inmc2 Variable
Contravariant permutation of the nonmetricity vector components. Used in the con-
nection coefficients if inonmet_flag is true. Defined as:
c c cd
-inm kdelta - kdelta inm + g inm g
c a b a b d ab
inmc2 = -------------------------------------------
ab 2
ikt1 Variable
Covariant permutation of the torsion tensor (also known as contorsion). Defined as:
d d d
-g - gitr itr - itr g
ad cb bd ca ab cd
ikt1 = ----------------------------------
abc 2
ikt2 Variable
Contravariant permutation of the torsion tensor (also known as contorsion). Defined
as:
c cd
ikt2 = g ikt1
ab abd
itr Variable
The torsion tensor. For a metric with torsion, repeated covariant differentiation on a
scalar function will not commute, as demonstrated by the following example:
(%i1) load(itensor);
(%o1) /share/tensor/itensor.lisp
(%i2) imetric:g;
(%o2) g
(%i3) covdiff(covdiff(f([],[]),i),j)-covdiff(covdiff(f([],[]),j),i)$
(%i4) ishow(%)$
%4 %2
(%t4) f ichr2 - f ichr2
,%4 j i ,%2 i j
(%i5) canform(%);
(%o5) 0
(%i6) itorsion_flag:true;
(%o6) true
(%i7) covdiff(covdiff(f([],[]),i),j)-covdiff(covdiff(f([],[]),j),i)$
(%i8) ishow(%)$
%8 %6
(%t8) f icc2 - f icc2 - f + f
,%8 j i ,%6 i j ,j i ,i j
(%i9) ishow(canform(%))$
%1 %1
(%t9) f icc2 - f icc2
,%1 j i ,%1 i j
Chapter 29: itensor 263
(%i10) ishow(canform(ev(%,icc2)))$
%1 %1
(%t10) f ikt2 - f ikt2
,%1 i j ,%1 j i
(%i11) ishow(canform(ev(%,ikt2)))$
%2 %1 %2 %1
(%t11) f g ikt1 - f g ikt1
,%2 i j %1 ,%2 j i %1
(%i12) ishow(factor(canform(rename(expand(ev(%,ikt1))))))$
%3 %2 %1 %1
f g g (itr - itr )
,%3 %2 %1 j i i j
(%t12) ------------------------------------
2
(%i13) decsym(itr,2,1,[anti(all)],[]);
(%o13) done
(%i14) defcon(g,g,kdelta);
(%o14) done
(%i15) subst(g,nounify(g),%th(3))$
(%i16) ishow(canform(contract(%)))$
%1
(%t16) - f itr
,%1 i j
(%i1) load(itensor);
(%o1) /share/tensor/itensor.lisp
(%i2) decsym(a,2,0,[anti(all)],[]);
(%o2) done
(%i3) ishow(a([i,j],[])|v)$
%1
(%t3) v a
%1 j
(%i4) ishow(a([j,i],[])|v)$
%1
(%t4) - v a
%1 j
Note that it is essential that the tensors used with the | operator be declared totally
antisymmetric in their covariant indices. Otherwise, the results will be incorrect.
(%i1) load(itensor);
(%o1) /share/tensor/itensor.lisp
(%i2) load(tentex);
(%o2) /share/tensor/tentex.lisp
(%i3) idummyx:m;
(%o3) m
(%i4) ishow(icurvature([j,k,l],[i]))$
m1 i m1 i i i
(%t4) ichr2 ichr2 - ichr2 ichr2 - ichr2 + ichr2
j k m1 l j l m1 k j l,k j k,l
(%i5) tentex(%)$
$$\Gamma_{j\,k}^{m_1}\,\Gamma_{l\,m_1}^{i}-\Gamma_{j\,l}^{m_1}\,
\Gamma_{k\,m_1}^{i}-\Gamma_{j\,l,k}^{i}+\Gamma_{j\,k,l}^{i}$$
Note the use of the idummyx assignment, to avoid the appearance of the percent sign
in the TeX expression, which may lead to compile errors.
NB: This version of the tentex function is somewhat experimental.
(%i2) eqn:ishow(t([i,j],[k])=f([],[])*g([l,m],[])*a([],[m],j)*b([i],[l,k]))$
k m l k
(%t2) t = f a b g
i j ,j i l m
(%i3) ic_convert(eqn);
(%o3) for i thru dim do (for j thru dim
g , l, 1, dim), m, 1, dim)))
l, m
(%i4) imetric(g);
(%o4) done
(%i5) metricconvert:true;
(%o5) true
(%i6) ic_convert(eqn);
(%o6) for i thru dim do (for j thru dim
lg , l, 1, dim), m, 1, dim)))
l, m
30 ctensor
Matrix entered.
270 Maxima Manual
1
(%t4) mcs = -
1, 2, 2 x
1
(%t5) mcs = -
1, 3, 3 x
d
x
(%t6) mcs = ---
1, 4, 4 2 d
x
(%t7) mcs = - -
2, 2, 1 a
cos(y)
(%t8) mcs = ------
2, 3, 3 sin(y)
2
x sin (y)
(%t9) mcs = - ---------
3, 3, 1 a
d
x
(%t11) mcs = ---
4, 4, 1 2 a
(%o11) done
csetup () Function
A function in the ctensor (component tensor) package which initializes the package
and allows the user to enter a metric interactively. See ctensor for more details.
(%i1) load(ctensor);
(%o1) /share/tensor/ctensor.mac
(%i2) ct_coordsys([r*cos(theta)*cos(phi),r*cos(theta)*sin(phi),
r*sin(theta),[r,theta,phi]]);
(%o2) done
(%i3) lg:trigsimp(lg);
[ 1 0 0 ]
[ ]
[ 2 ]
(%o3) [ 0 r 0 ]
[ ]
[ 2 2 ]
[ 0 0 r cos (theta) ]
(%i4) ct_coords;
(%o4) [r, theta, phi]
(%i5) dim;
(%o5) 3
(%i1) load(ctensor);
(%o1) /share/tensor/ctensor.mac
(%i2) cframe_flag:true;
(%o2) true
(%i3) ct_coordsys([r*cos(theta)*cos(phi),r*cos(theta)*sin(phi),
r*sin(theta),[r,theta,phi]]);
(%o3) done
Chapter 30: ctensor 273
(%i4) fri;
[ cos(phi) cos(theta) - cos(phi) r sin(theta) - sin(phi) r cos(theta) ]
[ ]
(%o4) [ sin(phi) cos(theta) - sin(phi) r sin(theta) cos(phi) r cos(theta) ]
[ ]
[ sin(theta) r cos(theta) 0 ]
(%i5) cmetric();
(%o5) false
(%i6) lg:trigsimp(lg);
[ 1 0 0 ]
[ ]
[ 2 ]
(%o6) [ 0 r 0 ]
[ ]
[ 2 2 ]
[ 0 0 r cos (theta) ]
The optional argument extra arg can be any one of the following:
cylindrical tells ct_coordsys to attach an additional cylindrical coordinate.
minkowski tells ct_coordsys to attach an additional coordinate with negative metric
signature.
all tells ct_coordsys to call cmetric and christof(false) after setting up the
metric.
If the global variable verbose is set to true, ct_coordsys displays the values of dim,
ct_coords, and either lg or lfg and fri, depending on the value of cframe_flag.
lg -- ug
\ \
lcs -- mcs -- ric -- uric
\ \ \
\ tracer - ein -- lein
\
riem -- lriem -- weyl
\
274 Maxima Manual
uriem
ctensor can also work using moving frames. When cframe_flag is set to true, the
following tensors can be calculated:
lfg -- ufg
\
fri -- fr -- lcs -- mcs -- lriem -- ric -- uric
\ | \ \ \
lg -- ug | weyl tracer - ein -- lein
|\
| riem
|
\uriem
scurvature () Function
returns the scalar curvature (obtained by contracting the Ricci tensor) of the Rie-
mannian manifold with the given metric.
Chapter 30: ctensor 275
rinvariant () Function
Forms the Kretchmann-invariant (kinvariant) obtained by contracting the tensors
lriem[i,j,k,l]*uriem[i,j,k,l].
This object is not automatically simplified since it can be very large.
Function Comments
---------------------------------
christof() For mcs only
ricci()
uricci()
einstein()
riemann()
weyl()
checkdiv()
ctaylor () Function
The ctaylor function truncates its argument by converting it to a Taylor-series using
taylor, and then calling ratdisrep. This has the combined effect of dropping terms
higher order in the expansion variable ctayvar. The order of terms that should be
dropped is defined by ctaypov; the point around which the series expansion is carried
out is specified in ctaypt.
As an example, consider a simple metric that is a perturbation of the Minkowski
metric. Without further restrictions, even a diagonal metric produces expressions for
the Einstein tensor that are far too complex:
(%i1) load(ctensor);
(%o1) /share/tensor/ctensor.mac
(%i2) ratfac:true;
(%o2) true
(%i3) derivabbrev:true;
(%o3) true
(%i4) ct_coords:[t,r,theta,phi];
(%o4) [t, r, theta, phi]
Chapter 30: ctensor 277
(%i5) lg:matrix([-1,0,0,0],[0,1,0,0],[0,0,r^2,0],[0,0,0,r^2*sin(theta)^2]);
[ - 1 0 0 0 ]
[ ]
[ 0 1 0 0 ]
[ ]
(%o5) [ 2 ]
[ 0 0 r 0 ]
[ ]
[ 2 2 ]
[ 0 0 0 r sin (theta) ]
(%i6) h:matrix([h11,0,0,0],[0,h22,0,0],[0,0,h33,0],[0,0,0,h44]);
[ h11 0 0 0 ]
[ ]
[ 0 h22 0 0 ]
(%o6) [ ]
[ 0 0 h33 0 ]
[ ]
[ 0 0 0 h44 ]
(%i7) depends(l,r);
(%o7) [l(r)]
(%i8) lg:lg+l*h;
[ h11 l - 1 0 0 0 ]
[ ]
[ 0 h22 l + 1 0 0 ]
[ ]
(%o8) [ 2 ]
[ 0 0 r + h33 l 0 ]
[ ]
[ 2 2 ]
[ 0 0 0 r sin (theta) + h44 l ]
(%i9) cmetric(false);
(%o9) done
(%i10) einstein(false);
(%o10) done
(%i11) ntermst(ein);
[[1, 1], 62]
[[1, 2], 0]
[[1, 3], 0]
[[1, 4], 0]
[[2, 1], 0]
[[2, 2], 24]
[[2, 3], 0]
[[2, 4], 0]
[[3, 1], 0]
[[3, 2], 0]
[[3, 3], 46]
[[3, 4], 0]
[[4, 1], 0]
[[4, 2], 0]
278 Maxima Manual
[[4, 3], 0]
[[4, 4], 46]
(%o12) done
(%i14) ctayswitch:true;
(%o14) true
(%i15) ctayvar:l;
(%o15) l
(%i16) ctaypov:1;
(%o16) 1
(%i17) ctaypt:0;
(%o17) 0
(%i18) christof(false);
(%o18) done
(%i19) ricci(false);
(%o19) done
(%i20) einstein(false);
(%o20) done
(%i21) ntermst(ein);
[[1, 1], 6]
[[1, 2], 0]
[[1, 3], 0]
[[1, 4], 0]
[[2, 1], 0]
[[2, 2], 13]
[[2, 3], 2]
[[2, 4], 0]
[[3, 1], 0]
[[3, 2], 2]
[[3, 3], 9]
[[3, 4], 0]
[[4, 1], 0]
[[4, 2], 0]
[[4, 3], 0]
[[4, 4], 9]
(%o21) done
(%i22) ratsimp(ein[1,1]);
2 2 4 2 2
(%o22) - (((h11 h22 - h11 ) (l ) r - 2 h33 l r ) sin (theta)
r r r
2 2 4 2
- 2 h44 l r - h33 h44 (l ) )/(4 r sin (theta))
r r r
Chapter 30: ctensor 279
This capability can be useful, for instance, when working in the weak field limit far
from a gravitational source.
nptetrad () Function
Computes a Newman-Penrose null tetrad (np) and its raised-index counterpart (npi).
See petrov for an example.
The null tetrad is constructed on the assumption that a four-diemensional orthonor-
mal frame metric with metric signature (-,+,+,+) is being used. The components of
the null tetrad are related to the inverse frame matrix as follows:
computationally expensive procedure. For this reason, in some cases it may be more
advantageous to use a coordinate base in the first place before the Weyl tensor is
computed. Note however, that constructing a Newman-Penrose null tetrad requires a
frame base. Therefore, a meaningful computation sequence may begin with a frame
base, which is then used to compute lg (computed automatically by cmetric and
then ug. At this point, you can switch back to a coordinate base by setting cframe_
flag to false before beginning to compute the Christoffel symbols. Changing to a
frame base at a later stage could yield inconsistent results, as you may end up with
a mixed bag of tensors, some computed in a frame base, some in a coordinate base,
with no means to distinguish between the two.
petrov () Function
Computes the Petrov classification of the metric characterized by psi[0]...psi[4].
For example, the following demonstrates how to obtain the Petrov-classification of
the Kerr metric:
(%i1) load(ctensor);
(%o1) /share/tensor/ctensor.mac
(%i2) (cframe_flag:true,gcd:spmod,ctrgsimp:true,ratfac:true);
(%o2) true
(%i3) ct_coordsys(exteriorschwarzschild,all);
(%o3) done
(%i4) ug:invert(lg)$
(%i5) weyl(false);
(%o5) done
(%i6) nptetrad(true);
(%t6) np =
[ sqrt(r - 2 m) sqrt(r) ]
[ --------------- --------------------- 0 0 ]
[ sqrt(2) sqrt(r) sqrt(2) sqrt(r - 2 m) ]
[ ]
[ sqrt(r - 2 m) sqrt(r) ]
[ --------------- - --------------------- 0 0 ]
[ sqrt(2) sqrt(r) sqrt(2) sqrt(r - 2 m) ]
[ ]
[ r %i r sin(theta) ]
[ 0 0 ------- --------------- ]
[ sqrt(2) sqrt(2) ]
[ ]
[ r %i r sin(theta) ]
[ 0 0 ------- - --------------- ]
[ sqrt(2) sqrt(2) ]
sqrt(r) sqrt(r - 2 m)
(%t7) npi = matrix([- ---------------------, ---------------, 0, 0],
sqrt(2) sqrt(r - 2 m) sqrt(2) sqrt(r)
sqrt(r) sqrt(r - 2 m)
Chapter 30: ctensor 281
1 %i
[0, 0, ---------, --------------------],
sqrt(2) r sqrt(2) r sin(theta)
1 %i
[0, 0, ---------, - --------------------])
sqrt(2) r sqrt(2) r sin(theta)
(%o7) done
(%i7) psi(true);
(%t8) psi = 0
0
(%t9) psi = 0
1
m
(%t10) psi = --
2 3
r
(%t11) psi = 0
3
(%t12) psi = 0
4
(%o12) done
(%i12) petrov();
(%o12) D
m m m
282 Maxima Manual
- g tr - g tr - tr g
im kj jm ki ij km
kt = -------------------------------
ijk 2
k km
kt = g kt
ij ijm
Note that only the mixed-index tensor is calculated and stored in the array kt.
The nonmetricity coefficients are calculated from the user-supplied nonmetricity vector
nm. From this, the nonmetricity coefficients nmc are computed as follows:
k k km
-nm D - D nm + g nm g
k i j i j m ij
nmc = ------------------------------
ij 2
ctransform (M ) Function
A function in the ctensor (component tensor) package which will perform a coordi-
nate transformation upon an arbitrary square symmetric matrix M. The user must
input the functions which define the transformation. (Formerly called transform.)
equations. For the Einstein tensor (ein), which is a two dimensional array, if com-
puted for the metric in the example below, findde gives the following independent
differential equations:
(%i1) load(ctensor);
(%o1) /share/tensor/ctensor.mac
(%i2) derivabbrev:true;
(%o2) true
(%i3) dim:4;
(%o3) 4
(%i4) lg:matrix([a,0,0,0],[0,x^2,0,0],[0,0,x^2*sin(y)^2,0],[0,0,0,-d]);
[ a 0 0 0 ]
[ ]
[ 2 ]
[ 0 x 0 0 ]
(%o4) [ ]
[ 2 2 ]
[ 0 0 x sin (y) 0 ]
[ ]
[ 0 0 0 - d ]
(%i5) depends([a,d],x);
(%o5) [a(x), d(x)]
(%i6) ct_coords:[x,y,z,t];
(%o6) [x, y, z, t]
(%i7) cmetric();
(%o7) done
(%i8) einstein(false);
(%o8) done
(%i9) findde(ein,2);
2
(%o9) [d x - a d + d, 2 a d d x - a (d ) x - a d d x + 2 a d d
x x x x x x x
2 2
- 2 a d , a x + a - a]
x x
(%i10) deindex;
(%o10) [[1, 1], [2, 2], [4, 4]]
cograd () Function
Computes the covariant gradient of a scalar function allowing the user to choose the
corresponding vector name as the example under contragrad illustrates.
contragrad () Function
Computes the contravariant gradient of a scalar function allowing the user to choose
the corresponding vector name as the example below for the Schwarzschild metric
illustrates:
284 Maxima Manual
(%i1) load(ctensor);
(%o1) /share/tensor/ctensor.mac
(%i2) derivabbrev:true;
(%o2) true
(%i3) ct_coordsys(exteriorschwarzschild,all);
(%o3) done
(%i4) depends(f,r);
(%o4) [f(r)]
(%i5) cograd(f,g1);
(%o5) done
(%i6) listarray(g1);
(%o6) [0, f , 0, 0]
r
(%i7) contragrad(f,g2);
(%o7) done
(%i8) listarray(g2);
f r - 2 f m
r r
(%o8) [0, -------------, 0, 0]
r
dscalar () Function
computes the tensor d’Alembertian of the scalar function once dependencies have
been declared upon the function. For example:
(%i1) load(ctensor);
(%o1) /share/tensor/ctensor.mac
(%i2) derivabbrev:true;
(%o2) true
(%i3) ct_coordsys(exteriorschwarzschild,all);
(%o3) done
(%i4) depends(p,r);
(%o4) [p(r)]
(%i5) factor(dscalar(p));
2
p r - 2 m p r + 2 p r - 2 m p
r r r r r r
(%o5) --------------------------------------
2
r
checkdiv () Function
computes the covariant divergence of the mixed second rank tensor (whose first index
must be covariant) by printing the corresponding n components of the vector field (the
divergence) where n = dim. If the argument to the function is g then the divergence
of the Einstein tensor will be formed and must be zero. In addition, the divergence
(vector) is given the array name div.
Chapter 30: ctensor 285
bdvac (f ) Function
generates the covariant components of the vacuum field equations of the Brans- Dicke
gravitational theory. The scalar field is specified by the argument f, which should be
a (quoted) function name with functional dependencies, e.g., ’p(x).
The components of the second rank covariant field tensor are represented by the array
bd.
invariant1 () Function
generates the mixed Euler- Lagrange tensor (field equations) for the invariant density
of R^2. The field equations are the components of an array named inv1.
invariant2 () Function
*** NOT YET IMPLEMENTED ***
generates the mixed Euler- Lagrange tensor (field equations) for the invariant density
of ric[i,j]*uriem[i,j]. The field equations are the components of an array named
inv2.
bimetric () Function
*** NOT YET IMPLEMENTED ***
generates the field equations of Rosen’s bimetric theory. The field equations are the
components of an array named rosen.
diagmatrixp (M ) Function
Returns true if M is a diagonal matrix or (2D) array.
symmetricp (M ) Function
Returns true if M is a symmetric matrix or (2D) array.
ntermst (f ) Function
gives the user a quick picture of the "size" of the doubly subscripted tensor (array) f.
It prints two element lists where the second element corresponds to NTERMS of the
components specified by the first elements. In this way, it is possible to quickly find
the non-zero expressions and attempt simplification.
(%i1) load(ctensor);
(%o1) /share/tensor/ctensor.mac
(%i2) ratfac:true;
(%o2) true
(%i3) ct_coordsys(exteriorschwarzschild,all);
(%o3) done
(%i4) riemann(false);
(%o4) done
(%i5) cdisplay(riem);
[ 0 0 0 0 ]
[ ]
[ 2 ]
[ 3 m (r - 2 m) m 2 m ]
[ 0 - ------------- + -- - ---- 0 0 ]
[ 4 3 4 ]
[ r r r ]
[ ]
riem = [ m (r - 2 m) ]
1, 1 [ 0 0 ----------- 0 ]
[ 4 ]
[ r ]
[ ]
[ m (r - 2 m) ]
[ 0 0 0 ----------- ]
[ 4 ]
[ r ]
[ 2 m (r - 2 m) ]
[ 0 ------------- 0 0 ]
[ 4 ]
[ r ]
riem = [ ]
1, 2 [ 0 0 0 0 ]
[ ]
[ 0 0 0 0 ]
[ ]
[ 0 0 0 0 ]
[ m (r - 2 m) ]
[ 0 0 - ----------- 0 ]
[ 4 ]
[ r ]
riem = [ ]
1, 3 [ 0 0 0 0 ]
[ ]
[ 0 0 0 0 ]
[ ]
[ 0 0 0 0 ]
Chapter 30: ctensor 287
[ m (r - 2 m) ]
[ 0 0 0 - ----------- ]
[ 4 ]
[ r ]
riem = [ ]
1, 4 [ 0 0 0 0 ]
[ ]
[ 0 0 0 0 ]
[ ]
[ 0 0 0 0 ]
[ 0 0 0 0 ]
[ ]
[ 2 m ]
[ - ------------ 0 0 0 ]
riem = [ 2 ]
2, 1 [ r (r - 2 m) ]
[ ]
[ 0 0 0 0 ]
[ ]
[ 0 0 0 0 ]
[ 2 m ]
[ ------------ 0 0 0 ]
[ 2 ]
[ r (r - 2 m) ]
[ ]
[ 0 0 0 0 ]
[ ]
riem = [ m ]
2, 2 [ 0 0 - ------------ 0 ]
[ 2 ]
[ r (r - 2 m) ]
[ ]
[ m ]
[ 0 0 0 - ------------ ]
[ 2 ]
[ r (r - 2 m) ]
[ 0 0 0 0 ]
[ ]
[ m ]
[ 0 0 ------------ 0 ]
riem = [ 2 ]
2, 3 [ r (r - 2 m) ]
[ ]
[ 0 0 0 0 ]
[ ]
[ 0 0 0 0 ]
288 Maxima Manual
[ 0 0 0 0]
[ ]
[ m ]
[ 0 0 0 ------------ ]
riem = [ 2 ]
2, 4 [ r (r - 2 m) ]
[ ]
[ 0 0 0 0 ]
[ ]
[ 0 0 0 0 ]
[ 0 0 0 0 ]
[ ]
[ 0 0 0 0 ]
[ ]
riem = [ m ]
3, 1 [ - 0 0 0 ]
[ r ]
[ ]
[ 0 0 0 0 ]
[ 0 0 0 0 ]
[ ]
[ 0 0 0 0 ]
[ ]
riem = [ m ]
3, 2 [ 0 - 0 0 ]
[ r ]
[ ]
[ 0 0 0 0 ]
[ m ]
[ - - 0 0 0
]
[ r ]
[ ]
[ m ]
[ 0 - - 0 0 ]
riem = [ r ]
3, 3 [ ]
[ 0 0 0 0 ]
[ ]
[ 2 m - r ]
[ 0 0 0 ------- + 1 ]
[ r ]
[ 0 0 0 0 ]
[ ]
[ 0 0 0 0 ]
Chapter 30: ctensor 289
[ ]
riem = [ 2 m ]
3, 4 [ 0 0 0 - --- ]
[ r ]
[ ]
[ 0 0 0 0 ]
[ 0 0 0 0 ]
[ ]
[ 0 0 0 0 ]
[ ]
riem = [ 0 0 0 0 ]
4, 1 [ ]
[ 2 ]
[ m sin (theta) ]
[ ------------- 0 0 0 ]
[ r ]
[ 0 0 0 0 ]
[ ]
[ 0 0 0 0 ]
[ ]
riem = [ 0 0 0 0 ]
4, 2 [ ]
[ 2 ]
[ m sin (theta) ]
[ 0 ------------- 0 0 ]
[ r ]
[ 0 0 0 0 ]
[ ]
[ 0 0 0 0 ]
[ ]
riem = [ 0 0 0 0 ]
4, 3 [ ]
[ 2 ]
[ 2 m sin (theta) ]
[ 0 0 - --------------- 0 ]
[ r ]
[ 2 ]
[ m sin (theta) ]
[ - ------------- 0 0 0 ]
[ r ]
[ ]
[ 2 ]
[ m sin (theta) ]
riem = [ 0 - ------------- 0 0 ]
4, 4 [ r ]
290 Maxima Manual
[ ]
[ 2 ]
[ 2 m sin (theta) ]
[ 0 0 --------------- 0 ]
[ r ]
[ ]
[ 0 0 0 0 ]
(%o5) done
dim Variable
Default value: 4
An option in the ctensor (component tensor) package. dim is the dimension of the
manifold with the default 4. The command dim: n will reset the dimension to any
other value n.
diagmetric Variable
Default value: false
An option in the ctensor (component tensor) package. If diagmetric is true special
routines compute all geometrical objects (which contain the metric tensor explicitly)
by taking into consideration the diagonality of the metric. Reduced run times will, of
course, result. Note: this option is set automatically by csetup if a diagonal metric
is specified.
ctrgsimp Variable
Causes trigonometric simplifications to be used when tensors are computed. Presently,
ctrgsimp affects only computations involving a moving frame.
ctayswitch Variable
If set to true, causes some ctensor computations to be carried out using Taylor-
series expansions. Presently, christof, ricci, uricci, einstein, and weyl take
into account this setting.
ctayvar Variable
Variable used for Taylor-series expansion if ctayswitch is set to true.
ctaypov Variable
Maximum power used in Taylor-series expansion when ctayswitch is set to true.
ctaypt Variable
Point around which Taylor-series expansion is carried out when ctayswitch is set to
true.
gdet Variable
The determinant of the metric tensor lg. Computed by cmetric when cframe_flag
is set to false.
ratchristof Variable
Causes rational simplification to be applied by christof.
rateinstein Variable
Default value: true
If true rational simplification will be performed on the non-zero components of Ein-
stein tensors; if ratfac is true then the components will also be factored.
ratriemann Variable
Default value: true
One of the switches which controls simplification of Riemann tensors; if true, then
rational simplification will be done; if ratfac is true then each of the components
will also be factored.
ratweyl Variable
Default value: true
If true, this switch causes the weyl function to apply rational simplification to the
values of the Weyl tensor. If ratfac is true, then the components will also be
factored.
292 Maxima Manual
lfg Variable
The covariant frame metric. By default, it is initialized to the 4-dimensional Lorentz
frame with signature (+,+,+,-). Used when cframe_flag is true.
ufg Variable
The inverse frame metric. Computed from lfg when cmetric is called while cframe_
flag is set to true.
riem Variable
The (3,1) Riemann tensor. Computed when the function riemann is invoked. For
information about index ordering, see the description of riemann.
if cframe_flag is true, riem is computed from the covariant Riemann-tensor lriem.
lriem Variable
The covariant Riemann tensor. Computed by lriemann.
uriem Variable
The contravariant Riemann tensor. Computed by uriemann.
ric Variable
The mixed Ricci-tensor. Computed by ricci.
uric Variable
The contravariant Ricci-tensor. Computed by uricci.
lg Variable
The metric tensor. This tensor must be specified (as a dim by dim matrix) before
other computations can be performed.
ug Variable
The inverse of the metric tensor. Computed by cmetric.
weyl Variable
The Weyl tensor. Computed by weyl.
fb Variable
Frame bracket coefficients, as computed by frame_bracket.
kinvariant Variable
The Kretchmann invariant. Computed by rinvariant.
np Variable
A Newman-Penrose null tetrad. Computed by nptetrad.
Chapter 30: ctensor 293
npi Variable
The raised-index Newman-Penrose null tetrad. Computed by nptetrad. Defined as
ug.np. The product np.transpose(npi) is constant:
(%i39) trigsimp(np.transpose(npi));
[ 0 - 1 0 0 ]
[ ]
[ - 1 0 0 0 ]
(%o39) [ ]
[ 0 0 0 1 ]
[ ]
[ 0 0 1 0 ]
tr Variable
User-supplied rank-3 tensor representing torsion. Used by contortion.
kt Variable
The contortion tensor, computed from tr by contortion.
nm Variable
User-supplied nonmetricity vector. Used by nonmetricity.
nmc Variable
The nonmetricity coefficients, computed from nm by nonmetricity.
tensorkill Variable
Variable indicating if the tensor package has been initialized. Set and used by csetup,
reset by init_ctensor.
ct coords Variable
Default value: []
An option in the ctensor (component tensor) package. ct_coords contains a list
of coordinates. While normally defined when the function csetup is called, one may
redefine the coordinates with the assignment ct_coords: [j1, j2, ..., jn] where
the j’s are the new coordinate names. See also csetup.
30.2.11 Changes
In November, 2004, the ctensor package was extensively rewritten. Many functions and
variables have been renamed in order to make the package compatible with the commercial
version of Macsyma.
New Name Old Name Description
--------------------------------------------------------------------------
ctaylor() DLGTAYLOR() Taylor-series expansion of an expression
lgeod[] EM Geodesic equations
ein[] G[] Mixed Einstein-tensor
ric[] LR[] Mixed Ricci-tensor
ricci() LRICCICOM() Compute the mixed Ricci-tensor
ctaypov MINP Maximum power in Taylor-series expansion
cgeodesic() MOTION Compute geodesic equations
ct_coords OMEGA Metric coordinates
ctayvar PARAM Taylor-series expansion variable
lriem[] R[] Covariant Riemann-tensor
uriemann() RAISERIEMANN() Compute the contravariant Riemann-tensor
ratriemann RATRIEMAN Rational simplification of the Riemann-tensor
uric[] RICCI[] Contravariant Ricci-tensor
uricci() RICCICOM() Compute the contravariant Ricci-tensor
cmetric() SETMETRIC() Set up the metric
ctaypt TAYPT Point for Taylor-series expansion
ctayswitch TAYSWITCH Taylor-series setting switch
csetup() TSETUP() Start interactive setup session
ctransform() TTRANSFORM() Interactive coordinate transformation
uriem[] UR[] Contravariant Riemann-tensor
weyl[] W[] (3,1) Weyl-tensor
Chapter 31: atensor 295
31 atensor
(%i1) load(atensor);
(%o1) /share/tensor/atensor.mac
(%i2) init_atensor(clifford,0,0,2);
(%o2) done
(%i3) atensimp(v[1].v[1]);
(%o3) - 1
(%i4) atensimp((v[1].v[2]).(v[1].v[2]));
(%o4) - 1
(%i5) q:zeromatrix(4,4);
[ 0 0 0 0 ]
[ ]
[ 0 0 0 0 ]
(%o5) [ ]
[ 0 0 0 0 ]
[ ]
[ 0 0 0 0 ]
(%i6) q[1,1]:1;
(%o6) 1
(%i7) for i thru adim do q[1,i+1]:q[i+1,1]:v[i];
(%o7) done
(%i8) q[1,4]:q[4,1]:v[1].v[2];
(%o8) v . v
1 2
(%i9) for i from 2 thru 4 do for j from 2 thru 4 do
q[i,j]:atensimp(q[i,1].q[1,j]);
(%o9) done
(%i10) q;
[ 1 v v v . v ]
296 Maxima Manual
[ 1 2 1 2 ]
[ ]
[ v - 1 v . v - v ]
[ 1 1 2 2 ]
(%o10) [ ]
[ v - v . v - 1 v ]
[ 2 1 2 1 ]
[ ]
[ v . v v - v - 1 ]
[ 1 2 2 1 ]
atensor recognizes as base vectors indexed symbols, where the symbol is that stored in
asymbol and the index runs between 1 and adim. For indexed symbols, and indexed symbols
only, the bilinear forms sf, af, and av are evaluated. The evaluation substitutes the value
of aform[i,j] in place of fun(v[i],v[j]) where v represents the value of asymbol and
fun is either af or sf; or, it substitutes v[aform[i,j]] in place of av(v[i],v[j]).
Needless to say, the functions sf, af and av can be redefined.
When the atensor package is loaded, the following flags are set:
dotscrules:true;
dotdistrib:true;
dotexptsimp:false;
If you wish to experiment with a nonassociative algebra, you may also consider setting
dotassoc to false. In this case, however, atensimp will not always be able to obtain the
desired simplifications.
supplied, atensor will configure the values of adim and aform appropriately. Other-
wise, adim will default to 0 and aform will not be defined.
lie_envelop: The algebra of the Lie envelope is defined by the commutation relation
u.v-v.u=2*av(u,v) where av is an antisymmetric function.
The init_atensor function also recognizes several predefined algebra types:
complex implements the algebra of complex numbers as the Clifford algebra Cl(0,1).
The call init_atensor(complex) is equivalent to init_atensor(clifford,0,0,1).
quaternion implements the algebra of quaternions. The call init_
atensor(quaternion) is equivalent to init_atensor(clifford,0,0,2).
pauli implements the algebra of Pauli-spinors as the Clifford-algebra Cl(3,0). A call
to init_atensor(pauli) is equivalent to init_atensor(clifford,3).
dirac implements the algebra of Dirac-spinors as the Clifford-algebra Cl(3,1). A call
to init_atensor(dirac) is equivalent to init_atensor(clifford,3,0,1).
adim Variable
The dimensionality of the algebra. atensor uses the value of adim to determine if an
indexed object is a valid base vector. Defaults to 0.
aform Variable
Default values for the bilinear forms sf, af, and av. The default is the identity matrix
ident(3).
asymbol Variable
The symbol for base vectors. Defaults to v.
sf (u, v) Function
A symmetric scalar function that is used in commutation relations. The default
implementation checks if both arguments are base vectors using abasep and if that
is the case, substitutes the corresponding value from the matrix aform.
af (u, v) Function
An antisymmetric scalar function that is used in commutation relations. The default
implementation checks if both arguments are base vectors using abasep and if that
is the case, substitutes the corresponding value from the matrix aform.
298 Maxima Manual
av (u, v) Function
An antisymmetric function that is used in commutation relations. The default imple-
mentation checks if both arguments are base vectors using abasep and if that is the
case, substitutes the corresponding value from the matrix aform.
For instance:
(%i1) load(atensor);
(%o1) /share/tensor/atensor.mac
(%i2) adim:3;
(%o2) 3
(%i3) aform:matrix([0,3,2],[3,0,1],[2,1,0]);
[ 0 3 2 ]
[ ]
(%o3) [ 3 0 1 ]
[ ]
[ 2 1 0 ]
(%i4) asymbol:x;
(%o4) x
(%i5) av(x[1],x[2]);
(%o5) x
3
32 Series
cauchysum Variable
Default value: false
When multiplying together sums with inf as their upper limit, if sumexpand is true
and cauchysum is true then the Cauchy product will be used rather than the usual
product. In the Cauchy product the index of the inner summation is a function of
the index of the outer one rather than varying independently.
Example:
(%i1) sumexpand: false$
(%i2) cauchysum: false$
(%i3) s: sum (f(i), i, 0, inf) * sum (g(j), j, 0, inf);
inf inf
==== ====
\ \
(%o3) ( > f(i)) > g(j)
/ /
==== ====
i = 0 j = 0
(%i4) sumexpand: true$
(%i5) cauchysum: true$
(%i6) ’’s;
inf i1
==== ====
\ \
(%o6) > > g(i1 - i2) f(i2)
/ /
==== ====
i1 = 0 i2 = 0
deftaylor returns a list of the functions f 1, ..., f n. deftaylor evaluates its argu-
ments.
Example:
(%i1) deftaylor (f(x), x^2 + sum(x^i/(2^i*i!^2), i, 4, inf));
(%o1) [f]
(%i2) powerseries (f(x), x, 0);
inf
==== i1
\ x 2
(%o2) > -------- + x
/ i1 2
==== 2 i1!
i1 = 4
(%i3) taylor (exp (sqrt (f(x))), x, 0, 4);
2 3 4
x 3073 x 12817 x
(%o3)/T/ 1 + x + -- + ------- + -------- + . . .
2 18432 307200
maxtayorder Variable
Default value: true
When maxtayorder is true, then during algebraic manipulation of (truncated) Taylor
series, taylor tries to retain as many terms as are known to be correct.
niceindicespref Variable
Default value: [i, j, k, l, m, n]
niceindicespref is the list from which niceindices takes the names of indices for
sums and products.
The elements of niceindicespref are typically names of variables, although that is
not enforced by niceindices.
Example:
(%i1) niceindicespref: [p, q, r, s, t, u]$
(%i2) product (sum (f (foo + i*j*bar), foo, 1, inf), bar, 1, inf);
inf inf
/===\ ====
! ! \
(%o2) ! ! > f(bar i j + foo)
! ! /
bar = 1 ====
foo = 1
(%i3) niceindices (%);
inf inf
/===\ ====
! ! \
(%o3) ! ! > f(i j q + p)
! ! /
q = 1 ====
p = 1
4 3 2 n
2 (n + 1) (63 n + 112 n + 18 n - 22 n + 3) 4 2
(%o2) ------------------------------------------------ - ------
693 binomial(2 n, n) 3 11 7
(%i3) unsum (%, n);
4 n
n 4
(%o3) ----------------
binomial(2 n, n)
(%i4) unsum (prod (i^2, i, 1, n), n);
n - 1
/===\
! ! 2
(%o4) ( ! ! i ) (n - 1) (n + 1)
! !
i = 1
(%i5) nusum (%, n, 1, n);
pade (taylor series, numer deg bound, denom deg bound) Function
Returns a list of all rational functions which have the given Taylor series expansion
where the sum of the degrees of the numerator and the denominator is less than or
equal to the truncation level of the power series, i.e. are "best" approximants, and
which additionally satisfy the specified degree bounds.
taylor series is a univariate Taylor series. numer deg bound and denom deg bound
are positive integers specifying degree bounds on the numerator and denominator.
taylor series can also be a Laurent series, and the degree bounds can be inf which
causes all rational functions whose total degree is less than or equal to the length
of the power series to be returned. Total degree is defined as numer deg bound +
denom deg bound. Length of a power series is defined as "truncation level" + 1 -
min(0, "order of series").
(%i1) taylor (1 + x + x^2 + x^3, x, 0, 3);
2 3
(%o1)/T/ 1 + x + x + x + . . .
(%i2) pade (%, 1, 1);
1
(%o2) [- -----]
x - 1
(%i3) t: taylor(-(83787*x^10 - 45552*x^9 - 187296*x^8
+ 387072*x^7 + 86016*x^6 - 1507328*x^5
+ 1966080*x^4 + 4194304*x^3 - 25165824*x^2
Chapter 32: Series 303
+ 67108864*x - 134217728)
/134217728, x, 0, 10);
2 3 4 5 6 7
x 3 x x 15 x 23 x 21 x 189 x
(%o3)/T/ 1 - - + ---- - -- - ----- + ----- - ----- - ------
2 16 32 1024 2048 32768 65536
8 9 10
5853 x 2847 x 83787 x
+ ------- + ------- - --------- + . . .
4194304 8388608 134217728
(%i4) pade (t, 4, 4);
(%o4) []
There is no rational function of degree 4 numerator/denominator, with this power
series expansion. You must in general have degree of the numerator and degree of
the denominator adding up to at least the degree of the power series, in order to have
enough unknown coefficients to solve.
(%i5) pade (t, 5, 5);
5 4 3
(%o5) [- (520256329 x - 96719020632 x - 489651410240 x
2
- 1619100813312 x - 2176885157888 x - 2386516803584)
5 4 3
/(47041365435 x + 381702613848 x + 1360678489152 x
2
+ 2856700692480 x + 3370143559680 x + 2386516803584)]
powerdisp Variable
Default value: false
When powerdisp is true, a sum is displayed with its terms in order of increasing
power. Thus a polynomial is displayed as a truncated power series, with the constant
term first and the highest power last.
By default, terms of a sum are displayed in order of decreasing power.
log(sin(x))
so we’ll try again after applying the rule:
d
/ -- (sin(x))
[ dx
log(sin(x)) = i ----------- dx
] sin(x)
/
in the first simplification we have returned:
/
[
i cot(x) dx - log(x)
]
/
inf
==== i1 2 i1 2 i1
\ (- 1) 2 bern(2 i1) x
> ------------------------------
/ i1 (2 i1)!
====
i1 = 1
(%o2) -------------------------------------
2
psexpand Variable
Default value: false
When psexpand is true, an extended rational function expression is displayed fully
expanded. The switch ratexpand has the same effect.
When psexpand is false, a multivariate expression is displayed just as in the rational
function package.
When psexpand is multi, then terms with the same total degree in the variables are
grouped together.
3 2 3
(3 a + 9 a + 9 a - 1) x
+ -------------------------- + . . .
48
(%i2) %^2;
3
x
(%o2)/T/ 1 + (a + 1) x - -- + . . .
6
(%i3) taylor (sqrt (x + 1), x, 0, 5);
2 3 4 5
x x x 5 x 7 x
(%o3)/T/ 1 + - - -- + -- - ---- + ---- + . . .
2 8 16 128 256
(%i4) %^2;
(%o4)/T/ 1 + x + . . .
(%i5) product ((1 + x^i)^2.5, i, 1, inf)/(1 + x^2);
inf
/===\
! ! i 2.5
! ! (x + 1)
! !
i = 1
(%o5) -----------------
2
x + 1
(%i6) ev (taylor(%, x, 0, 3), keepfloat);
2 3
(%o6)/T/ 1 + 2.5 x + 3.375 x + 6.5625 x + . . .
(%i7) taylor (1/log (x + 1), x, 0, 3);
2 3
1 1 x x 19 x
(%o7)/T/ - + - - -- + -- - ----- + . . .
x 2 12 24 720
(%i8) taylor (cos(x) - sec(x), x, 0, 5);
4
2 x
Chapter 32: Series 307
(%o8)/T/ - x - -- + . . .
6
(%i9) taylor ((cos(x) - sec(x))^3, x, 0, 5);
(%o9)/T/ 0 + . . .
(%i10) taylor (1/(cos(x) - sec(x))^3, x, 0, 5);
2 4
1 1 11 347 6767 x 15377 x
(%o10)/T/ - -- + ---- + ------ - ----- - ------- - --------
6 4 2 15120 604800 7983360
x 2 x 120 x
+ . . .
(%i11) taylor (sqrt (1 - k^2*sin(x)^2), x, 0, 6);
2 2 4 2 4
k x (3 k - 4 k ) x
(%o11)/T/ 1 - ----- - ----------------
2 24
6 4 2 6
(45 k - 60 k + 16 k ) x
- -------------------------- + . . .
720
(%i12) taylor ((x + 1)^n, x, 0, 4);
2 2 3 2 3
(n - n) x (n - 3 n + 2 n) x
(%o12)/T/ 1 + n x + ----------- + --------------------
2 6
4 3 2 4
(n - 6 n + 11 n - 6 n) x
+ ---------------------------- + . . .
24
(%i13) taylor (sin (y + x), x, 0, 3, y, 0, 3);
3 2
y y
(%o13)/T/ y - -- + . . . + (1 - -- + . . .) x
6 2
3 2
y y 2 1 y 3
+ (- - + -- + . . .) x + (- - + -- + . . .) x + . . .
2 12 6 12
(%i14) taylor (sin (y + x), [x, y], 0, 3);
3 2 2 3
x + 3 y x + 3 y x + y
(%o14)/T/ y + x - ------------------------- + . . .
6
(%i15) taylor (1/sin (y + x), x, 0, 3, y, 0, 3);
1 y 1 1 1 2
308 Maxima Manual
(%o15)/T/ - + - + . . . + (- -- + - + . . .) x + (-- + . . .) x
y 6 2 6 3
y y
1 3
+ (- -- + . . .) x + . . .
4
y
(%i16) taylor (1/sin (y + x), [x, y], 0, 3);
3 2 2 3
1 x + y 7 x + 21 y x + 21 y x + 7 y
(%o16)/T/ ----- + ----- + ------------------------------- + . . .
x + y 6 360
taylordepth Variable
Default value: 3
If there are still no nonzero terms, taylor doubles the degree of the expansion of
g(x) so long as the degree of the expansion is less than or equal to n 2^taylordepth.
2 2
+ (1 - a - 2 a (y - a) - (y - a) ) x
2 2 2
+ (1 - a - 2 a (y - a) - (y - a) ) x
2 2 3
+ (1 - a - 2 a (y - a) - (y - a) ) x + . . .
(%i2) taylorinfo(%);
(%o2) [[y, a, inf], [x, 0, 3]]
When taylor_logexpand is true, all logarithms are expanded fully so that zero-
recognition problems involving logarithmic identities do not disturb the expansion
process. However, this scheme is not always mathematically correct since it ignores
branch information.
When taylor_logexpand is set to false, then the only expansion of logarithms that
occur is that necessary to obtain a formal power series.
verbose Variable
Default value: false
When verbose is true, powerseries prints progress messages.
Chapter 33: Number Theory 311
33 Number Theory
cf (expr) Function
Converts expr into a continued fraction. expr is an expression comprising continued
fractions and square roots of integers. Operands in the expression may be combined
with arithmetic operators. Aside from continued fractions and square roots, factors
in the expression must be integer or rational numbers. Maxima does not know about
operations on continued fractions outside of cf.
cf evaluates its arguments after binding listarith to false. cf returns a continued
fraction, represented as a list.
A continued fraction a + 1/(b + 1/(c + ...)) is represented by the list [a, b, c,
...]. The list elements a, b, c, ... must evaluate to integers. expr may also contain
sqrt (n) where n is an integer. In this case cf will give as many terms of the continued
fraction as the value of the variable cflength times the period.
A continued fraction can be evaluated to a number by evaluating the arithmetic
representation returned by cfdisrep. See also cfexpand for another way to evaluate
a continued fraction.
See also cfdisrep, cfexpand, and cflength.
Examples:
• expr is an expression comprising continued fractions and square roots of integers.
(%i1) cf ([5, 3, 1]*[11, 9, 7] + [3, 7]/[4, 3, 2]);
(%o1) [59, 17, 2, 1, 1, 1, 27]
(%i2) cf ((3/17)*[1, -2, 5]/sqrt(11) + (8/13));
(%o2) [0, 1, 1, 1, 3, 2, 1, 4, 1, 9, 1, 9, 2]
• cflength controls how many periods of the continued fraction are computed for
algebraic, irrational numbers.
(%i1) cflength: 1$
(%i2) cf ((1 + sqrt(5))/2);
(%o2) [1, 1, 1, 1, 2]
(%i3) cflength: 2$
(%i4) cf ((1 + sqrt(5))/2);
(%o4) [1, 1, 1, 1, 1, 1, 1, 2]
(%i5) cflength: 3$
(%i6) cf ((1 + sqrt(5))/2);
(%o6) [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]
• A continued fraction can be evaluated by evaluating the arithmetic representation
returned by cfdisrep.
(%i1) cflength: 3$
(%i2) cfdisrep (cf (sqrt (3)))$
(%i3) ev (%, numer);
(%o3) 1.731707317073171
• Maxima does not know about operations on continued fractions outside of cf.
(%i1) cf ([1,1,1,1,1,2] * 3);
(%o1) [4, 1, 5, 2]
(%i2) cf ([1,1,1,1,1,2]) * 3;
(%o2) [3, 3, 3, 3, 3, 6]
Chapter 33: Number Theory 313
cflength Variable
Default value: 1
cflength controls the number of terms of the continued fraction the function cf will
give, as the value cflength times the period. Thus the default is to give one period.
(%i1) cflength: 1$
(%i2) cf ((1 + sqrt(5))/2);
(%o2) [1, 1, 1, 1, 2]
(%i3) cflength: 2$
(%i4) cf ((1 + sqrt(5))/2);
(%o4) [1, 1, 1, 1, 1, 1, 1, 2]
(%i5) cflength: 3$
(%i6) cf ((1 + sqrt(5))/2);
(%o6) [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]
%gamma Variable
The Euler-Mascheroni constant, 0.5772156649015329 ....
zerobern Variable
Default value: true
When zerobern is false, bern excludes the Bernoulli numbers which are equal to
zero. See bern.
zeta%pi Variable
Default value: true
When zeta%pi is true, zeta returns an expression proportional to %pi^n for even
integer n. Otherwise, zeta returns a noun form zeta (n) for even integer n.
(%i1) zeta%pi: true$
(%i2) zeta (4);
4
%pi
(%o2) ----
90
Chapter 33: Number Theory 317
34 Symmetries
3 4 3 4
+ 2 a b x y + 2 a b x y
(%i2) contract (psym, [x, y, z]);
3 4
(%o2) 2 a b x y
Autres fonctions de changements de repre’sentations :
cont2part, explose, part2cont, partpol, tcontract, tpartpol.
2 2 2 2
- 4 e2 f2 - (e1 - 2 e2) (f1 - 2 f2) + e1 f1
+ -----------------------------------------------
2
(%i2) ratsimp (%);
2 2 2
(%o2) y - e1 f1 y + (e1 - 4 e2) f2 + e2 f1
(%i3) ratsimp (direct ([z^3-e1*z^2+e2*z-e3,z^2 - f1* z + f2],
z, b*v + a*u, [[u, v], [a, b]]));
6 5 2 2 2 4
(%o3) y - 2 e1 f1 y + ((2 e1 - 6 e2) f2 + (2 e2 + e1 ) f1 ) y
3 3 3
+ ((9 e3 + 5 e1 e2 - 2 e1 ) f1 f2 + (- 2 e3 - 2 e1 e2) f1 ) y
2 2 4 2
+ ((9 e2 - 6 e1 e2 + e1 ) f2
2 2 2 2 4
+ (- 9 e1 e3 - 6 e2 + 3 e1 e2) f1 f2 + (2 e1 e3 + e2 ) f1 )
2 2 2 3 2
y + (((9 e1 - 27 e2) e3 + 3 e1 e2 - e1 e2) f1 f2
2 2 3 5
+ ((15 e2 - 2 e1 ) e3 - e1 e2 ) f1 f2 - 2 e2 e3 f1 ) y
2 3 3 2 2 3
+ (- 27 e3 + (18 e1 e2 - 4 e1 ) e3 - 4 e2 + e1 e2 ) f2
2 3 3 2 2
+ (27 e3 + (e1 - 9 e1 e2) e3 + e2 ) f1 f2
2 4 2 6
+ (e1 e2 e3 - 9 e3 ) f1 f2 + e3 f1
Recherche du polyno^me dont les racines sont les somme a+u ou a est racine de z^2
- e1* z + e2 et u est racine de z^2 - f1* z + f2
(%i1) ratsimp (direct ([z^2 - e1* z + e2, z^2 - f1* z + f2],
z, a + u, [[u], [a]]));
Chapter 34: Symmetries 321
4 3 2
(%o1) y + (- 2 f1 - 2 e1) y + (2 f2 + f1 + 3 e1 f1 + 2 e2
2 2 2 2
+ e1 ) y + ((- 2 f1 - 2 e1) f2 - e1 f1 + (- 2 e2 - e1 ) f1
2 2 2
- 2 e1 e2) y + f2 + (e1 f1 - 2 e2 + e1 ) f2 + e2 f1 + e1 e2 f1
2
+ e2
direct peut prendre deux drapeaux possibles : elementaires et puissances (valeur
par de’faut) qui permettent de de’composer les polyno^mes syme’triques apparaissant
dans ce calcul par les fonctions syme’triques e’le’mentaires ou les fonctions puissances
respectivement.
Fonctions de sym utilis’ees dans cette fonction :
multi_orbit (donc orbit), pui_direct, multi_elem (donc elem), multi_pui (donc
pui), pui2ele, ele2pui (si le drapeau direct est a‘ puissances).
+ (- 2 (49 - e2) - 2) e2
(%i2) ratsimp (%);
2
(%o2) 28 e3 + 2 e2 - 198 e2 + 2401
Autres fonctions de changements de bases :
comp2ele, comp2pui, ele2comp, ele2pui, mon2schur, multi_elem, multi_pui, pui,
pui2comp, pui2ele, puireduc, schur2comp.
(%i1) pui;
(%o1) 1
(%i2) pui ([3, a, b], u*x*y*z, [x, y, z]);
2
a (a - b) u (a b - p3) u
(%o2) ------------ - ------------
6 3
(%i3) ratsimp (%);
3
(2 p3 - 3 a b + a ) u
(%o3) ---------------------
6
Autres fonctions de changements de bases :
comp2ele, comp2pui, ele2comp, ele2pui, elem, mon2schur, multi_elem, multi_
pui, pui2comp, pui2ele, puireduc, schur2comp.
pui direct (orbite, [lvar 1, ..., lvar n], [d 1, d 2, ..., d n]) Function
Soit f un polynome en n blocs de variables lvar 1, ..., lvar n. Soit c i le nombre de
variables dans lvar i . Et SC le produit des n groupes syme’triques de degre’ c 1, ...,
c n. Ce groupe agit naturellement sur f. La liste orbite est l’orbite, note’e SC(f ),
de la fonction f sous l’action de SC. (Cette liste peut e^tre obtenue avec la fonction
: multi_orbit). Les di sont des entiers tels que c 1 <= d 1, c 2 <= d 2, ..., c n <=
d n. Soit SD le produit des groupes syme’triques S d1 x S d2 x ... x S dn.
La fonction pui_direct rame‘ne les n premie‘res fonctions puissances de SD(f )
de’duites des fonctions puissances de SC(f ) ou‘ n est le cardinal de SD(f ).
Le re’sultat est rendue sous forme multi-contracte’e par rapport a SD. i.e. on ne
conserve qu’un e’le’ment par orbite sous l’action de SD).
(%i1) l: [[x, y], [a, b]];
(%o1) [[x, y], [a, b]]
(%i2) pui_direct (multi_orbit (a*x + b*y, l), l, [2, 2]);
2 2
(%o2) [a x, 4 a b x y + a x ]
(%i3) pui_direct (multi_orbit (a*x + b*y, l), l, [3, 2]);
2 2 2 2 3 3
(%o3) [2 a x, 4 a b x y + 2 a x , 3 a b x y + 2 a x ,
2 2 2 2 3 3 4 4
12 a b x y + 4 a b x y + 2 a x ,
3 2 3 2 4 4 5 5
10 a b x y + 5 a b x y + 2 a x ,
3 3 3 3 4 2 4 2 5 5 6 6
40 a b x y + 15 a b x y + 6 a b x y + 2 a x ]
328 Maxima Manual
(%i4) pui_direct ([y + x + 2*c, y + x + 2*b, y + x + 2*a], [[x, y], [a, b, c]],
2 2
(%o4) [3 x + 2 a, 6 x y + 3 x + 4 a x + 4 a ,
2 3 2 2 3
9 x y + 12 a x y + 3 x + 6 a x + 12 a x + 8 a ]
• produit,
• cayley,
• generale.
(%i1) resolvante: unitaire$
(%i2) resolvante (x^7 - 14*x^5 + 56*x^3 - 56*x + 22, x, x^3 - 1, [x]);
" resolvante unitaire " [7, 0, 28, 0, 168, 0, 1120, - 154, 7840, - 2772, 56448,
12 9 6 3 15 12 9 6 3
x - 4 x + 6 x - 4 x + 1, x - 5 x + 10 x - 10 x + 5 x
18 15 12 9 6 3
- 1, x - 6 x + 15 x - 20 x + 15 x - 6 x + 1,
21 18 15 12 9 6 3
x - 7 x + 21 x - 35 x + 35 x - 21 x + 7 x - 1]
[- 7, 1127, - 6139, 431767, - 5472047, 201692519, - 3603982011]
7 6 5 4 3 2
(%o2) y + 7 y - 539 y - 1841 y + 51443 y + 315133 y
+ 376999 y + 125253
(%i3) resolvante: lineaire$
(%i4) resolvante (x^4 - 1, x, x1 + 2*x2 + 3*x3, [x1, x2, x3]);
4
+ 344489984 y
+ 655360000
(%i5) resolvante: general$
(%i6) resolvante (x^4 - 1, x, x1 + 2*x2 + 3*x3, [x1, x2, x3]);
4
+ 344489984 y + 655360000
(%i7) resolvante (x^4 - 1, x, x1 + 2*x2 + 3*x3, [x1, x2, x3, x4]);
24 20 16 12 8
(%o7) y + 80 y + 7520 y + 1107200 y + 49475840 y
4
+ 344489984 y + 655360000
(%i8) direct ([x^4 - 1], x, x1 + 2*x2 + 3*x3, [[x1, x2, x3]]);
24 20 16 12 8
(%o8) y + 80 y + 7520 y + 1107200 y + 49475840 y
4
+ 344489984 y + 655360000
(%i9) resolvante :lineaire$
(%i10) resolvante (x^4 - 1, x, x1 + x2 + x3, [x1, x2, x3]);
24 23 22 21 20
+ 1323 y + 352947 y - 46305 y - 2463339 y + 324135 y
19 18 17 15
- 30618 y - 453789 y - 40246444 y + 282225202 y
14 12 11 10
- 44274492 y + 155098503 y + 12252303 y + 2893401 y
Chapter 34: Symmetries 331
9 8 7 6
- 171532242 y + 6751269 y + 2657205 y - 94517766 y
5 3
- 3720087 y + 26040609 y + 14348907
(%i18) resolvante: symetrique$
(%i19) resolvante (x^7 - 7*x + 3, x, x1*x2*x3, [x1, x2, x3]);
24 23 22 21 20
+ 1323 y + 352947 y - 46305 y - 2463339 y + 324135 y
19 18 17 15
- 30618 y - 453789 y - 40246444 y + 282225202 y
14 12 11 10
- 44274492 y + 155098503 y + 12252303 y + 2893401 y
9 8 7 6
- 171532242 y + 6751269 y + 2657205 y - 94517766 y
5 3
- 3720087 y + 26040609 y + 14348907
(%i20) resolvante: cayley$
(%i21) resolvante (x^5 - 4*x^2 + x + 1, x, a, []);
+ 93392896
Pour la re’solvante de Cayley, les 2 derniers arguments sont neutres et le polyno^me
donne’ en entre’e doit ne’cessairement e^tre de degre’ 5.
Voir e’galement :
resolvante_bipartite, resolvante_produit_sym, resolvante_unitaire,
resolvante_alternee1, resolvante_klein, resolvante_klein3, resolvante_
vierer, resolvante_diedrale.
6 5 4 3 2
- 945 x - 4970 x - 18333 x - 29079 x - 20745 x - 25326 x
- 697
Voir e’galement :
resolvante_produit_sym, resolvante_unitaire, resolvante_alternee1,
resolvante_klein, resolvante_klein3, resolvante_vierer, resolvante.
4 3 2 10 8 7 6 5 4
- y + 14 y + 3 y + 1, y + 3 y + 14 y - y - 14 y - 31 y
3 2 5 4
- 21 y - 2 y + 1, y - 2 y - 3 y - 1, y - 1]
(%i2) resolvante: produit$
(%i3) resolvante (x^5 + 3*x^4 + 2*x - 1, x, a*b*c, [a, b, c]);
[1, 1, 1, 1, 1]]
(%i3) treinat ([3, 2]);
(%o3) [[5], [4, 1], [3, 2]]
Voir e’galement : lgtreillis, ltreillis et treillis.
Chapter 35: Groups 335
35 Groups
<2>
else (if not i = j then p(i, j) else p(i, i)), j, 1, n - 1,
i, 1, j)
(%i2) p(i,j) := concat(x,i).concat(x,j);
(%o2) p(i, j) := concat(x, i) . concat(x, j)
(%i3) symet(5);
<2> <3> <2> <2> <3>
(%o3) [x1 , (x1 . x2) , x2 , (x1 . x3) , (x2 . x3) ,
Rows tried 71
(%o6) 20
336 Maxima Manual
(%i7) table:todd_coxeter_state[2]$
(%i8) table[1];
(%o8) {Array: (SIGNED-BYTE 30) #(0 2 1 3 7 6 5 4 8 11 17 9 12 14 #
13 20 16 10 18 19 15 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0)}
Note only the elements 1 thru 20 of this array %o8 are meaningful. table[1][4] = 7
indicates coset4.var1 = coset7
Chapter 36: Runtime Environment 337
36 Runtime Environment
36.2 Interrupts
The user can stop a time-consuming computation with the ^C (control-C) character.
The default action is to stop the computation and print another user prompt. In this case,
it is not possible to restart a stopped computation.
If the variable *debugger-hook* is set to nil, by executing
:lisp (setq *debugger-hook* nil)
then upon receiving ^C, Maxima will enter the Lisp debugger, and the user may use the
debugger to inspect the Lisp environment. The stopped computation can be restarted by
entering continue in the Lisp debugger. The means of returning to Maxima from the Lisp
debugger (other than running the computation to completion) is different for each version
of Lisp.
On Unix systems, the character ^Z (control-Z) causes Maxima to stop altogether, and
control is returned to the shell prompt. The fg command causes Maxima to resume from
the point at which it was stopped.
feature declaration
Maxima understands two distinct types of features, system features and features
which apply to mathematical expressions. See also status for information about sys-
tem features. See also features and featurep for information about mathematical
features.
feature itself is not the name of a function or variable.
338 Maxima Manual
room () Function
room (true) Function
room (false) Function
Prints out a description of the state of storage and stack management in Maxima.
room calls the Lisp function of the same name.
• room () prints out a moderate description.
• room (true) prints out a verbose description.
• room (false) prints out a terse description.
37 Miscellaneous Options
37.2 Share
The Maxima "share" directory contains programs and other files of interest to Maxima
users, but not part of the core implementation of Maxima. These programs are typically
loaded via load or setup_autoload.
:lisp *maxima-sharedir* displays the location of the share directory within the user’s
file system.
printfile ("share.usg") prints an out-of-date list of share packages. Users may find
it more informative to browse the share directory using a file system browser.
aliases Variable
Default value: []
aliases is the list of atoms which have a user defined alias (set up by the alias,
ordergreat, orderless functions or by declaring the atom a noun with declare).
alphabetic declaration
declare (char, alphabetic) adds char to Maxima’s alphabet, which initially con-
tains the letters A through Z, a through z, % and _. char is specified as a string of
length 1, e.g., "~".
(%i1) declare ("~", alphabetic);
(%o1) done
(%i2) foo~bar;
(%o2) foo~bar
(%i3) atom (foo~bar);
(%o3) true
genindex Variable
Default value: i
genindex is the alphabetic prefix used to generate the next variable of summation
when necessary.
gensumnum Variable
Default value: 0
gensumnum is the numeric suffix used to generate the next variable of summation. If
it is set to false then the index will consist only of genindex with no numeric suffix.
inf Variable
Real positive infinity.
infinity Variable
Complex infinity, an infinite magnitude of arbitrary phase angle. See also inf and
minf.
infolists Variable
Default value: []
infolists is a list of the names of all of the information lists in Maxima. These are:
labels - all bound %i, %o, and %t labels.
values - all bound atoms which are user variables, not Maxima options or switches,
created by : or :: or functional binding.
functions - all user-defined functions, created by :=.
arrays - declared and undeclared arrays, created by :, ::, or :=.
macros - any macros defined by the user.
myoptions - all options ever reset by the user (whether or not they are later reset to
their default values).
rules - user-defined pattern matching and simplification rules, created by tellsimp,
tellsimpafter, defmatch, or defrule.
aliases - atoms which have a user-defined alias, created by the alias, ordergreat,
orderless functions or by declaring the atom as a noun with declare.
dependencies - atoms which have functional dependencies, created by the depends
or gradef functions.
Chapter 37: Miscellaneous Options 341
gradefs - functions which have user-defined derivatives, created by the gradef func-
tion.
props - atoms which have any property other than those mentioned above, such as
atvalues, matchdeclares, etc., as well as properties specified in the declare function.
let_rule_packages - a list of all the user-defined let rule packages plus the special
package default_let_rule_package. (default_let_rule_package is the name of
the rule package used when one is not explicitly set by the user.)
m1pbranch Variable
Default value: false
m1pbranch is the principal branch for -1 to a power. Quantities such as (-1)^(1/3)
(that is, an "odd" rational exponent) and (-1)^(1/4) (that is, an "even" rational
exponent) are handled as follows:
domain:real
(-1)^(1/3): -1
(-1)^(1/4): (-1)^(1/4)
domain:complex
m1pbranch:false m1pbranch:true
(-1)^(1/3) 1/2+%i*sqrt(3)/2
(-1)^(1/4) sqrt(2)/2+%i*sqrt(2)/2
342 Maxima Manual
remove always returns done whether or not an atom has a specified property.
This behavior is unlike the more specific remove functions (remvalue, remarray,
remfunction, and remrule).
2
(%i4) legendre_p (1, %pi);
(%o4) %pi
(%i5) legendre_q (1, %pi);
%pi + 1
%pi log(-------)
1 - %pi
(%o5) ---------------- - 1
2
346 Maxima Manual
Chapter 38: Rules and Patterns 347
/
x + %pi
(%i7) checklimits (%);
(%o7) [b = x + 2 %pi, a = x + %pi, x = t, f = sin(t)]
(%i8) a;
(%o8) x + %pi
(%i9) b;
(%o9) x + 2 %pi
(%i10) f;
(%o10) sin(t)
(%i11) x;
(%o11) t
be accepted only if predname (arg1’, ..., argn’) evaluates to true where argi’ is
the value matched to argi. The argi may be the name of any atom or the argument
of any kernel appearing in prod. repl may be any rational expression. If any of the
atoms or arguments from prod appear in repl the appropriate substitutions will be
made.
letrat when false, letsimp will simplify the numerator and denominator of expr
independently and return the result. Substitutions such as n!/n goes to (n-1)! will
fail. To handle such situations letrat should be set to true, then the numerator,
denominator, and their quotient will be simplified in that order.
These substitution functions allow you to work with several rule packages at once.
Each rule package can contain any number of let’ed rules and is referred to by a user
supplied name. let ([prod, repl, predname, arg 1, ..., arg n], package name)
adds the rule predname to the rule package package name. letsimp (expr,
package name) applies the rules in package name. letsimp (expr, package name1,
package name2, ...) is equivalent to letsimp (expr, package name1) followed by
letsimp (%, package name2), ....
current_let_rule_package is the name of the rule package that is presently be-
ing used. The user may reset this variable to the name of any rule package previ-
ously defined via the let command. Whenever any of the functions comprising the
let package are called with no package name, the current_let_rule_package is
used. If a call such as letsimp (expr, rule pkg name) is made, the rule package
rule pkg name is used for that letsimp command only, and current_let_rule_
package is not changed. If not otherwise specified, current_let_rule_package de-
faults to default_let_rule_package.
(%i1) matchdeclare ([a, a1, a2], true)$
(%i2) oneless (x, y) := is (x = y-1)$
(%i3) let (a1*a2!, a1!, oneless, a2, a1);
(%o3) a1 a2! --> a1! where oneless(a2, a1)
(%i4) letrat: true$
(%i5) let (a1!/a1, (a1-1)!);
a1!
(%o5) --- --> (a1 - 1)!
a1
(%i6) letsimp (n*m!*(n-1)!/m);
(%o6) (m - 1)! n!
(%i7) let (sin(a)^2, 1 - cos(a)^2);
2 2
(%o7) sin (a) --> 1 - cos (a)
(%i8) letsimp (sin(x)^4);
4 2
(%o8) cos (x) - 2 cos (x) + 1
letrat Variable
Default value: false
When letrat is false, letsimp simplifies the numerator and denominator of a ratio
separately, and does not simplify the quotient.
Chapter 38: Rules and Patterns 351
When letrat is true, the numerator, denominator, and their quotient will be sim-
plified in that order.
(%i1) matchdeclare (n, true)$
(%i2) let (n!/n, (n-1)!);
n!
(%o2) -- --> (n - 1)!
n
(%i3) letrat: false$
(%i4) letsimp (a!/a);
a!
(%o4) --
a
(%i5) letrat: true$
(%i6) letsimp (a!/a);
(%o6) (a - 1)!
letrules () Function
letrules (package name) Function
Displays the rules in a rule package. letrules () displays the rules in the current
rule package. letrules (package name) displays the rules in package_name.
The current rule package is named by current_let_rule_package. If not otherwise
specified, current_let_rule_package defaults to default_let_rule_package.
For pattern matching, predicates refer to functions which are either false or not
false. Any non false value acts like true.
matchdeclare (a, true) permits a to match any expression.
Examples:
• q matches an expression not containing x or %e.
(%i1) matchdeclare (q, freeof (x, %e))$
(%o5) done
(%i6) !-3, 5-!;
16
(%o6) - --
15
(%i7) "!-" (3, 5);
16
(%o7) - --
15
(%o14) done
(%i15) matchdeclare (a, true);
(%o15) done
(%i16) tellsimp (sin(a)^2, 1 - cos(a)^2);
(%o16) [^rule3, simpexpt]
(%i17) sin(y)^2;
2
(%o17) 1 - cos (y)
39 Lists
makelist (expr, x, list) returns a list, the j’th element of which is equal to ev
(expr, x=list[j]) for j equal to 1 through length (list).
Examples:
(%i1) makelist(concat(x,i),i,1,6);
(%o1) [x1, x2, x3, x4, x5, x6]
(%i2) makelist(x=y,y,[a,b,c]);
(%o2) [x = a, x = b, x = c]
40 Function Definition
40.2 Function
To define a function in Maxima you use the := operator. E.g.
f(x) := sin(x)
defines a function f. Anonmyous functions may also be created using lambda. For example
lambda ([i, j], ...)
can be used instead of f where
f(i,j) := block ([], ...);
map (lambda ([i], i+1), l)
would return a list with 1 added to each term.
You may also define a function with a variable number of arguments, by having a final
argument which is assigned to a list of the extra arguments:
(%i1) f ([u]) := u;
(%o1) f([u]) := u
(%i2) f (1, 2, 3, 4);
(%o2) [1, 2, 3, 4]
(%i3) f (a, b, [u]) := [a, b, u];
(%o3) f(a, b, [u]) := [a, b, u]
(%i4) f (1, 2, 3, 4, 5, 6);
(%o4) [1, 2, [3, 4, 5, 6]]
The right hand side of a function is an expression. Thus if you want a sequence of
expressions, you do
f(x) := (expr1, expr2, ...., exprn);
and the value of exprn is what is returned by the function.
If you wish to make a return from some expression inside the function then you must
use block and return.
block ([], expr1, ..., if (a > 10) then return(a), ..., exprn)
is itelf an expression, and so could take the place of the right hand side of a function
definition. Here it may happen that the return happens earlier than the last expression.
The first [] in the block, may contain a list of variables and variable assignments, such
as [a: 3, b, c: []], which would cause the three variables a,b,and c to not refer to their
global values, but rather have these special values for as long as the code executes inside
the block, or inside functions called from inside the block. This is called dynamic binding,
since the variables last from the start of the block to the time it exits. Once you return
from the block, or throw out of it, the old values (if any) of the variables will be restored.
It is certainly a good idea to protect your variables in this way. Note that the assignments
in the block variables, are done in parallel. This means, that if you had used c: a in the
above, the value of c would have been the value of a at the time you just entered the block,
but before a was bound. Thus doing something like
362 Maxima Manual
40.3 Macros
40.3.1 Semantics
The elements of the list variables are evaluated left to right (the syntax atom is
equivalent to atom: atom). then these values are substituted into <expression> in
parallel. If any atom appears as a single argument to the special form splice (i.e.
splice (atom)) inside expr, then the value associated with that atom must be a
Maxima list, and it is spliced into expr instead of substituted.
40.3.2 Simplification
The arguments to buildq need to be protected from simplification until the substi-
tutions have been carried out. This code should effect that by using ’.
buildq can be useful for building functions on the fly. One of the powerful things
about Maxima is that you can have your functions define other functions to help
solve the problem. Further below we discuss building a recursive function, for a
series solution. This defining of functions inside functions usually uses define, which
evaluates its arguments. A number of examples are included under splice.
used rather than the function because apply has its first argument evaluated as well
as its second.
and no further expressions are evaluated. This "non-local return" thus goes through
any depth of nesting to the nearest enclosing catch. If there is no catch enclosing a
throw, an error message is printed.
If the evaluation of the arguments does not lead to the evaluation of any throw then
the value of catch is the value of expr n.
(%i1) lambda ([x], if x < 0 then throw(x) else f(x))$
(%i2) g(l) := catch (map (’’%, l))$
(%i3) g ([1, 2, 3, 7]);
(%o3) [f(1), f(2), f(3), f(7)]
(%i4) g ([1, 2, -3, 7]);
(%o4) - 3
The function g returns a list of f of each element of l if l consists only of non-negative
numbers; otherwise, g "catches" the first negative element of l and "throws" it up.
- y
(%t7) f(x, y) := x
- y
(%t8) g := x
x, y
- y
(%t9) h (y) := x
x
1
(%t10) h (y) := --
5 y
5
1
(%t11) h (y) := ---
10 y
10
- y
(%t12) i (y) := 8
8
functions Variable
Default value: []
functions is the list of user-defined Maxima functions in the current session. A
user-defined function is a function constructed by define or :=. A function may be
defined at the Maxima prompt or in a Maxima file loaded by load or batch. Lisp
functions, however, are not added to functions.
fundef (f ) Function
Returns the definition of the function f.
The argument may be the name of a macro (defined with ::=), an ordinary function
(defined with := or define), an array function (defined with := or define, but
Chapter 40: Function Definition 369
1
(%o14) lambda([a, b], h2 : lambda([a], a b), h2(-))
2
(%i15) h(%pi, %gamma);
%gamma
(%o15) ------
2
• Since lambda quotes its arguments, lambda expression i below does not define
a "multiply by a" function. Such a function can be defined via buildq, as in
lambda expression i2 below.
(%i16) i: lambda ([a], lambda ([x], a*x));
(%o16) lambda([a], lambda([x], a x))
(%i17) i(1/2);
(%o17) lambda([x], a x)
(%i18) i2: lambda([a], buildq([a: a], lambda([x], a*x)));
(%o18) lambda([a], buildq([a : a], lambda([x], a x)))
(%i19) i2(1/2);
x
(%o19) lambda([x], -)
2
(%i20) i2(1/2)(%pi);
%pi
(%o20) ---
2
macroexpansion Variable
Default value: false
macroexpansion controls advanced features which affect the efficiency of macros.
Possible settings:
• false – Macros expand normally each time they are called.
• expand – The first time a particular call is evaluated, the expansion is remem-
bered internally, so that it doesn’t have to be recomputed on subsequent calls
making subsequent calls faster. The macro call still calls grind and display
normally. However, extra memory is required to remember all of the expansions.
• displace – The first time a particular call is evaluated, the expansion is substi-
tuted for the call. This requires slightly less storage than when macroexpansion
is set to expand and is just as fast, but has the disadvantage that the origi-
nal macro call is no longer remembered and hence the expansion will be seen if
display or grind is called. See documentation for translate and macros for
more details.
372 Maxima Manual
number, list, or any), and the second argument is an expression which is evaluated
and returned as the value of mode_identity. However, if the return value is not
allowed by the mode declared in the first argument, an error or warning is signalled.
The important thing is that the mode of the expression as determined by the Maxima
to Lisp translator, will be that given as the first argument, independent of anything
that goes on in the second argument. E.g., x: 3.3; mode_identity (fixnum, x);
yields an error. mode_identity (flonum, x) returns 3.3 . This has a number of
uses, e.g., if you knew that first (l) returned a number then you might write mode_
identity (number, first (l)). However, a more efficient way to do it would be to
define a new primitive,
firstnumb (x) ::= buildq ([x], mode_identity (number, x));
and use firstnumb every time you take the first of a list of numbers.
transcompile Variable
Default value: true
When transcompile is true, translate and translate_file generate declarations
to make the translated code more suitable for compilation.
compfile sets transcompile: true for the duration.
function should not be used if any variables are mode_declare’d canonical rational
expressions (CRE). Also the prederror: false setting will not translate.
savedef - if true will cause the Maxima version of a user function to remain when
the function is translate’d. This permits the definition to be displayed by dispfun
and allows the function to be edited.
transrun - if false will cause the interpreted version of all functions to be run
(provided they are still around) rather than the translated version.
The result returned by translate is a list of the names of the functions translated.
transrun Variable
Default value: true
When transrun is false will cause the interpreted version of all functions to be run
(provided they are still around) rather than the translated version.
Chapter 40: Function Definition 375
tr numer Variable
Default value: false
When tr_numer is true numer properties are used for atoms which have them, e.g.
%pi.
tr semicompile Variable
Default value: false
When tr_semicompile is true, translate_file and compfile output forms which
will be macroexpanded but not compiled into machine code by the Lisp compiler.
tr windy Variable
Default value: true
- Generate "helpfull" comments and programming hints.
41 Program Flow
backtrace () Function
backtrace (n) Function
Prints the call stack, that is, the list of functions which called the currently active
function.
backtrace() prints the entire call stack.
backtrace (n) prints the n most recent functions, including the currently active
function.
backtrace can be called from a script, a function, or the interactive prompt (not only
in a debugging context).
• backtrace() prints the entire call stack.
(%i1) h(x) := g(x/7)$
(%i2) g(x) := f(x-11)$
(%i3) f(x) := e(x^2)$
(%i4) e(x) := (backtrace(), 2*x + 13)$
(%i5) h(10);
#0: e(x=4489/49)
#1: f(x=-67/7)
#2: g(x=10/7)
#3: h(x=10)
9615
(%o5) ----
49
• backtrace (n) prints the n most recent functions, including the currently active
function.
(%i1) h(x) := (backtrace(1), g(x/7))$
(%i2) g(x) := (backtrace(1), f(x-11))$
(%i3) f(x) := (backtrace(1), e(x^2))$
(%i4) e(x) := (backtrace(1), 2*x + 13)$
(%i5) h(10);
#0: h(x=10)
#0: g(x=10/7)
#0: f(x=-67/7)
#0: e(x=4489/49)
9615
(%o5) ----
49
380 Maxima Manual
do special operator
The do statement is used for performing iteration. Due to its great generality the do
statement will be described in two parts. First the usual form will be given which
is analogous to that used in several other programming languages (Fortran, Algol,
PL/I, etc.); then the other features will be mentioned.
There are three variants of this form that differ only in their terminating conditions.
They are:
• for variable: initial value step increment thru limit do body
• for variable: initial value step increment while condition do body
• for variable: initial value step increment unless condition do body
(Alternatively, the step may be given after the termination condition or limit.)
initial value, increment, limit, and body can be any expressions. If the increment is
1 then "step 1" may be omitted.
The execution of the do statement proceeds by first assigning the initial value to the
variable (henceforth called the control-variable). Then: (1) If the control-variable has
exceeded the limit of a thru specification, or if the condition of the unless is true,
or if the condition of the while is false then the do terminates. (2) The body is
evaluated. (3) The increment is added to the control-variable. The process from (1)
to (3) is performed repeatedly until the termination condition is satisfied. One may
also give several termination conditions in which case the do terminates when any of
them is satisfied.
In general the thru test is satisfied when the control-variable is greater than the limit
if the increment was non-negative, or when the control-variable is less than the limit
if the increment was negative. The increment and limit may be non-numeric expres-
sions as long as this inequality can be determined. However, unless the increment
is syntactically negative (e.g. is a negative number) at the time the do statement
is input, Maxima assumes it will be positive when the do is executed. If it is not
positive, then the do may not terminate properly.
Note that the limit, increment, and termination condition are evaluated each time
through the loop. Thus if any of these involve much computation, and yield a result
that does not change during all the executions of the body, then it is more efficient
to set a variable to their value prior to the do and use this variable in the do form.
The value normally returned by a do statement is the atom done. However, the
function return may be used inside the body to exit the do prematurely and give it
any desired value. Note however that a return within a do that occurs in a block
will exit only the do and not the block. Note also that the go function may not be
used to exit from a do into a surrounding block.
The control-variable is always local to the do and thus any variable may be used
without affecting the value of a variable with the same name outside of the do. The
control-variable is unbound after the do terminates.
(%i1) for a:-3 thru 26 step 7 do display(a)$
a = - 3
a = 4
Chapter 41: Program Flow 381
a = 11
a = 18
a = 25
(%i1) s: 0$
(%i2) for i: 1 while i <= 10 do s: s+i;
(%o2) done
(%i3) s;
(%o3) 55
Note that the condition while i <= 10 is equivalent to unless i > 10 and also thru
10.
(%i1) series: 1$
(%i2) term: exp (sin (x))$
(%i3) for p: 1 unless p > 7 do
(term: diff (term, x)/p,
series: series + subst (x=0, term)*x^p)$
(%i4) series;
7 6 5 4 2
x x x x x
(%o4) -- - --- - -- - -- + -- + x + 1
90 240 15 8 2
which gives 8 terms of the Taylor series for e^sin(x).
(%i1) poly: 0$
(%i2) for i: 1 thru 5 do
for j: i step -1 thru 1 do
poly: poly + i*x^j$
(%i3) poly;
5 4 3 2
(%o3) 5 x + 9 x + 12 x + 14 x + 15 x
(%i4) guess: -3.0$
(%i5) for i: 1 thru 10 do
(guess: subst (guess, x, 0.5*(x + 10/x)),
if abs (guess^2 - 10) < 0.00005 then return (guess));
(%o5) - 3.162280701754386
This example computes the negative square root of 10 using the Newton- Raphson
iteration a maximum of 10 times. Had the convergence criterion not been met the
value returned would have been done. Additional Forms of the do Statement
Instead of always adding a quantity to the control-variable one may sometimes wish
to change it in some other way for each iteration. In this case one may use next
expression instead of step increment. This will cause the control-variable to be set
to the result of evaluating expression each time through the loop.
(%i6) for count: 2 next 3*count thru 20 do display (count)$
count = 2
count = 6
382 Maxima Manual
count = 18
As an alternative to for variable: value ...do... the syntax for variable from
value ...do... may be used. This permits the from value to be placed after the
step or next value or after the termination condition. If from value is omitted then
1 is used as the initial value.
Sometimes one may be interested in performing an iteration where the control-variable
is never actually used. It is thus permissible to give only the termination conditions
omitting the initialization and updating information as in the following example to
compute the square-root of 5 using a poor initial guess.
(%i1) x: 1000$
(%i2) thru 20 do x: 0.5*(x + 5.0/x)$
(%i3) x;
(%o3) 2.23606797749979
(%i4) sqrt(5), numer;
(%o4) 2.23606797749979
If it is desired one may even omit the termination conditions entirely and just give do
body which will continue to evaluate the body indefinitely. In this case the function
return should be used to terminate execution of the do.
(%i1) newton (f, x):= ([y, df, dfx], df: diff (f (’x), ’x),
do (y: ev(df), x: x - f(x)/y,
if abs (f (x)) < 5e-6 then return (x)))$
(%i2) sqr (x) := x^2 - 5.0$
(%i3) newton (sqr, 1000);
(%o3) 2.236068027062195
(Note that return, when executed, causes the current value of x to be returned as
the value of the do. The block is exited and this value of the do is returned as the
value of the block because the do is the last statement in the block.)
One other form of the do is available in Maxima. The syntax is:
for variable in list end tests do body
The elements of list are any expressions which will successively be assigned to the
variable on each iteration of the body. The optional termination tests end tests can
be used to terminate execution of the do; otherwise it will terminate when the list
is exhausted or when a return is executed in the body. (In fact, list may be any
non-atomic expression, and successive parts are taken.)
(%i1) for f in [log, rho, atan] do ldisp(f(1))$
(%t1) 0
(%t2) rho(1)
%pi
(%t3) ---
4
(%i4) ev(%t3,numer);
(%o4) 0.78539816
Chapter 41: Program Flow 383
errormsg () Function
Reprints the most recent error message. The variable error holds the message, and
errormsg formats and prints it.
go (tag) Function
is used within a block to transfer control to the statement of the block which is tagged
with the argument to go. To tag a statement, precede it by an atomic argument as
another statement in the block. For example:
block ([x], x:1, loop, x+1, ..., go(loop), ...)
The argument to go must be the name of a tag appearing in the same block. One
cannot use go to transfer to tag in a block other than the one containing the go.
if special operator
The if statement is used for conditional execution. The syntax is:
if <condition> then <expr_1> else <expr_2>
The result of an if statement is expr 1 if condition is true and expr 2 otherwise.
expr 1 and expr 2 are any Maxima expressions (including nested if statements),
and condition is an expression which evaluates to true or false and is composed of
relational and logical operators which are as follows:
Operation Symbol Type
maperror Variable
Default value: true
When maperror is false, causes all of the mapping functions, for example
Chapter 41: Program Flow 385
prederror Variable
Default value: true
When prederror is true, an error message is displayed whenever the predicate of an
if statement or an is function fails to evaluate to either true or false.
If false, unknown is returned instead in this case. The prederror:false mode is
not supported in translated code.
scanmap (f, expr, bottomup) applies f to expr in a bottom-up manner. E.g., for
undefined f,
scanmap(f,a*x+b) ->
f(a*x+b) -> f(f(a*x)+f(b)) -> f(f(f(a)*f(x))+f(b))
scanmap(f,a*x+b,bottomup) -> f(a)*f(x)+f(b)
-> f(f(a)*f(x))+f(b) ->
f(f(f(a)*f(x))+f(b))
In this case, you get the same answer both ways.
42 Debugging
(%o1) /tmp/foobar.mac
(%o2) 1094
The file /tmp/foobar.mac is the following:
foo(y) := block ([u:y^2],
u: u+3,
u: u^2,
u);
bar(x,y) := (
x: x+2,
y: y+2,
x: foo(y),
x+y);
USE OF THE DEBUGGER THROUGH EMACS
If the user is running the code under GNU emacs in a shell window (dbl shell), or is
running the graphical interface version, xmaxima, then if he stops at a break point, he will
see his current position in the source file which will be displayed in the other half of the
window, either highlighted in red, or with a little arrow pointing at the right line. He can
advance single lines at a time by typing M-n (Alt-n).
Under Emacs you should run in a dbl shell, which requires the dbl.el file in the elisp
directory. Make sure you install the elisp files or add the Maxima elisp directory to your
path: e.g., add the following to your ‘.emacs’ file or the site-init.el
(setq load-path (cons "/usr/share/maxima/5.9.1/emacs" load-path))
(autoload ’dbl "dbl")
then in emacs
M-x dbl
should start a shell window in which you can run programs, for example Maxima, gcl,
gdb etc. This shell window also knows about source level debugging, and display of source
code in the other window.
The user may set a break point at a certain line of the file by typing C-x space. This
figures out which function the cursor is in, and then it sees which line of that function the
cursor is on. If the cursor is on, say, line 2 of foo, then it will insert in the other window
the command, “:br foo 2”, to break foo at its second line. To have this enabled, the
user must have maxima-mode.el turned on in the window in which the file foobar.mac is
visiting. There are additional commands available in that file window, such as evaluating
the function into the Maxima, by typing Alt-Control-x.
The number of arguments taken depends on the particular command. Also, you need
not type the whole command, just enough to be unique among the break keywords. Thus
:br would suffice for :break.
The keyword commands are listed below.
:break F n
Set a breakpoint in function F at line offset n from the beginning of the function.
If F is given as a string, then it is assumed to be a file, and n is the offset from
the beginning of the file. The offset is optional. If not given, it is assumed to
be zero (first line of the function or file).
:bt Print a backtrace of the stack frames
:continue
Continue the computation
:delete Delete the specified breakpoints, or all if none are specified
:disable Disable the specified breakpoints, or all if none are specified
:enable Enable the specified breakpoints, or all if none are specified
:frame n Print stack frame n, or the current frame if none is specified
:help Print help on a debugger command, or all commands if none is specified
:info Print information about item
:lisp some-form
Evaluate some-form as a Lisp form
:lisp-quiet some-form
Evaluate Lisp form some-form without any output
:next Like :step, except :next steps over function calls
:quit Quit the current debugger level without completing the computation
:resume Continue the computation
:step Continue the computation until it reaches a new source line
:top Return to the Maxima prompt (from any debugger level) without completing
the computation
refcheck Variable
Default value: false
When refcheck is true, Maxima prints a message each time a bound variable is used
for the first time in a computation.
390 Maxima Manual
setcheck Variable
Default value: false
If setcheck is set to a list of variables (which can be subscripted), Maxima prints
a message whenever the variables, or subscripted occurrences of them, are bound
with the ordinary assignment operator :, the :: assignment operator, or function
argument binding, but not the function assignment := nor the macro assignment ::=
operators. The message comprises the name of the variable and the value it is bound
to.
setcheck may be set to all or true thereby including all variables.
Each new assignment of setcheck establishes a new list of variables to check, and
any variables previously assigned to setcheck are forgotten.
The names assigned to setcheck must be quoted if they would otherwise evaluate
to something other than themselves. For example, if x, y, and z are already bound,
then enter
setcheck: [’x, ’y, ’z]$
to put them on the list of variables to check.
No printout is generated when a variable on the setcheck list is assigned to itself,
e.g., X: ’X.
setcheckbreak Variable
Default value: false
When setcheckbreak is true, Maxima will present a break prompt whenever a
variable on the setcheck list is assigned a new value. The break occurs before the
assignment is carried out. At this point, setval holds the value to which the variable
is about to be assigned. Hence, one may assign a different value by assigning to
setval.
See also setcheck and setval.
setval Variable
Holds the value to which a variable is about to be set when a setcheckbreak occurs.
Hence, one may assign a different value by assigning to setval.
See also setcheck and setcheckbreak.
timer quotes its arguments. f(x) := x^2$ g:f$ timer(g)$ does not put f on the
timer list.
If trace(f) is in effect, then timer(f) has no effect; trace and timer cannot both
be in effect at the same time.
See also timer_devalue.
trace quotes its arguments. Thus, f(x) := x^2$ g:f$ trace(g)$ does not put f on
the trace list.
When a function is redefined, it is removed from the timer list. Thus after timer(f)$
f(x) := x^2$, function f is no longer on the timer list.
If timer (f) is in effect, then trace (f) has no effect; trace and timer can’t both
be in effect for the same function.
(%i4) ff(3);
Here is the same function, with the break option conditional on a predicate:
(%i5) trace_options (ff, break(pp))$
(%i7) ff(6);
Chapter 42: Debugging 393
43 Indices
396 Maxima Manual
Appendix A: Function and Variable Index 397
M N
m1pbranch (Variable) . . . . . . . . . . . . . . . . . . . . . . . 341 nc_degree (Function) . . . . . . . . . . . . . . . . . . . . . . . 235
macroexpansion (Variable) . . . . . . . . . . . . . . . . . . 371 ncexpt (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . 228
mainvar (declaration) . . . . . . . . . . . . . . . . . . . . . . . . 58 ncharpoly (Function) . . . . . . . . . . . . . . . . . . . . . . . 228
negdistrib (Variable) . . . . . . . . . . . . . . . . . . . . . . . 59
make_array (Function) . . . . . . . . . . . . . . . . . . . . . . 210
negsumdispflag (Variable) . . . . . . . . . . . . . . . . . . . 59
make_random_state (Function) . . . . . . . . . . . . . . . 29 newcontext (Function) . . . . . . . . . . . . . . . . . . . . . . . 99
make_transform (Function) . . . . . . . . . . . . . . . . . . . 71 newdet (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . 229
makebox (Function) . . . . . . . . . . . . . . . . . . . . . . . . . 255 newton (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . 204
makefact (Function) . . . . . . . . . . . . . . . . . . . . . . . . 137 niceindices (Function) . . . . . . . . . . . . . . . . . . . . . 300
makegamma (Function) . . . . . . . . . . . . . . . . . . . . . . . 137 niceindicespref (Variable) . . . . . . . . . . . . . . . . . 301
makelist (Function) . . . . . . . . . . . . . . . . . . . . . . . . 359 ninth (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
map (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384 nm (Variable) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
mapatom (Function) . . . . . . . . . . . . . . . . . . . . . . . . . 384 nmc (Variable) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
maperror (Variable) . . . . . . . . . . . . . . . . . . . . . . . . 384 noeval (special symbol) . . . . . . . . . . . . . . . . . . . . . . 59
nolabels (Variable). . . . . . . . . . . . . . . . . . . . . . . . . . 20
maplist (Function) . . . . . . . . . . . . . . . . . . . . . . . . . 385
nonmetricity (Function) . . . . . . . . . . . . . . . . . . . . 282
matchdeclare (Function) . . . . . . . . . . . . . . . . . . . . 351 nonscalar (declaration) . . . . . . . . . . . . . . . . . . . . . 229
matchfix (Function) . . . . . . . . . . . . . . . . . . . . . . . . 352 nonscalarp (Function) . . . . . . . . . . . . . . . . . . . . . . 229
matrix (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . 223 not (operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
matrix_element_add (Variable) . . . . . . . . . . . . . . 226 noun (declaration) . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
matrix_element_mult (Variable) . . . . . . . . . . . . . 227 noundisp (Variable). . . . . . . . . . . . . . . . . . . . . . . . . . 59
matrix_element_transpose (Variable) . . . . . . . 227 nounify (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . 48
matrixmap (Function) . . . . . . . . . . . . . . . . . . . . . . . 226 nouns (special symbol) . . . . . . . . . . . . . . . . . . . . . . . 59
matrixp (Function) . . . . . . . . . . . . . . . . . . . . . . . . . 226 np (Variable) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
mattrace (Function) . . . . . . . . . . . . . . . . . . . . . . . . 228 npi (Variable) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
nptetrad (Function) . . . . . . . . . . . . . . . . . . . . . . . . 279
max (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
nroots (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . 189
maxapplydepth (Variable) . . . . . . . . . . . . . . . . . . . . 58 nterms (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
maxapplyheight (Variable) . . . . . . . . . . . . . . . . . . . 58 ntermst (Function) . . . . . . . . . . . . . . . . . . . . . . . . . 285
maxnegex (Variable). . . . . . . . . . . . . . . . . . . . . . . . . . 58 nthroot (Function) . . . . . . . . . . . . . . . . . . . . . . . . . 189
maxposex (Variable). . . . . . . . . . . . . . . . . . . . . . . . . . 58 ntrig (Package) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
maxtayorder (Variable) . . . . . . . . . . . . . . . . . . . . . 300 num (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
member (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . 360 numberp (Function) . . . . . . . . . . . . . . . . . . . . . . . . . 342
min (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 numer (special symbol) . . . . . . . . . . . . . . . . . . . . . . . 59
minfactorial (Function) . . . . . . . . . . . . . . . . . . . . 315 numerval (Function) . . . . . . . . . . . . . . . . . . . . . . . . . 59
minor (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 numfactor (Function) . . . . . . . . . . . . . . . . . . . . . . . 137
nusum (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
mod (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
mode_check_errorp (Variable) . . . . . . . . . . . . . . . 372
mode_check_warnp (Variable) . . . . . . . . . . . . . . . . 372 O
mode_checkp (Variable) . . . . . . . . . . . . . . . . . . . . . 372
obase (Variable) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
mode_declare (Function) . . . . . . . . . . . . . . . . . . . . 372 oddp (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
mode_identity (Function) . . . . . . . . . . . . . . . . . . . 372 ode2 (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
modulus (Variable) . . . . . . . . . . . . . . . . . . . . . . . . . . 111 op (Function). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
mon2schur (Function) . . . . . . . . . . . . . . . . . . . . . . . 323 openplot_curves (Function) . . . . . . . . . . . . . . . . . 65
mono (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 operatorp (Function) . . . . . . . . . . . . . . . . . . . . . . . . 48
monomial_dimensions (Function) . . . . . . . . . . . . 236 opproperties (Variable) . . . . . . . . . . . . . . . . . . . . . 60
multi_elem (Function) . . . . . . . . . . . . . . . . . . . . . . 323 opsubst (Variable) . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
multi_orbit (Function) . . . . . . . . . . . . . . . . . . . . . 324 optimize (Function) . . . . . . . . . . . . . . . . . . . . . . . . . 49
multi_pui (Function) . . . . . . . . . . . . . . . . . . . . . . . 324 optimprefix (Variable) . . . . . . . . . . . . . . . . . . . . . . 49
optionset (Variable) . . . . . . . . . . . . . . . . . . . . . . . . 20
multinomial (Function) . . . . . . . . . . . . . . . . . . . . . 324
or (operator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
multiplicative (declaration) . . . . . . . . . . . . . . . . 58 orbit (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
multiplicities (Variable) . . . . . . . . . . . . . . . . . . 188 ordergreat (Function) . . . . . . . . . . . . . . . . . . . . . . . 49
multsym (Function) . . . . . . . . . . . . . . . . . . . . . . . . . 324 ordergreatp (Function) . . . . . . . . . . . . . . . . . . . . . . 49
multthru (Function) . . . . . . . . . . . . . . . . . . . . . . . . . 47 orderless (Function) . . . . . . . . . . . . . . . . . . . . . . . . 49
myoptions (Variable) . . . . . . . . . . . . . . . . . . . . . . . . 20 orderlessp (Function) . . . . . . . . . . . . . . . . . . . . . . . 49
404 Maxima Manual
U vectorpotential (Function) . . . . . . . . . . . . . . . . . 34
ueivects (Function) . . . . . . . . . . . . . . . . . . . . . . . . 231 vectorsimp (Function) . . . . . . . . . . . . . . . . . . . . . . 232
ufg (Variable) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 verb (special symbol) . . . . . . . . . . . . . . . . . . . . . . . . 53
ug (Variable) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 verbify (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . 53
ultraspherical (Function). . . . . . . . . . . . . . . . . . 144 verbose (Variable) . . . . . . . . . . . . . . . . . . . . . . . . . . 310
undiff (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . 253
uniteigenvectors (Function) . . . . . . . . . . . . . . . 231
unitvector (Function) . . . . . . . . . . . . . . . . . . . . . . 231
W
unknown (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . 63 weyl (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
unorder (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . 33 weyl (Variable) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
unsum (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 with_stdout (Macro) . . . . . . . . . . . . . . . . . . . . . . . . 90
untellrat (Function) . . . . . . . . . . . . . . . . . . . . . . . 121 writefile (Function) . . . . . . . . . . . . . . . . . . . . . . . . 90
untimer (Function) . . . . . . . . . . . . . . . . . . . . . . . . . 391
untrace (Function) . . . . . . . . . . . . . . . . . . . . . . . . . 393
uric (Variable) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 X
uricci (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . 274 xgraph_curves (Function) . . . . . . . . . . . . . . . . . . . . 66
uriem (Variable) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 xthru (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
uriemann (Function) . . . . . . . . . . . . . . . . . . . . . . . . 275
use_fast_arrays (option variable) . . . . . . . . . . . 211
uvect (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 Z
zerobern (Variable) . . . . . . . . . . . . . . . . . . . . . . . . 316
zeroequiv (Function) . . . . . . . . . . . . . . . . . . . . . . . . 34
V zeromatrix (Function) . . . . . . . . . . . . . . . . . . . . . . 232
values (Variable) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 zeta (Function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
vect_cross (Variable) . . . . . . . . . . . . . . . . . . . . . . 232 zeta%pi (Variable) . . . . . . . . . . . . . . . . . . . . . . . . . . 316
408 Maxima Manual
i
Short Contents
.............................................. 1
1 Introduction to Maxima . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Bug Detection and Reporting . . . . . . . . . . . . . . . . . . . . . . . 7
3 Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4 Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
6 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
7 Simplification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
8 Plotting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
9 Input and Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
10 Floating Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
11 Contexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
12 Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
13 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
14 Logarithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
15 Trigonometric . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
16 Special Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
17 Orthogonal Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . 139
18 Elliptic Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
19 Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
20 Differentiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
21 Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
22 Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
23 Differential Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
24 Numerical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
25 Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
26 Arrays and Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
27 Matrices and Linear Algebra . . . . . . . . . . . . . . . . . . . . . . 213
28 Affine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
29 itensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
30 ctensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
31 atensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
32 Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
33 Number Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
34 Symmetries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
ii Maxima Manual
35 Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
36 Runtime Environment . . . . . . . . . . . . . . . . . . . . . . . . . . 337
37 Miscellaneous Options . . . . . . . . . . . . . . . . . . . . . . . . . . 339
38 Rules and Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
39 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
40 Function Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
41 Program Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
42 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
43 Indices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
A Function and Variable Index . . . . . . . . . . . . . . . . . . . . . . 397
iii
Table of Contents
.............................................. 1
1 Introduction to Maxima . . . . . . . . . . . . . . . . . . . . 3
3 Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1 Introduction to Help. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2 Lisp and Maxima . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.3 Garbage Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.4 Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.5 Definitions for Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4 Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.1 Introduction to Command Line. . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.2 Definitions for Command Line. . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.1 nary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.2 nofix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.3 operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.4 postfix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.5 prefix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.6 Definitions for Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
6.1 Introduction to Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
6.2 Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
6.3 Complex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
6.4 Inequality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
6.5 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
6.6 Definitions for Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
7 Simplification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
7.1 Definitions for Simplification . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
8 Plotting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
8.1 Definitions for Plotting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
iv Maxima Manual
10 Floating Point . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
10.1 Definitions for Floating Point . . . . . . . . . . . . . . . . . . . . . . . . . . 91
11 Contexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
11.1 Definitions for Contexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
12 Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
12.1 Introduction to Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . 101
12.2 Definitions for Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
13 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
13.1 Definitions for Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
14 Logarithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
14.1 Definitions for Logarithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
15 Trigonometric . . . . . . . . . . . . . . . . . . . . . . . . . . 127
15.1 Introduction to Trigonometric . . . . . . . . . . . . . . . . . . . . . . . . . 127
15.2 Definitions for Trigonometric . . . . . . . . . . . . . . . . . . . . . . . . . . 127
19 Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
19.1 Definitions for Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
20 Differentiation . . . . . . . . . . . . . . . . . . . . . . . . . . 153
20.1 Definitions for Differentiation . . . . . . . . . . . . . . . . . . . . . . . . . 153
v
21 Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
21.1 Introduction to Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
21.2 Definitions for Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
22 Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
22.1 Definitions for Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
24 Numerical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
24.1 Introduction to Numerical . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
24.2 Fourier packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
24.3 Definitions for Numerical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
24.4 Definitions for Fourier Series . . . . . . . . . . . . . . . . . . . . . . . . . . 204
25 Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
25.1 Definitions for Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
28 Affine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
28.1 Definitions for Affine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
29 itensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
29.1 Introduction to itensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
29.1.1 New tensor notation . . . . . . . . . . . . . . . . . . . . . . . . . 239
29.1.2 Indicial tensor manipulation . . . . . . . . . . . . . . . . . . 240
29.2 Definitions for itensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
29.2.1 Managing indexed objects . . . . . . . . . . . . . . . . . . . . 243
29.2.2 Tensor symmetries . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
29.2.3 Indicial tensor calculus . . . . . . . . . . . . . . . . . . . . . . . 252
29.2.4 Tensors in curved spaces . . . . . . . . . . . . . . . . . . . . . 256
29.2.5 Moving frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
29.2.6 Torsion and nonmetricity. . . . . . . . . . . . . . . . . . . . . 261
29.2.7 Exterior algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
29.2.8 Exporting TeX expressions . . . . . . . . . . . . . . . . . . . 266
29.2.9 Interfacing with ctensor . . . . . . . . . . . . . . . . . . . . . . 266
29.2.10 Reserved words. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
vi Maxima Manual
30 ctensor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
30.1 Introduction to ctensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
30.2 Definitions for ctensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
30.2.1 Initialization and setup . . . . . . . . . . . . . . . . . . . . . . 271
30.2.2 The tensors of curved space . . . . . . . . . . . . . . . . . . 273
30.2.3 Taylor series expansion. . . . . . . . . . . . . . . . . . . . . . . 276
30.2.4 Frame fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
30.2.5 Algebraic classification . . . . . . . . . . . . . . . . . . . . . . . 279
30.2.6 Torsion and nonmetricity. . . . . . . . . . . . . . . . . . . . . 281
30.2.7 Miscellaneous features . . . . . . . . . . . . . . . . . . . . . . . 282
30.2.8 Utility functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
30.2.9 Variables used by ctensor . . . . . . . . . . . . . . . . . . . 290
30.2.10 Reserved names . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
30.2.11 Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
31 atensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
31.1 Introduction to atensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
31.2 Definitions for atensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
32 Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
32.1 Introduction to Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
32.2 Definitions for Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
34 Symmetries . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
34.1 Definitions for Symmetries . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
35 Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
35.1 Definitions for Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
39 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
39.1 Introduction to Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
39.2 Definitions for Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
42 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
42.1 Source Level Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
42.2 Keyword Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388
42.3 Definitions for Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
43 Indices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395