2 * Introduction to Command Line::
3 * Functions and Variables for Command Line::
4 * Functions and Variables for Display::
7 @c -----------------------------------------------------------------------------
8 @node Introduction to Command Line, Functions and Variables for Command Line, Command Line, Command Line
9 @section Introduction to Command Line
10 @c -----------------------------------------------------------------------------
12 This section documents Maxima's interactive command-line interface,
13 called a read-eval-print loop (REPL).
15 For information on command-line options, see @mrefdot{command_line_options}
16 @c end concepts Command Line
18 @c -----------------------------------------------------------------------------
19 @node Functions and Variables for Command Line, Functions and Variables for Display, Introduction to Command Line, Command Line
20 @section Functions and Variables for Command Line
21 @c -----------------------------------------------------------------------------
23 @c -----------------------------------------------------------------------------
25 @defvr {System variable} __
26 @vrindex Current input expression
28 @code{__} is the input expression currently being evaluated. That is, while an
29 input expression @var{expr} is being evaluated, @code{__} is @var{expr}.
31 @code{__} is assigned the input expression before the input is simplified or
32 evaluated. However, the value of @code{__} is simplified (but not evaluated)
35 @code{__} is recognized by @mref{batch} and @mrefdot{load} In a file processed
36 by @code{batch}, @code{__} has the same meaning as at the interactive prompt.
37 In a file processed by @code{load}, @code{__} is bound to the input expression
38 most recently entered at the interactive prompt or in a batch file; @code{__}
39 is not bound to the input expressions in the file being processed. In
40 particular, when @code{load (@var{filename})} is called from the interactive
41 prompt, @code{__} is bound to @code{load (@var{filename})} while the file is
44 See also @mref{_} and @mrefdot{%}
49 @c print ("I was called as", __);
51 @c g (x) := (print ("Current input expression =", __), 0);
52 @c [aa : 1, bb : 2, cc : 3];
53 @c (aa + bb + cc)/(dd + ee + g(x));
57 (%i1) print ("I was called as", __);
58 I was called as print(I was called as, __)
59 (%o1) print(I was called as, __)
66 (%i3) g (x) := (print ("Current input expression =", __), 0);
67 (%o3) g(x) := (print("Current input expression =", __), 0)
70 (%i4) [aa : 1, bb : 2, cc : 3];
74 (%i5) (aa + bb + cc)/(dd + ee + g(x));
76 Current input expression = --------------
84 @opencatbox{Categories:}
85 @category{Global variables}
89 @c -----------------------------------------------------------------------------
91 @defvr {System variable} _
92 @vrindex Previous input
94 @code{_} is the most recent input expression (e.g., @code{%i1}, @code{%i2},
97 @code{_} is assigned the input expression before the input is simplified or
98 evaluated. However, the value of @code{_} is simplified (but not evaluated)
101 @code{_} is recognized by @mref{batch} and @mrefdot{load} In a file processed
102 by @code{batch}, @code{_} has the same meaning as at the interactive prompt.
103 In a file processed by @code{load}, @code{_} is bound to the input expression
104 most recently evaluated at the interactive prompt or in a batch file; @code{_}
105 is not bound to the input expressions in the file being processed.
107 See also @mref{__} and @mrefdot{%}
145 ((%SIN) ((MQUOTIENT) $%PI 2))
175 @opencatbox{Categories:}
176 @category{Console interaction}
177 @category{Global variables}
181 @c -----------------------------------------------------------------------------
183 @defvr {System variable} %
184 @vrindex Previous output
186 @code{%} is the output expression (e.g., @code{%o1}, @code{%o2}, @code{%o3},
187 @dots{}) most recently computed by Maxima, whether or not it was displayed.
189 @code{%} is recognized by @mref{batch} and @mrefdot{load} In a file processed
190 by @code{batch}, @code{%} has the same meaning as at the interactive prompt.
191 In a file processed by @code{load}, @code{%} is bound to the output expression
192 most recently computed at the interactive prompt or in a batch file; @code{%}
193 is not bound to output expressions in the file being processed.
195 See also @mrefcomma{_} @mrefcomma{%%} and @mrefdot{%th}
197 @opencatbox{Categories:}
198 @category{Console interaction}
199 @category{Global variables}
203 @c -----------------------------------------------------------------------------
205 @defvr {System variable} %%
206 @vrindex Previous result in compound expression
208 In compound statements, namely @mrefcomma{block} @mrefcomma{lambda} or
209 @code{(@var{s_1}, ..., @var{s_n})}, @code{%%} is the value of the previous
212 At the first statement in a compound statement, or outside of a compound
213 statement, @code{%%} is undefined.
215 @code{%%} is recognized by @mref{batch} and @mrefcomma{load} and it has the
216 same meaning as at the interactive prompt.
222 The following two examples yield the same result.
225 (%i1) block (integrate (x^5, x), ev (%%, x=2) - ev (%%, x=1));
229 (%i2) block ([prev], prev: integrate (x^5, x),
230 ev (prev, x=2) - ev (prev, x=1));
237 A compound statement may comprise other compound statements. Whether a
238 statement be simple or compound, @code{%%} is the value of the previous
242 (%i3) block (block (a^n, %%*42), %%/6);
247 Within a compound statement, the value of @code{%%} may be inspected at a break
248 prompt, which is opened by executing the @mref{break} function. For example,
249 entering @code{%%;} in the following example yields @code{42}.
252 (%i4) block (a: 42, break ())$
254 Entering a Maxima break point. Type 'exit;' to resume.
260 @opencatbox{Categories:}
261 @category{Global variables}
265 @c -----------------------------------------------------------------------------
267 @fnindex N'th previous output
268 @deffn {Function} %th (@var{i})
270 The value of the @var{i}'th previous output expression. That is, if the next
271 expression to be computed is the @var{n}'th output, @code{%th (@var{m})} is the
272 (@var{n} - @var{m})'th output.
274 @code{%th} is recognized by @mref{batch} and @mrefdot{load} In a file processed
275 by @code{batch}, @code{%th} has the same meaning as at the interactive prompt.
276 In a file processed by @code{load}, @code{%th} refers to output expressions most
277 recently computed at the interactive prompt or in a batch file; @code{%th} does
278 not refer to output expressions in the file being processed.
280 See also @mref{%} and @mrefdot{%%}
284 @code{%th} is useful in @code{batch} files or for referring to a group of
285 output expressions. This example sets @code{s} to the sum of the last five
295 (%i6) block (s: 0, for i:1 thru 5 do s: s + %th(i), s);
299 @opencatbox{Categories:}
300 @category{Console interaction}
304 @c -----------------------------------------------------------------------------
306 @fnindex Fetch documentation
307 @deffn {Special symbol} ?
309 As prefix to a function or variable name, @code{?} signifies that the name is a
310 Lisp name, not a Maxima name. For example, @code{?round} signifies the Lisp
311 function @code{ROUND}. See @ref{Lisp and Maxima} for more on this point.
313 The notation @code{? word} (a question mark followed a word, separated by
314 whitespace) is equivalent to @code{describe("word")}. The question mark must
315 occur at the beginning of an input line; otherwise it is not recognized as a
316 request for documentation. See also @mrefdot{describe}
318 @opencatbox{Categories:}
320 @category{Console interaction}
324 @c -----------------------------------------------------------------------------
326 @fnindex Fetch documentation (inexact search)
327 @deffn {Special symbol} ??
329 The notation @code{?? word} (@code{??} followed a word, separated by whitespace)
330 is equivalent to @code{describe("word", inexact)}. The question mark must occur
331 at the beginning of an input line; otherwise it is not recognized as a request
332 for documentation. See also @mrefdot{describe}
334 @opencatbox{Categories:}
336 @category{Console interaction}
340 @c -----------------------------------------------------------------------------
342 @fnindex Input terminator (without display)
343 @deffn {Input terminator} $
345 The dollar sign @code{$} terminates an input expression,
346 and the most recent output @code{%} and an output label, e.g. @code{%o1},
347 are assigned the result, but the result is not displayed.
370 @c -----------------------------------------------------------------------------
372 @deffn {Input terminator} ;
374 The semicolon @code{;} terminates an input expression,
375 and the resulting output is displayed.
391 @c -----------------------------------------------------------------------------
393 @defvr {Option variable} inchar
394 Default value: @code{%i}
396 @code{inchar} is the prefix of the labels of expressions entered by the user.
397 Maxima automatically constructs a label for each input expression by
398 concatenating @code{inchar} and @mrefdot{linenum}
400 @code{inchar} may be assigned any string or symbol, not necessarily a single
401 character. Because Maxima internally takes into account only the first char of
402 the prefix, the prefixes @code{inchar}, @mrefcomma{outchar} and
403 @mref{linechar} should have a different first char. Otherwise some commands
404 like @code{kill(inlabels)} do not work as expected.
406 See also @mrefdot{labels}
416 (%i1) inchar: "input";
420 (input2) expand((a+b)^3);
422 (%o2) b + 3 a b + 3 a b + a
426 @opencatbox{Categories:}
427 @category{Display flags and variables}
431 @c -----------------------------------------------------------------------------
433 @defvr {System variable} infolists
434 Default value: @code{[]}
436 @code{infolists} is a list of the names of all of the information
437 lists in Maxima. These are:
441 All bound @code{%i}, @code{%o}, and @code{%t} labels.
443 All bound atoms which are user variables, not Maxima options or switches,
444 created by @mref{:} or @mref{::} or functional binding.
445 @c WHAT IS INTENDED BY "FUNCTIONAL BINDING" HERE ??
447 All user-defined functions, created by @mref{:=} or @mrefdot{define}
449 All arrays, @mref{hashed arrays} and @mref{memoizing functions}.
451 All user-defined macro functions, created by @mrefdot{::=}
453 All options ever reset by the user (whether or not they
454 are later reset to their default values).
456 All user-defined pattern matching and simplification rules, created
457 by @mrefcomma{tellsimp} @mrefcomma{tellsimpafter} @mrefcomma{defmatch} or
460 All atoms which have a user-defined alias, created by the @mrefcomma{alias}@w{}
461 @mrefcomma{ordergreat} @mref{orderless} functions or by declaring the atom as a
462 @mref{noun} with @mrefdot{declare}
464 All atoms which have functional dependencies, created by the
465 @mref{depends}, @mref{dependencies}, or @mref{gradef} functions.
467 All functions which have user-defined derivatives, created by the
468 @mref{gradef} function.
469 @c UMM, WE REALLY NEED TO BE SPECIFIC -- WHAT DOES "ETC" CONTAIN HERE ??
471 All atoms which have any property other than those mentioned above, such as
472 properties established by @mref{atvalue} or @mref{matchdeclare}, etc.,
473 as well as properties established in the @mref{declare} function.
475 @c Is also documented in Structures.texi. But it definitively is an infolist
476 @c so it has to be documented here, too.
477 All structs defined using @mrefdot{defstruct}
478 @item let_rule_packages
479 All user-defined @mref{let} rule packages
480 plus the special package @mrefdot{default_let_rule_package}
481 (@code{default_let_rule_package} is the name of the rule package used when
482 one is not explicitly set by the user.)
485 @opencatbox{Categories:}
486 @category{Declarations and inferences}
487 @category{Global variables}
491 @c REVIEW FOR ACCURACY AND COMPLETENESS
492 @c THIS ITEM IS VERY IMPORTANT !!
495 @c -----------------------------------------------------------------------------
497 @deffn {Function} kill @
498 @fname{kill} (@var{a_1}, @dots{}, @var{a_n}) @
499 @fname{kill} (labels) @
500 @fname{kill} (inlabels, outlabels, linelabels) @
501 @fname{kill} (@var{n}) @
502 @fname{kill} ([@var{m}, @var{n}]) @
503 @fname{kill} (values, functions, arrays, @dots{}) @
505 @fname{kill} (allbut (@var{a_1}, @dots{}, @var{a_n}))
507 Removes all bindings (value, function, array, or rule) from the arguments
508 @var{a_1}, @dots{}, @var{a_n}. An argument @var{a_k} may be a symbol or a
509 single array element. When @var{a_k} is a single array element, @code{kill}
510 unbinds that element without affecting any other elements of the array.
512 Several special arguments are recognized. Different kinds of arguments
513 may be combined, e.g., @code{kill (inlabels, functions, allbut (foo, bar))}.
515 @code{kill (labels)} unbinds all input, output, and intermediate expression
516 labels created so far. @code{kill (inlabels)} unbinds only input labels which
517 begin with the current value of @mrefdot{inchar} Likewise,
518 @code{kill (outlabels)} unbinds only output labels which begin with the current
519 value of @mrefcomma{outchar} and @code{kill (linelabels)} unbinds only
520 intermediate expression labels which begin with the current value of
523 @code{kill (@var{n})}, where @var{n} is an integer,
524 unbinds the @var{n} most recent input and output labels.
526 @code{kill ([@var{m}, @var{n}])} unbinds input and output labels @var{m} through
529 @code{kill (@var{infolist})}, where @var{infolist} is any item in
530 @code{infolists} (such as @mrefcomma{values} @mrefcomma{functions} or
531 @mref{arrays}) unbinds all items in @var{infolist}.
532 See also @mrefdot{infolists}
534 @code{kill (all)} unbinds all items on all infolists. @code{kill (all)} does
535 not reset global variables to their default values; see @mref{reset} on this
538 @code{kill (allbut (@var{a_1}, ..., @var{a_n}))} unbinds all items on all
539 infolists except for @var{a_1}, @dots{}, @var{a_n}.
540 @code{kill (allbut (@var{infolist}))} unbinds all items except for the ones on
541 @var{infolist}, where @var{infolist} is @mrefcomma{values}@w{}
542 @mrefcomma{functions} @mrefcomma{arrays} etc.
544 The memory taken up by a bound property is not released until all symbols are
545 unbound from it. In particular, to release the memory taken up by the value of
546 a symbol, one unbinds the output label which shows the bound value, as well as
547 unbinding the symbol itself.
549 @code{kill} quotes its arguments. The quote-quote operator @code{'@w{}'}
552 @code{kill (@var{symbol})} unbinds all properties of @var{symbol}. In contrast,
553 the functions @mrefcomma{remvalue} @mrefcomma{remfunction}@w{}
554 @mrefcomma{remarray} and @mref{remrule} unbind a specific property.
555 Note that facts declared by @mref{assume} don't require a symbol they apply to,
556 therefore aren't stored as properties of symbols and therefore aren't affected
559 @code{kill} always returns @code{done}, even if an argument has no binding.
561 @opencatbox{Categories:}
562 @category{Evaluation}
563 @category{Console interaction}
564 @category{Session management}
568 @c -----------------------------------------------------------------------------
570 @deffn {Function} labels (@var{symbol})
572 Returns the list of input, output, or intermediate expression labels which begin
573 with @var{symbol}. Typically @var{symbol} is the value of
574 @mrefcomma{inchar} @mrefcomma{outchar} or @mrefdot{linechar}
575 If no labels begin with @var{symbol}, @code{labels} returns an empty list.
577 By default, Maxima displays the result of each user input expression, giving the
578 result an output label. The output display is suppressed by terminating the
579 input with @code{$} (dollar sign) instead of @code{;} (semicolon). An output
580 label is constructed and bound to the result, but not displayed, and the label
581 may be referenced in the same way as displayed output labels. See also
582 @mrefcomma{%} @mrefcomma{%%} and @mrefdot{%th}
584 Intermediate expression labels can be generated by some functions. The option
585 variable @mref{programmode} controls whether @mref{solve} and some other
586 functions generate intermediate expression labels instead of returning a list of
587 expressions. Some other functions, such as @mrefcomma{ldisplay} always generate
588 intermediate expression labels.
590 See also @mrefcomma{inchar} @mrefcomma{outchar} @mrefcomma{linechar} and
593 @opencatbox{Categories:}
594 @category{Display functions}
595 @category{Console interaction}
599 @defvr {System variable} labels
601 The variable @code{labels} is the list of input, output, and intermediate
602 expression labels, including all previous labels if @code{inchar},
603 @code{outchar}, or @code{linechar} were redefined.
605 @opencatbox{Categories:}
606 @category{Display flags and variables}
607 @category{Console interaction}
611 @c -----------------------------------------------------------------------------
613 @defvr {Option variable} linechar
614 Default value: @code{%t}
616 @code{linechar} is the prefix of the labels of intermediate expressions
617 generated by Maxima. Maxima constructs a label for each intermediate expression
618 (if displayed) by concatenating @code{linechar} and @mrefdot{linenum}
620 @code{linechar} may be assigned any string or symbol, not necessarily a single
621 character. Because Maxima internally takes into account only the first char of
622 the prefix, the prefixes @mrefcomma{inchar} @mrefcomma{outchar} and
623 @code{linechar} should have a different first char. Otherwise some commands
624 like @code{kill(inlabels)} do not work as expected.
626 Intermediate expressions might or might not be displayed.
627 See @mref{programmode} and @mrefdot{labels}
629 @opencatbox{Categories:}
630 @category{Display flags and variables}
634 @c EXPAND; SHOW WHAT HAPPENS WHEN linenum IS ASSIGNED A VALUE
636 @c -----------------------------------------------------------------------------
638 @defvr {System variable} linenum
640 The line number of the current pair of input and output expressions.
642 @opencatbox{Categories:}
643 @category{Display flags and variables}
644 @category{Console interaction}
650 @c -----------------------------------------------------------------------------
652 @defvr {System variable} myoptions
653 Default value: @code{[]}
655 @code{myoptions} is the list of all options ever reset by the user,
656 whether or not they get reset to their default value.
658 @opencatbox{Categories:}
659 @category{Global variables}
660 @category{Session management}
661 @category{Console interaction}
665 @c -----------------------------------------------------------------------------
667 @defvr {Option variable} nolabels
668 Default value: @code{false}
670 When @code{nolabels} is @code{true}, input and output result labels (@code{%i}
671 and @code{%o}, respectively) are displayed, but the labels are not bound to
672 results, and the labels are not appended to the @mref{labels} list. Since
673 labels are not bound to results, garbage collection can recover the memory taken
676 Otherwise input and output result labels are bound to results, and the labels
677 are appended to the @code{labels} list.
679 Intermediate expression labels (@code{%t}) are not affected by @code{nolabels};
680 whether @code{nolabels} is @code{true} or @code{false}, intermediate expression
681 labels are bound and appended to the @code{labels} list.
683 See also @mrefcomma{batch} @mrefcomma{load} and @mrefdot{labels}
685 @opencatbox{Categories:}
686 @category{Global flags}
687 @category{Session management}
693 @c -----------------------------------------------------------------------------
695 @defvr {Option variable} optionset
696 Default value: @code{false}
698 When @code{optionset} is @code{true}, Maxima prints out a message whenever a
699 Maxima option is reset. This is useful if the user is doubtful of the spelling
700 of some option and wants to make sure that the variable he assigned a value to
701 was truly an option variable.
706 (%i1) optionset:true;
707 assignment: assigning to option optionset
709 (%i2) gamma_expand:true;
710 assignment: assigning to option gamma_expand
714 @opencatbox{Categories:}
715 @category{Global flags}
716 @category{Session management}
717 @category{Console interaction}
721 @c -----------------------------------------------------------------------------
724 @defvr {Option variable} outchar
725 Default value: @code{%o}
727 @code{outchar} is the prefix of the labels of expressions computed by Maxima.
728 Maxima automatically constructs a label for each computed expression by
729 concatenating @code{outchar} and @mrefdot{linenum}
731 @code{outchar} may be assigned any string or symbol, not necessarily a single
732 character. Because Maxima internally takes into account only the first char of
733 the prefix, the prefixes @mrefcomma{inchar} @code{outchar} and
734 @mref{linechar} should have a different first char. Otherwise some commands
735 like @code{kill(inlabels)} do not work as expected.
737 See also @mref{labels}.
742 @c outchar: "output";
747 (%i1) outchar: "output";
751 (%i2) expand((a+b)^3);
753 (output2) b + 3 a b + 3 a b + a
757 @opencatbox{Categories:}
758 @category{Display flags and variables}
762 @c -----------------------------------------------------------------------------
764 @deffn {Function} playback @
765 @fname{playback} () @
766 @fname{playback} (@var{n}) @
767 @fname{playback} ([@var{m}, @var{n}]) @
768 @fname{playback} ([@var{m}]) @
769 @fname{playback} (input) @
770 @fname{playback} (slow) @
771 @fname{playback} (time) @
772 @fname{playback} (grind)
774 Displays input, output, and intermediate expressions, without recomputing them.
775 @code{playback} only displays the expressions bound to labels; any other output
776 (such as text printed by @mref{print} or @mrefcomma{describe} or error messages)
777 is not displayed. See also @mrefdot{labels}
779 @code{playback} quotes its arguments. The quote-quote operator @code{'@w{}'}
780 defeats quotation. @code{playback} always returns @code{done}.
782 @code{playback ()} (with no arguments) displays all input, output, and
783 intermediate expressions generated so far. An output expression is displayed
784 even if it was suppressed by the @code{$} terminator when it was originally
787 @code{playback (@var{n})} displays the most recent @var{n} expressions.
788 Each input, output, and intermediate expression counts as one.
790 @code{playback ([@var{m}, @var{n}])} displays input, output, and intermediate
791 expressions with numbers from @var{m} through @var{n}, inclusive.
793 @code{playback ([@var{m}])} is equivalent to
794 @code{playback ([@var{m}, @var{m}])}; this usually prints one pair of input and
797 @code{playback (input)} displays all input expressions generated so far.
799 @code{playback (slow)} pauses between expressions and waits for the user to
800 press @code{enter}. This behavior is similar to @mrefdot{demo}
801 @c WHAT DOES THE FOLLOWING MEAN ???
802 @code{playback (slow)} is useful in conjunction with @code{save} or
803 @mref{stringout} when creating a secondary-storage file in order to pick out
806 @code{playback (time)} displays the computation time for each expression.
807 @c DON'T BOTHER TO MENTION OBSOLETE OPTIONS !!!
808 @c The arguments @code{gctime} and @code{totaltime} have the same effect as @code{time}.
810 @code{playback (grind)} displays input expressions in the same format as the
811 @code{grind} function. Output expressions are not affected by the @code{grind}
812 option. See @mrefdot{grind}
814 Arguments may be combined, e.g., @code{playback ([5, 10], grind, time, slow)}.
815 @c APPEARS TO BE input INTERSECT (UNION OF ALL OTHER ARGUMENTS). CORRECT ???
817 @opencatbox{Categories:}
818 @category{Display functions}
819 @category{Console interaction}
823 @c -----------------------------------------------------------------------------
826 @defvr {Option variable} prompt
827 Default value: @code{_}
829 @code{prompt} is the prompt symbol of the @mref{demo} function,
830 @code{playback (slow)} mode, and the Maxima break loop (as invoked by
833 @opencatbox{Categories:}
834 @category{Global variables}
835 @category{Console interaction}
839 @c -----------------------------------------------------------------------------
841 @deffn {Function} quit ([@var{exit-code}])
843 Terminates the Maxima session. Note that the function must be invoked as
844 @code{quit();} or @code{quit()$}, not @code{quit} by itself.
845 @code{quit} supports returning an exit code to the shell for Lisps and
846 OSes that support exit codes. The default exit code is 0 (usually
847 indicating no errors encountered). Thus @code{quit(1)} indicates to the
848 shell that maxima exited with some kind of failure. This is useful in
849 scripts where maxima can indicate to the shell that maxima failed to
850 compute something or some other bad thing happened.
852 To stop a lengthy computation, type @code{control-C}. The default action is to
853 return to the Maxima prompt. If @code{*debugger-hook*} is @code{nil},
854 @code{control-C} opens the Lisp debugger. See also @ref{Debugging}.
856 @opencatbox{Categories:}
857 @category{Console interaction}
861 @c -----------------------------------------------------------------------------
863 @deffn {Function} read (@var{expr_1}, @dots{}, @var{expr_n})
865 Prints @var{expr_1}, @dots{}, @var{expr_n}, then reads one expression from the
866 console and returns the evaluated expression. The expression is terminated with
867 a semicolon @code{;} or dollar sign @code{$}.
869 See also @mref{readonly}
875 (%i2) foo: read ("foo is", foo, " -- enter new value.")$
876 foo is 42 -- enter new value.
883 @opencatbox{Categories:}
884 @category{Console interaction}
888 @c -----------------------------------------------------------------------------
890 @deffn {Function} readonly (@var{expr_1}, @dots{}, @var{expr_n})
892 Prints @var{expr_1}, @dots{}, @var{expr_n}, then reads one expression from the
893 console and returns the expression (without evaluation). The expression is
894 terminated with a @code{;} (semicolon) or @code{$} (dollar sign).
896 See also @mrefdot{read}
902 (%i2) foo: readonly ("Enter an expression:");
907 (%i3) foo: read ("Enter an expression:");
913 @opencatbox{Categories:}
914 @category{Console interaction}
918 @c -----------------------------------------------------------------------------
920 @deffn {Function} reset ()
922 Resets many global variables and options, and some other variables, to their
925 @code{reset} processes the variables on the Lisp list
926 @code{*variable-initial-values*}. The Lisp macro @code{defmvar} puts variables
927 on this list (among other actions). Many, but not all, global variables and
928 options are defined by @code{defmvar}, and some variables defined by
929 @code{defmvar} are not global variables or options.
931 @opencatbox{Categories:}
932 @category{Session management}
936 @c -----------------------------------------------------------------------------
938 @defvr {Option variable} showtime
939 Default value: @code{false}
941 When @code{showtime} is @code{true}, the computation time and elapsed time is
942 printed with each output expression.
944 The computation time is always recorded, so @mref{time} and @mref{playback} can
945 display the computation time even when @code{showtime} is @code{false}.
947 See also @mrefdot{timer}
949 @opencatbox{Categories:}
950 @category{Display flags and variables}
955 @c -----------------------------------------------------------------------------
957 @deffn {Function} to_lisp ()
959 Enters the Lisp system under Maxima. @code{(to-maxima)} returns to Maxima.
963 Define a function and enter the Lisp system under Maxima. The definition is
964 inspected on the property list, then the function definition is extracted,
965 factored and stored in the variable @code{$result}. The variable can be used in Maxima
966 after returning to Maxima.
973 Type (to-maxima) to restart, ($quit) to quit Maxima.
974 MAXIMA> (symbol-plist '$f)
975 (MPROPS (NIL MEXPR ((LAMBDA) ((MLIST) $X)
976 ((MPLUS) ((MEXPT) $X 2) $X))))
977 MAXIMA> (setq $result ($factor (caddr (mget '$f 'mexpr))))
978 ((MTIMES SIMP FACTORED) $X ((MPLUS SIMP IRREDUCIBLE) 1 $X))
986 @opencatbox{Categories:}
987 @category{Console interaction}
991 @c -----------------------------------------------------------------------------
992 @anchor{eval_string_lisp}
993 @deffn {Function} eval_string_lisp (@var{str})
995 Sequentially read lisp forms from the string @var{str} and evaluate them.
996 Any values produced from the last form are returned as a Maxima list.
1001 @c eval_string_lisp ("");
1002 @c eval_string_lisp ("(values)");
1003 @c eval_string_lisp ("69");
1004 @c eval_string_lisp ("1 2 3");
1005 @c eval_string_lisp ("(values 1 2 3)");
1006 @c eval_string_lisp ("(defun $foo (x) (* 2 x))");
1011 (%i1) eval_string_lisp ("");
1015 (%i2) eval_string_lisp ("(values)");
1019 (%i3) eval_string_lisp ("69");
1023 (%i4) eval_string_lisp ("1 2 3");
1027 (%i5) eval_string_lisp ("(values 1 2 3)");
1031 (%i6) eval_string_lisp ("(defun $foo (x) (* 2 x))");
1040 See also @ref{eval_string}.
1042 @opencatbox{Categories:}
1043 @category{Debugging}
1044 @category{Evaluation}
1049 @c -----------------------------------------------------------------------------
1051 @defvr {System variable} values
1052 Initial value: @code{[]}
1054 @code{values} is a list of all bound user variables (not Maxima options or
1055 switches). The list comprises symbols bound by @mrefcomma{:} or @mrefdot{::}
1057 If the value of a variable is removed with the commands @code{kill},
1058 @mrefcomma{remove} or @mref{remvalue} the variable is deleted from
1061 See @mref{functions} for a list of user defined functions.
1065 First, @code{values} shows the symbols @code{a}, @code{b}, and @code{c}, but
1066 not @code{d}, it is not bound to a value, and not the user function @code{f}.
1067 The values are removed from the variables. @code{values} is the empty list.
1070 @c [a:99, b:: a-90, c:a-b, d, f(x):=x^2];
1072 @c [kill(a), remove(b,value), remvalue(c)];
1077 (%i1) [a:99, b:: a-90, c:a-b, d, f(x):=x^2];
1079 (%o1) [99, 9, 90, d, f(x) := x ]
1086 (%i3) [kill(a), remove(b,value), remvalue(c)];
1087 (%o3) [done, done, [c]]
1095 @opencatbox{Categories:}
1096 @category{Evaluation}
1097 @category{Global variables}
1101 @c -----------------------------------------------------------------------------
1102 @node Functions and Variables for Display, , Functions and Variables for Command Line, Command Line
1103 @section Functions and Variables for Display
1104 @c -----------------------------------------------------------------------------
1106 @c -----------------------------------------------------------------------------
1108 @defvr {Option variable} %edispflag
1109 Default value: @code{false}
1111 When @code{%edispflag} is @code{true}, Maxima displays @code{%e} to a negative
1112 exponent as a quotient. For example, @code{%e^-x} is displayed as
1113 @code{1/%e^x}. See also @mrefdot{exptdispflag}
1128 (%i2) %edispflag:true$
1138 @opencatbox{Categories:}
1139 @category{Exponential and logarithm functions}
1140 @category{Display flags and variables}
1144 @c -----------------------------------------------------------------------------
1146 @defvr {Option variable} absboxchar
1147 Default value: @code{!}
1149 @code{absboxchar} is the character used to draw absolute value
1150 signs around expressions which are more than one line tall.
1152 @code{absboxchar} is only used when @code{display2d_unicode} is @code{false}.
1157 (%i1) display2d_unicode: false $
1163 @opencatbox{Categories:}
1164 @category{Display flags and variables}
1168 @c AFTER REVIEWING src/displa.lisp, IT LOOKS LIKE THIS VARIABLE HAS NO EFFECT
1169 @c CUT IT ON THE NEXT PASS
1170 @c @defvar cursordisp
1171 @c Default value: @code{true}
1173 @c When @code{cursordisp} is @code{true}, expressions are drawn by
1174 @c the displayer in logical sequence. This only works with a console
1175 @c which can do cursor movement. If @code{false}, expressions are
1176 @c printed line by line.
1178 @c @code{cursordisp} is always @code{false} when a @code{writefile} is in
1183 @c -----------------------------------------------------------------------------
1184 @anchor{declare_index_properties}
1185 @deffn {Function} declare_index_properties (@var{a}, [@var{p_1}, @var{p_2}, @var{p_3}, ...])
1186 @deffnx {Function} declare_index_properties ([@var{a}, @var{b}, @var{c}, ...], [@var{p_1}, @var{p_2}, @var{p_3}, ...])
1187 @deffnx {Symbol} postsubscript
1188 @deffnx {Symbol} postsuperscript
1189 @deffnx {Symbol} presuperscript
1190 @deffnx {Symbol} presubscript
1192 Declares the properties of indices applied to the symbol @var{a}
1193 or each of the of symbols @var{a}, @var{b}, @var{c}, ....
1194 If multiple symbols are given,
1195 the whole list of properties applies to each symbol.
1197 Given a symbol with indices, @code{@var{a}[@var{i_1}, @var{i_2}, @var{i_3}, ...]},
1198 the @code{k}-th property @var{p_k} applies to the @code{k}-th index @var{i_k}.
1199 There may be any number of index properties, in any order.
1201 Each property @var{p_k} must one of these four recognized properties:
1202 @code{postsubscript}, @code{postsuperscript}, @code{presuperscript}, or @code{presubscript},
1203 to denote indices which are displayed, respectively,
1204 to the right and below, to the right and above, to the left and above, or to the left and below.
1206 Index properties apply only to the 2-dimensional display of indexed variables
1207 (i.e., when @mref{display2d} is @code{true})
1208 and TeX output via @code{tex}.
1209 Otherwise, index properties are ignored.
1210 Index properties do not change the input of indexed variables,
1211 do not change the algebraic properties of indexed variables,
1212 and do not change the 1-dimensional display of indexed variables.
1214 @code{declare_index_properties} quotes (does not evaluate) its arguments.
1216 @code{remove_index_properties} removes index properties.
1217 @code{kill} also removes index properties (and all other properties).
1219 @code{get_index_properties} retrieves index properties.
1223 Given a symbol with indices, @code{@var{a}[@var{i_1}, @var{i_2}, @var{i_3}, ...]},
1224 the @code{k}-th property @var{p_k} applies to the @code{k}-th index @var{i_k}.
1225 There may be any number of index properties, in any order.
1228 @c declare_index_properties (A, [presubscript, postsubscript]);
1229 @c declare_index_properties (B, [postsuperscript, postsuperscript,
1230 @c presuperscript]);
1231 @c declare_index_properties (C, [postsuperscript, presubscript,
1232 @c presubscript, presuperscript]);
1239 (%i1) declare_index_properties (A, [presubscript, postsubscript]);
1243 (%i2) declare_index_properties (B, [postsuperscript, postsuperscript,
1248 (%i3) declare_index_properties (C, [postsuperscript, presubscript,
1249 presubscript, presuperscript]);
1263 (%i6) C[w, x, y, z];
1270 Index properties apply only to the 2-dimensional display of indexed variables and TeX output.
1271 Otherwise, index properties are ignored.
1274 @c declare_index_properties (A, [presubscript, postsubscript]);
1277 @c display2d: false $
1279 @c display2d: true $
1281 @c stringdisp: true $
1282 @c string (A[w, x]);
1286 (%i1) declare_index_properties (A, [presubscript, postsubscript]);
1295 (%i3) tex (A[w, x]);
1296 $$@{@}_@{w@}A_@{x@}$$
1299 (%i4) display2d: false $
1304 (%i6) display2d: true $
1306 (%i7) grind (A[w, x]);
1310 (%i8) stringdisp: true $
1312 (%i9) string (A[w, x]);
1317 @opencatbox{Categories:}
1318 @category{Display flags and variables}
1322 @c -----------------------------------------------------------------------------
1323 @anchor{get_index_properties}
1324 @deffn {Function} get_index_properties (@var{a})
1326 Returns the properties for @var{a} established by @code{declare_index_properties}.
1328 See also @mrefdot{remove_index_properties}
1330 @opencatbox{Categories:}
1331 @category{Display flags and variables}
1335 @c -----------------------------------------------------------------------------
1336 @anchor{remove_index_properties}
1337 @deffn {Function} remove_index_properties (@var{a}, @var{b}, @var{c}, ...)
1339 Removes the properties established by @code{declare_index_properties}.
1340 All index properties are removed from each symbol @var{a}, @var{b}, @var{c}, ....
1342 @code{remove_index_properties} quotes (does not evaluate) its arguments.
1344 @opencatbox{Categories:}
1345 @category{Display flags and variables}
1349 @c -----------------------------------------------------------------------------
1350 @anchor{display_index_separator}
1351 @defvr {Symbol property} display_index_separator
1353 When a symbol @var{A} has index display properties declared via @code{declare_index_properties},
1354 the value of the property @code{display_index_separator}
1355 is the string or other expression which is displayed between indices.
1357 The value of @code{display_index_separator}
1358 is assigned by @code{put(@var{A}, @var{S}, display_index_separator)},
1359 where @var{S} is a string or other expression.
1360 The assigned value is retrieved by @code{get(@var{A}, display_index_separator)}.
1362 The display index separator @var{S} can be a string, including an empty string,
1363 or @code{false}, indicating the default separator, or any expression.
1364 If not a string and not @code{false}, the property value is coerced to a string via @code{string}.
1366 If no display index separator is assigned, the default separator is used.
1367 The default separator is a comma.
1368 There is no way to change the default separator.
1370 Each symbol has its own value of @code{display_index_separator}.
1372 See also @mref{put}, @mref{get}, and @mrefdot{declare_index_properties}
1376 When a symbol @var{A} has index display properties,
1377 the value of the property @code{display_index_separator}
1378 is the string or other expression which is displayed between indices.
1379 The value is assigned by @code{put(@var{A}, @var{S}, display_index_separator)},
1382 @c declare_index_properties (A, [postsuperscript, postsuperscript,
1383 @c presubscript, presubscript]);
1384 @c put (A, ";", display_index_separator);
1389 (%i1) declare_index_properties (A, [postsuperscript, postsuperscript,
1390 presubscript, presubscript]);
1394 (%i2) put (A, ";", display_index_separator);
1398 (%i3) A[w, x, y, z];
1405 The assigned value is retrieved by @code{get(@var{A}, display_index_separator)}.
1408 @c declare_index_properties (A, [postsuperscript, postsuperscript,
1409 @c presubscript, presubscript]);
1410 @c put (A, ";", display_index_separator);
1411 @c get (A, display_index_separator);
1415 (%i1) declare_index_properties (A, [postsuperscript, postsuperscript,
1416 presubscript, presubscript]);
1420 (%i2) put (A, ";", display_index_separator);
1424 (%i3) get (A, display_index_separator);
1429 The display index separator @var{S} can be a string, including an empty string,
1430 or @code{false}, indicating the default separator, or any expression.
1433 @c declare_index_properties (A, [postsuperscript, postsuperscript,
1434 @c presubscript, presubscript]);
1436 @c put (A, "-", display_index_separator);
1438 @c put (A, " ", display_index_separator);
1440 @c put (A, "", display_index_separator);
1442 @c put (A, false, display_index_separator);
1444 @c put (A, 'foo, display_index_separator);
1449 (%i1) declare_index_properties (A, [postsuperscript, postsuperscript,
1450 presubscript, presubscript]);
1454 (%i2) A[w, x, y, z];
1460 (%i3) put (A, "-", display_index_separator);
1464 (%i4) A[w, x, y, z];
1470 (%i5) put (A, " ", display_index_separator);
1474 (%i6) A[w, x, y, z];
1480 (%i7) put (A, "", display_index_separator);
1484 (%i8) A[w, x, y, z];
1490 (%i9) put (A, false, display_index_separator);
1494 (%i10) A[w, x, y, z];
1500 (%i11) put (A, 'foo, display_index_separator);
1504 (%i12) A[w, x, y, z];
1511 If no display index separator is assigned, the default separator is used.
1512 The default separator is a comma.
1515 @c declare_index_properties (A, [postsuperscript, postsuperscript,
1516 @c presubscript, presubscript]);
1521 (%i1) declare_index_properties (A, [postsuperscript, postsuperscript,
1522 presubscript, presubscript]);
1526 (%i2) A[w, x, y, z];
1533 Each symbol has its own value of @code{display_index_separator}.
1536 @c declare_index_properties (A, [postsuperscript, postsuperscript,
1537 @c presubscript, presubscript]);
1538 @c put (A, " ", display_index_separator);
1539 @c declare_index_properties (B, [presuperscript, presuperscript,
1540 @c postsubscript, postsubscript]);
1541 @c put (B, ";", display_index_separator);
1542 @c A[w, x, y, z] + B[w, x, y, z];
1546 (%i1) declare_index_properties (A, [postsuperscript, postsuperscript,
1547 presubscript, presubscript]);
1551 (%i2) put (A, " ", display_index_separator);
1555 (%i3) declare_index_properties (B, [postsuperscript, postsuperscript, presubscript, presubscript]);
1559 (%i4) put (B, ";", display_index_separator);
1563 (%i5) A[w, x, y, z] + B[w, x, y, z];
1570 @opencatbox{Categories:}
1571 @category{Display flags and variables}
1575 @c -----------------------------------------------------------------------------
1577 @deffn {Function} disp (@var{expr_1}, @var{expr_2}, @dots{})
1579 is like @mref{display} but only the value of the arguments are displayed rather
1580 than equations. This is useful for complicated arguments which don't have names
1581 or where only the value of the argument is of interest and not the name.
1583 See also @mref{ldisp} and @mrefdot{print}
1590 @c disp(x, b[1,2], sin(1.0));
1596 (%i3) disp(x, b[1,2], sin(1.0));
1608 @opencatbox{Categories:}
1609 @category{Display functions}
1613 @c -----------------------------------------------------------------------------
1615 @deffn {Function} display (@var{expr_1}, @var{expr_2}, @dots{})
1617 Displays equations whose left side is @var{expr_i} unevaluated, and whose right
1618 side is the value of the expression centered on the line. This function is
1619 useful in blocks and @mref{for} statements in order to have intermediate results
1620 displayed. The arguments to @code{display} are usually atoms, subscripted
1621 variables, or function calls.
1623 See also @mrefcomma{ldisplay} @mrefcomma{disp} and @mrefdot{ldisp}
1630 @c display(x, b[1,2], sin(1.0));
1636 (%i3) display(x, b[1,2], sin(1.0));
1643 sin(1.0) = 0.8414709848078965
1649 @opencatbox{Categories:}
1650 @category{Display functions}
1654 @c -----------------------------------------------------------------------------
1656 @defvr {Option variable} display2d
1657 Default value: @code{true}
1659 When @code{display2d} is @code{true},
1660 the console display is an attempt to present mathematical expressions
1661 as they might appear in books and articles,
1662 using only letters, numbers, and some punctuation characters.
1663 This display is sometimes called the "pretty printer" display.
1665 When @code{display2d} is @code{true},
1666 Maxima attempts to honor the global variable for line length, @code{linel}.
1667 When an atom (symbol, number, or string) would otherwise cause a line to exceed @code{linel},
1668 the atom may be printed in pieces on successive lines,
1669 with a continuation character (backslash, @code{\}) at the end of the leading piece;
1670 however, in some cases, such atoms are printed without a line break,
1671 and the length of the line is greater than @code{linel}.
1673 When @code{display2d} is @code{false},
1674 the console display is a 1-dimensional or linear form
1675 which is the same as the output produced by @code{grind}.
1677 When @code{display2d} is @code{false},
1678 the value of @mref{stringdisp} is ignored,
1679 and strings are always displayed with quote marks.
1681 When @code{display2d} is @code{false},
1682 Maxima attempts to honor @code{linel},
1683 but atoms are not broken across lines,
1684 and the actual length of an output line may exceed @code{linel}.
1686 See also @mref{leftjust} to switch between a left justified and a centered
1687 display of equations.
1704 (%i2) display2d:false$
1711 @opencatbox{Categories:}
1712 @category{Display flags and variables}
1716 @c -----------------------------------------------------------------------------
1717 @anchor{display_format_internal}
1718 @defvr {Option variable} display_format_internal
1719 Default value: @code{false}
1721 When @code{display_format_internal} is @code{true}, expressions are displayed
1722 without being transformed in ways that hide the internal mathematical
1723 representation. The display then corresponds to what @mref{inpart} returns
1724 rather than @mrefdot{part}
1730 a-b; a - b a + (- 1) b
1743 @opencatbox{Categories:}
1744 @category{Display flags and variables}
1748 @c -----------------------------------------------------------------------------
1749 @anchor{with_default_2d_display}
1750 @deffn {Function} with_default_2d_display (expr)
1752 While maxima by default realizes 2d Output using ASCII-Art some frontend
1753 change that to TeX, MathML or a specific XML dialect that better suits
1754 the needs for this specific frontend. @code{with_default_2d_display}
1755 temporarily switches maxima to the default 2D ASCII Art formatter for
1756 outputting the result of @code{expr}.
1758 See also @mref{set_alt_display} and @mrefdot{display2d}
1760 @opencatbox{Categories:}
1761 @category{Display functions}
1765 @c -----------------------------------------------------------------------------
1766 @anchor{display2d_unicode}
1767 @defvr {Option variable} display2d_unicode
1768 Default value: @code{true}
1770 When @code{display2d_unicode} is @code{true},
1771 the 2-d pretty printer (enabled by the global flag @code{display2d}) uses Unicode drawing characters [1] to display
1772 integrals, summations, products, matrices, ratios, derivatives,
1773 @code{box} expressions, @code{at} expressions, and absolute value expressions.
1775 Otherwise, the pretty printer uses only ASCII characters to display every kind of expression.
1777 In addition to displaying expressions in console interaction (as @code{%o} labeled expressions),
1778 the 2-d pretty printer is invoked to display expressions for @code{print},
1779 and @code{printf} with the @code{~m} format specifier.
1784 Expressions displayed by 2-d pretty printer using Unicode drawing characters
1785 (@code{display2d_unicode} equal to @code{true}),
1788 @image{figures/maxima-unicode-display-variety-1,8cm}
1790 Same expressions, displayed using only ASCII characters
1791 (@code{display2d_unicode} equal to @code{false}),
1794 @image{figures/maxima-unicode-display-variety-1-ascii,8cm}
1800 [1] @url{https://en.wikipedia.org/wiki/Box-drawing_character}
1802 @opencatbox{Categories:}
1803 @category{Display flags and variables}
1808 @c IS THIS FUNCTION STILL USEFUL ???
1809 @c REPHRASE, NEEDS EXAMPLES
1811 @c -----------------------------------------------------------------------------
1813 @deffn {Function} dispterms (@var{expr})
1815 Displays @var{expr} in parts one below the other. That is, first the operator
1816 of @var{expr} is displayed, then each term in a sum, or factor in a product, or
1817 part of a more general expression is displayed separately. This is useful if
1818 @var{expr} is too large to be otherwise displayed. For example if @code{P1},
1819 @code{P2}, @dots{} are very large expressions then the display program may run
1820 out of storage space in trying to display @code{P1 + P2 + ...} all at once.
1821 However, @code{dispterms (P1 + P2 + ...)} displays @code{P1}, then below it
1822 @code{P2}, etc. When not using @code{dispterms}, if an exponential expression
1823 is too wide to be displayed as @code{A^B} it appears as @code{expt (A, B)} (or
1824 as @code{ncexpt (A, B)} in the case of @code{A^^B}).
1829 (%i1) dispterms(2*a*sin(x)+%e^x);
1841 @opencatbox{Categories:}
1842 @category{Display functions}
1846 @c -----------------------------------------------------------------------------
1849 @deffn {Special symbol} expt (@var{a}, @var{b})
1850 @deffnx {Special symbol} ncexpt (@var{a}, @var{b})
1852 If an exponential expression is too wide to be displayed as
1853 @code{@var{a}^@var{b}} it appears as @code{expt (@var{a}, @var{b})} (or as
1854 @code{ncexpt (@var{a}, @var{b})} in the case of @code{@var{a}^^@var{b}}).
1856 @c THIS SEEMS LIKE A BUG TO ME. expt, ncexpt SHOULD BE RECOGNIZED SINCE MAXIMA
1857 @c ITSELF PRINTS THEM SOMETIMES. THESE SHOULD JUST SIMPLIFY TO ^ AND ^^,
1859 @code{expt} and @code{ncexpt} are not recognized in input.
1862 @c -----------------------------------------------------------------------------
1863 @anchor{exptdispflag}
1864 @defvr {Option variable} exptdispflag
1865 Default value: @code{true}
1867 When @code{exptdispflag} is @code{true}, Maxima displays expressions
1868 with negative exponents using quotients. See also @mrefdot{%edispflag}
1873 (%i1) exptdispflag:true;
1880 (%i3) exptdispflag:false;
1887 @opencatbox{Categories:}
1888 @category{Expressions}
1889 @category{Display flags and variables}
1893 @c -----------------------------------------------------------------------------
1895 @deffn {Function} grind (@var{expr})
1897 The function @code{grind} prints @var{expr} to the console in a form suitable
1898 for input to Maxima. @code{grind} always returns @code{done}.
1900 When @var{expr} is the name of a function or macro, @code{grind} prints the
1901 function or macro definition instead of just the name.
1903 See also @mrefcomma{string} which returns a string instead of printing its
1904 output. @code{grind} attempts to print the expression in a manner which makes
1905 it slightly easier to read than the output of @code{string}.
1907 @code{grind} evaluates its argument.
1914 @c [aa, 1729, aa + 1729];
1916 @c matrix ([aa, 17], [29, bb]);
1918 @c set (aa, 17, 29, bb);
1920 @c exp (aa / (bb + 17)^29);
1922 @c expr: expand ((aa + bb)^10);
1925 @c cholesky (A):= block ([n : length (A), L : copymatrix (A),
1926 @c p : makelist (0, i, 1, length (A))],
1927 @c for i thru n do for j : i thru n do
1928 @c (x : L[i, j], x : x - sum (L[j, k] * L[i, k], k, 1, i - 1),
1929 @c if i = j then p[i] : 1 / sqrt(x) else L[j, i] : x * p[i]),
1930 @c for i thru n do L[i, i] : 1 / p[i],
1931 @c for i thru n do for j : i + 1 thru n do L[i, j] : 0, L)$
1932 @c grind (cholesky);
1933 @c string (fundef (cholesky));
1946 (%i3) [aa, 1729, aa + 1729];
1947 (%o3) [aa, 1729, aa + 1729]
1955 (%i5) matrix ([aa, 17], [29, bb]);
1962 matrix([aa,17],[29,bb])$
1966 (%i7) set (aa, 17, 29, bb);
1967 (%o7) @{17, 29, aa, bb@}
1975 (%i9) exp (aa / (bb + 17)^29);
1988 (%i11) expr: expand ((aa + bb)^10);
1990 (%o11) bb + 10 aa bb + 45 aa bb + 120 aa bb + 210 aa bb
1992 + 252 aa bb + 210 aa bb + 120 aa bb + 45 aa bb
1997 (%i12) grind (expr);
1998 bb^10+10*aa*bb^9+45*aa^2*bb^8+120*aa^3*bb^7+210*aa^4*bb^6
1999 +252*aa^5*bb^5+210*aa^6*bb^4+120*aa^7*bb^3+45*aa^8*bb^2
2004 (%i13) string (expr);
2005 (%o13) bb^10+10*aa*bb^9+45*aa^2*bb^8+120*aa^3*bb^7+210*aa^4*bb^6\
2006 +252*aa^5*bb^5+210*aa^6*bb^4+120*aa^7*bb^3+45*aa^8*bb^2+10*aa^9*\
2010 (%i14) cholesky (A):= block ([n : length (A), L : copymatrix (A),
2011 p : makelist (0, i, 1, length (A))],
2012 for i thru n do for j : i thru n do
2013 (x : L[i, j], x : x - sum (L[j, k] * L[i, k], k, 1, i - 1),
2014 if i = j then p[i] : 1 / sqrt(x) else L[j, i] : x * p[i]),
2015 for i thru n do L[i, i] : 1 / p[i],
2016 for i thru n do for j : i + 1 thru n do L[i, j] : 0, L)$
2017 define: warning: redefining the built-in function cholesky
2020 (%i15) grind (cholesky);
2022 [n:length(A),L:copymatrix(A),
2023 p:makelist(0,i,1,length(A))],
2025 (for j from i thru n do
2026 (x:L[i,j],x:x-sum(L[j,k]*L[i,k],k,1,i-1),
2027 if i = j then p[i]:1/sqrt(x)
2028 else L[j,i]:x*p[i])),
2029 for i thru n do L[i,i]:1/p[i],
2030 for i thru n do (for j from i+1 thru n do L[i,j]:0),L)$
2034 (%i16) string (fundef (cholesky));
2035 (%o16) cholesky(A):=block([n:length(A),L:copymatrix(A),p:makelis\
2036 t(0,i,1,length(A))],for i thru n do (for j from i thru n do (x:L\
2037 [i,j],x:x-sum(L[j,k]*L[i,k],k,1,i-1),if i = j then p[i]:1/sqrt(x\
2038 ) else L[j,i]:x*p[i])),for i thru n do L[i,i]:1/p[i],for i thru \
2039 n do (for j from i+1 thru n do L[i,j]:0),L)
2043 @opencatbox{Categories:}
2044 @category{Display functions}
2048 @defvr {Option variable} grind
2050 When the variable @code{grind} is @code{true}, the output of @code{string} and
2051 @mref{stringout} has the same format as that of @code{grind}; otherwise no
2052 attempt is made to specially format the output of those functions. The default
2053 value of the variable @code{grind} is @code{false}.
2055 @code{grind} can also be specified as an argument of @mrefdot{playback} When
2056 @code{grind} is present, @code{playback} prints input expressions in the same
2057 format as the @code{grind} function. Otherwise, no attempt is made to specially
2058 format input expressions.
2060 @opencatbox{Categories:}
2061 @category{Display flags and variables}
2065 @c -----------------------------------------------------------------------------
2067 @defvr {Option variable} ibase
2068 Default value: @code{10}
2070 @code{ibase} is the base for integers read by Maxima.
2072 @code{ibase} may be assigned any integer between 2 and 36 (decimal), inclusive.
2073 When @code{ibase} is greater than 10,
2074 the numerals comprise the decimal numerals 0 through 9
2075 plus letters of the alphabet @code{A}, @code{B}, @code{C}, @dots{},
2076 as needed to make @code{ibase} digits in all.
2077 Letters are interpreted as digits only if the first digit is 0 through 9.
2079 Uppercase and lowercase letters are not distinguished.
2080 The numerals for base 36, the largest acceptable base,
2081 comprise 0 through 9 and @code{A} through @code{Z}.
2083 Whatever the value of @code{ibase},
2084 when an integer is terminated by a decimal point,
2085 it is interpreted in base 10.
2087 See also @mrefdot{obase}
2091 @code{ibase} less than 10 (for example binary numbers).
2096 @c 1111111111111111;
2105 (%i3) 1111111111111111;
2110 @code{ibase} greater than 10.
2111 Letters are interpreted as digits only if the first digit is 0
2112 through 9 which means that hexadecimal numbers might need to
2113 be prepended by a 0.
2139 (%i5) symbolp (abcd);
2147 (%i7) symbolp (0abcd);
2152 When an integer is terminated by a decimal point,
2153 it is interpreted in base 10.
2177 @opencatbox{Categories:}
2178 @category{Console interaction}
2182 @c -----------------------------------------------------------------------------
2184 @deffn {Function} ldisp (@var{expr_1}, @dots{}, @var{expr_n})
2186 Displays expressions @var{expr_1}, @dots{}, @var{expr_n} to the console as
2187 printed output. @code{ldisp} assigns an intermediate expression label to each
2188 argument and returns the list of labels.
2190 See also @mrefcomma{disp} @mrefcomma{display} and @mrefdot{ldisplay}
2198 (%i2) f: expand (e);
2200 (%o2) b + 3 a b + 3 a b + a
2206 (%t4) b + 3 a b + 3 a b + a
2214 (%o5) b + 3 a b + 3 a b + a
2217 @opencatbox{Categories:}
2218 @category{Display functions}
2222 @c -----------------------------------------------------------------------------
2224 @deffn {Function} ldisplay (@var{expr_1}, @dots{}, @var{expr_n})
2226 Displays expressions @var{expr_1}, @dots{}, @var{expr_n} to the console as
2227 printed output. Each expression is printed as an equation of the form
2228 @code{lhs = rhs} in which @code{lhs} is one of the arguments of @code{ldisplay}
2229 and @code{rhs} is its value. Typically each argument is a variable.
2230 @mref{ldisp} assigns an intermediate expression label to each equation and
2231 returns the list of labels.
2233 See also @mrefcomma{display} @mrefcomma{disp} and @mrefdot{ldisp}
2241 (%i2) f: expand (e);
2243 (%o2) b + 3 a b + 3 a b + a
2244 (%i3) ldisplay (e, f);
2249 (%t4) f = b + 3 a b + 3 a b + a
2257 (%o5) f = b + 3 a b + 3 a b + a
2260 @opencatbox{Categories:}
2261 @category{Display functions}
2265 @c -----------------------------------------------------------------------------
2267 @defvr {Option variable} leftjust
2268 Default value: @code{false}
2270 When @code{leftjust} is @code{true}, equations in 2D-display are drawn left
2271 justified rather than centered.
2273 See also @mref{display2d} to switch between 1D- and 2D-display.
2278 (%i1) expand((x+1)^3);
2280 (%o1) x + 3 x + 3 x + 1
2281 (%i2) leftjust:true$
2282 (%i3) expand((x+1)^3);
2284 (%o3) x + 3 x + 3 x + 1
2287 @opencatbox{Categories:}
2288 @category{Display flags and variables}
2292 @c -----------------------------------------------------------------------------
2294 @defvr {Option variable} linel
2295 Default value: @code{79}
2297 @code{linel} is the assumed width (in characters) of the console display for the
2298 purpose of displaying expressions. @code{linel} may be assigned any value by
2299 the user, although very small or very large values may be impractical. Text
2300 printed by built-in Maxima functions, such as error messages and the output of
2301 @mrefcomma{describe} is not affected by @code{linel}.
2303 @opencatbox{Categories:}
2304 @category{Display flags and variables}
2308 @c -----------------------------------------------------------------------------
2311 @defvr {Option variable} lispdisp
2312 Default value: @code{false}
2314 When @code{lispdisp} is @code{true}, Lisp symbols are displayed with a leading
2315 question mark @code{?}. Otherwise, Lisp symbols are displayed with no leading
2316 mark. This has the same effect for 1-d and 2-d display.
2327 (%i1) lispdisp: false$
2332 (%i3) lispdisp: true$
2339 @opencatbox{Categories:}
2340 @category{Display flags and variables}
2344 @c NEEDS CLARIFICATION, EXAMPLES
2346 @c -----------------------------------------------------------------------------
2347 @anchor{negsumdispflag}
2348 @defvr {Option variable} negsumdispflag
2349 Default value: @code{true}
2351 When @code{negsumdispflag} is @code{true}, @code{x - y} displays as @code{x - y}
2352 instead of as @code{- y + x}. Setting it to @code{false} causes the special
2353 check in display for the difference of two expressions to not be done. One
2354 application is that thus @code{a + %i*b} and @code{a - %i*b} may both be
2355 displayed the same way.
2357 @opencatbox{Categories:}
2358 @category{Display flags and variables}
2362 @c -----------------------------------------------------------------------------
2364 @defvr {Option variable} obase
2365 Default value: @code{10}
2367 @code{obase} is the base for integers displayed by Maxima.
2369 @code{obase} may be assigned any integer between 2 and 36 (decimal), inclusive.
2370 When @code{obase} is greater than 10,
2371 the numerals comprise the decimal numerals 0 through 9
2372 plus capital letters of the alphabet A, B, C, @dots{}, as needed.
2373 A leading 0 digit is displayed if the leading digit is otherwise a letter.
2374 The numerals for base 36, the largest acceptable base,
2375 comprise 0 through 9, and A through Z.
2377 See also @mrefdot{ibase}
2426 @opencatbox{Categories:}
2427 @category{Display flags and variables}
2428 @category{Console interaction}
2432 @c -----------------------------------------------------------------------------
2434 @defvr {Option variable} pfeformat
2435 Default value: @code{false}
2437 When @code{pfeformat} is @code{true}, a ratio of integers is displayed with the
2438 solidus (forward slash) character, and an integer denominator @code{n} is
2439 displayed as a leading multiplicative term @code{1/n}.
2444 (%i1) pfeformat: false$
2453 (%i4) pfeformat: true$
2460 @opencatbox{Categories:}
2461 @category{Display flags and variables}
2465 @c -----------------------------------------------------------------------------
2467 @defvr {Option variable} powerdisp
2468 Default value: @code{false}
2470 When @code{powerdisp} is @code{true},
2471 a sum is displayed with its terms in order of increasing power.
2472 Thus a polynomial is displayed as a truncated power series,
2473 with the constant term first and the highest power last.
2475 By default, terms of a sum are displayed in order of decreasing power.
2480 (%i1) powerdisp:true;
2485 (%i3) powerdisp:false;
2492 @opencatbox{Categories:}
2493 @category{Display flags and variables}
2497 @c -----------------------------------------------------------------------------
2499 @deffn {Function} print (@var{expr_1}, @dots{}, @var{expr_n})
2501 Evaluates and displays @var{expr_1}, @dots{}, @var{expr_n} one after another,
2502 from left to right, starting at the left edge of the console display.
2504 The value returned by @code{print} is the value of its last argument.
2505 @code{print} does not generate intermediate expression labels.
2507 See also @mrefcomma{display} @mrefcomma{disp} @mrefcomma{ldisplay} and
2508 @mrefdot{ldisp} Those functions display one expression per line, while
2509 @code{print} attempts to display two or more expressions per line.
2511 To display the contents of a file, see @mrefdot{printfile}
2516 (%i1) r: print ("(a+b)^3 is", expand ((a+b)^3), "log (a^10/b) is",
2517 radcan (log (a^10/b)))$
2519 (a+b)^3 is b + 3 a b + 3 a b + a log (a^10/b) is
2523 (%o2) 10 log(a) - log(b)
2524 (%i3) disp ("(a+b)^3 is", expand ((a+b)^3), "log (a^10/b) is",
2525 radcan (log (a^10/b)))$
2529 b + 3 a b + 3 a b + a
2536 @opencatbox{Categories:}
2537 @category{Display functions}
2541 @c -----------------------------------------------------------------------------
2542 @anchor{sqrtdispflag}
2543 @defvr {Option variable} sqrtdispflag
2544 Default value: @code{true}
2546 When @code{sqrtdispflag} is @code{false}, causes @code{sqrt} to display with
2548 @c AND OTHERWISE ... ??
2550 @opencatbox{Categories:}
2551 @category{Mathematical functions}
2552 @category{Display flags and variables}
2556 @c -----------------------------------------------------------------------------
2558 @defvr {Option variable} stardisp
2559 Default value: @code{false}
2561 When @code{stardisp} is @code{true}, multiplication is
2562 displayed with an asterisk @code{*} between operands.
2564 @opencatbox{Categories:}
2565 @category{Display flags and variables}
2569 @c -----------------------------------------------------------------------------
2571 @defvr {Option variable} ttyoff
2572 Default value: @code{false}
2574 When @code{ttyoff} is @code{true}, output expressions are not displayed.
2575 Output expressions are still computed and assigned labels. See @mrefdot{labels}
2577 Text printed by built-in Maxima functions, such as error messages and the output
2578 of @mrefcomma{describe} is not affected by @code{ttyoff}.
2580 @opencatbox{Categories:}
2581 @category{Display flags and variables}