Next: , Previous:   [Contents][Index]

4 Command Line


4.1 Introduction to Command Line


4.2 Functions and Variables for Command Line

System variable: __

__ is the input expression currently being evaluated. That is, while an input expression expr is being evaluated, __ is expr.

__ is assigned the input expression before the input is simplified or evaluated. However, the value of __ is simplified (but not evaluated) when it is displayed.

__ is recognized by batch and load. In a file processed by batch, __ has the same meaning as at the interactive prompt. In a file processed by load, __ is bound to the input expression most recently entered at the interactive prompt or in a batch file; __ is not bound to the input expressions in the file being processed. In particular, when load (filename) is called from the interactive prompt, __ is bound to load (filename) while the file is being processed.

See also _ and %.

Examples:

(%i1) print ("I was called as", __);
I was called as print(I was called as, __) 
(%o1)              print(I was called as, __)
(%i2) foo (__);
(%o2)                     foo(foo(__))
(%i3) g (x) := (print ("Current input expression =", __), 0);
(%o3) g(x) := (print("Current input expression =", __), 0)
(%i4) [aa : 1, bb : 2, cc : 3];
(%o4)                       [1, 2, 3]
(%i5) (aa + bb + cc)/(dd + ee + g(x));
                            cc + bb + aa
Current input expression = -------------- 
                           g(x) + ee + dd
                                6
(%o5)                        -------
                             ee + dd
Categories: Global variables ·
System variable: _

_ is the most recent input expression (e.g., %i1, %i2, %i3, …).

_ is assigned the input expression before the input is simplified or evaluated. However, the value of _ is simplified (but not evaluated) when it is displayed.

_ is recognized by batch and load. In a file processed by batch, _ has the same meaning as at the interactive prompt. In a file processed by load, _ is bound to the input expression most recently evaluated at the interactive prompt or in a batch file; _ is not bound to the input expressions in the file being processed.

See also __ and %.

Examples:

(%i1) 13 + 29;
(%o1)                          42
(%i2) :lisp $_
((MPLUS) 13 29)
(%i2) _;
(%o2)                          42
(%i3) sin (%pi/2);
(%o3)                           1
(%i4) :lisp $_
((%SIN) ((MQUOTIENT) $%PI 2))
(%i4) _;
(%o4)                           1
(%i5) a: 13$
(%i6) b: 29$
(%i7) a + b;
(%o7)                          42
(%i8) :lisp $_
((MPLUS) $A $B)
(%i8) _;
(%o8)                         b + a
(%i9) a + b;
(%o9)                          42
(%i10) ev (_);
(%o10)                         42
System variable: %

% is the output expression (e.g., %o1, %o2, %o3, …) most recently computed by Maxima, whether or not it was displayed.

% is recognized by batch and load. In a file processed by batch, % has the same meaning as at the interactive prompt. In a file processed by load, % is bound to the output expression most recently computed at the interactive prompt or in a batch file; % is not bound to output expressions in the file being processed.

See also _, %%, and %th.

System variable: %%

In compound statements, namely block, lambda, or (s_1, ..., s_n), %% is the value of the previous statement.

At the first statement in a compound statement, or outside of a compound statement, %% is undefined.

%% is recognized by batch and load, and it has the same meaning as at the interactive prompt.

See also %.

Examples:

The following two examples yield the same result.

(%i1) block (integrate (x^5, x), ev (%%, x=2) - ev (%%, x=1));
                               21
(%o1)                          --
                               2
(%i2) block ([prev], prev: integrate (x^5, x),
               ev (prev, x=2) - ev (prev, x=1));
                               21
(%o2)                          --
                               2

A compound statement may comprise other compound statements. Whether a statement be simple or compound, %% is the value of the previous statement.

(%i3) block (block (a^n, %%*42), %%/6);
                                 n
(%o3)                         7 a

Within a compound statement, the value of %% may be inspected at a break prompt, which is opened by executing the break function. For example, entering %%; in the following example yields 42.

(%i4) block (a: 42, break ())$

Entering a Maxima break point. Type 'exit;' to resume.
_%%;
42
_
Categories: Global variables ·
Function: %th (i)

The value of the i’th previous output expression. That is, if the next expression to be computed is the n’th output, %th (m) is the (n - m)’th output.

%th is recognized by batch and load. In a file processed by batch, %th has the same meaning as at the interactive prompt. In a file processed by load, %th refers to output expressions most recently computed at the interactive prompt or in a batch file; %th does not refer to output expressions in the file being processed.

See also % and %%.

Example:

%th is useful in batch files or for referring to a group of output expressions. This example sets s to the sum of the last five output expressions.

(%i1) 1;2;3;4;5;
(%o1)                           1
(%o2)                           2
(%o3)                           3
(%o4)                           4
(%o5)                           5
(%i6) block (s: 0, for i:1 thru 5 do s: s + %th(i), s);
(%o6)                          15
Categories: Console interaction ·
Special symbol: ?

As prefix to a function or variable name, ? signifies that the name is a Lisp name, not a Maxima name. For example, ?round signifies the Lisp function ROUND. See Lisp and Maxima for more on this point.

The notation ? word (a question mark followed a word, separated by whitespace) is equivalent to describe("word"). The question mark must occur at the beginning of an input line; otherwise it is not recognized as a request for documentation. See also describe.

Categories: Help · Console interaction ·
Special symbol: ??

The notation ?? word (?? followed a word, separated by whitespace) is equivalent to describe("word", inexact). The question mark must occur at the beginning of an input line; otherwise it is not recognized as a request for documentation. See also describe.

Categories: Help · Console interaction ·
Input terminator: $

The dollar sign $ terminates an input expression, and the most recent output % and an output label, e.g. %o1, are assigned the result, but the result is not displayed.

See also ;.

Example:

(%i1) 1 + 2 + 3 $
(%i2) %;
(%o2)                           6
(%i3) %o1;
(%o3)                           6
Input terminator: ;

The semicolon ; terminates an input expression, and the resulting output is displayed.

See also $.

Example:

(%i1) 1 + 2 + 3;
(%o1)                           6
Option variable: inchar

Default value: %i

inchar is the prefix of the labels of expressions entered by the user. Maxima automatically constructs a label for each input expression by concatenating inchar and linenum.

inchar may be assigned any string or symbol, not necessarily a single character. Because Maxima internally takes into account only the first char of the prefix, the prefixes inchar, outchar, and linechar should have a different first char. Otherwise some commands like kill(inlabels) do not work as expected.

See also labels.

Example:

(%i1) inchar: "input";
(%o1)                         input
(input2) expand((a+b)^3);
                     3        2      2      3
(%o2)               b  + 3 a b  + 3 a  b + a
System variable: infolists

Default value: []

infolists is a list of the names of all of the information lists in Maxima. These are:

labels

All bound %i, %o, and %t labels.

values

All bound atoms which are user variables, not Maxima options or switches, created by : or :: or functional binding.

functions

All user-defined functions, created by := or define.

arrays

All arrays, hashed arrays and memoizing functions.

macros

All user-defined macro functions, created by ::=.

myoptions

All options ever reset by the user (whether or not they are later reset to their default values).

rules

All user-defined pattern matching and simplification rules, created by tellsimp, tellsimpafter, defmatch, or defrule.

aliases

All atoms which have a user-defined alias, created by the alias, ordergreat, orderless functions or by declaring the atom as a noun with declare.

dependencies

All atoms which have functional dependencies, created by the depends, dependencies, or gradef functions.

gradefs

All functions which have user-defined derivatives, created by the gradef function.

props

All atoms which have any property other than those mentioned above, such as properties established by atvalue or matchdeclare, etc., as well as properties established in the declare function.

structures

All structs defined using defstruct.

let_rule_packages

All user-defined let rule packages plus the special package default_let_rule_package. (default_let_rule_package is the name of the rule package used when one is not explicitly set by the user.)

Function: kill
    kill (a_1, …, a_n)
    kill (labels)
    kill (inlabels, outlabels, linelabels)
    kill (n)
    kill ([m, n])
    kill (values, functions, arrays, …)
    kill (all)
    kill (allbut (a_1, …, a_n))

Removes all bindings (value, function, array, or rule) from the arguments a_1, …, a_n. An argument a_k may be a symbol or a single array element. When a_k is a single array element, kill unbinds that element without affecting any other elements of the array.

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 (a_1, ..., a_n)) unbinds all items on all infolists except for a_1, …, a_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 quote-quote operator '' defeats quotation.

kill (symbol) unbinds all properties of symbol. In contrast, the functions remvalue, remfunction, remarray, and remrule unbind a specific property. Note that facts declared by assume don’t require a symbol they apply to, therefore aren’t stored as properties of symbols and therefore aren’t affected by kill.

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

Function: labels (symbol)

Returns the list of input, output, or intermediate expression labels which begin with symbol. Typically symbol is the value of inchar, outchar, or linechar. If no labels begin with symbol, labels returns an empty list.

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 option variable 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: labels

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

Option variable: linechar

Default value: %t

linechar is the prefix of the labels of intermediate expressions generated by Maxima. Maxima constructs a label for each intermediate expression (if displayed) by concatenating linechar and linenum.

linechar may be assigned any string or symbol, not necessarily a single character. Because Maxima internally takes into account only the first char of the prefix, the prefixes inchar, outchar, and linechar should have a different first char. Otherwise some commands like kill(inlabels) do not work as expected.

Intermediate expressions might or might not be displayed. See programmode and labels.

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.

Categories: Global flags · Session management ·
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.

Example:

(%i1) optionset:true;
assignment: assigning to option optionset
(%o1)                         true
(%i2) gamma_expand:true;
assignment: assigning to option gamma_expand
(%o2)                         true
Option variable: outchar

Default value: %o

outchar is the prefix of the labels of expressions computed by Maxima. Maxima automatically constructs a label for each computed expression by concatenating outchar and linenum.

outchar may be assigned any string or symbol, not necessarily a single character. Because Maxima internally takes into account only the first char of the prefix, the prefixes inchar, outchar and linechar should have a different first char. Otherwise some commands like kill(inlabels) do not work as expected.

See also labels.

Example:

(%i1) outchar: "output";
(output1)                    output
(%i2) expand((a+b)^3);
                     3        2      2      3
(output2)           b  + 3 a b  + 3 a  b + a
Function: playback
    playback ()
    playback (n)
    playback ([m, n])
    playback ([m])
    playback (input)
    playback (slow)
    playback (time)
    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 quote-quote 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).

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 ([exit-code])

Terminates the Maxima session. Note that the function must be invoked as quit(); or quit()$, not quit by itself. quit supports returning an exit code to the shell for Lisps and OSes that support exit codes. The default exit code is 0 (usually indicating no errors encountered). Thus quit(1) indicates to the shell that maxima exited with some kind of failure. This is useful in scripts where maxima can indicate to the shell that maxima failed to compute something or some other bad thing happened.

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.

Categories: Console interaction ·
Function: read (expr_1, …, expr_n)

Prints expr_1, …, expr_n, then reads one expression from the console and returns the evaluated expression. The expression is terminated with a semicolon ; or dollar sign $.

See also readonly

Example:

(%i1) foo: 42$ 
(%i2) foo: read ("foo is", foo, " -- enter new value.")$
foo is 42  -- enter new value. 
(a+b)^3;
(%i3) foo;
                                     3
(%o3)                         (b + a)
Categories: Console interaction ·
Function: readonly (expr_1, …, expr_n)

Prints expr_1, …, expr_n, then reads one expression from the console and returns the expression (without evaluation). The expression is terminated with a ; (semicolon) or $ (dollar sign).

See also read.

Examples:

(%i1) aa: 7$
(%i2) foo: readonly ("Enter an expression:");
Enter an expression: 
2^aa;
                                  aa
(%o2)                            2
(%i3) foo: read ("Enter an expression:");
Enter an expression: 
2^aa;
(%o3)                            128
Categories: Console interaction ·
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.

Categories: Session management ·
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: to_lisp ()

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

Example:

Define a function and enter the Lisp system under Maxima. The definition is inspected on the property list, then the function definition is extracted, factored and stored in the variable $result. The variable can be used in Maxima after returning to Maxima.

(%i1) f(x):=x^2+x;
                                  2
(%o1)                    f(x) := x  + x
(%i2) to_lisp();
Type (to-maxima) to restart, ($quit) to quit Maxima.
MAXIMA> (symbol-plist '$f)
(MPROPS (NIL MEXPR ((LAMBDA) ((MLIST) $X) 
                             ((MPLUS) ((MEXPT) $X 2) $X))))
MAXIMA> (setq $result ($factor (caddr (mget '$f 'mexpr))))
((MTIMES SIMP FACTORED) $X ((MPLUS SIMP IRREDUCIBLE) 1 $X))
MAXIMA> (to-maxima)
Returning to Maxima
(%o2)                         true
(%i3) result;
(%o3)                       x (x + 1)
Categories: Console interaction ·
Function: eval_string_lisp (str)

Sequentially read lisp forms from the string str and evaluate them. Any values produced from the last form are returned as a Maxima list.

Examples:

(%i1) eval_string_lisp ("");
(%o1) []
(%i2) eval_string_lisp ("(values)");
(%o2) []
(%i3) eval_string_lisp ("69");
(%o3) [69]
(%i4) eval_string_lisp ("1 2 3");
(%o4) [3]
(%i5) eval_string_lisp ("(values 1 2 3)");
(%o5) [1,2,3]
(%i6) eval_string_lisp ("(defun $foo (x) (* 2 x))");
(%o6) [foo]
(%i7) foo (5);
(%o7) 10

See also eval_string.

Categories: Debugging · Evaluation ·
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 ::.

If the value of a variable is removed with the commands kill, remove, or remvalue the variable is deleted from values.

See functions for a list of user defined functions.

Examples:

First, values shows the symbols a, b, and c, but not d, it is not bound to a value, and not the user function f. The values are removed from the variables. values is the empty list.

(%i1) [a:99, b:: a-90, c:a-b, d, f(x):=x^2];
                                           2
(%o1)              [99, 9, 90, d, f(x) := x ]
(%i2) values;
(%o2)                       [a, b, c]
(%i3) [kill(a), remove(b,value), remvalue(c)];
(%o3)                   [done, done, [c]]
(%i4) values;
(%o4)                          []
Categories: Evaluation · Global variables ·

4.3 Functions and Variables for Display

Option variable: %edispflag

Default value: false

When %edispflag is true, Maxima displays %e to a negative exponent as a quotient. For example, %e^-x is displayed as 1/%e^x. See also exptdispflag.

Example:

(%i1) %e^-10;
                               - 10
(%o1)                        %e
(%i2) %edispflag:true$
(%i3) %e^-10;
                               1
(%o3)                         ----
                                10
                              %e
Option variable: absboxchar

Default value: !

absboxchar is the character used to draw absolute value signs around expressions which are more than one line tall.

Example:

(%i1) abs((x^3+1));
                            ! 3    !
(%o1)                       !x  + 1!
Function: declare_index_properties (a, [p_1, p_2, p_3, ...])
Function: declare_index_properties ([a, b, c, ...], [p_1, p_2, p_3, ...])
Symbol: postsubscript
Symbol: postsuperscript
Symbol: presuperscript
Symbol: presubscript

Declares the properties of indices applied to the symbol a or each of the of symbols a, b, c, .... If multiple symbols are given, the whole list of properties applies to each symbol.

Given a symbol with indices, a[i_1, i_2, i_3, ...], the k-th property p_k applies to the k-th index i_k. There may be any number of index properties, in any order.

Each property p_k must one of these four recognized properties: postsubscript, postsuperscript, presuperscript, or presubscript, to denote indices which are displayed, respectively, to the right and below, to the right and above, to the left and above, or to the left and below.

Index properties apply only to the 2-dimensional display of indexed variables (i.e., when display2d is true) and TeX output via tex. Otherwise, index properties are ignored. Index properties do not change the input of indexed variables, do not change the algebraic properties of indexed variables, and do not change the 1-dimensional display of indexed variables.

declare_index_properties quotes (does not evaluate) its arguments.

remove_index_properties removes index properties. kill also removes index properties (and all other properties).

get_index_properties retrieves index properties.

Examples:

Given a symbol with indices, a[i_1, i_2, i_3, ...], the k-th property p_k applies to the k-th index i_k. There may be any number of index properties, in any order.

(%i1) declare_index_properties (A, [presubscript, postsubscript]);
(%o1)                         done
(%i2) declare_index_properties (B, [postsuperscript, postsuperscript,
 presuperscript]);
(%o2)                         done
(%i3) declare_index_properties (C, [postsuperscript, presubscript,
 presubscript, presuperscript]);
(%o3)                         done
(%i4) A[w, x];
(%o4)                           A
                               w x
(%i5) B[w, x, y];
                             y w, x
(%o5)                         B
(%i6) C[w, x, y, z];
                                z w
(%o6)                            C
                             x, y

Index properties apply only to the 2-dimensional display of indexed variables and TeX output. Otherwise, index properties are ignored.

(%i1) declare_index_properties (A, [presubscript, postsubscript]);
(%o1)                         done
(%i2) A[w, x];
(%o2)                           A
                               w x
(%i3) tex (A[w, x]);
$${}_{w}A_{x}$$
(%o3)                         false
(%i4) display2d: false $
(%i5) A[w, x];
(%o5) A[w,x]
(%i6) display2d: true $
(%i7) grind (A[w, x]);
A[w,x]$
(%o7)                         done
(%i8) stringdisp: true $
(%i9) string (A[w, x]);
(%o9)                       "A[w,x]"
Function: get_index_properties (a)

Returns the properties for a established by declare_index_properties.

See also remove_index_properties.

Function: remove_index_properties (a, b, c, ...)

Removes the properties established by declare_index_properties. All index properties are removed from each symbol a, b, c, ....

remove_index_properties quotes (does not evaluate) its arguments.

Symbol property: display_index_separator

When a symbol A has index display properties declared via declare_index_properties, the value of the property display_index_separator is the string or other expression which is displayed between indices.

The value of display_index_separator is assigned by put(A, S, display_index_separator), where S is a string or other expression. The assigned value is retrieved by get(A, display_index_separator).

The display index separator S can be a string, including an empty string, or false, indicating the default separator, or any expression. If not a string and not false, the property value is coerced to a string via string.

If no display index separator is assigned, the default separator is used. The default separator is a comma. There is no way to change the default separator.

Each symbol has its own value of display_index_separator.

See also put, get, and declare_index_properties.

Examples:

When a symbol A has index display properties, the value of the property display_index_separator is the string or other expression which is displayed between indices. The value is assigned by put(A, S, display_index_separator),

(%i1) declare_index_properties (A, [postsuperscript, postsuperscript,
 presubscript, presubscript]);
(%o1)                         done
(%i2) put (A, ";", display_index_separator);
(%o2)                           ;
(%i3) A[w, x, y, z];
                                 w;x
(%o3)                           A
                             y;z

The assigned value is retrieved by get(A, display_index_separator).

(%i1) declare_index_properties (A, [postsuperscript, postsuperscript,
 presubscript, presubscript]);
(%o1)                         done
(%i2) put (A, ";", display_index_separator);
(%o2)                           ;
(%i3) get (A, display_index_separator);
(%o3)                           ;

The display index separator S can be a string, including an empty string, or false, indicating the default separator, or any expression.

(%i1) declare_index_properties (A, [postsuperscript, postsuperscript,
 presubscript, presubscript]);
(%o1)                         done
(%i2) A[w, x, y, z];
                                 w, x
(%o2)                           A
                            y, z
(%i3) put (A, "-", display_index_separator);
(%o3)                           -
(%i4) A[w, x, y, z];
                                 w-x
(%o4)                           A
                             y-z
(%i5) put (A, " ", display_index_separator);
(%o5)                            
(%i6) A[w, x, y, z];
                                 w x
(%o6)                           A
                             y z
(%i7) put (A, "", display_index_separator);
(%o7) 
(%i8) A[w, x, y, z];
                                 wx
(%o8)                           A
                              yz
(%i9) put (A, false, display_index_separator);
(%o9)                         false
(%i10) A[w, x, y, z];
                                 w, x
(%o10)                          A
                            y, z
(%i11) put (A, 'foo, display_index_separator);
(%o11)                         foo
(%i12) A[w, x, y, z];
                                 wfoox
(%o12)                          A
                           yfooz

If no display index separator is assigned, the default separator is used. The default separator is a comma.

(%i1) declare_index_properties (A, [postsuperscript, postsuperscript,
 presubscript, presubscript]);
(%o1)                         done
(%i2) A[w, x, y, z];
                                 w, x
(%o2)                           A
                            y, z

Each symbol has its own value of display_index_separator.

(%i1) declare_index_properties (A, [postsuperscript, postsuperscript,
 presubscript, presubscript]);
(%o1)                         done
(%i2) put (A, " ", display_index_separator);
(%o2)                            
(%i3) declare_index_properties (B, [postsuperscript, postsuperscript, presubscript, presubscript]);
(%o3)                         done
(%i4) put (B, ";", display_index_separator);
(%o4)                           ;
(%i5) A[w, x, y, z] + B[w, x, y, z];
                            w;x       w x
(%o5)                      B    +    A
                        y;z       y z
Function: disp (expr_1, expr_2, …)

is like display but only the value of the arguments are displayed rather than equations. This is useful for complicated arguments which don’t have names or where only the value of the argument is of interest and not the name.

See also ldisp and print.

Example:

(%i1) b[1,2]:x-x^2$
(%i2) x:123$
(%i3) disp(x, b[1,2], sin(1.0));
                               123

                                  2
                             x - x

                       0.8414709848078965

(%o3)                         done
Categories: Display functions ·
Function: display (expr_1, expr_2, …)

Displays equations whose left side is expr_i unevaluated, and whose right side is the value of the expression centered on the line. This function is useful in blocks and for statements in order to have intermediate results displayed. The arguments to display are usually atoms, subscripted variables, or function calls.

See also ldisplay, disp, and ldisp.

Example:

(%i1) b[1,2]:x-x^2$
(%i2) x:123$
(%i3) display(x, b[1,2], sin(1.0));
                             x = 123

                                      2
                         b     = x - x
                          1, 2

                  sin(1.0) = 0.8414709848078965

(%o3)                         done
Categories: Display functions ·
Option variable: display2d

Default value: true

When display2d is true, the console display is an attempt to present mathematical expressions as they might appear in books and articles, using only letters, numbers, and some punctuation characters. This display is sometimes called the "pretty printer" display.

When display2d is true, Maxima attempts to honor the global variable for line length, linel. When an atom (symbol, number, or string) would otherwise cause a line to exceed linel, the atom may be printed in pieces on successive lines, with a continuation character (backslash, \) at the end of the leading piece; however, in some cases, such atoms are printed without a line break, and the length of the line is greater than linel.

When display2d is false, the console display is a 1-dimensional or linear form which is the same as the output produced by grind.

When display2d is false, the value of stringdisp is ignored, and strings are always displayed with quote marks.

When display2d is false, Maxima attempts to honor linel, but atoms are not broken across lines, and the actual length of an output line may exceed linel.

See also leftjust to switch between a left justified and a centered display of equations.

Example:

(%i1) x/(x^2+1);
                               x
(%o1)                        ------
                              2
                             x  + 1
(%i2) display2d:false$
(%i3) x/(x^2+1);
(%o3) x/(x^2+1)
Option variable: display_format_internal

Default value: false

When display_format_internal is true, expressions are displayed without being transformed in ways that hide the internal mathematical representation. The display then corresponds to what inpart returns rather than part.

Examples:

User     part       inpart
a-b;      a - b     a + (- 1) b

           a            - 1
a/b;       -         a b
           b
                       1/2
sqrt(x);   sqrt(x)    x

          4 X        4
X*4/3;    ---        - X
           3         3
Function: with_default_2d_display (expr)

While maxima by default realizes 2d Output using ASCII-Art some frontend change that to TeX, MathML or a specific XML dialect that better suits the needs for this specific frontend. with_default_2d_display temporarily switches maxima to the default 2D ASCII Art formatter for outputting the result of expr.

See also set_alt_display and display2d.

Categories: Display functions ·
Function: dispterms (expr)

Displays expr in parts one below the other. That is, first the operator of expr is displayed, then each term in a sum, or factor in a product, or part of a more general expression is displayed separately. This is useful if expr is too large to be otherwise displayed. For example if P1, P2, … are very large expressions then the display program may run out of storage space in trying to display P1 + P2 + ... all at once. However, dispterms (P1 + P2 + ...) displays P1, then below it P2, etc. When not using dispterms, if an exponential expression is too wide to be displayed as A^B it appears as expt (A, B) (or as ncexpt (A, B) in the case of A^^B).

Example:

(%i1) dispterms(2*a*sin(x)+%e^x);

+

2 a sin(x)

  x
%e

(%o1)                         done
Categories: Display functions ·
Special symbol: expt (a, b)
Special symbol: ncexpt (a, b)

If an exponential expression is too wide to be displayed as a^b it appears as expt (a, b) (or as ncexpt (a, b) in the case of a^^b).

expt and ncexpt are not recognized in input.

Option variable: exptdispflag

Default value: true

When exptdispflag is true, Maxima displays expressions with negative exponents using quotients. See also %edispflag.

Example:

(%i1) exptdispflag:true;
(%o1)                         true
(%i2) 10^-x;
                                1
(%o2)                          ---
                                 x
                               10
(%i3) exptdispflag:false;
(%o3)                         false
(%i4) 10^-x;
                                - x
(%o4)                         10
Function: grind (expr)

The function grind prints expr to the console in a form suitable for input to Maxima. grind always returns done.

When expr is the name of a function or macro, grind prints the function or macro definition instead of just the name.

See also string, which returns a string instead of printing its output. grind attempts to print the expression in a manner which makes it slightly easier to read than the output of string.

grind evaluates its argument.

Examples:

(%i1) aa + 1729;
(%o1)                       aa + 1729
(%i2) grind (%);
aa+1729$
(%o2)                         done
(%i3) [aa, 1729, aa + 1729];
(%o3)                 [aa, 1729, aa + 1729]
(%i4) grind (%);
[aa,1729,aa+1729]$
(%o4)                         done
(%i5) matrix ([aa, 17], [29, bb]);
                           [ aa  17 ]
(%o5)                      [        ]
                           [ 29  bb ]
(%i6) grind (%);
matrix([aa,17],[29,bb])$
(%o6)                         done
(%i7) set (aa, 17, 29, bb);
(%o7)                   {17, 29, aa, bb}
(%i8) grind (%);
{17,29,aa,bb}$
(%o8)                         done
(%i9) exp (aa / (bb + 17)^29);
                                aa
                            -----------
                                     29
                            (bb + 17)
(%o9)                     %e
(%i10) grind (%);
%e^(aa/(bb+17)^29)$
(%o10)                        done
(%i11) expr: expand ((aa + bb)^10);
         10           9        2   8         3   7         4   6
(%o11) bb   + 10 aa bb  + 45 aa  bb  + 120 aa  bb  + 210 aa  bb
         5   5         6   4         7   3        8   2
 + 252 aa  bb  + 210 aa  bb  + 120 aa  bb  + 45 aa  bb
        9        10
 + 10 aa  bb + aa
(%i12) grind (expr);
bb^10+10*aa*bb^9+45*aa^2*bb^8+120*aa^3*bb^7+210*aa^4*bb^6
     +252*aa^5*bb^5+210*aa^6*bb^4+120*aa^7*bb^3+45*aa^8*bb^2
     +10*aa^9*bb+aa^10$
(%o12)                        done
(%i13) string (expr);
(%o13) bb^10+10*aa*bb^9+45*aa^2*bb^8+120*aa^3*bb^7+210*aa^4*bb^6\
+252*aa^5*bb^5+210*aa^6*bb^4+120*aa^7*bb^3+45*aa^8*bb^2+10*aa^9*\
bb+aa^10
(%i14) cholesky (A):= block ([n : length (A), L : copymatrix (A),
  p : makelist (0, i, 1, length (A))],
  for i thru n do for j : i thru n do
  (x : L[i, j], x : x - sum (L[j, k] * L[i, k], k, 1, i - 1),
  if i = j then p[i] : 1 / sqrt(x) else L[j, i] : x * p[i]),
  for i thru n do L[i, i] : 1 / p[i],
  for i thru n do for j : i + 1 thru n do L[i, j] : 0, L)$
define: warning: redefining the built-in function cholesky
(%i15) grind (cholesky);
cholesky(A):=block(
         [n:length(A),L:copymatrix(A),
          p:makelist(0,i,1,length(A))],
         for i thru n do
             (for j from i thru n do
                  (x:L[i,j],x:x-sum(L[j,k]*L[i,k],k,1,i-1),
                   if i = j then p[i]:1/sqrt(x)
                       else L[j,i]:x*p[i])),
         for i thru n do L[i,i]:1/p[i],
         for i thru n do (for j from i+1 thru n do L[i,j]:0),L)$
(%o15)                        done
(%i16) string (fundef (cholesky));
(%o16) cholesky(A):=block([n:length(A),L:copymatrix(A),p:makelis\
t(0,i,1,length(A))],for i thru n do (for j from i thru n do (x:L\
[i,j],x:x-sum(L[j,k]*L[i,k],k,1,i-1),if i = j then p[i]:1/sqrt(x\
) else L[j,i]:x*p[i])),for i thru n do L[i,i]:1/p[i],for i thru \
n do (for j from i+1 thru n do L[i,j]:0),L)
Categories: Display functions ·
Option variable: grind

When the variable grind is true, the output of string and stringout has the same format as that of grind; otherwise no attempt is made to specially format the output of those functions. The default value of the variable grind is false.

grind can also be specified as an argument of playback. When grind is present, playback prints input expressions in the same format as the grind function. Otherwise, no attempt is made to specially format input expressions.

Option variable: ibase

Default value: 10

ibase is the base for integers read by Maxima.

ibase may be assigned any integer between 2 and 36 (decimal), inclusive. When ibase is greater than 10, the numerals comprise the decimal numerals 0 through 9 plus letters of the alphabet A, B, C, …, as needed to make ibase digits in all. Letters are interpreted as digits only if the first digit is 0 through 9.

Uppercase and lowercase letters are not distinguished. The numerals for base 36, the largest acceptable base, comprise 0 through 9 and A through Z.

Whatever the value of ibase, when an integer is terminated by a decimal point, it is interpreted in base 10.

See also obase.

Examples:

ibase less than 10 (for example binary numbers).

(%i1) ibase : 2 $
(%i2) obase;
(%o2)                          10
(%i3) 1111111111111111;
(%o3)                         65535

ibase greater than 10. Letters are interpreted as digits only if the first digit is 0 through 9 which means that hexadecimal numbers might need to be prepended by a 0.

(%i1) ibase : 16 $
(%i2) obase;
(%o2)                          10
(%i3) 1000;
(%o3)                         4096
(%i4) abcd;
(%o4)                         abcd
(%i5) symbolp (abcd);
(%o5)                         true
(%i6) 0abcd;
(%o6)                         43981
(%i7) symbolp (0abcd);
(%o7)                         false

When an integer is terminated by a decimal point, it is interpreted in base 10.

(%i1) ibase : 36 $
(%i2) obase;
(%o2)                          10
(%i3) 1234;
(%o3)                         49360
(%i4) 1234.;
(%o4)                         1234
Categories: Console interaction ·
Function: ldisp (expr_1, …, expr_n)

Displays expressions expr_1, …, expr_n to the console as printed output. ldisp assigns an intermediate expression label to each argument and returns the list of labels.

See also disp, display, and ldisplay.

Examples:

(%i1) e: (a+b)^3;
                                   3
(%o1)                       (b + a)
(%i2) f: expand (e);
                     3        2      2      3
(%o2)               b  + 3 a b  + 3 a  b + a
(%i3) ldisp (e, f);
                                   3
(%t3)                       (b + a)

                     3        2      2      3
(%t4)               b  + 3 a b  + 3 a  b + a

(%o4)                      [%t3, %t4]
(%i4) %t3;
                                   3
(%o4)                       (b + a)
(%i5) %t4;
                     3        2      2      3
(%o5)               b  + 3 a b  + 3 a  b + a
Categories: Display functions ·
Function: ldisplay (expr_1, …, expr_n)

Displays expressions expr_1, …, expr_n to the console as printed output. Each expression is printed as an equation of the form lhs = rhs in which lhs is one of the arguments of ldisplay and rhs is its value. Typically each argument is a variable. ldisp assigns an intermediate expression label to each equation and returns the list of labels.

See also display, disp, and ldisp.

Examples:

(%i1) e: (a+b)^3;
                                   3
(%o1)                       (b + a)
(%i2) f: expand (e);
                     3        2      2      3
(%o2)               b  + 3 a b  + 3 a  b + a
(%i3) ldisplay (e, f);
                                     3
(%t3)                     e = (b + a)

                       3        2      2      3
(%t4)             f = b  + 3 a b  + 3 a  b + a

(%o4)                      [%t3, %t4]
(%i4) %t3;
                                     3
(%o4)                     e = (b + a)
(%i5) %t4;
                       3        2      2      3
(%o5)             f = b  + 3 a b  + 3 a  b + a
Categories: Display functions ·
Option variable: leftjust

Default value: false

When leftjust is true, equations in 2D-display are drawn left justified rather than centered.

See also display2d to switch between 1D- and 2D-display.

Example:

(%i1) expand((x+1)^3);
                        3      2
(%o1)                  x  + 3 x  + 3 x + 1
(%i2) leftjust:true$
(%i3) expand((x+1)^3);
       3      2
(%o3) x  + 3 x  + 3 x + 1
Option variable: linel

Default value: 79

linel is the assumed width (in characters) of the console display for the purpose of displaying expressions. linel may be assigned any value by the user, although very small or very large values may be impractical. Text printed by built-in Maxima functions, such as error messages and the output of describe, is not affected by linel.

Option variable: lispdisp

Default value: false

When lispdisp is true, Lisp symbols are displayed with a leading question mark ?. Otherwise, Lisp symbols are displayed with no leading mark. This has the same effect for 1-d and 2-d display.

Examples:

(%i1) lispdisp: false$
(%i2) ?foo + ?bar;
(%o2)                       foo + bar
(%i3) lispdisp: true$
(%i4) ?foo + ?bar;
(%o4)                      ?foo + ?bar
Option variable: negsumdispflag

Default value: true

When negsumdispflag is true, x - y displays as x - y instead of as - y + x. Setting it to false causes the special check in display for the difference of two expressions to not be done. One application is that thus a + %i*b and a - %i*b may both be displayed the same way.

Option variable: obase

Default value: 10

obase is the base for integers displayed by Maxima.

obase may be assigned any integer between 2 and 36 (decimal), inclusive. When obase is greater than 10, the numerals comprise the decimal numerals 0 through 9 plus capital letters of the alphabet A, B, C, …, as needed. A leading 0 digit is displayed if the leading digit is otherwise a letter. The numerals for base 36, the largest acceptable base, comprise 0 through 9, and A through Z.

See also ibase.

Examples:

(%i1) obase : 2;
(%o1)                          10
(%i10) 2^8 - 1;
(%o10)                      11111111
(%i11) obase : 8;
(%o3)                          10
(%i4) 8^8 - 1;
(%o4)                       77777777
(%i5) obase : 16;
(%o5)                          10
(%i6) 16^8 - 1;
(%o6)                       0FFFFFFFF
(%i7) obase : 36;
(%o7)                          10
(%i8) 36^8 - 1;
(%o8)                       0ZZZZZZZZ
Option variable: pfeformat

Default value: false

When pfeformat is true, a ratio of integers is displayed with the solidus (forward slash) character, and an integer denominator n is displayed as a leading multiplicative term 1/n.

Examples:

(%i1) pfeformat: false$
(%i2) 2^16/7^3;
                              65536
(%o2)                         -----
                               343
(%i3) (a+b)/8;
                              b + a
(%o3)                         -----
                                8
(%i4) pfeformat: true$ 
(%i5) 2^16/7^3;
(%o5)                       65536/343
(%i6) (a+b)/8;
(%o6)                      1/8 (b + a)
Option variable: powerdisp

Default value: false

When powerdisp is true, a sum is displayed with its terms in order of increasing power. Thus a polynomial is displayed as a truncated power series, with the constant term first and the highest power last.

By default, terms of a sum are displayed in order of decreasing power.

Example:

(%i1) powerdisp:true;
(%o1)                         true
(%i2) x^2+x^3+x^4;
                           2    3    4
(%o2)                     x  + x  + x
(%i3) powerdisp:false;
(%o3)                         false
(%i4) x^2+x^3+x^4;
                           4    3    2
(%o4)                     x  + x  + x
Function: print (expr_1, …, expr_n)

Evaluates and displays expr_1, …, expr_n one after another, from left to right, starting at the left edge of the console display.

The value returned by print is the value of its last argument. print does not generate intermediate expression labels.

See also display, disp, ldisplay, and ldisp. Those functions display one expression per line, while print attempts to display two or more expressions per line.

To display the contents of a file, see printfile.

Examples:

(%i1) r: print ("(a+b)^3 is", expand ((a+b)^3), "log (a^10/b) is",
      radcan (log (a^10/b)))$
            3        2      2      3
(a+b)^3 is b  + 3 a b  + 3 a  b + a  log (a^10/b) is 

                                              10 log(a) - log(b) 
(%i2) r;
(%o2)                  10 log(a) - log(b)
(%i3) disp ("(a+b)^3 is", expand ((a+b)^3), "log (a^10/b) is",
      radcan (log (a^10/b)))$
                           (a+b)^3 is

                     3        2      2      3
                    b  + 3 a b  + 3 a  b + a

                         log (a^10/b) is

                       10 log(a) - log(b)
Categories: Display functions ·
Option variable: sqrtdispflag

Default value: true

When sqrtdispflag is false, causes sqrt to display with exponent 1/2.

Option variable: stardisp

Default value: false

When stardisp is true, multiplication is displayed with an asterisk * between operands.

Option variable: ttyoff

Default value: false

When ttyoff is true, output expressions are not displayed. Output expressions are still computed and assigned labels. See labels.

Text printed by built-in Maxima functions, such as error messages and the output of describe, is not affected by ttyoff.


Next: , Previous:   [Contents][Index]