[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4. Command Line


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 Introduction to Command Line

Operator: "'"

The single quote operator ' prevents evaluation.

Applied to a symbol, the single quote prevents evaluation of the symbol.

Applied to a function call, the single quote prevents evaluation of the function call, although the arguments of the function are still evaluated (if evaluation is not otherwise prevented). The result is the noun form of the function call.

Applied to a parenthesized expression, the single quote prevents evaluation of all symbols and function calls in the expression. E.g., '(f(x)) means do not evaluate the expression f(x). 'f(x) (with the single quote applied to f instead of f(x)) means return the noun form of f applied to [x].

The single quote does not prevent simplification.

When the global flag noundisp is true, nouns display with a single quote. This switch is always true when displaying function definitions.

See also the quote-quote operator '' and nouns.

Examples:

Applied to a symbol, the single quote prevents evaluation of the symbol.

 
(%i1) aa: 1024;
(%o1)                         1024
(%i2) aa^2;
(%o2)                        1048576
(%i3) 'aa^2;
                                 2
(%o3)                          aa
(%i4) ''%;
(%o4)                        1048576

Applied to a function call, the single quote prevents evaluation of the function call. The result is the noun form of the function call.

 
(%i1) x0: 5;
(%o1)                           5
(%i2) x1: 7;
(%o2)                           7
(%i3) integrate (x^2, x, x0, x1);
                               218
(%o3)                          ---
                                3
(%i4) 'integrate (x^2, x, x0, x1);
                             7
                            /
                            [   2
(%o4)                       I  x  dx
                            ]
                            /
                             5
(%i5) %, nouns;
                               218
(%o5)                          ---
                                3

Applied to a parenthesized expression, the single quote prevents evaluation of all symbols and function calls in the expression.

 
(%i1) aa: 1024;
(%o1)                         1024
(%i2) bb: 19;
(%o2)                          19
(%i3) sqrt(aa) + bb;
(%o3)                          51
(%i4) '(sqrt(aa) + bb);
(%o4)                     bb + sqrt(aa)
(%i5) ''%;
(%o5)                          51

The single quote does not prevent simplification.

 
(%i1) sin (17 * %pi) + cos (17 * %pi);
(%o1)                          - 1
(%i2) '(sin (17 * %pi) + cos (17 * %pi));
(%o2)                          - 1
Operator: "''"

The '' (double single quotes) operator causes an extra evaluation to occur. E.g., ''%i4 will re-evaluate input line %i4. ''(f(x)) means evaluate the expression f(x) an extra time. ''f(x) (with the double single quotes applied to f instead of f(x)) means return the verb form of f applied to [x].


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2 Definitions for Command Line

Function: alias (new_name_1, old_name_1, ..., new_name_n, old_name_n)

provides an alternate name for a (user or system) function, variable, array, etc. Any even number of arguments may be used.

Option variable: debugmode

Default value: false

When a Maxima error occurs, Maxima will start the debugger if debugmode is true. The user may enter commands to examine the call stack, set breakpoints, step through Maxima code, and so on. See debugging for a list of debugger commands.

Enabling debugmode will not catch Lisp errors.

Function: ev (expr, arg_1, ..., arg_n)

Evaluates the expression expr in the environment specified by the arguments arg_1, ..., arg_n. The arguments are switches (Boolean flags), assignments, equations, and functions. ev returns the result (another expression) of the evaluation.

The evaluation is carried out in steps, as follows.

  1. First the environment is set up by scanning the arguments which may be any or all of the following.
    • simp causes expr 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 expr to be resimplified without being reevaluated.
    • nouns causes the evaluation of noun forms (typically unevaluated functions such as 'integrate or 'diff) in expr.
    • 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 expr to have their determinant kept outside of the inverse rather than dividing through each element.
    • diff causes all differentiations indicated in expr to be performed.
    • derivlist (x, y, z, ...) 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 expr 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 expr to occur. (See step (5) below.)
    • A where A is an atom declared to be an evaluation flag (see evflag) causes A to be bound to true during the evaluation of expr.
    • V: expression (or alternately V=expression) causes V to be bound to the value of expression during the evaluation of expr. Note that if V is a Maxima option, then expression is used for its value during the evaluation of expr. 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.
    • F where F, a function name, has been declared to be an evaluation function (see evfun) causes F to be applied to expr.
    • Any other function names (e.g., sum) cause evaluation of occurrences of those names in expr as though they were verbs.
    • In addition a function occurring in expr (say F(x)) may be defined locally for the purpose of this evaluation of expr by giving F(x) := expression 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., [%t1, %t2] where %t1 and %t2 are equations) such as that returned by solve.

    The arguments of ev may be given in any order with the exception of substitution equations which are handled in sequence, left to right, and evaluation functions which are composed, e.g., ev (expr, ratsimp, realpart) is handled as realpart (ratsimp (expr)).

    The simp, numer, float, and pred switches may also be set locally in a block, or globally in Maxima so that they will remain in effect until being reset.

    If expr is a canonical rational expression (CRE), then the expression returned by ev is also a CRE, 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 arguments or in the value of some arguments if the value is an equation. The variables (subscripted variables which do not have associated array functions as well as non-subscripted variables) in the expression expr are replaced by their global values, except for those appearing in this list. Usually, expr is just a label or % (as in %i2 in the example 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 arguments, they are carried out now.
  4. The resulting expression is then re-evaluated (unless one of the arguments was noeval) and simplified according to the arguments. Note that any function calls in expr 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 arguments was eval, steps (3) and (4) are repeated.

Examples

 
(%i1) sin(x) + cos(y) + (w+1)^2 + 'diff (sin(w), w);
                                     d                    2
(%o1)              cos(y) + sin(x) + -- (sin(w)) + (w + 1)
                                     dw
(%i2) ev (%, sin, expand, diff, x=2, y=1);
                          2
(%o2)           cos(w) + w  + 2 w + cos(1) + 1.909297426825682

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

 
expr, arg_1, ..., arg_n

This is not permitted as part of another expression, e.g., in functions, blocks, etc.

Notice the parallel binding process in the following example.

 
(%i3) programmode: false;
(%o3)                                false
(%i4) x+y, x: a+y, y: 2;
(%o4)                              y + a + 2
(%i5) 2*x - 3*y = 3$
(%i6) -3*x + 2*y = -4$
(%i7) solve ([%o5, %o6]);
Solution

                                          1
(%t7)                               y = - -
                                          5

                                         6
(%t8)                                x = -
                                         5
(%o8)                            [[%t7, %t8]]
(%i8) %o6, %o8;
(%o8)                              - 4 = - 4
(%i9) x + 1/x > gamma (1/2);
                                   1
(%o9)                          x + - > sqrt(%pi)
                                   x
(%i10) %, numer, x=1/2;
(%o10)                      2.5 > 1.772453850905516
(%i11) %, pred;
(%o11)                               true
Property: evflag

Some Boolean flags have the evflag property. ev treats such flags specially. A flag with the evflag property will be bound to true during the execution of ev if it is mentioned in the call to ev. For example, demoivre and ratfac are bound to true during the call ev (%, demoivre, ratfac).

The flags which have the evflag property are: algebraic, cauchysum, demoivre, dotscrules, %emode, %enumer, exponentialize, exptisolate, factorflag, float, halfangles, infeval, isolate_wrt_times, keepfloat, letrat, listarith, logabs, logarc, logexpand, lognegint, lognumer, m1pbranch, numer_pbranch, programmode, radexpand, ratalgdenom, ratfac, ratmx, ratsimpexpons, simp, simpsum, sumexpand, and trigexpand.

The construct :lisp (putprop '|$foo| t 'evflag) gives the evflag property to the variable foo, so foo is bound to true during the call ev (%, foo). Equivalently, ev (%, foo:true) has the same effect.

Property: evfun

Some functions have the evfun property. ev treats such functions specially. A function with the evfun property will be applied during the execution of ev if it is mentioned in the call to ev. For example, ratsimp and radcan will be applied during the call ev (%, ratsimp, radcan).

The functions which have the evfun property are: bfloat, factor, fullratsimp, logcontract, polarform, radcan, ratexpand, ratsimp, rectform, rootscontract, trigexpand, and trigreduce.

The construct :lisp (putprop '|$foo| t 'evfun) gives the evfun property to the function foo, so that foo is applied during the call ev (%, foo). Equivalently, foo (ev (%)) has the same effect.

Option variable: infeval

Enables "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.

Function: kill (symbol_1, ..., symbol_n)
Function: kill (labels)
Function: kill (inlabels, outlabels, linelabels)
Function: kill (n)
Function: kill ([m, n])
Function: kill (values, functions, arrays, ...)
Function: kill (all)
Function: kill (allbut (symbol_1, ..., symbol_n))

Removes all bindings (value, function, array, or rule) from the arguments symbol_1, ..., symbol_n. An argument may be a single array element or subscripted function.

Several special arguments are recognized. Different kinds of arguments may be combined, e.g., kill (inlabels, functions, allbut (foo, bar)).

kill (labels) unbinds all input, output, and intermediate expression labels created so far. kill (inlabels) unbinds only input labels which begin with the current value of inchar. Likewise, kill (outlabels) unbinds only output labels which begin with the current value of outchar, and kill (linelabels) unbinds only intermediate expression labels which begin with the current value of linechar.

kill (n), where n is an integer, unbinds the n most recent input and output labels.

kill ([m, n]) unbinds input and output labels m through n.

kill (infolist), where infolist is any item in infolists (such as values, functions, or arrays) unbinds all items in infolist. See also infolists.

kill (all) unbinds all items on all infolists. kill (all) does not reset global variables to their default values; see reset on this point.

kill (allbut (symbol_1, ..., symbol_n)) unbinds all items on all infolists except for symbol_1, ..., symbol_n. kill (allbut (infolist)) unbinds all items except for the ones on infolist, where infolist is values, functions, arrays, etc.

The memory taken up by a bound property is not released until all symbols are unbound from it. In particular, to release the memory taken up by the value of a symbol, one unbinds the output label which shows the bound value, as well as unbinding the symbol itself.

kill quotes its arguments. The double single quotes operator, '', defeats the quotation.

kill (symbol) unbinds all properties of symbol. In contrast, remvalue, remfunction, remarray, and remrule unbind a specific property.

kill always returns done, even if an argument has no binding.

Function: labels (symbol)
System variable: labels

Returns the list of input, output, or intermediate expression labels which begin with symbol. Typically symbol is the value of inchar, outchar, or linechar. The label character may be given with or without a percent sign, so, for example, i and %i yield the same result.

If no labels begin with symbol, labels returns an empty list.

The function labels quotes its argument. The double single quotes operator '' defeats quotation. For example, labels (''inchar) returns the input labels which begin with the current input label character.

The variable labels is the list of input, output, and intermediate expression labels, including all previous labels if inchar, outchar, or linechar were redefined.

By default, Maxima displays the result of each user input expression, giving the result an output label. The output display is suppressed by terminating the input with $ (dollar sign) instead of ; (semicolon). An output label is constructed and bound to the result, but not displayed, and the label may be referenced in the same way as displayed output labels. See also %, %%, and %th.

Intermediate expression labels can be generated by some functions. The flag programmode controls whether solve and some other functions generate intermediate expression labels instead of returning a list of expressions. Some other functions, such as ldisplay, always generate intermediate expression labels.

See also inchar, outchar, linechar, and infolists.

System variable: linenum

The line number of the current pair of input and output expressions.

System variable: myoptions

Default value: []

myoptions is the list of all options ever reset by the user, whether or not they get reset to their default value.

Option variable: nolabels

Default value: false

When nolabels is true, input and output result labels (%i and %o, respectively) are displayed, but the labels are not bound to results, and the labels are not appended to the labels list. Since labels are not bound to results, garbage collection can recover the memory taken up by the results.

Otherwise input and output result labels are bound to results, and the labels are appended to the labels list.

Intermediate expression labels (%t) are not affected by nolabels; whether nolabels is true or false, intermediate expression labels are bound and appended to the labels list.

See also batch, load, and labels.

Option variable: optionset

Default value: false

When optionset is true, Maxima prints out a message whenever a Maxima option is reset. This is useful if the user is doubtful of the spelling of some option and wants to make sure that the variable he assigned a value to was truly an option variable.

Function: playback ()
Function: playback (n)
Function: playback ([m, n])
Function: playback ([m])
Function: playback (input)
Function: playback (slow)
Function: playback (time)
Function: playback (grind)

Displays input, output, and intermediate expressions, without recomputing them. playback only displays the expressions bound to labels; any other output (such as text printed by print or describe, or error messages) is not displayed. See also labels.

playback quotes its arguments. The double single quotes operator, '', defeats quotation. playback always returns done.

playback () (with no arguments) displays all input, output, and intermediate expressions generated so far. An output expression is displayed even if it was suppressed by the $ terminator when it was originally computed.

playback (n) displays the most recent n expressions. Each input, output, and intermediate expression counts as one.

playback ([m, n]) displays input, output, and intermediate expressions with numbers from m through n, inclusive.

playback ([m]) is equivalent to playback ([m, m]); this usually prints one pair of input and output expressions.

playback (input) displays all input expressions generated so far.

playback (slow) pauses between expressions and waits for the user to press enter. This behavior is similar to demo. playback (slow) is useful in conjunction with save or stringout when creating a secondary-storage file in order to pick out useful expressions.

playback (time) displays the computation time for each expression.

playback (grind) displays input expressions in the same format as the grind function. Output expressions are not affected by the grind option. See grind.

Arguments may be combined, e.g., playback ([5, 10], grind, time, slow).

Function: printprops (a, i)
Function: printprops ([a_1, ..., a_n], i)
Function: printprops (all, i)

Displays 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.

Option variable: prompt

Default value: _

prompt is the prompt symbol of the demo function, playback (slow) mode, and the Maxima break loop (as invoked by break).

Function: quit ()

Terminates the Maxima session. Note that the function must be invoked as quit(); or quit()$, not quit by itself.

To stop a lengthy computation, type control-C. The default action is to return to the Maxima prompt. If *debugger-hook* is nil, control-C opens the Lisp debugger. See also debugging.

Function: remfunction (f_1, ..., f_n)
Function: remfunction (all)

Unbinds the function definitions of the symbols f_1, ..., f_n. The arguments may be the names of ordinary functions (created by := or define) or macro functions (created by ::=).

remfunction (all) unbinds all function definitions.

remfunction quotes its arguments.

remfunction returns a list of the symbols for which the function definition was unbound. false is returned in place of any symbol for which there is no function definition.

Function: reset ()

Resets many global variables and options, and some other variables, to their default values.

reset processes the variables on the Lisp list *variable-initial-values*. The Lisp macro defmvar puts variables on this list (among other actions). Many, but not all, global variables and options are defined by defmvar, and some variables defined by defmvar are not global variables or options.

Option variable: showtime

Default value: false

When showtime is true, the computation time and elapsed time is printed with each output expression.

The computation time is always recorded, so time and playback can display the computation time even when showtime is false.

See also timer.

Function: sstatus (feature, package)

Sets the status of feature in package. After sstatus (feature, package) is executed, status (feature, package) returns true. This can be useful for package writers, to keep track of what features they have loaded in.

Function: to_lisp ()

Enters the Lisp system under Maxima. (to-maxima) returns to Maxima.

System variable: values

Initial value: []

values is a list of all bound user variables (not Maxima options or switches). The list comprises symbols bound by : , ::, or :=.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated on March, 19 2006 using texi2html 1.76.