[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
9.1 Introduction to Input and Output | ||
9.2 Files | ||
9.3 Definitions for Input and Output |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A file is simply an area on a particular storage device which contains data or text.
Files on the disks are figuratively grouped into "directories".
A directory is just a list of files.
Commands which deal with files are:
save
,
load
,
loadfile
,
stringout
,
batch
,
demo
,
writefile
,
closefile
,
and
appendfile
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
__
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
, but not by load
.
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 |
_
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
, but not by load
.
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 |
%
is the output expression (e.g., %o1
, %o2
, %o3
, ...)
most recently computed by Maxima,
whether or not it was displayed.
%
is recognized by batch
, but not by load
.
See also _
, %%
, and %th
.
In compound statements,
namely block
, lambda
, or (s_1, ..., s_n)
,
%%
is the value of the previous statement.
For example,
block (integrate (x^5, x), ev (%%, x=2) - ev (%%, x=1)); block ([prev], prev: integrate (x^5, x), ev (prev, x=2) - ev (prev, x=1)); |
yield the same result, namely 21/2
.
A compound statement may comprise other compound statements.
Whether a statement be simple or compound,
%%
is the value of the previous statement.
For example,
block (block (a^n, %%*42), %%/6) |
yields 7*a^n
.
Within a compound statement, the value of %%
may be inspected at a break prompt,
which is opened by executing the break
function.
For example, at the break prompt opened by
block (a: 42, break ())$ |
entering %%;
yields 42
.
At the first statement in a compound statement,
or outside of a compound statement,
%%
is undefined.
%%
is recognized by both batch
and load
.
See also %
.
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
.
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 useful in batch
files or for referring to a group of output expressions.
For example,
block (s: 0, for i:1 thru 10 do s: s + %th (i))$ |
sets s
to the sum of the last ten output expressions.
%th
is recognized by batch
, but not by load
.
See also %
.
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")
.
Default value: !
absboxchar
is the character used to draw absolute value
signs around expressions which are more than one line tall.
Default value: false
file_output_append
governs whether file output functions
append or truncate their output file.
When file_output_append
is true
,
such functions append to their output file.
Otherwise, the output file is truncated.
save
, stringout
, and with_stdout
respect file_output_append
.
Other functions which write output files do not respect file_output_append
.
In particular, plotting and translation functions always truncate their output file,
and tex
and appendfile
always append.
Appends a console transcript to filename.
appendfile
is the same as writefile
,
except that the transcript file, if it exists, is always appended.
closefile
closes the transcript file opened by appendfile
or writefile
.
Reads Maxima expressions from filename and evaluates them.
batch
searches for filename in the list file_search_maxima
.
See file_search
.
filename comprises a sequence of Maxima expressions,
each terminated with ;
or $
.
The special variable %
and the function %th
refer to previous results within the file.
The file may include :lisp
constructs.
Spaces, tabs, and newlines in the file are ignored.
A suitable input file may be created by a text editor or by the stringout
function.
batch
reads each input expression from filename,
displays the input to the console,
computes the corresponding output expression,
and displays the output expression.
Input labels are assigned to the input expressions
and output labels are assigned to the output expressions.
batch
evaluates every input expression in the file
unless there is an error.
If user input is requested (by asksign
or askinteger
, for example)
batch
pauses to collect the requisite input and then continue.
It may be possible to halt batch
by typing control-C
at the console.
The effect of control-C
depends on the underlying Lisp implementation.
batch
has several uses,
such as to provide a reservoir for working command lines,
to give error-free demonstrations,
or to help organize one's thinking in solving complex problems.
batch
evaluates its argument.
batch
has no return value.
See also load
, batchload
, and demo
.
Reads Maxima expressions from filename and evaluates them,
without displaying the input or output expressions
and without assigning labels to output expressions.
Printed output (such as produced by print
or describe
)
is displayed, however.
The special variable %
and the function %th
refer to previous results from the interactive interpreter,
not results within the file.
The file cannot include :lisp
constructs.
batchload
returns the path of filename, as a string.
batchload
evaluates its argument.
See also batch
and load
.
Closes the transcript file opened by writefile
or appendfile
.
Collapses expr by causing all of its
common (i.e., equal) subexpressions to share (i.e., use the same cells),
thereby saving space. (collapse
is a subroutine used by the optimize
command.) Thus, calling collapse
may be useful
after loading in a save
file. You can collapse several expressions
together by using collapse ([expr_1, ..., expr_n])
. Similarly, you can
collapse the elements of the array A
by doing
collapse (listarray ('A))
.
Concatenates its arguments. The arguments must evaluate to atoms. The return value is a symbol if the first argument is a symbol and a Maxima string otherwise.
concat
evaluates its arguments.
The single quote '
prevents evaluation.
(%i1) y: 7$ (%i2) z: 88$ (%i3) concat (y, z/2); (%o3) 744 (%i4) concat ('y, z/2); (%o4) y44 |
A symbol constructed by concat
may
be assigned a value and appear in expressions.
The ::
(double colon) assignment operator evaluates its left-hand side.
(%i5) a: concat ('y, z/2); (%o5) y44 (%i6) a:: 123; (%o6) 123 (%i7) y44; (%o7) 123 (%i8) b^a; y44 (%o8) b (%i9) %, numer; 123 (%o9) b |
Note that although concat (1, 2)
looks like a number, it is a Maxima string.
(%i10) concat (1, 2) + 3; (%o10) 12 + 3 |
Concatenates its arguments into a string.
Unlike concat
, the arguments do not need to be atoms.
The result is a Lisp string.
(%i1) sconcat ("xx[", 3, "]:", expand ((x+y)^3)); (%o1) xx[3]:y^3+3*x*y^2+3*x^2*y+x^3 |
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.
Displays the contraction properties of
its arguments as were given to defcon
. dispcon (all)
displays all the
contraction properties which were defined.
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 disp
.
(%i1) display(B[1,2]); 2 B = X - X 1, 2 (%o1) done |
Default value: true
When display2d
is false
,
the console display is a string (1-dimensional) form rather than a display
(2-dimensional) form.
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 |
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
).
Default value: 10
error_size
modifies error messages according to the size of expressions which appear in them.
If the size of an expression (as determined by the Lisp function ERROR-SIZE
)
is greater than error_size
,
the expression is replaced in the message by a symbol,
and the symbol is assigned the expression.
The symbols are taken from the list error_syms
.
Otherwise, the expression is smaller than error_size
,
and the expression is displayed in the message.
See also error
and error_syms
.
Example:
The size of U
, as determined by ERROR-SIZE
, is 24.
(%i1) U: (C^D^E + B + A)/(cos(X-1) + 1)$ (%i2) error_size: 20$ (%i3) error ("Example expression is", U); Example expression is errexp1 -- an error. Quitting. To debug this try debugmode(true); (%i4) errexp1; E D C + B + A (%o4) -------------- cos(X - 1) + 1 (%i5) error_size: 30$ (%i6) error ("Example expression is", U); E D C + B + A Example expression is -------------- cos(X - 1) + 1 -- an error. Quitting. To debug this try debugmode(true); |
Default value: [errexp1, errexp2, errexp3]
In error messages,
expressions larger than error_size
are replaced by symbols, and the
symbols are set to the expressions. The symbols are taken from the
list error_syms
.
The first too-large expression is replaced by error_syms[1]
,
the second by error_syms[2]
, and so on.
If there are more too-large expressions than there are elements of error_syms
,
symbols are constructed automatically,
with the n-th symbol equivalent to concat ('errexp, n)
.
See also error
and error_size
.
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.
Default value: true
When exptdispflag
is true
, Maxima displays expressions
with negative exponents using quotients, e.g., X^(-1)
as 1/X
.
Constructs a modified path from path and filename.
If the final component of path is of the form ###.something
,
the component is replaced with filename.something
.
Otherwise, the final component is simply replaced by filename.
file_search
searches for the file filename and returns the path to the file
(as a string) if it can be found; otherwise file_search
returns false
.
file_search (filename)
searches in the default search directories,
which are specified by the file_search_maxima
, file_search_lisp
, and file_search_demo
variables.
file_search
first checks if the actual name passed exists,
before attempting to match it to "wildcard" file search patterns.
See file_search_maxima
concerning file search patterns.
The argument filename can be a path and file name, or just a file name, or, if a file search directory includes a file search pattern, just the base of the file name (without an extension). For example,
file_search ("/home/wfs/special/zeta.mac"); file_search ("zeta.mac"); file_search ("zeta"); |
all find the same file, assuming the file exists and /home/wfs/special/###.mac
is in file_search_maxima
.
file_search (filename, pathlist)
searches only in the directories
specified by pathlist,
which is a list of strings.
The argument pathlist supersedes the default search directories,
so if the path list is given, file_search
searches only the ones specified,
and not any of the default search directories.
Even if there is only one directory in pathlist, it must still be given as a one-element list.
The user may modify the default search directories. See file_search_maxima
.
file_search
is invoked by load
with file_search_maxima
and file_search_lisp
as the search directories.
These variables specify lists of directories to be searched
by load
, demo
, and some other Maxima functions.
The default values of these variables
name various directories in the Maxima installation.
The user can modify these variables, either to replace the default values or to append additional directories. For example,
file_search_maxima: ["/usr/local/foo/###.mac", "/usr/local/bar/###.mac"]$ |
replaces the default value of file_search_maxima
,
while
file_search_maxima: append (file_search_maxima, ["/usr/local/foo/###.mac", "/usr/local/bar/###.mac"])$ |
appends two additional directories.
It may be convenient to put such an expression in the file maxima-init.mac
so that the file search path is assigned automatically when Maxima starts.
Multiple filename extensions and multiple paths can be specified by
special "wildcard" constructions.
The string ###
expands into the sought-after name,
while a comma-separated list enclosed in curly braces {foo,bar,baz}
expands
into multiple strings.
For example, supposing the sought-after name is neumann
,
"/home/{wfs,gcj}/###.{lisp,mac}" |
expands into /home/wfs/neumann.lisp
, /home/gcj/neumann.lisp
, /home/wfs/neumann.mac
, and /home/gcj/neumann.mac
.
Returns a guess about the content of filename, based on the filename extension. filename need not refer to an actual file; no attempt is made to open the file and inspect the content.
The return value is a symbol, either object
, lisp
, or maxima
.
If the extension starts with m
or d
, file_type
returns maxima
.
If the extension starts with l
, file_type
returns lisp
.
If none of the above, file_type
returns object
.
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
.
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.
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)$ (%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) |
Default value: 10
Integers entered into Maxima are interpreted
with respect to the base ibase
.
ibase
may be assigned any integer between 2 and 35 (decimal), inclusive.
When ibase
is greater than 10, the numerals comprise the decimal numerals 0 through 9
plus capital letters of the alphabet A, B, C, ..., as needed.
The numerals for base 35, the largest acceptable base,
comprise 0 through 9 and A through Y.
See also obase
.
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.
(%i1) inchar: "input"; (%o1) input (input1) expand ((a+b)^3); 3 2 2 3 (%o1) b + 3 a b + 3 a b + a (input2) |
See also labels
.
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
.
(%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 |
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
.
(%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 |
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.
Intermediate expressions might or might not be displayed.
See programmode
and labels
.
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
.
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.
Examples:
(%i1) lispdisp: false$ (%i2) ?foo + ?bar; (%o2) foo + bar (%i3) lispdisp: true$ (%i4) ?foo + ?bar; (%o4) ?foo + ?bar |
Evaluates expressions in filename,
thus bringing variables, functions, and other objects into Maxima.
The binding of any existing object is clobbered by the binding recovered from filename.
To find the file,
load
calls file_search
with file_search_maxima
and file_search_lisp
as the search directories.
If load
succeeds, it returns the name of the file.
Otherwise load
prints an error message.
load
works equally well for Lisp code and Maxima code.
Files created by save
, translate_file
, and compile_file
, which create Lisp code,
and stringout
, which creates Maxima code,
can all be processed by load
.
load
calls loadfile
to load Lisp files and batchload
to load Maxima files.
See also loadfile
, batch
, batchload
, and demo
.
loadfile
processes Lisp files;
batch
, batchload
, and demo
process Maxima files.
See file_search
for more detail about the file search mechanism.
load
evaluates its argument.
Evaluates Lisp expressions in filename.
loadfile
does not invoke file_search
, so filename
must include
the file extension and as much of the path as needed to find the file.
loadfile
can process files created by save
, translate_file
, and compile_file
.
The user may find it more convenient to use load
instead of loadfile
.
loadfile
quotes its argument, so filename
must be a literal string,
not a string variable.
The double-single-quote operator defeats quotation.
Default value: true
loadprint
tells whether to print a message when a file is loaded.
loadprint
is true
, always print a message.
loadprint
is 'loadfile
, print a message only if
a file is loaded by the function loadfile
.
loadprint
is 'autoload
,
print a message only if a file is automatically loaded.
See setup_autoload
.
loadprint
is false
, never print a message.
Default value: 10
obase
is the base for integers displayed by Maxima.
obase
may be assigned any integer between 2 and 35 (decimal), inclusive.
When obase
is greater than 10, the numerals comprise the decimal numerals 0 through 9
plus capital letters of the alphabet A, B, C, ..., as needed.
The numerals for base 35, the largest acceptable base,
comprise 0 through 9, and A through Y.
See also ibase
.
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.
(%i1) outchar: "output"; (output1) output (%i2) expand ((a+b)^3); 3 2 2 3 (output2) b + 3 a b + 3 a b + a (%i3) |
See also labels
.
Default value: false
Package designers who use save
or translate
to create packages (files) for others
to use may want to set packagefile: true
to prevent information
from being added to Maxima's information-lists (e.g. values
,
functions
) except where necessary when the file is loaded in.
In this way, the contents of the package will not get in the
user's way when he adds his own data. Note that this will not
solve the problem of possible name conflicts. Also note that
the flag simply affects what is output to the package file.
Setting the flag to true
is also useful for creating Maxima
init files.
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
.
(%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) |
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
.
(%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) |
Prints elements of a list enclosed by curly braces { }
,
suitable as part of a program in the Tcl/Tk language.
tcl_output (list, i0, skip)
prints list, beginning with element i0 and printing elements
i0 + skip
, i0 + 2 skip
, etc.
tcl_output (list, i0)
is equivalent to tcl_output (list, i0, 2)
.
tcl_output ([list_1, ..., list_n], i)
prints the i'th elements of list_1, ..., list_n.
Examples:
(%i1) tcl_output ([1, 2, 3, 4, 5, 6], 1, 3)$ {1.000000000 4.000000000 } (%i2) tcl_output ([1, 2, 3, 4, 5, 6], 2, 3)$ {2.000000000 5.000000000 } (%i3) tcl_output ([3/7, 5/9, 11/13, 13/17], 1)$ {((RAT SIMP) 3 7) ((RAT SIMP) 11 13) } (%i4) tcl_output ([x1, y1, x2, y2, x3, y3], 2)$ {$Y1 $Y2 $Y3 } (%i5) tcl_output ([[1, 2, 3], [11, 22, 33]], 1)$ {SIMP 1.000000000 11.00000000 } |
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
.
(%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) |
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).
(%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 |
See also read
.
Replaces parts of expr at the specified integer depth with descriptive summaries.
sum(n)
where n is the number of operands of the sum.
product(n)
where n is the number of operands of the product.
expt
.
quotient
.
negterm
.
When depth is greater than or equal to the maximum depth of expr,
reveal (expr, depth)
returns expr unmodified.
reveal
evaluates its arguments.
reveal
returns the summarized expression.
Example:
(%i1) e: expand ((a - b)^2)/expand ((exp(a) + exp(b))^2); 2 2 b - 2 a b + a (%o1) ------------------------- b + a 2 b 2 a 2 %e + %e + %e (%i2) reveal (e, 1); (%o2) quotient (%i3) reveal (e, 2); sum(3) (%o3) ------ sum(3) (%i4) reveal (e, 3); expt + negterm + expt (%o4) ------------------------ product(2) + expt + expt (%i5) reveal (e, 4); 2 2 b - product(3) + a (%o5) ------------------------------------ product(2) product(2) 2 expt + %e + %e (%i6) reveal (e, 5); 2 2 b - 2 a b + a (%o6) -------------------------- sum(2) 2 b 2 a 2 %e + %e + %e (%i7) reveal (e, 6); 2 2 b - 2 a b + a (%o7) ------------------------- b + a 2 b 2 a 2 %e + %e + %e |
Default value: ]
rmxchar
is the character drawn on the right-hand side of a matrix.
See also lmxchar
.
Stores the current values of name_1, name_2, name_3, ..., in filename.
The arguments are the names of variables, functions, or other objects.
If a name has no value or function associated with it, it is ignored.
save
returns filename.
save
stores data in the form of Lisp expressions.
The data stored by save
may be recovered by load (filename)
.
The global flag file_output_append
governs
whether save
appends or truncates the output file.
When file_output_append
is true
,
save
appends to the output file.
Otherwise, save
truncates the output file.
In either case, save
creates the file if it does not yet exist.
The special form save (filename, values, functions, labels, ...)
stores the items named by values
, functions
, labels
, etc.
The names may be any specified by the variable infolists
.
values
comprises all user-defined variables.
The special form save (filename, [m, n])
stores the values of
input and output labels m through n.
Note that m and n must be literal integers or double-quoted symbols.
Input and output labels may also be stored one by one, e.g., save ("foo.1", %i42, %o42)
.
save (filename, labels)
stores all input and output labels.
When the stored labels are recovered, they clobber existing labels.
The special form save (filename, name_1=expr_1, name_2=expr_2, ...)
stores the values of expr_1, expr_2, ...,
with names name_1, name_2, ....
It is useful to apply this form to input and output labels, e.g., save ("foo.1", aa=%o88)
.
The right-hand side of the equality in this form may be any expression, which is evaluated.
This form does not introduce the new names into the current Maxima environment,
but only stores them in filename.
These special forms and the general form of save
may be mixed at will.
For example, save (filename, aa, bb, cc=42, functions, [11, 17])
.
The special form save (filename, all)
stores the current state of Maxima.
This includes all user-defined variables, functions, arrays, etc., as well
as some automatically defined items.
The saved items include system variables,
such as file_search_maxima
or showtime
, if they have been assigned new values by the user;
see myoptions
.
save
quotes its arguments.
filename must be a string, not a string variable.
The first and last labels to save, if specified, must be integers.
The double quote operator evaluates a string variable to its string value,
e.g., s: "foo.1"$ save (''s, all)$
,
and integer variables to their integer values, e.g., m: 5$ n: 12$ save ("foo.1", [''m, ''n])$
.
Default value: true
When savedef
is true
, the Maxima version of a
user function is preserved when the function is translated.
This permits the definition to be displayed by dispfun
and allows the function to
be edited.
When savedef
is false
, the names of translated functions are
removed from the functions
list.
Displays expr
with the indexed objects in it shown
having covariant indices as subscripts, contravariant indices as
superscripts. The derivative indices are displayed as subscripts,
separated from the covariant indices by a comma.
Returns a list of the canonical rational expression (CRE) variables in expression expr
.
See also ratvars
.
Default value: false
When stardisp
is true
, multiplication is
displayed with an asterisk *
between operands.
Converts expr
to Maxima's linear notation
just as if it had been typed in.
The return value of string
is a string,
and thus it cannot be used in a computation.
Default value: false
When ?stringdisp
is true
,
strings are displayed enclosed in double quote marks.
Otherwise,
quote marks are not displayed.
?stringdisp
is always true
when displaying a function definition.
?stringdisp
is a Lisp variable,
so it must be written with a leading question mark ?
.
Examples:
(%i1) ?stringdisp: false$ (%i2) "This is an example string."; (%o2) This is an example string. (%i3) foo () := print ("This is a string in a function definition."); (%o3) foo() := print("This is a string in a function definition.") (%i4) ?stringdisp: true$ (%i5) "This is an example string."; (%o5) "This is an example string." |
stringout
writes expressions to a file in the same form the
expressions would be typed for input. The file can then be used
as input for the batch
or demo
commands, and it may be edited for
any purpose. stringout
can be executed while writefile
is in progress.
The global flag file_output_append
governs
whether stringout
appends or truncates the output file.
When file_output_append
is true
,
stringout
appends to the output file.
Otherwise, stringout
truncates the output file.
In either case, stringout
creates the file if it does not yet exist.
The general form of stringout
writes the values of one or more
expressions to the output file. Note that if an expression is a
variable, only the value of the variable is written and not the name
of the variable. As a useful special case, the expressions may be
input labels (%i1
, %i2
, %i3
, ...) or output labels (%o1
, %o2
, %o3
, ...).
If grind
is true
, stringout
formats the output using the grind
format. Otherwise the string
format is used. See grind
and string
.
The special form stringout (filename, [m, n])
writes the
values of input labels m through n, inclusive.
The special form stringout (filename, input)
writes all
input labels to the file.
The special form stringout (filename, functions)
writes all
user-defined functions (named by the global list functions
) to the file.
The special form stringout (filename, values)
writes all
user-assigned variables (named by the global list values
)
to the file. Each variable is printed as an
assignment statement, with the name of the variable, a colon, and its
value. Note that the general form of stringout
does not print
variables as assignment statements.
Prints a representation of an expression suitable for the TeX document preparation system. The result is a fragment of a document, which can be copied into a larger document but not processed by itself.
tex (expr)
prints a TeX representation of expr on the console.
tex (label)
prints a TeX representation of the expression named by label
and assigns it an equation label (to be displayed to the left of the expression).
The TeX equation label is the same as the Maxima label.
tex (expr, filename)
appends a TeX representation of expr
to the file filename.
tex
quotes the filename argument; quote-quote ''
forces evaluation of the argument.
tex (label, filename)
appends a TeX representation of the
expression named by label, with an equation label, to the file filename.
tex
quotes the filename argument; quote-quote ''
forces evaluation of the argument.
tex
evaluates its argument after testing it to see if it is a label.
Quote-quote ''
forces evaluation of the argument, thereby defeating the test
and preventing the label.
See also texput
.
Examples:
(%i1) integrate (1/(1+x^3), x); 2 x - 1 2 atan(-------) log(x - x + 1) sqrt(3) log(x + 1) (%o1) - --------------- + ------------- + ---------- 6 sqrt(3) 3 (%i2) tex (%o1); $$-{{\log \left(x^2-x+1\right)}\over{6}}+{{\arctan \left({{2\,x-1 }\over{\sqrt{3}}}\right)}\over{\sqrt{3}}}+{{\log \left(x+1\right) }\over{3}}\leqno{\tt (\%o1)}$$ (%o2) (\%o1) (%i3) tex (integrate (sin(x), x)); $$-\cos x$$ (%o3) false (%i4) tex (%o1, "foo.tex"); (%o4) (\%o1) |
Set the TeX output for the atom a, which can be a symbol or the name of an operator.
texput (a, s)
causes the tex
function
to interpolate the string s into the TeX output in place of a.
texput (a, s, operator_type)
,
where operator_type is prefix
, infix
, or postfix
causes the tex
function to interpolate s into the TeX output in place of a,
and to place the interpolated text in the appropriate position.
texput (a, [s_1, s_2], matchfix)
causes the tex
function to interpolate s_1 and s_2 into the TeX output
on either side of the arguments of a.
The arguments (if more than one) are separated by commas.
texput (a, [s_1, s_2, s_3], matchfix)
causes the tex
function to interpolate s_1 and s_2 into the TeX output
on either side of the arguments of a,
with s_3 separating the arguments.
Examples:
(%i1) texput (me,"\\mu_e"); (%o1) \mu_e (%i2) tex (me); $$\mu_e$$ (%o2) false (%i3) texput (lcm, "\\mathrm{lcm}"); (%o3) \mathrm{lcm} (%i4) tex (lcm (a, b)); $$\mathrm{lcm}\left(a , b\right)$$ (%o4) false (%i5) prefix ("grad"); (%o5) grad (%i6) texput ("grad", " \\nabla ", prefix); (%o6) 180 (%i7) tex (grad f); $$ \nabla f$$ (%o7) false (%i8) infix ("~"); (%o8) ~ (%i9) texput ("~", " \\times ", infix); (%o9) 180 (%i10) tex (a ~ b); $$a \times b$$ (%o10) false (%i11) postfix ("@"); (%o11) @ (%i12) texput ("@", "!!", postfix); (%o12) 160 (%i13) tex (x @); $$x!!$$ (%o13) false (%i14) matchfix ("<<", ">>"); (%o14) << (%i15) texput ("<<", [" \\langle ", " \\rangle "], matchfix); (%o15) \langle ( \rangle , false) (%i16) tex (<<a>>); $$ \langle a \rangle $$ (%o16) false (%i17) tex (<<a, b>>); $$ \langle a , b \rangle $$ (%o17) false (%i18) texput ("<<", [" \\langle ", " \\rangle ", " \\, | \\,"], matchfix); (%o18) \langle ( \rangle , \, | \,) (%i19) tex (<<a>>); $$ \langle a \rangle $$ (%o19) false (%i20) tex (<<a, b>>); $$ \langle a \, | \,b \rangle $$ (%o20) false |
Executes command as a separate process.
The command is passed to the default shell for execution.
system
is not supported by all operating
systems, but generally exists in Unix and Unix-like environments.
Supposing _hist.out
is a list of frequencies which you wish to plot as a bar graph
using xgraph
.
(%i1) (with_stdout("_hist.out", for i:1 thru length(hist) do ( print(i,hist[i]))), system("xgraph -bar -brw .7 -nl < _hist.out")); |
In order to make the plot be done in the background (returning control to Maxima) and remove the temporary file after it is done do:
system("(xgraph -bar -brw .7 -nl < _hist.out; rm -f _hist.out)&") |
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
.
Opens filename and then evaluates expr_1, expr_2, expr_3, ....
The values of the arguments are not stored in filename,
but any printed output generated by evaluating the arguments
(from print
, display
, disp
, or grind
, for example)
goes to filename instead of the console.
The global flag file_output_append
governs
whether with_stdout
appends or truncates the output file.
When file_output_append
is true
,
with_stdout
appends to the output file.
Otherwise, with_stdout
truncates the output file.
In either case, with_stdout
creates the file if it does not yet exist.
with_stdout
returns the value of its final argument.
See also writefile
.
(%i1) with_stdout ("tmp.out", for i:5 thru 10 do print (i, "! yields", i!))$ (%i2) printfile ("tmp.out")$ 5 ! yields 120 6 ! yields 720 7 ! yields 5040 8 ! yields 40320 9 ! yields 362880 10 ! yields 3628800 |
Begins writing a transcript of the Maxima session to filename. All interaction between the user and Maxima is then recorded in this file, just as it appears on the console.
As the transcript is printed in the console output format,
it cannot be reloaded into Maxima.
To make a file containing expressions which can be reloaded,
see save
and stringout
.
save
stores expressions in Lisp form, while stringout
stores expressions in Maxima form.
The effect of executing writefile
when filename already exists
depends on the underlying Lisp implementation;
the transcript file may be clobbered, or the file may be appended.
appendfile
always appends to the transcript file.
It may be convenient to execute playback
after
writefile
to save the display of previous interactions.
As playback
displays only the input and output variables (%i1
, %o1
, etc.),
any output generated by a print statement in a function
(as opposed to a return value) is not displayed by playback
.
closefile
closes the transcript file opened by writefile
or appendfile
.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on March, 19 2006 using texi2html 1.76.