Maxima Manual
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:
sonia$ maxima
GCL (GNU Common Lisp) Version(2.3) Tue Mar 21 14:15:15 CST 2000
Licensed under GNU Library General Public License
Contains Enhancements by W. Schelter
Maxima 5.4 Tue Mar 21 14:14:45 CST 2000 (enhancements by W. Schelter)
Licensed under the GNU Public License (see file COPYING)
(C1) factor(10!);
8 4 2
(D1) 2 3 5 7
(C2) expand((x+y)^6);
6 5 2 4 3 3 4 2 5 6
(D2) y + 6 x y + 15 x y + 20 x y + 15 x y + 6 x y + x
(C3) factor(x^6-1);
2 2
(D3) (x - 1) (x + 1) (x - x + 1) (x + x + 1)
(C4) quit();
sonia$
MAXIMA can search the info pages. Use the describe command to show
all the commands and variables containing a string, and optionally their
documentation:
(C1) describe(factor);
0: DONTFACTOR :(maxima.info)Definitions for Matrices and ..
1: EXPANDWRT_FACTORED :Definitions for Simplification.
2: FACTOR :Definitions for Polynomials.
3: FACTORFLAG :Definitions for Polynomials.
4: FACTORIAL :Definitions for Number Theory.
5: FACTOROUT :Definitions for Polynomials.
6: FACTORSUM :Definitions for Polynomials.
7: GCFACTOR :Definitions for Polynomials.
8: GFACTOR :Definitions for Polynomials.
9: GFACTORSUM :Definitions for Polynomials.
10: MINFACTORIAL :Definitions for Number Theory.
11: NUMFACTOR :Definitions for Special Functions.
12: SAVEFACTORS :Definitions for Polynomials.
13: SCALEFACTORS :Definitions for Miscellaneous Options.
14: SOLVEFACTORS :Definitions for Equations.
Enter n, all, none, or multiple choices eg 1 3 : 2 8;
Info from file /d/linux/local/lib/maxima-5.4/info/maxima.info:
- Function: FACTOR (EXP)
factors the expression exp, containing any number of variables or
functions, into factors irreducible over the integers.
FACTOR(exp, p) factors exp over the field of integers with an
element adjoined whose minimum polynomial is p. FACTORFLAG[FALSE]
if FALSE suppresses the factoring of integer factors of rational
expressions. DONTFACTOR may be set to a list of variables with
respect to which factoring is not to occur. (It is initially
empty). Factoring also will not take place with respect to any
variables which are less important (using the variable ordering
assumed for CRE form) than those on the DONTFACTOR list.
SAVEFACTORS[FALSE] if 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. BERLEFACT[TRUE] if FALSE then the
Kronecker factoring algorithm will be used otherwise the Berlekamp
algorithm, which is the default, will be used. INTFACLIM[1000] is
the largest divisor which will be tried when factoring a bignum
integer. If set to 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), complete factorization of the integer will be
attempted. The user's setting of INTFACLIM is used for internal
calls to FACTOR. Thus, INTFACLIM may be reset to prevent MACSYMA
from taking an inordinately long time factoring large integers.
NEWFAC[FALSE] may be set to true to use the new factoring routines.
Do EXAMPLE(FACTOR); for examples.
- Function: GFACTOR (EXP)
factors the polynomial exp over the Gaussian integers (i. e.
with SQRT(-1) = %I adjoined). This is like FACTOR(exp,A**2+1)
where A is %I.
(C1) GFACTOR(X**4-1);
(D1) (X - 1) (X + 1) (X + %I) (X - %I)
(D1) 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:
(C2) u:expand((x+y)^6);
6 5 2 4 3 3 4 2 5 6
(D2) y + 6 x y + 15 x y + 20 x y + 15 x y + 6 x y + x
(C3) diff(u,x);
5 4 2 3 3 2 4 5
(D3) 6 y + 30 x y + 60 x y + 60 x y + 30 x y + 6 x
(C4) factor(d3);
5
(D4) 6 (y + x)
MAXIMA knows about complex numbers and numerical constants:
(C6) cos(%pi);
(D6) - 1
(C7) %e^(%i*%pi);
(D7) - 1
MAXIMA can do differential and integral calculus:
(C8) u:expand((x+y)^6);
6 5 2 4 3 3 4 2 5 6
(D8) y + 6 x y + 15 x y + 20 x y + 15 x y + 6 x y + x
(C9) diff(%,x);
5 4 2 3 3 2 4 5
(D9) 6 y + 30 x y + 60 x y + 60 x y + 30 x y + 6 x
(C10) integrate(1/(1+x^3),x);
2 x - 1
2 ATAN(-------)
LOG(x - x + 1) SQRT(3) LOG(x + 1)
(D10) - --------------- + ------------- + ----------
6 SQRT(3) 3
MAXIMA can solve linear systems and cubic equations:
(C11) linsolve( [ 3*x + 4*y = 7, 2*x + a*y = 13], [x,y]);
7 a - 52 25
(D11) [x = --------, y = -------]
3 a - 8 3 a - 8
(C12) solve( x^3 - 3*x^2 + 5*x = 15, x);
(D12) [x = - SQRT(5) %I, x = SQRT(5) %I, x = 3]
MAXIMA can solve nonlinear sets of equations. Note that if you don't
want a result printed, you can finish your command with $ instead
of ;.
(C13) eq1: x^2 + 3*x*y + y^2 = 0$
(C14) eq2: 3*x + y = 1$
(C15) solve([eq1, eq2]);
3 SQRT(5) + 7 SQRT(5) + 3
(D15) [[y = - -------------, x = -----------],
2 2
3 SQRT(5) - 7 SQRT(5) - 3
[y = -------------, x = - -----------]]
2 2
Under the X window system, MAXIMA can generate plots of one or more
functions:
(C13) plot2d(sin(x)/x,[x,-20,20]);
(YMIN -3.0 YMAX 3.0 0.29999999999999999)
(D13) 0
(C14) plot2d([atan(x), erf(x), tanh(x)], [x,-5,5]);
(YMIN -3.0 YMAX 3.0 0.29999999999999999)
(YMIN -3.0 YMAX 3.0 0.29999999999999999)
(YMIN -3.0 YMAX 3.0 0.29999999999999999)
(D14) 0
(C15) plot3d(sin(sqrt(x^2+y^2))/sqrt(x^2+y^2),[x,-12,12],[y,-12,12]);
(D15) 0
Moving the cursor to the top left corner of the plot window will pop up
a menu that will, among other things, let you generate a PostScript file
of the plot. (By default, the file is placed in your home directory.)
You can rotate a 3D plot.
The most useful online help command is DESCRIBE which obtains help
on all commands containing a particular string. Here by command we
mean a built in operator such as INTEGRATE or FACTOR etc. As a typing
short cut you may type ? fact in lieu of describe("fact")
(C3) ? inte;
0: (maxima.info)Integration.
1: Introduction to Integration.
2: Definitions for Integration.
3: INTERRUPTS.
4: ASKINTEGER :Definitions for Simplification.
5: DISPLAY_FORMAT_INTERNAL :Definitions for Input and Output.
6: INTEGERP :Definitions for Miscellaneous Options.
7: INTEGRATE :Definitions for Integration.
8: INTEGRATION_CONSTANT_COUNTER :Definitions for Integration.
9: INTERPOLATE :Definitions for Numerical.
Enter n, all, none, or multiple choices eg 1 3 : 7 8;
Info from file /d/linux2/local/share/info/maxima.info:
- Function: INTEGRATE (EXP, VAR)
integrates exp with respect to var or returns an integral
expression (the noun form) if it cannot perform the integration
(see note 1 below). Roughly speaking three stages are used:
...
In the above the user said he wanted items 7 and 8. Note the ;
following the two numbers. He might have typed all to
see help on all the items.
All of Maxima is of course written in lisp. There is
a naming convention for functions and variables: All symbols which
begin with a "$" sign at lisp level, are read with the "$" sign stripped
off at Macsyma level. For example, there are two lisp functions
TRANSLATE and $TRANSLATE. If at macsyma level you enter
TRANSLATE(FOO); the function which is called is the $translate function.
To access the other function you must prefix with a "?". Note you
may not put a space after the ? since that would indicate
you were looking for help!
(C1) ?TRANSLATE(FOO);
Of course, this may well not do what you wanted it to do since it is a
completely different function.
To enter a lisp command you may use
(C1) :lisp (foo 1 2)
or to get a lisp prompt use to_lisp();, or alternately type
Ctrl-c to enter into a debug break.
This will cause a lisp break loop to be entered. You
could now evaluate $d2
and view the value of the line label D2, in its internal lisp
format. Typing :q will quit to top level, if you are in
a debug break. If you had exited maxima with to_lisp();
then you should type
MAXIMA>(run)
at the lisp prompt, to restart the Maxima session.
If you intend to write lisp functions to be called at macsyma
level you should name them by names beginning with a "$". Note
that all symbols typed at lisp level are automatically read in
upper case, unless you do something like |$odeSolve| to
force the case to be respected. Maxima interprets symbols
as mixed case, if the symbol has already been read before
or at the time it was first read there
was not an already existing symbol with the same letters but upper
case only. Thus if you type
(C1) Integrate;
(D1) INTEGRATE
(C2) Integ;
(D2) Integ
The symbol Integrate already existed in upper case since it
is a Maxima primitive, but INTEG, does not already exist, so the Integ
is permitted. This may seem a little bizarre, but we wish to keep
old maxima code working, which assumes that Maxima primitives may
be in upper or lower case. An advantage of this system is that if
you type in lower case, you will immediately see which are the maxima
keywords and functions.
To enter Maxima forms at lisp level, you may use the #$ macro.
(setq $foo #$[x,y]$)
This will have the same effect as entering
(C1)FOO:[X,Y];
except that foo will not appear in the VALUES list. In order to view
foo in macsyma printed format you may type
(displa $foo)
In this documentation when we wish to refer to a macsyma symbol we
shall generally omit the $ just as you would when typing at macsyma level.
This will cause confusion when we also wish to refer to a lisp symbol.
In this case we shall usually try to use lower case for the lisp symbol
and upper case for the macsyma symbol. For example LIST for $list and
list for the lisp symbol whose printname is "list".
Since functions defined using the MAXIMA language are not ordinary
lisp functions, you must use mfuncall to call them.
For example:
(D2) FOO(X, Y) := X + Y + 3
then at lisp level
CL-MAXIMA>>(mfuncall '$foo 4 5)
12
A number of lisp functions are shadowed in the maxima package. This is
because their use within maxima is not compatible with the definition as
a system function. For example typep behaves differently common lisp
than it did in Maclisp. If you want to refer to the zeta lisp typep
while in the maxima package you should use global:typep (or cl:typep for
common lisp). Thus
(macsyma:typep '(1 2)) ==> 'list
(lisp:typep '(1 2))==> error (lisp:type-of '(1 2))==> 'cons
To see which symbols are shadowed look in "src/maxima-package.lisp" or
do a describe of the package at lisp level.
Symbolic computation tends to create a good deal
of garbage, and effective handling of this can be crucial to successful
completion of some programs.
Under GCL, on UNIX systems where the mprotect system call is available
(including SUN OS 4.0 and some variants of BSD) a stratified garbage collection
is available. This limits the collection to pages which have been recently
written to. See the GCL documentation under ALLOCATE and GBC. At the
lisp level doing (setq si::*notify-gbc* t) will help you determine which
areas might need more space.
The source for the documentation is in `.texi' texinfo format.
From this format we can produce the info files used by the online
commands ? and describe. Also html and pdf
files can be produced.
Additionally there are examples so that you may do
example(integrate);
(C4) example(integrate);
(C5) test(f):=BLOCK([u],u:INTEGRATE(f,x),RATSIMP(f-DIFF(u,x)));
(D5) test(f) := BLOCK([u], u :
INTEGRATE(f, x), RATSIMP(f - DIFF(u, x)));
(C6) test(SIN(x));
(D6) 0
(C7) test(1/(x+1));
(D7) 0
(C8) test(1/(x^2+1));
(D8) 0
(C9) INTEGRATE(SIN(X)^3,X);
...
- Function: DEMO (file)
-
this is the same as BATCH but pauses after each command
line and continues when a space is typed (you may need to type
; followed by a newline, if running under xmaxima). The demo
files have suffix .dem
- Function: DESCRIBE (cmd)
-
This command prints documentation on all commands which contain
the substring "cmd". Thus
(C1) describe("integ");
0: (maxima.info)Integration.
1: Introduction to Integration.
2: Definitions for Integration.
3: ASKINTEGER :Definitions for Simplification.
..
Enter n, all, none, or multiple choices eg 1 3 : 2 3;
Info from file /d/linux2/local/share/info/maxima.info:
Definitions for Integration
===========================
- Function: CHANGEVAR (EXP,F(X,Y),Y,X)
...
see section Introduction to Help
- Function: EXAMPLE (command)
-
will start up a demonstration of how command works
on some expressions. After each command line it will pause and wait
for a space to be typed, as in the DEMO command.
- Function: %TH (i)
-
is the ith previous computation. That is, if the next
expression to be computed is D(j) this is D(j-i). This is useful in
BATCH files or for referring to a group of D expressions. For
example, if SUM is initialized to 0 then FOR I:1 THRU 10 DO
SUM:SUM+%TH(I) will set SUM to the sum of the last ten D expressions.
- operator: "'"
-
- (single quote) has the effect of preventing evaluation. E.g.
'(F(X)) means do not evaluate the expression F(X). 'F(X) means
return the noun form of F applied to [X].
- operator: """
-
- (two single quotes) causes an extra evaluation to occur. E.g.
"c4; will re-execute line C4. "(F(X)) means evaluate the
expression F(X) an extra time. "F(X) means return the verb form of F
applied to [X].
- Function: ALIAS (newname1, oldname1, newname2, oldname2, ...)
-
provides an
alternate name for a (user or system) function, variable, array, etc.
Any even number of arguments may be used.
- Function: DEBUG ()
-
LISPDEBUGMODE(); DEBUGPRINTMODE(); and DEBUG(); make
available to the user debugging features used by systems programmers.
These tools are powerful, and although some conventions are different
from the usual macsyma level it is felt their use is very intuitive.
[Some printout may be verbose for slow terminals, there are switches
for controlling this.] These commands were designed for the user who
must debug translated macsyma code, as such they are a boon. See
MACDOC;TRDEBG USAGE for more information. For more help, consult GJC.
- Variable: DEBUGMODE
-
default: [FALSE] - causes MACSYMA to enter a MACSYMA break
loop whenever a MACSYMA error occurs if it is TRUE and to terminate
that mode if it is FALSE. If it is set to ALL then the user may
examine BACKTRACE for the list of functions currently entered.
- Function: DEBUGPRINTMODE ()
-
LISPDEBUGMODE(); DEBUGPRINTMODE(); and DEBUG();
make available to the user debugging features used by systems
programmers. These tools are powerful, and although some conventions
are different from the usual macsyma level it is felt their use is
very intuitive. [Some printout may be verbose for slow terminals,
there are switches for controlling this.] These commands were
designed for the user who must debug translated macsyma code, as such
they are a boon. See MACDOC;TRDEBG USAGE for more information. For
more help, consult GJC.
- Function: EV (exp, arg1, ..., argn)
-
is one of MACSYMA's most powerful and
versatile commands. It evaluates the expression exp in the environment
specified by the argi. This is done in steps, as follows:
-
(1) First the environment is set up by scanning the argi which may
be as follows:
SIMP causes exp to be simplified regardless of the setting of the
switch SIMP which inhibits simplification if FALSE.
NOEVAL supresses the evaluation phase of EV (see step (4) below).
This is useful in conjunction with the other switches and in causing
exp to be resimplified without being reevaluated.
EXPAND causes expansion.
EXPAND(m,n) causes expansion, setting the values of MAXPOSEX and
MAXNEGEX to m and n respectively.
DETOUT causes any matrix inverses computed in exp to have their
determinant kept outside of the inverse rather than dividing through
each element.
DIFF causes all differentiations indicated in exp to be performed.
DERIVLIST(var1,...,vark) causes only differentiations with respect to
the indicated variables.
FLOAT causes non-integral rational numbers to be converted to floating
point.
NUMER causes some mathematical functions (including exponentiation)
with numerical arguments to be evaluated in floating point. It causes
variables in exp which have been given numervals to be replaced by
their values. It also sets the FLOAT switch on.
PRED causes predicates (expressions which evaluate to TRUE or FALSE)
to be evaluated.
EVAL causes an extra post-evaluation of exp to occur. (See step (5)
below.)
E where E is an atom declared to be an EVFLAG causes E to be bound to
TRUE during the evaluation of exp.
V:expression (or alternately V=expression) causes V to be bound to the
value of expression during the evaluation of exp. Note that if V is a
MACSYMA option, then expression is used for its value during the
evaluation of exp. If more than one argument to EV is of this type
then the binding is done in parallel. If V is a non-atomic expression
then a substitution rather than a binding is performed.
E where E, a function name, has been declared to be an EVFUN causes E
to be applied to exp.
Any other function names (e.g. SUM) cause evaluation of occurrences
of those names in exp as though they were verbs.
In addition a function occurring in exp (say F(args)) may be defined
locally for the purpose of this evaluation of exp by giving
F(args):=body as an argument to EV.
If an atom not mentioned above or a subscripted variable or
subscripted expression was given as an argument, it is evaluated and
if the result is an equation or assignment then the indicated binding
or substitution is performed. If the result is a list then the
members of the list are treated as if they were additional arguments
given to EV. This permits a list of equations to be given (e.g. [X=1,
Y=A**2] ) or a list of names of equations (e.g. [E1,E2] where E1 and
E2 are equations) such as that returned by SOLVE.
The argi of EV may be given in any order with the exception of
substitution equations which are handled in sequence, left to right,
and EVFUNS which are composed, e.g. EV(exp,RATSIMP,REALPART) is
handled as REALPART(RATSIMP(exp)).
The SIMP, NUMER, FLOAT, and PRED switches may also be set locally in a
block, or globally at the "top level" in MACSYMA so that they will
remain in effect until being reset.
If exp is in CRE form then EV will return a result in CRE form
provided the NUMER and FLOAT switches are not both TRUE.
-
(2) During step (1), a list is made of the non-subscripted
variables appearing on the left side of equations in the argi or in
the value of some argi if the value is an equation. The variables
(both subscripted variables which do not have associated array
functions, and non-subscripted variables) in the expression exp are
replaced by their global values, except for those appearing in this
list. Usually, exp is just a label or % (as in (C2) below), so this
step simply retrieves the expression named by the label, so that EV
may work on it.
-
(3) If any substitutions are indicated by the argi, they are
carried out now.
-
(4) The resulting expression is then re-evaluated (unless one of
the argi was NOEVAL) and simplified according the the argi. Note that
any function calls in exp will be carried out after the variables in
it are evaluated and that EV(F(X)) thus may behave like F(EV(X)).
-
(5) If one of the argi was EVAL, steps (3) and (4) are repeated.
Examples
(C1) SIN(X)+COS(Y)+(W+1)**2+'DIFF(SIN(W),W);
d 2
(D1) COS(Y) + SIN(X) + -- SIN(W) + (W + 1)
dW
(C2) EV(%,SIN,EXPAND,DIFF,X=2,Y=1);
2
(D2) COS(W) + W + 2 W + COS(1) + 1.90929742
An alternate top level syntax has been provided for EV, whereby one
may just type in its arguments, without the EV(). That is, one may
write simply
exp, arg1, ...,argn.
This is not permitted as part of
another expression, i.e. in functions, blocks, etc.
(C4) X+Y,X:A+Y,Y:2;
(D4) Y + A + 2
(Notice the parallel binding process)
(C5) 2*X-3*Y=3$
(C6) -3*X+2*Y=-4$
(C7) SOLVE([D5,D6]);
SOLUTION
1
(E7) Y = - -
5
6
(E8) X = -
5
(D8) [E7, E8]
(C9) D6,D8;
(D9) - 4 = - 4
(C10) X+1/X > GAMMA(1/2);
1
(D10) X + - > SQRT(%PI)
X
(C11) %,NUMER,X=1/2;
(D11) 2.5 > 1.7724539
(C12) %,PRED;
(D12) TRUE
- Variable: EVFLAG
-
default: [] - the list of things known to the EV function. An
item will be bound to TRUE during the execution of EV if it is
mentioned in the call to EV, e.g. EV(%,numer);. Initial evflags are
FLOAT, PRED, SIMP, NUMER, DETOUT, EXPONENTIALIZE, DEMOIVRE,
KEEPFLOAT, LISTARITH, TRIGEXPAND, SIMPSUM, ALGEBRAIC,
RATALGDENOM, FACTORFLAG, %EMODE, LOGARC, LOGNUMER,
RADEXPAND, RATSIMPEXPONS, RATMX, RATFAC, INFEVAL, %ENUMER,
PROGRAMMODE, LOGNEGINT, LOGABS, LETRAT, HALFANGLES,
EXPTISOLATE, ISOLATE_WRT_TIMES, SUMEXPAND, CAUCHYSUM,
NUMER_PBRANCH, M1PBRANCH, DOTSCRULES, and LOGEXPAND.
- Variable: EVFUN
-
- the list of functions known to the EV function which will get
applied if their name is mentioned. Initial evfuns are FACTOR,
TRIGEXPAND, TRIGREDUCE, BFLOAT, RATSIMP, RATEXPAND, RADCAN,
LOGCONTRACT, RECTFORM, and POLARFORM.
- special symbol: INFEVAL
-
leads to an "infinite evaluation" mode. EV repeatedly
evaluates an expression until it stops changing. To prevent a
variable, say X, from being evaluated away in this mode, simply
include X='X as an argument to EV. Of course expressions such as
EV(X,X=X+1,INFEVAL); will generate an infinite loop. CAVEAT
EVALUATOR.
- Function: KILL (arg1, arg2, ...)
-
eliminates its arguments from the MACSYMA
system. If argi is a variable (including a single array element),
function, or array, the designated item with all of its properties is
removed from core. If argi=LABELS then all input, intermediate, and
output lines to date (but not other named items) are eliminated. If
argi=CLABELS then only input lines will be eliminated; if argi=ELABELS
then only intermediate E-lines will be eliminated; if argi=DLABELS
only the output lines will be eliminated. If argi is the name of any
of the other information lists (the elements of the MACSYMA variable
INFOLISTS), then every item in that class (and its properties) is
KILLed and if argi=ALL then every item on every information list
previously defined as well as LABELS is KILLed. If argi=a number (say
n), then the last n lines (i.e. the lines with the last n line
numbers) are deleted. If argi is of the form [m,n] then all lines
with numbers between m and n inclusive are killed. Note that
KILL(VALUES) or KILL(variable) will not free the storage occupied
unless the labels which are pointing to the same expressions are also
KILLed. Thus if a large expression was assigned to X on line C7 one
should do KILL(D7) as well as KILL(X) to release the storage occupied.
KILL(ALLBUT(name1,...,namek) will do a KILL(ALL) except it will not
KILL the names specified. (Note: namei means a name such as U, V, F,
G, not an infolist such as FUNCTIONS.)
KILL removes all properties from the given argument thus
KILL(VALUES) will kill all properties associated with every item on
the VALUES list whereas the REMOVE set of functions
(REMVALUE,REMFUNCTION,REMARRAY,REMRULE) remove a specific property.
Also the latter print out a list of names or FALSE if the specific
argument doesn't exist whereas KILL always has value "DONE" even if
the named item doesn't exist.
Note that killing expressions will not help the problem which
occurs on MC indicated by "NO CORE - FASLOAD" which results when
either too many FASL files have been loaded in or when allocation
level has gotten too high. In either of these cases, no amount of
killing will cause the size of these spaces to decrease. Killing
expressions only causes some spaces to get emptied out but not made
smaller.
- Function: LABELS (char)
-
takes a char C, D, or E as arg and generates a list of all
C-labels, D-labels, or E- labels, respectively. If you've generated
many E- labels via SOLVE, then
FIRST(REST(LABELS(C)))
reminds you
what the last C-label was.
LABELS will take as arg any symbolic name, so if you have reset INCHAR,
OUTCHAR, or LINECHAR, it will return the list of labels whose first
character matches the first character of the arg you give to LABELS.
The variable, LABELS, default: [], is a list of C, D, and E lines
which are bound.
- Variable: LASTTIME
-
- the time to compute the last expression in milliseconds
presented as a list of "time" and "gctime".
- Variable: LINENUM
-
- the line number of the last expression.
- Variable: MYOPTIONS
-
default: [] - all options ever reset by the user (whether
or not they get reset to their default value).
- Variable: NOLABELS
-
default: [FALSE] - if TRUE then no labels will be bound
except for E lines generated by the solve functions. This is most
useful in the "BATCH" mode where it eliminates the need to do
KILL(LABELS) in order to free up storage.
- Variable: OPTIONSET
-
default: [FALSE] - if TRUE, MACSYMA will print out a
message whenever a MACSYMA 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.
- Function: PLAYBACK (arg)
-
"plays back" input and output lines. If arg=n (a
number) the last n expressions (Ci, Di, and Ei count as 1 each) are
"played-back", while if arg is omitted, all lines are. If arg=INPUT
then only input lines are played back. If arg=[m,n] then all lines
with numbers from m to n inclusive are played-back. If m=n then [m]
is sufficient for arg. Arg=SLOW places PLAYBACK in a slow-mode
similar to DEMO's (as opposed to the "fast" BATCH). This is useful in
conjunction with SAVE or STRINGOUT when creating a secondary-storage
file in order to pick out useful expressions. If arg=TIME then the
computation times are displayed as well as the expressions. If
arg=GCTIME or TOTALTIME, then a complete breakdown of computation
times are displayed, as with SHOWTIME:ALL;. Arg=STRING strings-out
(see STRING function) all input lines when playing back rather than
displaying them. If ARG=GRIND "grind" mode can also be turned on (for
processing input lines) (see GRIND). One may include any number of
options as in PLAYBACK([5,10],20,TIME,SLOW).
- Function: PRINTPROPS (a, i)
-
will display the property with the indicator i
associated with the atom a. a may also be a list of atoms or the atom
ALL in which case all of the atoms with the given property will be
used. For example, PRINTPROPS([F,G],ATVALUE). PRINTPROPS is for
properties that cannot otherwise be displayed, i.e. for
ATVALUE, ATOMGRAD, GRADEF, and MATCHDECLARE.
- Variable: PROMPT
-
default: [_] is the prompt symbol of the DEMO function,
PLAYBACK(SLOW) mode, and (MACSYMA-BREAK).
- Function: QUIT ()
-
kills the current MACSYMA but doesn't affect the user's other
jobs; equivalent to exiting to DCL and stopping the MACSYMA process.
One may "quit" to MACSYMA top-level by typing Control-C Control-G;
Control-C gets NIL's interrupt prompt, at which one types either
Control-G or just G. Typing X at the Interrupt prompt will cause a
quit in a computation started within a MACSYMA-BREAK without disrupting
the suspended main computation.
- Function: REMFUNCTION (f1, f2, ...)
-
removes the user defined functions
f1,f2,... from MACSYMA. If there is only one argument of ALL then all
functions are removed.
- Function: RESET ()
-
causes all MACSYMA options to be set to their default values.
(Please note that this does not include features of terminals such as
LINEL which can only be changed by assignment as they are not
considered to be computational features of MACSYMA.)
- Function: RESTORE (file-specification)
-
reinitializes all quantities filed away
by a use of the SAVE or STORE functions, in a prior MACSYMA session,
from the file given by file-specification without bringing them into
core.
- Variable: SHOWTIME
-
default: [FALSE] - if TRUE then the computation time will be
printed automatically with each output expression. By setting
SHOWTIME:ALL, in addition to the cpu time MACSYMA now also prints out
(when not zero) the amount of time spent in garbage collection (gc) in
the course of a computation. This time is of course included in the
time printed out as "time=" . (It should be noted that since the
"time=" time only includes computation time and not any intermediate
display time or time it takes to load in out-of-core files, and since
it is difficult to ascribe "responsibility" for gc's, the gctime
printed will include all gctime incurred in the course of the
computation and hence may in rare cases even be larger than "time=").
- Function: SSTATUS (feature,package)
-
- meaning SET STATUS. It can be used to
SSTATUS( FEATURE, HACK_PACKAGE) so that STATUS( FEATURE, HACK_PACKAGE)
will then return TRUE. This can be useful for package writers, to
keep track of what FEATURES they have loaded in.
- Function: TOBREAK ()
-
causes the MACSYMA break which was left by typing
TOPLEVEL; to be re-entered. If TOBREAK is given any argument
whatsoever, then the break will be exited, which is equivalent to
typing TOBREAK() immediately followed by EXIT;.
- Function: TOPLEVEL ()
-
During a break one may type TOPLEVEL;. This will cause
top-level MACSYMA to be entered recursively. Labels will now be bound
as usual. Everything will be identical to the previous top-level
state except that the computation which was interrupted is saved. The
function TOBREAK() will cause the break which was left by typing
TOPLEVEL; to be re-entered. If TOBREAK is given any argument
whatsoever, then the break will be exited, which is equivalent to
typing TOBREAK() immediately followed by EXIT;.
- Function: TO_LISP ()
-
enters the LISP system under MACSYMA. This is useful on
those systems where control-uparrow is not available for this
function.
- Variable: TTYINTFUN
-
default: [FALSE] - Governs the function which will be run
whenever the User-interrupt-character is typed. To use this feature,
one sets TTYINTFUN (default FALSE meaning feature not in use) to a
function of no arguments. Then whenever (e.g.) ^U (control-U) is
typed, this function is run. E.g. suppose you have a FOR statement
loop which increments I, and you want an easy way of checking on the
value of I while the FOR statement is running. You can do:
TTYINTFUN:PRINTI$ PRINTI():=PRINT(I)$ , then whenever you type (e.g.)
^U you get the check you want.
- Variable: TTYINTNUM
-
default: [21] (the ascii value of Control-U (^U), U being
the 21st letter of the alphabet). This controls what character
becomes the User-interrupt-character. ^U was chosen for it mnemonic
value. Most users should not reset TTYINTNUM unless they are already
using ^U for something else.
- Variable: VALUES
-
default:[] - all bound atoms, i.e. user variables, not MACSYMA
Options or Switches, (set up by : , :: , or functional binding).
- 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. Do
DESCRIBE(SYNTAX); for more details. 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).
- 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 MACSYMA 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. Do
DESCRIBE(SYNTAX); for more details.
- See OPERATORS
- 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. Do DESCRIBE(SYNTAX); for details.
- 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. Do DESCRIBE(SYNTAX); for more details.
- operator: "!"
-
The factorial operator, which is the product of all the integers
from 1 up to its argument. Thus 5! = 1*2*3*4*5 = 120. The value of
/the option FACTLIM (default: [-1]) gives the highest factorial which is
automatically expanded. If it is -1 then all integers are expanded.
See also the FACTORIAL, MINFACTORIAL, and FACTCOMB commands.
- operator: "!!"
-
Stands for double factorial which is defined as the product of
all the consecutive odd (or even) integers from 1 (or 2) to the odd
(or even) argument. Thus 8!! is 2*4*6*8 = 384.
- 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. Do APROPOS(DOT); for a list of the switches
which affect the dot operator. DESCRIBE(switch-name); will explain
them.
- 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 DESCRIBE(MACROS).
- operator: ":="
-
The function definition operator. E.g. F(X):=SIN(X) defines
a function F.
- operator: "="
-
denotes an equation to MACSYMA. To the pattern matcher in
MACSYMA it denotes a total relation that holds between two expressions
if and only if the expressions are syntactically identical.
- special symbol: ADDITIVE
-
- If DECLARE(F,ADDITIVE) has been executed, then:
(1) If F is univariate, whenever the simplifier encounters F applied
to a sum, F will be distributed over that sum. I.e. F(Y+X); will
simplify to F(Y)+F(X).
(2) If F is a function of 2 or more arguments, additivity is defined as
additivity in the first argument to F, as in the case of 'SUM or
'INTEGRATE, i.e. F(H(X)+G(X),X); will simplify to F(H(X),X)+F(G(X),X).
This simplification does not occur when F is applied to expressions of
the form SUM(X[I],I,lower-limit,upper-limit).
- keyword: ALLBUT
-
works with the PART commands (i.e. PART, INPART, SUBSTPART,
SUBSTINPART, DPART, and LPART). For example,
if EXPR is E+D+C+B+A,
then PART(EXPR,[2,5]);
==> D+A
while
PART(EXPR,ALLBUT(2,5))==>E+C+B
It also works with the KILL command,
KILL(ALLBUT(name1,...,namek))
will do a KILL(ALL) except it will not
KILL the names specified. Note: namei means a name such as function
name such as U, F, FOO, or G, not an infolist such as FUNCTIONS.
- declaration: ANTISYMMETRIC
-
- If DECLARE(H,ANTISYMMETRIC); is done, this tells the
simplifier that H is antisymmetric. 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.
- Function: CABS (exp)
-
returns the complex absolute value (the complex modulus) of
exp.
- declaration: COMMUTATIVE
-
- 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.
- Function: ENTIER (X)
-
largest integer <= X where X is numeric. FIX (as in
FIXnum) is a synonym for this, so FIX(X); is precisely the same.
- Function: EQUAL (expr1,expr2)
-
used with an "IS", returns TRUE (or FALSE) if
and only if expr1 and expr2 are equal (or not equal) for all possible
values of their variables (as determined by RATSIMP). Thus
IS(EQUAL((X+1)**2,X**2+2*X+1)) returns TRUE whereas if X is unbound
IS((X+1)**2=X**2+2*X+1) returns FALSE. Note also that IS(RAT(0)=0)
gives FALSE but IS(EQUAL(RAT(0),0)) gives TRUE. If a determination
can't be made with EQUAL then a simplified but equivalent form is
returned whereas = always causes either TRUE or FALSE to be returned.
All variables occurring in exp are presumed to be real valued.
EV(exp,PRED) is equivalent to IS(exp).
(C1) IS(X**2 >= 2*X-1);
(D1) TRUE
(C2) ASSUME(A>1);
(D2) DONE
(C3) IS(LOG(LOG(A+1)+1)>0 AND A^2+1>2*A);
(D3) TRUE
- Function: EVAL
-
causes an extra post-evaluation of exp to occur.
- Function: EVENP (exp)
-
is TRUE if exp is an even integer. FALSE is returned in
all other cases.
- Function: FIX (x)
-
a synonym for ENTIER(X) - largest integer <= X where X is
numeric.
- Function: FULLMAP (fn, exp1, ...)
-
is similar to MAP but it will keep mapping
down all subexpressions until the main operators are no longer the
same. The user should be aware that FULLMAP is used by the MACSYMA
simplifier for certain matrix manipulations; thus, the user might see
an error message concerning FULLMAP even though FULLMAP was not
explicitly called by the user.
(C1) A+B*C$
(C2) FULLMAP(G,%);
(D2) G(B) G(C) + G(A)
(C3) MAP(G,D1);
(D3) G(B C) + G(A)
- Function: FULLMAPL (fn, list1, ...)
-
is similar to FULLMAP but it only maps onto
lists and matrices
(C1) FULLMAPL("+",[3,[4,5]],[[A,1],[0,-1.5]]);
(D1) [[A + 3, 4], [4, 3.5]]
- Function: IS (exp)
-
attempts to determine whether exp (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 (default: TRUE). IS errs out if the value of
PREDERROR is TRUE and returns UNKNOWN if PREDERROR is FALSE.
- Function: ISQRT (X)
-
takes one integer argument and returns the "integer SQRT"
of its absolute value.
- Function: MAX (X1, X2, ...)
-
yields the maximum of its arguments (or returns a
simplified form if some of its arguments are non-numeric).
- Function: MIN (X1, X2, ...)
-
yields the minimum of its arguments (or returns a
simplified form if some of its arguments are non-numeric).
- Function: MOD (poly)
-
converts the polynomial poly to a modular representation
with respect to the current modulus which is the value of the variable
MODULUS.
MOD(poly,m) specifies a MODULUS m to be used for converting poly, if
it is desired to override the current global value of MODULUS.
See DESCRIBE(MODULUS); .
- Function: ODDP (exp)
-
is TRUE if exp is an odd integer. FALSE is returned in all
other cases.
- operator: PRED
-
(EVFLAG) causes predicates (expressions which evaluate to TRUE
or FALSE) to be evaluated.
- Function: RANDOM (X)
-
returns a random integer between 0 and X-1. If no
argument is given then a random integer between -2^(29) and 2^(29) -1
is returned. If X is FALSE then the random sequence is restarted from
the beginning.
Note that the range of the returned result when no argument is given
differs in NIL MACSYMA from that of PDP-10 and Multics MACSYMA, which
is -2^(35) to 2^(35) -1. This range is the range of the FIXNUM
datatype of the underlying LISP.
- Function: SIGN (exp)
-
attempts to determine the sign of its specified expression
on the basis of the facts in the current data base. It returns one of
the following answers: POS (positive), NEG (negative), ZERO, PZ
(positive or zero), NZ (negative or zero), PN (positive or negative),
or PNZ (positive, negative, or zero, i.e. nothing known).
- Function: SIGNUM (X)
-
if X<0 then -1 else if X>0 then 1 else 0. If X is not
numeric then a simplified but equivalent form is returned. For
example, SIGNUM(-X) gives -SIGNUM(X).
- Function: SORT (list,optional-predicate)
-
sorts the list using a suitable
optional-predicate of two arguments (such as "<" or ORDERLESSP). If
the optional-predicate is not given, then MACSYMA's built-in ordering
predicate is used.
- Function: SQRT (X)
-
the square root of X. It is represented internally by
X^(1/2). Also see ROOTSCONTRACT.
RADEXPAND[TRUE] - if TRUE will cause nth roots of factors of a product
which are powers of n to be pulled outside of the radical, e.g.
SQRT(16*X^2) will become 4*X only if RADEXPAND is TRUE.
- Variable: SQRTDISPFLAG
-
default: [TRUE] - if FALSE causes SQRT to display with
exponent 1/2.
- Function: SUBLIS (list,expr)
-
allows multiple substitutions into an expression in
parallel. Sample syntax:
SUBLIS([A=B,B=A],SIN(A)+COS(B));
=> SIN(B) + COS(A)
The variable SUBLIS_APPLY_LAMBDA[TRUE] controls simplification after
SUBLIS. For full documentation, see the file SHARE2;SUBLIS INFO.
- Function: SUBLIST (L,F)
-
returns the list of elements of the list L for which the
function F returns TRUE. E.g., SUBLIST([1,2,3,4],EVENP); returns
[2,4].
- Variable: SUBLIS_APPLY_LAMBDA
-
default:[TRUE] - controls whether LAMBDA's
substituted are applied in simplification after SUBLIS is used or
whether you have to do an EV to get things to apply. TRUE means do the
application.
- Function: SUBST (a, b, c)
-
substitutes a for b in c. b must be an atom, or a
complete subexpression of c. For example, X+Y+Z is a complete
subexpression of 2*(X+Y+Z)/W while X+Y is not. When b does not have
these characteristics, one may sometimes use SUBSTPART or RATSUBST
(see below). Alternatively, if b is of the form e/f then one could
use SUBST(a*f,e,c) while if b is of the form e**(1/f) then one could
use SUBST(a**f,e,c). The SUBST command also discerns the X^Y in X^-Y
so that SUBST(A,SQRT(X),1/SQRT(X)) yields 1/A. a and b may also be
operators of an expression enclosed in "s or they may be function
names. If one wishes to substitute for the independent variable in
derivative forms then the AT function (see below) should be used.
Note: SUBST is an alias for SUBSTITUTE.
SUBST(eq1,exp) or SUBST([eq1,...,eqk],exp) are other permissible
forms. The eqi are equations indicating substitutions to be made.
For each equation, the right side will be substituted for the left in
the expression exp.
EXPTSUBST[FALSE] if TRUE permits substitutions like Y for %E**X in
%E**(A*X) to take place.
OPSUBST[TRUE] if 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.
(C1) SUBST(A,X+Y,X+(X+Y)**2+Y);
2
(D1) Y + X + A
(C2) SUBST(-%I,%I,A+B*%I);
(D2) A - %I B
(Note that C2 is one way of obtaining the complex conjugate of an analytic
expression.) For further examples, do EXAMPLE(SUBST);
- Function: SUBSTINPART (x, exp, n1, ...)
-
is like SUBSTPART but works on the
internal representation of exp.
(C1) X.'DIFF(F(X),X,2);
2
d
(D1) X . (--- F(X))
2
dX
(C2) SUBSTINPART(D**2,%,2);
2
(D2) X . D
(C3) SUBSTINPART(F1,F[1](X+1),0);
(D3) F1(X + 1)
Additional Information
If the last argument to a part function is a list of indices then
several subexpressions are picked out, each one corresponding to an
index of the list. Thus
(C1) PART(X+Y+Z,[1,3]);
(D1) Z+X
PIECE holds the value of 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 as shown below.
If PARTSWITCH[FALSE] is set to TRUE then END is returned when a
selected part of an expression doesn't exist, otherwise an error
message is given.
(C1) 27*Y**3+54*X*Y**2+36*X**2*Y+Y+8*X**3+X+1;
3 2 2 3
(D1) 27 Y + 54 X Y + 36 X Y + Y + 8 X + X + 1
(C2) PART(D1,2,[1,3]);
2
(D2) 54 Y
(C3) SQRT(PIECE/54);
(D3) Y
(C4) SUBSTPART(FACTOR(PIECE),D1,[1,2,3,5]);
3
(D4) (3 Y + 2 X) + Y + X + 1
(C5) 1/X+Y/X-1/Z;
1 Y 1
(D5) - - + - + -
Z X X
(C6) SUBSTPART(XTHRU(PIECE),%,[2,3]);
Y + 1 1
(D6) ----- - -
X Z
Also, setting the option INFLAG to TRUE and calling PART/SUBSTPART is
the same as calling INPART/SUBSTINPART.
- Function: SUBSTPART (x, exp, n1, ..., nk)
-
substitutes x for the subexpression
picked out by the rest of the arguments as in PART. It returns the
new value of exp. x may be some operator to be substituted for an
operator of exp. In some cases it needs to be enclosed in "s (e.g.
SUBSTPART("+",A*B,0); -> B + A ).
(C1) 1/(X**2+2);
1
(D1) ------
2
X + 2
(C2) SUBSTPART(3/2,%,2,1,2);
1
(D2) --------
3/2
X + 2
(C3) A*X+F(B,Y);
(D3) A X + F(B, Y)
(C4) SUBSTPART("+",%,1,0);
(D4) X + F(B, Y) + A
Also, setting the option INFLAG to TRUE and calling PART/SUBSTPART is
the same as calling INPART/SUBSTINPART.
- Function: SUBVARP (exp)
-
is TRUE if exp is a subscripted variable, for example
A[I].
- Function: SYMBOLP (exp)
-
returns TRUE if "exp" is a "symbol" or "name", else
FALSE. I.e., in effect, SYMBOLP(X):=ATOM(X) AND NOT NUMBERP(X)$ .
- Function: UNORDER ()
-
stops 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. Do
DESCRIBE(ORDERGREAT); and DESCRIBE(ORDERLESS);, and also do
EXAMPLE(UNORDER); for specifics.
- Function: VECTORPOTENTIAL (givencurl)
-
Returns the vector potential of a given
curl vector, in the current coordinate system.
POTENTIALZEROLOC has a similar role as for POTENTIAL, but the order of
the left-hand sides of the equations must be a cyclic permutation of
the coordinate variables.
- Function: XTHRU (exp)
-
combines all terms of exp (which should be a sum) over a
common denominator without expanding products and exponentiated sums
as RATSIMP does. XTHRU cancels common factors in the numerator and
denominator of rational expressions but only if the factors are
explicit. Sometimes it is better to use XTHRU before RATSIMPing an
expression in order to cause explicit factors of the gcd of the
numerator and denominator to be canceled thus simplifying the
expression to be RATSIMPed.
(C1) ((X+2)**20-2*Y)/(X+Y)**20+(X+Y)**-19-X/(X+Y)**20;
20
1 X (X + 2) - 2 Y
(D1) --------- - --------- + ---------------
19 20 20
(Y + X) (Y + X) (Y + X)
(C2) XTHRU(%);
20
(X + 2) - Y
(D2) -------------
20
(Y + X)
- Function: ZEROEQUIV (exp,var)
-
tests whether the expression exp in the variable
var is equivalent to zero. It returns either TRUE, FALSE, or
DONTKNOW. 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) will return DONTKNOW because
of the presence of an extra parameter. The restrictions are:
(1) Do not use functions that MACSYMA does not know how to
differentiate and evaluate.
(2) If the expression has poles on the real line, there may be errors
in the result (but this is unlikely to occur).
(3) If the expression contains functions which are not solutions to
first order differential equations (e.g. Bessel functions) there may
be incorrect results.
(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.
There are a number of reserved words which cannot be used as
variable names. Their use would cause a possibly cryptic syntax error.
INTEGRATE NEXT FROM DIFF
IN AT LIMIT SUM
FOR AND ELSEIF THEN
ELSE DO OR IF
UNLESS PRODUCT WHILE THRU
STEP
Most things in MAXIMA are expressions. A sequence of expressions
can be made into an expression by separating them by commas and
putting parentheses around them. This is similar to the C
comma expression.
(C29) x:3$
(C30) joe:(x:x+1,x:x*x);
(D30) 16
(C31) joe:(if (x >17) then 2 else 4);
(D31) 4
(C32) joe:(if (x >17) then x:2 else joe:4,joe+x);
(D32) 20
Even loops in maxima are expressions, although the value they
return is the not to useful DONE
(C33) joe:(x:1,for i from 1 thru 10 do (x:x*i));
(D33) DONE
whereas what you really want is probably is to include a third
term in the comma expression which actually gives back the value.
(C34) joe:(x:1,for i from 1 thru 10 do (x:x*i),x);
(D34) 3628800
- There are two assignment operators in MACSYMA, : 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.
- A complex expression is specified in MACSYMA 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 of complex expressions can usually be accomplished by using
the REALPART, IMAGPART, RECTFORM, POLARFORM, ABS, CARG functions.
- MACSYMA has the usual inequality operators:
less than: <
greater than: >
greater than or equal to: >=
less than or equal to: <=
- It is possible to add new operators to MACSYMA (infix,
prefix, postfix, unary, or matchfix with given precedences), to remove
existing operators, or to redefine the precedence of existing
operators. While MACSYMA'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.
(C1) PREFIX("DDX")$
(C2) DDX Y$
/* means "DDX"(Y) */
(C3) INFIX("<-")$
(C4) A<-DDX Y$
/* means "<-"(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, MACSYMA 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.
(C20) PREFIX("DDX",180,ANY,ANY)$
(C21) DDXYZ;
(D21) DDX YZ
(C26) "ddx"(u):=u+4;
(D26) DDX u := u + 4
(C27) ddx 8;
(D27) 12
- Function: AT (exp, list)
-
will evaluate exp (which may be any expression) with
the variables assuming the values as specified for them in the list of
equations or the single equation similar to that given to the ATVALUE
function. If a subexpression depends on any of the variables in list
but it hasn't had an atvalue specified and it can't be evaluated then
a noun form of the AT will be returned which will display in a
two-dimensional form. Do EXAMPLE(AT); for an example.
- Function: BOX (expr)
-
returns expr enclosed in a box. The box is actually part
of the expression.
BOX(expr,label)
encloses expr in a labelled box.
label is a name which will be truncated in display if it is too long.
BOXCHAR["] - is the character used to draw the box in this and in
the DPART and LPART functions.
- Variable: BOXCHAR
-
default: ["] is the character used to draw the box in the BOX
and in the DPART and LPART functions.
- special operator: CONSTANT
-
- makes ai a constant as is %PI.
- Function: CONSTANTP (exp)
-
is TRUE if exp is a constant (i.e. composed of
numbers and %PI, %E, %I or any variables bound to a constant or
DECLAREd constant) else FALSE. Any function whose arguments are
constant is also considered to be a constant.
- Function: CONTRACT (exp)
-
carries out all possible contractions in exp, which may
be any well-formed combination of sums and products. This function
uses the information given to the DEFCON function. Since all tensors
are considered to be symmetric in all indices, the indices are sorted
into alphabetical order. Also all dummy indices are renamed using the
symbols !1,!2,... to permit the expression to be simplified as much as
possible by reducing equivalent terms to a canonical form. For best
results exp should be fully expanded. RATEXPAND is the fastest way to
expand products and powers of sums if there are no variables in the
denominators of the terms. The GCD switch should be FALSE if gcd
cancellations are unnecessary.
- Function: DECLARE (a1, f1, a2, f2, ...)
-
gives the atom ai the flag fi. The ai's
and fi's may also be lists of atoms and flags respectively in which
case each of the atoms gets all of the properties. The possible flags
and their meanings are:
CONSTANT - makes ai a constant as is %PI.
MAINVAR - makes ai a MAINVAR. The ordering scale for atoms: numbers <
constants (e.g. %E,%PI) < scalars < other variables < mainvars.
SCALAR - makes ai a scalar.
NONSCALAR - makes ai behave as does a list or matrix with respect to
the dot operator.
NOUN - makes the function ai a noun so that it won't be evaluated
automatically.
EVFUN - makes ai known to the EV function so that it will get applied
if its name is mentioned. Initial evfuns are
FACTOR, TRIGEXPAND,
TRIGREDUCE, BFLOAT, RATSIMP, RATEXPAND, and RADCAN
EVFLAG - makes ai known to the EV function so that it will be bound to
TRUE during the execution of EV if it is mentioned. Initial evflags
are
FLOAT, PRED, SIMP, NUMER, DETOUT, EXPONENTIALIZE, DEMOIVRE,
KEEPFLOAT, LISTARITH, TRIGEXPAND, SIMPSUM, ALGEBRAIC,
RATALGDENOM, FACTORFLAG, %EMODE, LOGARC, LOGNUMER,
RADEXPAND, RATSIMPEXPONS, RATMX, RATFAC, INFEVAL, %ENUMER,
PROGRAMMODE, LOGNEGINT, LOGABS, LETRAT, HALFANGLES,
EXPTISOLATE, ISOLATE_WRT_TIMES, SUMEXPAND, CAUCHYSUM,
NUMER_PBRANCH, M1PBRANCH, DOTSCRULES, and LOGEXPAND
BINDTEST - causes ai to signal an error if it ever is used in a
computation unbound. DECLARE([var1, var2, ...], BINDTEST) causes
MACSYMA to give an error message whenever any of the vari occur
unbound in a computation.
MACSYMA currently recognizes and uses the following features of
objects:
EVEN, ODD, INTEGER, RATIONAL, IRRATIONAL, REAL, IMAGINARY,
and COMPLEX
he useful features of functions include:
INCREASING,
DECREASING, ODDFUN (odd function), EVENFUN (even function),
COMMUTATIVE (or SYMMETRIC), ANTISYMMETRIC, LASSOCIATIVE and
RASSOCIATIVE
DECLARE(F,INCREASING) is in all respects equivalent to
ASSUME(KIND(F,INCREASING))
The ai and fi may also be lists of
objects or features. The command
FEATUREP(object,feature)
may be used
to determine if an object has been DECLAREd to have "feature". See
DESCRIBE(FEATURES); .
- Function: DISOLATE (exp, var1, var2, ..., varN)
-
is similar to ISOLATE(exp, var)
(Do DESCRIBE(ISOLATE);) except that it enables the user to isolate
more than one variable simultaneously. This might be useful, for
example, if one were attempting to change variables in a multiple
integration, and that variable change involved two or more of the
integration variables. To access this function, do
LOAD(DISOL)$ . A demo is available by DEMO("disol"); .
- Function: DISPFORM (exp)
-
returns the external representation of exp (wrt its
main operator). This should be useful in conjunction with PART which
also deals with the external representation. Suppose EXP is -A .
Then the internal representation of EXP is "*"(-1,A), while the
external representation is "-"(A). DISPFORM(exp,ALL) converts the
entire expression (not just the top-level) to external format. For
example, if EXP:SIN(SQRT(X)), then FREEOF(SQRT,EXP) and
FREEOF(SQRT,DISPFORM(EXP)) give TRUE, while
FREEOF(SQRT,DISPFORM(EXP,ALL)) gives FALSE.
- Function: DISTRIB (exp)
-
distributes sums over products. It differs from EXPAND
in that it works at only the top level of an expression, i.e. it doesn't
recurse and it is faster than EXPAND. It differs from MULTTHRU in
that it expands all sums at that level. For example,
DISTRIB((A+B)*(C+D)) -> A C + A D + B C + B D
MULTTHRU ((A+B)*(C+D)) -> (A + B) C + (A + B) D
DISTRIB (1/((A+B)*(C+D))) -> 1/ ((A+B) *(C+D))
EXPAND(1/((A+B)*(C+D)),1,0) -> 1/(A C + A D + B C + B D)
- Function: DPART (exp, n1, ..., nk)
-
selects the same subexpression as PART, but
instead of just returning that subexpression as its value, it returns
the whole expression with the selected subexpression displayed inside
a box. The box is actually part of the expression.
(C1) DPART(X+Y/Z**2,1,2,1);
Y
(D1) ---- + X
2
*****
* Z *
*****
- Function: EXP (X)
-
the exponential function. It is represented internally as
%E^X.
DEMOIVRE[FALSE] - if TRUE will cause %E^(A+B*%I) to become
%E^A*(COS(B)+%I*SIN(B)) if B is free of %I. A and B are not expanded.
%EMODE[TRUE] - when TRUE %E^(%PI*%I*X) will be simplified as
follows: it will become 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 will simplify further.
For other numerical X it will become %E^(%PI*%I*Y) where Y is X-2*k
for some integer k such that ABS(Y)<1. If %EMODE is FALSE no
simplification of %E^(%PI*%I*X) will take place.
%ENUMER[FALSE] - when TRUE will cause %E to be converted into
2.718... whenever NUMER is TRUE. The default is that this conversion
will take place only if the exponent in %E^X evaluates to a number.
- Variable: EXPTISOLATE
-
default: [FALSE] if TRUE will cause ISOLATE(expr,var); to
examine exponents of atoms (like %E) which contain var.
- Variable: EXPTSUBST
-
default: [FALSE] if TRUE permits substitutions such as Y
for %E**X in %E**(A*X) to take place.
- Function: FREEOF (x1, x2, ..., exp)
-
yields TRUE if the xi do not occur in exp
and FALSE otherwise. The xi are atoms or they may be subscripted
names, functions (e.g. SIN(X) ), or operators enclosed in "s. If
'var' is a "dummy variable" of 'exp', then FREEOF(var,exp); will
return TRUE. "Dummy variables" are mathematical things like the index
of a sum or product, the limit variable, and the definite integration
variable. Example: FREEOF(I,'SUM(F(I),I,0,N)); returns TRUE. Do
EXAMPLE(FREEOF); for more examples.
- Function: GENFACT (X, Y, Z)
-
is the generalized factorial of X which is:
X*(X-Z)*(X-2*Z)*...*(X-(Y-1)*Z). Thus, for integral X,
GENFACT(X,X,1)=X! and GENFACT(X,X/2,2)=X!!
- Function: IMAGPART (exp)
-
returns the imaginary part of the expression exp.
- Function: INDICES (exp)
-
returns a list of two elements. The first is a list of
the free indices in exp (those that occur only once); the second is
the list of dummy indices in exp (those that occur exactly twice).
- Function: INFIX (op)
-
- INFIX operators are used to denote functions of two
arguments, one given before the operator and one after, e.g. A^2 .
The INFIX("x") function is a syntax extention function to declare x to
be an INFIX operator. Do DESCRIBE(SYNTAX); for more details.
- Variable: INFLAG
-
default: [FALSE] if set to TRUE, the functions for part
extraction will look at the internal form of exp. 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.
- Function: INPART (exp, n1, ..., nk)
-
is similar to PART but works on the internal
representation of the expression rather than the displayed form and
thus may be faster since no formatting is done. Care should be taken
with respect to the order of subexpressions in sums and products
(since the order of variables in the internal form is often different
from that in the displayed form) and in dealing with unary minus,
subtraction, and division (since these operators are removed from the
expression). PART(X+Y,0) or INPART(X+Y,0) yield +, though in order to
refer to the operator it must be enclosed in "s. For example
...IF INPART(D9,0)="+" THEN ...
(C1) X+Y+W*Z;
(D1) W Z + Y + X
(C2) INPART(D1,3,2);
(D2) Z
(C3) PART(D1,1,2);
(D3) Z
(C4) 'LIMIT(F(X)**G(X+1),X,0,MINUS);
G(X + 1)
(D4) LIMIT F(X)
X ->0-
(C5) INPART(%,1,2);
(D5) G(X + 1)
- Function: ISOLATE (exp, var)
-
returns exp with subexpressions which are sums and
which do not contain var replaced by intermediate expression labels
(these being atomic symbols like E1, E2, ...). This is often useful
to avoid unnecessary expansion of subexpressions which don't contain
the variable of interest. Since the intermediate labels are bound to
the subexpressions they can all be substituted back by evaluating the
expression in which they occur.
EXPTISOLATE[FALSE] if TRUE will cause ISOLATE to examine exponents of
atoms (like %E) which contain var.
ISOLATE_WRT_TIMES[FALSE] if TRUE, then ISOLATE will also isolate wrt
products. E.g. compare both settings of the switch on
ISOLATE(EXPAND((A+B+C)^2),C); .
Do EXAMPLE(ISOLATE); for examples.
- Variable: ISOLATE_WRT_TIMES
-
default: [FALSE] - if set to TRUE, then ISOLATE
will also isolate wrt products. E.g. compare both settings of the
switch on ISOLATE(EXPAND((A+B+C)^2),C); .
- Variable: LISTCONSTVARS
-
default: [FALSE] - if TRUE 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.
- Variable: LISTDUMMYVARS
-
default: [TRUE] - if FALSE, "dummy variables" in the
expression will not be included in the list returned by LISTOFVARS.
(The meaning of "dummy variables" is as given in DESCRIBE(FREEOF):
"Dummy variables" are mathematical things like the index of a sum or
product, the limit variable, and the definite integration variable.)
Example: LISTOFVARS('SUM(F(I),I,0,N)); gives [I,N] if LISTDUMMYVARS is
TRUE, and [N] if LISTDUMMYVARS is FALSE.
- Function: LISTOFVARS (exp)
-
yields a list of the variables in exp.
LISTCONSTVARS[FALSE] if TRUE will cause LISTOFVARS to include %E, %PI,
%I, and any variables declared constant in the list it returns if they
appear in exp. The default is to omit these.
(C1) LISTOFVARS(F(X[1]+Y)/G**(2+A));
(D1) [X[1], Y, A, G]
- Function: LOPOW (exp, v)
-
the lowest exponent of v which explicitly appears in
exp. Thus
LOPOW((X+Y)**2+(X+Y)**A,X+Y) ==> MIN(A,2)
.
- Function: LPART (label, expr, n1, ..., nk)
-
is similar to DPART but uses a
labelled box. A labelled box is similar to the one produced by DPART
but it has a name in the top line.
- Function: MULTTHRU (exp)
-
multiplies a factor (which should be a sum) of exp by
the other factors of exp. That is exp is f1*f2*...*fn where at least
one factor, say fi, is a sum of terms. Each term in that sum is
multiplied by the other factors in the product. (Namely all the
factors except fi). MULTTHRU does not expand exponentiated sums.
This function is the fastest way to distribute products (commutative
or noncommutative) over sums. Since quotients are represented as
products MULTTHRU can be used to divide sums by products as well.
MULTTHRU(exp1, exp2) multiplies each term in exp2 (which should be a
sum or an equation) by exp1. If exp1 is not itself a sum then this
form is equivalent to MULTTHRU(exp1*exp2).
(C1) X/(X-Y)**2-1/(X-Y)-F(X)/(X-Y)**3;
1 X F(X)
(D1) - ----- + -------- - --------
X - Y 2 3
(X - Y) (X - Y)
(C2) MULTTHRU((X-Y)**3,%);
2
(D2) - (X - Y) + X (X - Y) - F(X)
(C3) RATEXPAND(D2);
2
(D3) - Y + X Y - F(X)
(C4) ((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
(D4) --------------------------------
2
A B S
(C5) MULTTHRU(%);
10
2 A B (B + A)
(D5) - + -- + -------
S 2 A B
S
(notice that (B+A)**10 is not expanded)
(C6) MULTTHRU(A.(B+C.(D+E)+F));
(D6) A . F + A . (C . (E + D)) + A . B
(compare with similar example under EXPAND)
- Function: NOUNIFY (f)
-
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.
- Function: NTERMS (exp)
-
gives the number of terms that exp would have if it were
fully expanded out and no cancellations or combination of terms
occurred. Note that expressions like SIN(E), SQRT(E), EXP(E), etc.
count as just one term regardless of how many terms E has (if it is a
sum).
- Function: OPTIMIZE (exp)
-
returns an expression that produces the same value and
side effects as exp but does so more efficiently by avoiding the
recomputation of common subexpressions. OPTIMIZE also has the side
effect of "collapsing" its argument so that all common subexpressions
are shared.
Do EXAMPLE(OPTIMIZE); for examples.
- Variable: OPTIMPREFIX
-
default: [%] - The prefix used for generated symbols by
the OPTIMIZE command.
- Function: ORDERGREAT (V1, ..., Vn)
-
sets up aliases for the variables V1, ..., Vn
such that V1 > V2 > ... > Vn > any other variable not mentioned as an
argument. See also ORDERLESS. Caveat: do EXAMPLE(ORDERGREAT); for
some specifics.
- Function: ORDERGREATP (exp1,exp2)
-
returns TRUE if exp2 precedes exp1 in the
ordering set up with the ORDERGREAT function (see DESCRIBE(ORDERGREAT);).
- Function: ORDERLESS (V1, ..., Vn)
-
sets up aliases for the variables V1, ..., Vn
such that V1 < V2 < ... < Vn < any other variable not mentioned as an
argument. Thus the complete ordering scale is: numerical constants <
declared constants < declared scalars < first argument to ORDERLESS <
... < last argument to ORDERLESS < variables which begin with A < ...
< variables which begin with Z < last argument to ORDERGREAT <
... < first argument to ORDERGREAT < declared MAINVARs. Caveat: do
EXAMPLE(ORDERLESS); for some specifics. For another ordering scheme,
see DESCRIBE(MAINVAR);.
- Function: ORDERLESSP (exp1,exp2)
-
returns TRUE if exp1 precedes exp2 in the
ordering set up by the ORDERLESS command (see DESCRIBE(ORDERLESS);).
- Function: PART (exp, n1, ..., nk)
-
deals with the displayed form of exp. It
obtains the part of exp as specified by the indices n1,...,nk. First
part n1 of exp is obtained, then part n2 of that, etc. The result is
part nk of ... part n2 of part n1 of exp. Thus PART(Z+2*Y,2,1) yields
2. PART can be used to obtain an element of a list, a row of a
matrix, etc.
If the last argument to a Part function is a list of indices then
several subexpressions are picked out, each one corresponding to an
index of the list. Thus PART(X+Y+Z,[1,3]) is Z+X.
PIECE 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 as shown below.
If PARTSWITCH[FALSE] is set to TRUE then END is returned when a
selected part of an expression doesn't exist, otherwise an error
message is given.
For examples, do EXAMPLE(PART);
- Function: PARTITION (exp, var)
-
returns a list of two expressions. They are (1)
the factors of exp (if it is a product), the terms of exp (if it is a
sum), or the list (if it is a list) which don't contain var and, (2)
the factors, terms, or list which do.
(C1) PARTITION(2*A*X*F(X),X);
(D1) [ 2 A , X F(X) ]
(C2) PARTITION(A+B,X);
(D2) [ A + B , 0 ]
(C3) PARTITION([A,B,F(A),C],A);
(D3) [[B,C],[A,F(A)]]
- Variable: PARTSWITCH
-
default: [FALSE] - if set to TRUE then END is returned
when a selected part of an expression doesn't exist, otherwise an
error message is given.
- Function: PICKAPART (exp,depth)
-
will assign E labels to all subexpressions of
exp down to the specified integer depth. This is useful for dealing
with large expressions and for automatically assigning parts of an
expression to a variable without having to use the part functions.
(C1) EXP:(A+B)/2+SIN(X^2)/3-LOG(1+SQRT(X+1));
2
SIN(X ) B + A
(D1) - LOG(SQRT(X + 1) + 1) + ------- + -----
3 2
(C2) PICKAPART(%,1);
(E2) - LOG(SQRT(X + 1) + 1)
2
SIN(X )
(E3) -------
3
B + A
(E4) -----
2
(D4) E4 + E3 + E2
- Variable: PIECE
-
- 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.
- Function: POWERS (expr, var)
-
gives the powers of var occuring in expr. To use
it, do LOAD(POWERS);. For details on usage, do
PRINTFILE("powers.usg");.
- Function: PRODUCT (exp, ind, lo, hi)
-
gives the product of the values of exp as
the index ind varies from lo to hi. The evaluation is similar to that
of SUM. No simplification of products is available at this time.
If hi is one less than lo, we have an "empty product" and PRODUCT
returns 1 rather than erring out. Also see DESCRIBE(PRODHACK).
(C1) PRODUCT(X+I*(I+1)/2,I,1,4);
(D1) (X + 1) (X + 3) (X + 6) (X + 10)
- Function: REALPART (exp)
-
gives the real part of exp. REALPART and IMAGPART will
work on expressions involving trigonometic and hyperbolic functions,
as well as SQRT, LOG, and exponentiation.
- Function: RECTFORM (exp)
-
returns an expression of the form A + B*%I, where A and
B are purely real.
- Function: REMBOX (expr, arg)
-
removes boxes from expr according to arg. If arg
is UNLABELED then all unlabelled boxes are removed. If arg is the
name of some label then only boxes with that label are removed. If
arg is omitted then all boxes labelled and unlabelled are removed.
- Function: SUM (exp, ind, lo, hi)
-
performs a summation of the values of exp as
the index ind varies from lo to hi. If the upper and lower limits
differ by an integer then each term in the sum is evaluated and added
together. Otherwise, if the SIMPSUM [FALSE] is TRUE the result is
simplified. This simplification may sometimes be able to produce a
closed form. If SIMPSUM is FALSE or if 'SUM is used, the value is a
sum noun form which is a representation of the sigma notation used in
mathematics.
If hi is one less than lo, we have an "empty sum" and SUM returns 0
rather than erring out.
Sums may be differentiated, added, subtracted, or multiplied with some
automatic simplification being performed.
Also see DESCRIBE(SUMHACK).
CAUCHYSUM[FALSE] when TRUE causes the Cauchy product to be used when
multiplying sums together 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.
GENINDEX[I] is the alphabetic prefix used to generate the next
variable of summation.
GENSUMNUM[0] 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.
Do EXAMPLE(SUM); for examples. See also SUMCONTRACT, INTOSUM,
BASHINDICES, and NICEINDICES.
- Function: LSUM (exp, ind, list)
-
performs the sum of EXP for each element IND of the LIST.
(C10) lsum(x^i,i,[1,2,7]);
7 2
(D10) x + x + x
If the last element LIST argument does not evaluate, or does not
evaluate to a Maxima list then the answer is left in noun form
(C13) lsum(i^2,i,rootsof(x^3-1));
====
\ 2
(D13) > i
/
====
3
i in ROOTSOF(x - 1)
- special symbol: VERB
-
- the opposite of "noun", i.e. a function form which "does
something" ("action" - for most functions the usual case). E.g.
INTEGRATE integrates a function, unless it is DECLAREd to be a "noun",
in which case it represents the INTEGRAL of the function. See NOUN,
NOUNIFY, and VERBIFY.
- Function: VERBIFY (f)
-
returns the function name f in its verb form (See also VERB,
NOUN, and NOUNIFY).
- Function: APPLY_NOUNS (exp)
-
causes the application of noun forms in an
expression. E.g. EXP:'DIFF(X^2/2,X); APPLY_NOUNS(EXP); gives X. This
gives the same result as EV(EXP,NOUNS); except that it can be faster
and use less storage. It also can be used in translated code, where
EV may cause problems. Note that it is called APPLY_NOUNS, not
EV_NOUNS, because what it does is to APPLY the rules corresponding to
the noun-form operators, which is not evaluation.
- Variable: ASKEXP
-
default: [] contains the expression upon which ASKSIGN is
called. A user may enter a MACSYMA break with ^A and inspect this
expression in order to answer questions asked by ASKSIGN.
- Function: ASKINTEGER (exp,<optional-arg>)
-
exp is any valid macsyma expression
and optional-arg is EVEN,ODD,INTEGER and defaults to INTEGER if not
given. This function attempts to determine from the data-base whether
exp is EVEN, ODD or just an INTEGER. It will ask the user if it
cannot tell otherwise and attempt to install the information in the
data-base if possible.
- Function: ASKSIGN (exp)
-
first attempts to determine whether the specified
expression is positive, negative, or zero. If it cannot, it asks the
user the necessary questions to complete its deduction. The user's
answer is recorded in the data base for the duration of the current
computation (one "C-line"). The value of ASKSIGN is one of POS, NEG,
or ZERO.
- Variable: DEMOIVRE
-
default: [FALSE] if TRUE will cause
%E^(A+B*%I) ==> %E^A*(COS(B)+%I*SIN(B))
if B is free of %I. A and B are not expanded.
DEMOIVRE:TRUE; is the way to reverse the effect of
EXPONENTIALIZE:TRUE;
DEMOIVRE(exp) will cause the conversion without setting the switch or
having to re-evaluate the expression with EV.
- Variable: DOMAIN
-
default: [REAL] - if set to COMPLEX, SQRT(X^2) will remain
SQRT(X^2) instead of returning ABS(X). The notion of a "domain" of
simplification is still in its infancy, and controls little more than
this at the moment.
- Function: EXPAND (exp)
-
will cause products of sums and exponentiated sums to be
multiplied out, numerators of rational expressions which are sums to
be split into their respective terms, and multiplication (commutative
and non-commutative) to be distributed over addition at all levels of
exp. For polynomials one should usually use RATEXPAND which uses a
more efficient algorithm (see DESCRIBE(RATEXPAND);).
MAXNEGEX[1000] and MAXPOSEX[1000] control the maximum negative and
positive exponents, respectively, which will expand.
EXPAND(exp,p,n) expands exp, using p for MAXPOSEX and n for MAXNEGEX.
This is useful in order to expand part but not all of an expression.
EXPON[0] - 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[0] - 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.
The EXPAND flag used with EV (see EV) causes expansion.
The file SHARE1;FACEXP FASL contains several related functions
(FACSUM and COLLECTTERMS are two) that provide the user with the
ability to structure expressions by controlled expansion.
Brief function descriptions are available in SHARE1;FACEXP USAGE.
A demo is available by doing BATCH("facexp.mc")$ .
- Function: EXPANDWRT (exp,var1,var2,...)
-
expands exp with respect to the vari.
All products involving the vari appear explicitly. The form returned
will be free of products of sums of expressions that are not free of
the vari. The vari may be variables, operators, or expressions. By
default, denominators are not expanded, but this can be controlled by
means of the switch EXPANDWRT_DENOM. Do LOAD(STOPEX); to use this
function.
- Variable: EXPANDWRT_DENOM
-
default:[FALSE] controls the treatment of rational
expressions by EXPANDWRT. If TRUE, then both the numerator and
denominator of the expression will be expanded according to the
arguments of EXPANDWRT, but if EXPANDWRT_DENOM is FALSE, then only the
numerator will be expanded in that way. Do LOAD(STOPEX) to use.
- Function: EXPANDWRT_FACTORED (exp, var1, var2, ..., varN)
-
is similar to
EXPANDWRT, but treats expressions that are products somewhat
differently. EXPANDWRT_FACTORED will perform the required expansion
only on those factors of exp that contain the variables in its argument list
argument list. Do LOAD(STOPEX) to use this
function.
- Variable: EXPON
-
default: [0] - 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.
- Variable: EXPONENTIALIZE
-
default: [FALSE] if TRUE will cause all circular and
hyperbolic functions to be converted to exponential form. (Setting
DEMOIVRE:TRUE; will reverse the effect.)
EXPONENTIALIZE(exp) will cause the conversion to exponential form of an
expression without setting the switch or having to re-evaluate the
expression with EV.
- Variable: EXPOP
-
default: [0] - 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.
- Variable: FACTLIM
-
default: [-1] gives the highest factorial which is
automatically expanded. If it is -1 then all integers are expanded.
- Function: INTOSUM (expr)
-
will take all things that a summation is multiplied
by, and put them inside the summation. If the index is used in the
outside expression, then the function tries to find a reasonable
index, the same as it does for SUMCONTRACT. This is essentially the
reverse idea of the OUTATIVE property of summations, but note that it
does not remove this property, it only bypasses it. In some cases, a
SCANMAP(MULTTHRU,expr) may be necessary before the INTOSUM.
- declaration: LASSOCIATIVE
-
- If DECLARE(G,LASSOCIATIVE); is done, this tells the
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).
- declaration: LINEAR
-
- One of MACSYMA's OPPROPERTIES. For univariate f so
declared, "expansion" F(X+Y) -> F(X)+F(Y), F(A*X) -> A*F(X) takes
place where A is a "constant". For functions F of >=2 args,
"linearity" is defined to be as in the case of 'SUM or 'INTEGRATE,
i.e. F(A*X+B,X) -> A*F(X,X)+B*F(1,X) for A,B FREEOF X. (LINEAR is
just ADDITIVE + OUTATIVE.)
- declaration: MAINVAR
-
- 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. compare 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, resimplification e.g. with EV(expression,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.)
- Variable: MAXAPPLYDEPTH
-
default: [10000] - the maximum depth to which APPLY1
and APPLY2 will delve.
- Variable: MAXAPPLYHEIGHT
-
default: [10000] - the maximum height to which APPLYB1
will reach before giving up.
- Variable: MAXNEGEX
-
default: [1000] - the largest negative exponent which will
be expanded by the EXPAND command (see also MAXPOSEX).
- Variable: MAXPOSEX
-
default: [1000] - the largest exponent which will be
expanded with the EXPAND command (see also MAXNEGEX).
- declaration: MULTIPLICATIVE
-
- If DECLARE(F,MULTIPLICATIVE) has been executed,
then:
(1) If F is univariate, whenever the simplifier encounters F applied
to a product, F will be distributed over that product. I.e. F(X*Y);
will simplify to F(X)*F(Y).
(2) If F is a function of 2 or more arguments, multiplicativity is
defined as multiplicativity in the first argument to F, i.e.
F(G(X)*H(X),X); will simplify 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,lower-limit,upper-limit).
- Variable: NEGDISTRIB
-
default: [TRUE] - when TRUE allows -1 to be distributed
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 MACSYMA.
- Variable: NEGSUMDISPFLAG
-
default: [TRUE] - when 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.
- special symbol: NOEVAL
-
- suppresses the evaluation phase of EV. This is useful in
conjunction with other switches and in causing expressions
to be resimplified without being reevaluated.
- declaration: NOUN
-
- One of the options of the DECLARE command. It makes a
function so DECLAREd a "noun", meaning that it won't be evaluated
automatically.
- Variable: NOUNDISP
-
default: [FALSE] - if TRUE will cause NOUNs to display with
a single quote. This switch is always TRUE when displaying function
definitions.
- special symbol: NOUNS
-
(EVFLAG) when used as an option to the EV command, converts all
"noun" forms occurring in the expression being EV'd to "verbs", i.e.
evaluates them. See also NOUN, NOUNIFY, VERB, and VERBIFY.
- special symbol: NUMER
-
causes some mathematical functions (including exponentiation)
with numerical arguments to be evaluated in floating point. It causes
variables in exp which have been given numervals to be replaced by
their values. It also sets the FLOAT switch on.
- Function: NUMERVAL (var1, exp1, var2, exp2, ...)
-
declares vari to have a
numerval of expi which is evaluated and substituted for the variable
in any expressions in which the variable occurs if the NUMER flag is
TRUE. (see the EV function).
- Variable: OPPROPERTIES
-
- the list of the special operator-properties handled by
the MACSYMA simplifier: LINEAR, ADDITIVE, MULTIPLICATIVE, OUTATIVE,
EVENFUN, ODDFUN, COMMUTATIVE, SYMMETRIC, ANTISYMMETRIC, NARY,
LASSOCIATIVE, and RASSOCIATIVE.
- Variable: OPSUBST
-
default:[TRUE] - if 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.
- declaration: OUTATIVE
-
- If DECLARE(F,OUTATIVE) has been executed, then:
(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. I.e. 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.
Initially, 'SUM, 'INTEGRATE, and 'LIMIT are declared to be OUTATIVE.
- declaration: POSFUN
-
- POSitive FUNction, e.g. DECLARE(F,POSFUN); IS(F(X)>0); ->
TRUE.
- Variable: PRODHACK
-
default: [FALSE] - if set to TRUE then PRODUCT(F(I),I,3,1);
will yield 1/F(2), by the identity
PRODUCT(F(I),I,A,B) = 1/PRODUCT(F(I),I,B+1,A-1) when A>B.
- Function: RADCAN (exp)
-
simplifies exp, which can contain logs, exponentials, and
radicals, by converting it into a form which is canonical over a large
class of expressions and a given ordering of variables; that is, all
functionally equivalent forms are mapped into a unique form. For a
somewhat larger class of expressions, RADCAN produces a regular form.
Two equivalent expressions in this class will not necessarily have the
same appearance, but their difference will be simplified by RADCAN to
zero. For some expressions RADCAN can be quite time consuming. This
is the cost of exploring certain relationships among the components of
the expression for simplifications based on factoring and
partial-fraction expansions of exponents. %E_TO_NUMLOG (default:
[FALSE]) - when set to TRUE, for "r" some rational number, and "x" some
expression, %E^(r*LOG(x)) will be simplified into x^r .
RADEXPAND[TRUE] when set to FALSE will inhibit certain
transformations: RADCAN(SQRT(1-X)) will remain SQRT(1-X) and will not
become %I SQRT(X-1). RADCAN(SQRT(X^2-2*X+1)) will remain SQRT(X^2-2*X
+ 1) and will not be transformed to X- 1.
Do EXAMPLE(RADCAN); for examples.
- Variable: RADEXPAND
-
default: [TRUE] - if set to ALL will cause 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) will become 4*X .
More particularly, consider SQRT(X^2).
(a) If RADEXPAND is ALL or ASSUME(X>0) has been done, SQRT(X^2) will
become X.
(b) If RADEXPAND is TRUE and DOMAIN is REAL (its default), SQRT(X^2)
will become ABS(X).
(c) If RADEXPAND is FALSE, or RADEXPAND is TRUE and DOMAIN is COMPLEX,
SQRT(X^2) will be returned.
(The notion of DOMAIN with settings of REAL or COMPLEX is still in
its infancy. Note that its setting here only matters when RADEXPAND is
TRUE.)
- Variable: RADPRODEXPAND
-
- this switch has been renamed RADEXPAND.
- Variable: RADSUBSTFLAG
-
default: [FALSE] - if TRUE permits RATSUBST to make
substitutions such as U for SQRT(X) in X.
- declaration: RASSOCIATIVE
-
- If DECLARE(G,RASSOCIATIVE); is done, this tells the
simplifier that G is right-associative. E.g.
G(G(A,B),G(C,D)) will simplify to G(A,G(B,G(C,D))).
- Function: SCSIMP (exp,rule1, rule2,...,rulen)
-
Sequential Comparative
Simplification [Stoute]) takes an expression (its first argument) and
a set of identities, or rules (its other arguments) and tries
simplifying. If a smaller expression is obtained, the process
repeats. Otherwise after all simplifications are tried, it returns
the original answer. For examples, try EXAMPLE(SCSIMP); .
- Function: SIMP
-
causes exp to be simplified regardless of the setting of the
switch SIMP which inhibits simplification if FALSE.
- Variable: SIMPSUM
-
default: [FALSE] - if 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 'SUM is used, the value is a
sum noun form which is a representation of the sigma notation used in
mathematics.
- Function: SUMCONTRACT (expr)
-
will combine all sums of an addition that have
upper and lower bounds that differ by constants. The result will be an
expression containing one summation for each set of such summations
added to all appropriate extra terms that had to be extracted to form
this sum. SUMCONTRACT will combine all compatible sums and use one of
the indices from one of the sums if it can, and then try to form a
reasonable index if it cannot use any supplied. It may be necessary
to do an INTOSUM(expr) before the SUMCONTRACT.
- Variable: SUMEXPAND
-
default: [FALSE] if TRUE, products of sums and
exponentiated sums are converted into nested sums. For example:
SUMEXPAND:TRUE$
SUM(F(I),I,0,M)*SUM(G(J),J,0,N); ->
'SUM('SUM(F(I1)*G(I2),I2,0,N),I1,0,M)
SUM(F(I),I,0,M)^2; -> 'SUM('SUM(F(I3)*F(I4),I4,0,M),I3,0,M)
If FALSE, they are left alone. See also CAUCHYSUM.
- Variable: SUMHACK
-
default: [FALSE] - if set to TRUE then SUM(F(I),I,3,1); will
yield -F(2), by the identity SUM(F(I),I,A,B) = - SUM(F(I),I,B+1,A-1)
when A>B.
- Variable: SUMSPLITFACT
-
default: [TRUE] - if set to FALSE will cause
MINFACTORIAL to be applied after a FACTCOMB.
- declaration: SYMMETRIC
-
- If DECLARE(H,SYMMETRIC); is done, this tells the
simplifier that H is a symmetric function. E.g. H(X,Z,Y) will
simplify to H(X, Y, Z). This is the same as COMMUTATIVE.
- Function: UNKNOWN (exp)
-
returns TRUE iff exp contains an operator or function
not known to the built-in simplifier.
- Variable: IN_NETMATH [FALSE]
-
If not nil, then plot2d will output a representation of the plot
which is suitable for openplot functions.
- Function: OPENPLOT_CURVES list rest-options
-
Takes a list of curves such as
[[x1,y1,x2,y2,...],[u1,v1,u2,v2,...],..]
or
[[[x1,y1],[x2,y2],...],.. ]
and plots them. This is similar to xgraph_curves, but uses the
open plot routines.
Addtional symbol arguments may be given such as
"{xrange -3 4}"
The following plots two curves, using big points, labeling the first one
jim and the second one jane.
openplot_curves([["{plotpoints 1} {pointsize 6} {label jim}
{text {xaxislabel {joe is nice}}}"] ,
[1,2,3,4,5,6,7,8],
["{label jane} {color pink } "], [3,1,4,2,5,7]]);
Some other special keywords are xfun, color, plotpoints, linecolors,
pointsize, nolines, bargraph, labelposition, xaxislabel, and
yaxislabel.
- Function: PLOT2D (expr,range,...,options,..)
-
- Function: PLOT2D ([expr1,expr2,..,exprn],xrange,...,options,..)
-
EXPR is an expression to be plotted on y axis as
a function of 1 variable.
RANGE is of the form [var,min,max] and expr is assumed to
be an expression to be plotted against VAR.
In the second form of the function a list of expressions may
be given to plot against VAR. Truncation in the y direction will
be performed, for the default y range. It may be specified
as an option or using SET_PLOT_OPTION.
plot2d(sin(x),[x,-5,5]);
plot2d(sec(x),[x,-2,2],[y,-20,20],[nticks,200]);
- Function: xgraph_curves(list)
-
graphs the list of `point sets' given in list by using xgraph.
A point set may be of the form
[x0,y0,x1,y1,x2,y2,...] or
[[x0,y0],[x1,y1],....]
A point set may also contain symbols which give labels or other
information.
xgraph_curves([pt_set1,pt_set2,pt_set3]);
would graph the three point sets as three curves.
pt_set:append(["NoLines: True","LargePixels: true"],
[x0,y0,x1,y1,...])
would make the point set [and subsequent ones], have
no lines between points, and to use large pixels.
See the man page on xgraph for more options to specify.
pt_set:append([concat("\"","x^2+y")],[x0,y0,x1,y1,...])
would make there be a "label" of "x^2+y" for this particular
point set. The " at the beginning is what tells
xgraph this is a label.
pt_set:append([concat("TitleText: Sample Data")],[x0,...])
would make the main title of the plot be "Sample Data" instead
of "Maxima PLot".
To make a bar graph with bars which are .2 units wide, and
to plot two possibly different such bar graphs:
xgraph_curves(
[append(["BarGraph: true","NoLines: true","BarWidth: .2"],
create_list([i-.2,i^2],i,1,3)),
append(["BarGraph: true","NoLines: true","BarWidth: .2"],
create_list([i+.2,.7*i^2],i,1,3))
]);
A temporary file `xgraph-out' is used.
- Variable: PLOT_OPTIONS
-
Members of this list indicate defaults for plotting. They may
be altered using SET_PLOT_OPTION
[X, - 3, 3]
[Y, - 3, 3]
are the x range and y range respectively.
[TRANSFORM_XY, FALSE]
if not false, should be the output of
make_transform([x,y,z], [f1(x,y,z),f2(x,y,z),f3(x,y,z)])
which produces a transformation from 3 space to 3 space, which
will be applied to the graph. A built in one is polar_xy which
gives the same as
make_transform([r,th,z],[r*cos(th),r*sin(th),z])
[RUN_VIEWER,TRUE] if not false, means run the viewer software - don't just
output a data file.
[GRID,30,30] means plot3d should divide the x range into 30 intervals
and similarly the y range.
[COLOUR_Z,false] applies to colouring done with plot_format ps.
[PLOT_FORMAT,OPENMATH] is for plot3d and currently OPENMATH,
GNUPLOT, PS, and GEOMVIEW are supported.
There are good quality public domain viewers for these formats.
They are openmath, izic, gnuplot, ghostview, and geomview.
The Openmath viewer is in the distribution, and is based on tcl/tk.
The executable is `maxima/bin/omplotdata'. The viewer lets you
zoom in, slide around, and rotate (if 3 dimensional). This format is
also the one used by netmath, for making plots with Netmath. (see
`http://www.ma.utexas.edu/users/wfs/netmath.html')
geomview is from the Geometry Center at the University of Minnesota, and
is available from
`http://www.geom.umn.edu/software/download/geomview.html' or by
anonymous ftp from `ftp://ftp.geom.umn.edu/pub/software/geomview/'. It
is currently not quite as pretty as izic, but provides excellent support
for multiple objects and multiple lights.
gnuplot is everywhere as is ghostview. We also provide mgnuplot,
a tcl interface for gnuplot, which lets you rotate the plots using
the mouse and a scale.
izic is available by ftp from zenon.inria.fr. Contact one of
{fournier,kajler,mourrain}@sophia.inria.fr.
It has beautiful colour gouraud shading, and very fast wireframe. It
runs on X windows.
- Function: PLOT3D (expr,xrange,yrange,...,options,..)
-
- Function: PLOT3D ([expr1,expr2,expr3],xrange,yrange,...,options,..)
-
plot3d(2^(-u^2+v^2),[u,-5,5],[v,-7,7]);
would plot z = 2^(-u^2+v^2) with u and v varying in [-5,5] and
[-7,7] respectively, and with u on the x axis, and v on the y axis.
An example of the second pattern of arguments is
plot3d([cos(x)*(3+y*cos(x/2)),sin(x)*(3+y*cos(x/2)),y*sin(x/2)],
[x,-%pi,%pi],[y,-1,1],['grid,50,15])
which will plot a moebius band, parametrized by the 3 expressions given
as the first argument to plot3d. An additional optional argument
[grid,50,15] gives the grid number of rectangles in the x direction and
y direction.
/* REal part of z ^ 1/3 */
plot3d(r^.33*cos(th/3),[r,0,1],[th,0,6*%pi],
['grid,12,80],['PLOT_FORMAT,ps],
['TRANSFORM_XY,POLAR_TO_XY],['VIEW_DIRECTION,1,1,1.4],
['COLOUR_Z,true])
Here the View_direction indicates the direction from which we
take a projection. We actually do this from infinitely far away,
but parallel to the line from view_direction to the origin. This
is currently only used in 'ps' plot_format, since the other viewers
allow interactive rotating of the object.
Another example is a moebius band:
plot3d([cos(x)*(3+y*cos(x/2)),
sin(x)*(3+y*cos(x/2)),y*sin(x/2)],
[x,-%pi,%pi],[y,-1,1],['grid,50,15]);
or a klein bottle:
plot3d([5*cos(x)*(cos(x/2)*cos(y)+sin(x/2)*sin(2*y)+3.0) - 10.0,
-5*sin(x)*(cos(x/2)*cos(y)+sin(x/2)*sin(2*y)+3.0),
5*(-sin(x/2)*cos(y)+cos(x/2)*sin(2*y))],
[x,-%pi,%pi],[y,-%pi,%pi],['grid,40,40])
or a torus
plot3d([cos(y)*(10.0+6*cos(x)),
sin(y)*(10.0+6*cos(x)),
-6*sin(x)], [x,0,2*%pi],[y,0,2*%pi],
['grid,40,40])
We can output to gnplot 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]);
- Function: PLOT2D_PS (expr,range)
-
writes to pstream a sequence of postscript commands which
plot EXPR for RANGE.
EXPR should be an expression of 1 variable.
RANGE should be of the form [variable,min,max]
over which to plot expr.
see CLOSEPS.
- Function: CLOSEPS ()
-
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.
- Function: SET_PLOT_OPTION (option)
-
option is of the format of one of the elements of the PLOT_OPTIONS
list.
Thus
SET_PLOT_OPTION([grid,30,40])
would change the default grid used by plot3d. Note that if the symbol
grid has a value, then you should quote it here:
SET_PLOT_OPTION(['grid,30,40])
so that the value will not be substituted.
- Function: PSDRAW_CURVE (ptlist)
-
Draws a curve connecting the points in PTLIST. The latter
may be of the form [x0,y0,x1,y1,...] or [[x0,y0],[x1,y1],...]
The function JOIN is handy for taking a list of x's and a
list of y's and splicing them together.
PSDRAW_CURVE simply invokes the more primitive function
PSCURVE. Here is the definition:
(defun $psdraw_curve (lis)
(p "newpath")
($pscurve lis)
(p "stroke"))
?DRAW2D may also be used to produce a list
points1:?draw2d(1/x,[.05,10],.03)
- Function: PSCOM (com)
-
COM will be inserted in the poscript file
eg
pscom("4.5 72 mul 5.5 72 mul translate 14 14 scale");
- A file is simply an area on a particular storage device which
contains data or text. The only storage devices which are used on the
MC machine are disks and tapes. Files on the disks are figuratively
grouped into "directories". A directory is just a list of all the
files stored under a given user name. Do DESCRIBE(FILEOP); for
details of how you may inspect your files using MACSYMA. Other
commands which deal with files are: SAVE, FASSAVE, STORE, LOAD,
LOADFILE, RESTORE, UNSTORE, STRINGOUT, BATCH, BATCON, DEMO, WRITEFILE,
CLOSEFILE, DELFILE, REMFILE, and APPENDFILE.
It is possible to play back the input lines in a temporary
scroll down window, and so not lose ones current work. This can
be done by typing Function E. A numeric argument tells it the line
number to start at, otherwise it will go back about 40 lines.
- Variable: %
-
The last D-line computed by MACSYMA (whether or not it was printed
out). (See also %%.)
- Variable: %%
-
The value of the last computation performed while in a
(MACSYMA-BREAK). Also may be used in compound statements in the nth
statement to refer to the value of the (n-1)th statement. E.g.
F(N):=(INTEGRATE(X^N,X),SUBST(3,X,%%)-SUBST(2,X,%%)); is in essence
equivalent to F(N):=BLOCK([%%], %%:INTEGRATE(X^N,X),
SUBST(3,X,%%)-SUBST(2,X,%%)); This will also work for communicating
between the (n-1)th and nth (non-atomic) BLOCK statements.
- Variable: %EDISPFLAG
-
default: [FALSE] - if TRUE, MACSYMA displays %E to a
negative exponent as a quotient, i.e. %E^-X as 1/%E^X.
- Function: %TH (i)
-
is the ith previous computation. That is, if the next
expression to be computed is D(j) this is D(j-i). This is useful in
BATCH files or for referring to a group of D expressions. For
example, if SUM is initialized to 0 then FOR I:1 THRU 10 DO
SUM:SUM+%TH(I) will set SUM to the sum of the last ten D expressions.
- special symbol: "?"
-
- As prefix to a function or variable name, signifies that the
function or variable is a LISP token, not a MACSYMA token. Two
question marks typed together, ??, will flush the current MACSYMA
command line.
- Variable: ABSBOXCHAR
-
default: [!] is the character used to draw absolute value
signs around expressions which are more than a single line high.
- Function: APPENDFILE (filename1, filename2, DSK, directory)
-
is like
WRITEFILE(DSK,directory) but appends to the file whose name is
specified by the first two arguments. A subsequent CLOSEFILE will
delete the original file and rename the appended file.
- Function: BACKUP ()
-
To "back up" and see what you did, see PLAYBACK.
- Function: BATCH (file-specification)
-
reads in and evaluates MACSYMA command
lines from a file - A facility for executing command lines stored on a
disk file rather than in the usual on-line mode. This facility has
several uses, namely to provide a reservoir for working command lines,
for giving error-free demonstrations, or helping in organizing one's
thinking in complex problem-solving situations where modifications may
be done via a text editor.
A batch file consists of a set of MACSYMA command lines, each with its
terminating ; or $, which may be further separated by spaces,
carriage- returns, form-feeds, and the like.
The BATCH function calls for reading in the command lines from the
file one at a time, echoing them on the user console, and executing
them in turn. Control is returned to the user console only when
serious errors occur or when the end of the file is met. Of course,
the user may quit out of the file-processing by typing control-G at
any point.
BATCH files may be created using a text editor or by use of the
STRINGOUT command. Do DESCRIBE(STRINGOUT) for details
DESCRIBE(FILE); and DESCRIBE(FILES); have additional information on
how the file argument is interpreted, and files in general.
- Variable: BATCHKILL
-
default: [FALSE] if TRUE then the effect of all previous
BATCH files is nullified because a KILL(ALL) and a RESET() will be
done automatically when the next one is read in. If BATCHKILL is
bound to any other atom then a KILL of the value of BATCHKILL will be
done.
- Function: BATCHLOAD (file-specification)
-
Batches in the file silently without
terminal output or labels.
- Function: BATCON (argument)
-
continues BATCHing in a file which was interrupted.
- Variable: BATCOUNT
-
default: [0] may be set to the number of the last expression
BATCHed in from a file. Thus BATCON(BATCOUNT-1) will resume BATCHing
from the expression before the last BATCHed in from before.
- Variable: BOTHCASES
-
default: [TRUE] if TRUE will cause MAXIMA to retain lower
case text as well as upper case. Note, however, that the names of any
MAXIMA special variables or functions are in upper case. The default
is now TRUE since it makes code more readable, allowing users to
have names like SeriesSolve.
Because of this we make the system variables and functions all upper
case, and users may enter them however they like (in upper or lower).
But all other variables and functions are case sensitive.
When you print out your program using for example grind(fundef(f))
then you will see that the symbols like 'IF', 'SIN',... all appear
in upper case whereas non system symbols appear in the case which
you used.
This is implemented as follows: If the symbol is being encountered for
the first time, if the upper case version is in the package and has a
nontrivial function or property list, then the upper case symbol is
used, and it is recorded on the mixed case one, that the upper case
should be used in future. If a symbol is already in the package then it
is just used.
In effect this means that most old programs should continue to work,
and that new ones may write sIn, Sin, SIN, sin etc and they will
all be interpreted as SIN. However if they write MySin this will
be different from MYSIN, because MYSIN is not a system function or
variable.
SeriesSolve(f,x):=
if (f = sin) ...
and this is read as
SeriesSolve(f,x):=
IF (f = SIN) ...
- Variable: CHANGE_FILEDEFAULTS
-
default: [TRUE] on PDP10 systems, and FALSE
elsewhere. Controls whether the user doing a LOADFILE or BATCH has
his file defaults changed to the file LOADFILEd or BATCHed. The TRUE
setting is for people who like DDT-style file defaulting. The FALSE
setting is for people who like the conventions of other operating
systems, who like LISP-style file defaulting, or who write packages
which do LOADFILEs or BATCHes which should not interfere with their
user's file defaults.
- Function: CLOSEFILE (filename1, filename2)
-
closes a file opened by WRITEFILE and
gives it the name filename1 filename2. (On a Lisp Machine one need
only say CLOSEFILE();.) Thus to save a file consisting of the display
of all input and output during some part of a session with MACSYMA the
user issues a WRITEFILE, transacts with MACSYMA, then issues a
CLOSEFILE. The user can also issue the PLAYBACK function after a
WRITEFILE to save the display of previous transactions. (Note that
what is saved this way is a copy of the display of expressions not the
expressions themselves). To save the actual expression in internal
form the SAVE function may be used. The expression can then be
brought back into MACSYMA via the LOADFILE function. To save the
expression in a linear form which may then be BATCHed in later, the
STRINGOUT function is used.
- Function: COLLAPSE (expression)
-
collapses" its argument by causing all of its
common (i.e. equal) subexpressions to share (i.e. use the same cells),
thereby saving space. (COLLAPSE is a subroutine used by the OPTIMIZE
command.) Thus, calling COLLAPSE may be useful before using FASSAVE
or after loading in a SAVE file. You can collapse several expressions
together by using COLLAPSE([expr1,...,exprN])$. Similarly, you can
collapse the elements of the array A by doing
COLLAPSE(LISTARRAY('A))$.
- Function: CONCAT (arg1, arg2, ...)
-
evaluates its arguments and returns the
concatenation of their values resulting in a name or a quoted string
the type being given by that of the first argument. Thus if X is
bound to 1 and D is unbound then CONCAT(X,2)="12" and
CONCAT(D,X+1)=D2.
- Function: SCONCAT (arg1, arg2, ...)
-
evaluates its arguments and concatenates them into a string. Unlike
CONCAT, the arguments do NOT need to be atoms. The result is a Common
Lisp String.
(C5) sconcat("xx[",3,"]:",expand((x+y)^3));
(D5) xx[3]:Y^3+3*X*Y^2+3*X^2*Y+X^3
The resulting string could be used in conjunction with print.
- Variable: CURSORDISP
-
default: [TRUE] If TRUE, causes expressions to be drawn by
the displayer in logical sequence. This only works with a console
which can do cursor movement. If FALSE, expressions are simply
printed line by line. CURSORDISP is FALSE when a WRITEFILE is in
effect.
- Variable: DIREC
-
- The value of this variable is the default file directory for
SAVE, STORE, FASSAVE, and STRINGOUT. It is initialized to the user's
login name, if he