daveg@csvax.caltech.edu (David Gillespie) (06/06/90)
Posting-number: Volume 13, Issue 40 Submitted-by: daveg@csvax.caltech.edu (David Gillespie) Archive-name: gmcalc/part14 ---- Cut Here and unpack ---- #!/bin/sh # this is part 14 of a multipart archive # do not concatenate these parts, unpack them in order with /bin/sh # file calc.texinfo continued # CurArch=14 if test ! -r s2_seq_.tmp then echo "Please unpack part 1 first!" exit 1; fi ( read Scheck if test "$Scheck" != $CurArch then echo "Please unpack part $Scheck next!" exit 1; else exit 0; fi ) < s2_seq_.tmp || exit 1 echo "x - Continuing file calc.texinfo" sed 's/^X//' << 'SHAR_EOF' >> calc.texinfo Xthe stack. These line numbers are ordinarily displayed on the lefthand side Xof the window. The @kbd{d l} (@code{calc-line-numbering}) command controls Xwhether these numbers appear. (Line numbers may be turned off since they Xslow the Calculator down a bit and also clutter the display.) X XThe @key{RET} (or equivalent @key{SPC}) key is only required to separate Xtwo consecutive numbers. X(After all, if you typed @kbd{1 2} by themselves the Calculator Xwould enter the number 12.) If you press @kbd{RET} or @kbd{SPC} @emph{not} Xright after typing a number, the key duplicates the number on the top of Xthe stack. @kbd{@key{RET} *} is thus a handy way to square a number.@refill X XThe @key{DEL} key pops and throws away the top number on the stack. XThe @key{TAB} key swaps the top two objects on the stack. X@xref{Stack and Trail}, for descriptions of these and other stack-related Xcommands.@refill X X@node Numeric Entry, Algebraic Entry, Stack Basics, Introduction X@section Numeric Entry X X@kindex 0-9 X@kindex # X@kindex . X@kindex @@ X@kindex e X@cindex Numeric entry X@cindex Entering numbers XPressing a digit or other numeric key begins numeric entry using the Xminibuffer. The number is pushed on the stack when you press the @key{RET} Xor @key{SPC} keys. If you press any other non-numeric key, the number is Xpushed onto the stack and the appropriate operation is performed. If Xyou press a numeric key which is not valid (say, a second decimal point), Xthe key is ignored. X X@cindex Minus signs X@cindex Negative numbers, entering X@kindex _ XThere are three different concepts corresponding to the word ``minus,'' Xtypified by @samp{a-b} (subtraction), @samp{-x} X(change-sign), and @samp{-5} (negative number). Calc uses three Xdifferent keys for these operations, respectively: X@kbd{-}, @kbd{n}, and @kbd{_} (the underscore). The @kbd{-} key subtracts Xthe two numbers on the top of the stack. The @kbd{n} key changes the sign Xof the number on the top of the stack or the number currently being entered. XThe @kbd{_} key begins entry of a negative number or changes the sign of Xthe number currently being entered. The following sequences all enter the Xnumber @samp{-5} onto the stack: @kbd{0 @key{RET} 5 -}, @kbd{5 n @key{RET}}, X@kbd{5 @key{RET} n}, @kbd{_ 5 @key{RET}}, @kbd{5 _ @key{RET}}.@refill X XDuring numeric entry, the only editing key available is @kbd{DEL}. X X@node Algebraic Entry, Quick Calculator, Numeric Entry, Introduction X@section Algebraic Entry X X@kindex ' X@pindex calc-algebraic-entry X@cindex Algebraic notation X@cindex Formulas, entering XCalculations can also be entered in algebraic form. This is accomplished Xby typing the apostrophe key, @kbd{'}, followed by the expression in Xstandard format: @kbd{@key{'} 2+3*4 @key{RET}} computes X@samp{2+(3*4)} = 14 and pushes that on the stack. If you wish you can Xignore the RPN aspect of Calc altogether and simply enter algebraic Xexpressions in this way. You may want to use @key{DEL} every so often to Xclear previous results off the stack.@refill X XYou can press the apostrophe key during normal numeric entry to switch Xthe half-entered number into algebraic entry mode. One reason to do this Xwould be to use the full Emacs cursor motion and editing keys, which are Xavailable during algebraic entry but not during numeric entry. X X@kindex m a X@pindex calc-algebraic-mode X@cindex Algebraic mode XIf you prefer algebraic entry, you can use the command @kbd{m a} X(@code{calc-algebraic-mode}) to set Algebraic mode. In this mode, Xdigits and other keys that would normally start numeric entry instead Xstart full algebraic entry; as long as your formula begins with a digit Xyou can omit the apostrophe. Open parentheses and square brackets also Xbegin algebraic entry. You can still do RPN calculations in this mode, Xbut you will have to press @key{RET} to terminate every number: X@kbd{2 @key{RET} 3 @key{RET} * 4 @key{RET} +} would accomplish the same Xthing as @kbd{2*3+4 @key{RET}}.@refill X XPressing @kbd{'} (the apostrophe) a second time re-enters the previous Xalgebraic formula. You can then use the normal Emacs editing keys to Xmodify this formula to your liking before pressing @key{RET}. X X@kindex $ X@cindex Formulas, referring to stack XWithin a formula entered from the keyboard, the symbol @kbd{$} Xrepresents the number on the top of the stack. If an entered formula Xcontains any @kbd{$} characters, the Calculator replaces the top of Xstack with that formula rather than simply pushing the formula onto the Xstack. Thus, @kbd{' 1+2 @key{RET}} pushes 3 on the stack, and @kbd{$*2 X@key{RET}} replaces it with 6. Note that the @kbd{$} key always Xinitiates algebraic entry; the @kbd{'} is unnecessary if @kbd{$} is the Xfirst character in the new formula.@refill X XHigher stack elements can be accessed from an entered formula with the Xsymbols @kbd{$$}, @kbd{$$$}, and so on. The number of stack elements Xremoved (to be replaced by the entered values) equals the number of dollar Xsigns in the longest such symbol in the formula. For example, @samp{$$+$$$} Xadds the second and third stack elements, replacing the top three elements Xwith the answer. (All information about the top stack element is thus lost Xsince no single @samp{$} appears in this formula.)@refill X XIf a sequence of formulas are entered separated by commas, each formula Xis pushed onto the stack in turn. For example, @samp{1,2,3} pushes Xthose three numbers onto the stack (leaving the 3 at the top), and X@samp{$+1,$-1} replaces a 5 on the stack with 4 followed by 6. Also, X@samp{$,$$} exchanges the top two elements of the stack, just like the X@key{TAB} key. X X@node Quick Calculator, Prefix Arguments, Algebraic Entry, Introduction X@section ``Quick Calculator'' Mode X X@pindex quick-calc X@cindex Quick Calculator XThere is another way to invoke the Calculator if all you need to do Xis make one or two quick calculations. Type @kbd{M-x quick-calc}, Xthen type any formula as an algebraic entry. The Calculator will Xcompute the result and display it in the echo area, without ever Xactually putting up a Calculator window. X XYou can use the @kbd{$} character in a Quick Calculator formula to Xrefer to the previous Quick Calculator result. Older results are Xnot retained; the Quick Calculator has no effect on the full XCalculator's stack or trail. If you compute a result and then Xforget what it was, just run @code{quick-calc} again and enter X@samp{$} as the formula. X XIf this is the first time you have used the Calculator in this Emacs Xsession, the @code{quick-calc} command will create the @code{*Calculator*} Xbuffer and perform all the usual initializations; it simply will Xrefrain from putting that buffer up in a new window. The Quick XCalculator refers to the @code{*Calculator*} buffer for all mode Xsettings. Thus, for example, to set the precision that the Quick XCalculator uses, simply run the full Calculator momentarily and use Xthe regular @kbd{p} command. X XPlease note that the Quick Calculator is not any faster at loading Xor computing the answer than the full Calculator; the name ``quick'' Xmerely refers to the fact that it's much less hassle to use for Xsmall calculations. X XYou may wish to use @code{global-set-key} to bind @code{quick-calc} Xto some convenient keystroke. X X@node Prefix Arguments, Undo, Quick Calculator, Introduction X@section Numeric Prefix Arguments X XMany Calculator commands use numeric prefix arguments. Some, such as X@kbd{b w} (@code{calc-word-size}), set a parameter to the value of the Xprefix argument, or display the current value if there is no prefix Xargument. Others require an argument and prompt for a number if you Xdon't give one as a prefix.@refill X XAs a rule, stack-manipulation commands accept a numeric prefix argument Xwhich is interpreted as an index into the stack. A positive argument Xoperates on the top @var{n} stack entries; a negative argument operates Xon the @var{n}th stack entry in isolation; and a zero argument operates Xon the entire stack. X XMost commands that perform computations (such as the arithmetic and Xscientific functions) accept a numeric prefix argument that allows the Xoperation to be applied across many stack elements. For unary operations X(that is, functions of one argument like absolute value or complex Xconjugate), a prefix argument applies that function to the top @var{n} Xstack entries simultaneously. For binary operations (functions of two Xarguments like addition, GCD, and vector concatenation), a positive Xprefix argument ``reduces'' the function across the top @var{n} Xstack elements (for example, @kbd{C-u 5 +} sums the top 5 stack entries; X@pxref{Reducing and Mapping}), and a negative argument maps the next-to-top X@var{n} stack elements with the top stack element as a second argument X(for example, @kbd{7 c-u -5 +} adds 7 to the top 5 stack elements). XThis feature is not available for operations which use the numeric prefix Xargument for some other purpose. X XNumeric prefixes are specified the same way as always in Emacs: Press Xa sequence of @key{META}-digits, or press @key{ESC} followed by digits, Xor press @kbd{C-u} followed by digits.@refill X X@kindex ~ X@pindex calc-num-prefix XYou can type @kbd{~} (@code{calc-num-prefix}) to pop an integer from the Xtop of the stack and enter it as the numeric prefix for the next command. XFor example, @kbd{C-u 16 p} sets the precision to 16 digits; an alternate X(silly) way to do this would be @kbd{2 @key{RET} 4 ^ ~ p}, i.e., compute 2 Xto the fourth power and set the precision to that value.@refill X XConversely, if you have typed a numeric prefix argument the @kbd{~} key Xpushes it onto the stack in the form of an integer. X X@node Undo, Error Messages, Prefix Arguments, Introduction X@section Undoing Mistakes X X@kindex U X@kindex C-_ X@pindex calc-undo X@cindex Mistakes, undoing X@cindex Undoing mistakes X@cindex Errors, undoing XThe shift-@kbd{U} key (@code{calc-undo}) undoes the most recent operation. XIf that operation added or dropped objects from the stack, those objects Xare removed or restored. If it was a @code{store} operation, you are Xqueried whether or not to restore the variable to its original value. XThe @kbd{U} key may be pressed any number of times to undo successively Xfarther back in time; with a numeric prefix argument it undoes a Xspecified number of operations. The undo history is cleared only by the X@kbd{q} (@code{calc-quit}) command. (Recall that @kbd{M-#} is usually Xmade synonymous with @code{calc-quit} while inside the Calculator; this Xalso clears the undo history.) X XCurrently the mode-setting commands (like @code{calc-precision}) are not Xundoable. You can undo past a point where you changed a mode, but you Xwill need to reset the mode yourself. X X@kindex D X@pindex calc-redo X@cindex Redoing after an Undo XThe shift-@kbd{D} key (@code{calc-redo}) redoes an operation that was Xmistakenly undone. Pressing @kbd{U} with a negative prefix argument is Xequivalent to executing @code{calc-redo}. You can redo any number of Xtimes, up to the number of recent consecutive undo commands. Redo Xinformation is cleared whenever you give any command that adds new undo Xinformation, i.e., if you undo, then enter a number on the stack or make Xany other change, then it will be too late to redo. X X@kindex X X@pindex calc-last-x X@cindex Last-X feature X@cindex Arguments, restoring XThe shift-@kbd{X} key (@code{calc-last-x}) is like undo in that it Xrestores the arguments of the most recent command onto the stack; Xhowever, it does not remove the result of that command. Given a numeric Xprefix argument, this command applies to the @samp{n}th most recent Xcommand which removed items from the stack; it pushes those items back Xonto the stack. X XIt is also possible to recall previous results or inputs using the trail. X@xref{Trail Commands}. X XThe standard Emacs @kbd{C-_} undo key is recognized as a synonym for @kbd{U}. X X@node Error Messages, Multiple Calculators, Undo, Introduction X@section Error Messages X X@kindex w X@pindex calc-why X@cindex Errors, messages X@cindex Why did an error occur? XMany situations that would produce an error message in other calculators Xsimply create unsimplified formulas in the Emacs Calculator. For example, X@kbd{1 @key{RET} 0 /} pushes the formula @samp{1 / 0}; @kbd{0 L} pushes Xthe formula @kbd{ln(0)}. When this happens, you can use the @kbd{w} X(@code{calc-why}) command to see a brief explanation of why the formula Xcould not be simplified. Press @kbd{w} repeatedly to see all the error Xmessages which arose from the last calculation. X X@kindex d w X@pindex calc-auto-why XThe @kbd{d w} (@code{calc-auto-why}) command turns on and off a mode in Xwhich these error messages are automatically displayed. Sometimes these Xmessages are a nuisance; for example, @samp{sqrt(a)} will produce the Xmessage @samp{Number expected: a}. For this reason the @kbd{d w} mode is Xoff by default. X X@node Multiple Calculators, Troubleshooting Commands, Error Messages, Introduction X@section Multiple Calculators X X@pindex another-calc XIt is possible to have any number of Calc Mode buffers at once. XUsually this is done by executing @kbd{M-x another-calc}, which Xis similar to @kbd{M-x calc} except that if a @samp{*Calculator*} Xbuffer already exists, a new, independent one with a name of the Xform @samp{*Calculator*<@var{n}>} is created. You can also use the Xcommand @code{calc-mode} to put any buffer into Calculator mode, but Xthis would ordinarily never be done. X XThe @kbd{q} (@code{calc-quit}) command does not destroy a Calculator buffer; Xit only closes its window. Use @kbd{M-x kill-buffer} to destroy a XCalculator buffer. X XEach Calculator buffer keeps its own stack, undo list, and mode settings Xsuch as precision, angular mode, and display formats. In Emacs terms, Xvariables such as @code{calc-stack} are buffer-local variables. The Xglobal default values of these variables are used only when a new XCalculator buffer is created. The @code{calc-quit} command saves Xthe stack and mode settings of the buffer being quit as the new defaults. X XThere is only one trail buffer, @samp{*Calc Trail*}, used by all XCalculator buffers. X X@node Troubleshooting Commands, , Multiple Calculators, Introduction X@section Troubleshooting Commands X XThis section describes commands you can use in case a computation Xincorrectly fails or gives the wrong answer. X X@menu X* Recursion Depth:: X* Caches:: X@end menu X X@node Recursion Depth, Caches, Troubleshooting Commands, Troubleshooting Commands X@subsection Recursion Depth X X@kindex M X@pindex calc-more-recursion-depth X@pindex calc-less-recursion-depth X@cindex Recursion depth X@cindex @code{max-lisp-eval-depth} X@cindex @code{max-specpdl-size} XCalc uses recursion in many of its calculations. Emacs Lisp keeps a Xvariable @code{max-lisp-eval-depth} which limits the amount of recursion Xpossible in an attempt to recover from program bugs. If a calculation Xever halts incorrectly because of a X``Lisp nesting exceeds @code{max-lisp-eval-depth}'' error, Xuse the @kbd{M} command (@code{calc-more-recursion-depth}) to increase Xthis limit.@refill X XThe limit is always increased (multiplied) by a factor of two. There is Xalso a @code{calc-less-recursion-depth} (or @kbd{x less}) command which Xdecreases this limit by a factor of two, down to a minimum value of 200. XThe default value is 1000. X XThese commands also double or halve @code{max-specpdl-size}, another Xinternal Lisp recursion limit. The minimum value for this limit is 600. X X@node Caches, , Recursion Depth, Troubleshooting Commands X@subsection Caches X X@cindex Caches X@cindex Flushing caches XCalc saves certain values after they have been computed once. For Xexample, the @kbd{P} (@code{calc-pi}) command initially ``knows'' the Xconstant @samp{pi} to about 20 decimal places; if the current precision Xis greater than this, it will recompute @samp{pi} using a series Xapproximation. This value will not need to be recomputed ever again Xunless you raise the precision still further. Many operations such as Xlogarithms and sines make use of similarly cached values such as X@samp{pi/4} and @samp{ln(2)}. The visible effect of caching is that Xhigh-precision computations may be especially slow the first time. XOther things cached include powers of two (for the binary arithmetic Xfunctions), matrix inverses and determinants, and symbolic integrals. X X@pindex calc-flush-caches XIf you suspect a Calculator cache has become corrupt, you can use the X@code{calc-flush-caches} command to reset all caches to the empty state. X(This should only be necessary in event of bugs in the Calculator.) X X@node Data Types, Stack and Trail, Introduction, Top X@chapter Data Types X XThis chapter discusses the various types of objects that can be placed Xon the Calculator stack, how they are displayed, and how they are Xentered. (@xref{Data Type Formats}, for information on how these data Xtypes are represented as Lisp objects.)@refill X XIntegers, fractions, and floats are various ways of describing real Xnumbers. HMS forms also for many purposes act as real numbers. These Xtypes can be combined to form complex numbers, modulo forms, error forms, Xor interval forms. (But these last four types cannot be combined with Xeach other: error forms may not contain modulo forms, for example.) XFinally, all these types of numbers may be combined into vectors, Xmatrices, or algebraic formulas. X X@menu X* Integers:: The most basic data type. X* Fractions:: This and above are called @dfn{rationals}. X* Floats:: This and above are called @dfn{reals}. X* Complex Numbers:: This and above are called @dfn{numbers}. X* Vectors and Matrices:: X* Strings:: X* HMS Forms:: X* Modulo Forms:: X* Error Forms:: X* Interval Forms:: X* Incomplete Objects:: X* Variables:: X* Formulas:: X@end menu X X@node Integers, Fractions, Data Types, Data Types X@section Integers X X@cindex Integers XThe Calculator stores integers to arbitrary precision. Addition, Xsubtraction, and multiplication of integers always yields an exact Xinteger result. (If the result of a division or exponentiation of Xintegers is not an integer, it is expressed in fractional or Xfloating-point form according to the current Fraction Mode. X@xref{Fraction Mode}.) X XA decimal integer is represented as an optional sign followed by a Xsequence of digits. Grouping (@pxref{Grouping Digits}) can be used to Xinsert a comma at every third digit for display purposes, but such Xcommas are not allowed during the entry of numbers.@refill X XA non-decimal integer is represented as an optional sign, a radix Xbetween 2 and 36, a @samp{#} symbol, and one or more digits. For radix 11 Xand above, the letters A through Z (upper- or lower-case) count as Xdigits and do not terminate numeric entry mode. @xref{Radix Modes}, for how Xto set the default radix for display of integers. Numbers of any radix Xmay be entered at any time. If you press @kbd{#} at the beginning of a Xnumber, the current display radix is used.@refill X X@node Fractions, Floats, Integers, Data Types X@section Fractions X X@cindex Fractions XA @dfn{fraction} is a ratio of two integers. Fractions are traditionally Xwritten ``2/3'' but Calc uses the notation @samp{2:3}. (The @kbd{/} key Xperforms RPN division; the following two sequences push the number X@samp{2:3} on the stack: @kbd{2 : 3 @key{RET}}, @kbd{2 @key{RET} 3 /}, Xassuming Fraction Mode has been enabled.) XWhen the Calculator produces a fractional result it always reduces it to Xsimplest form, which may in fact be an integer.@refill X XFractions may also be entered in a three-part form, where @samp{2:3:4} Xrepresents two-and-three-quarters. @xref{Fraction Formats}, for fraction Xdisplay formats.@refill X XNon-decimal fractions are entered and displayed in the form X@samp{@var{radix}#@var{num}:@var{denom}} (or in the analogous three-part Xform). The numerator and denominator always use the same radix.@refill X X@node Floats, Complex Numbers, Fractions, Data Types X@section Floats X X@cindex Floating-point numbers XA floating-point number or @dfn{float} is a number stored in scientific Xnotation. The number of significant digits in the fractional part is Xgoverned by the current floating precision (@pxref{Precision}). The Xexponent is stored as a Lisp integer with no overflow or underflow Xchecking; thus the safe limit is roughly 10^1000000 for large numbers, Xand 10^-1000000 for small numbers. X XIf a rational number and a float are mixed in a calculation, the result Xwill in general be expressed as a float. Commands that require an integer Xvalue (such as @code{calc-gcd}) will also accept integer-valued floats, Xi.e., a floating-point number with nothing after the decimal point. X XFloats are identified by the presence of a decimal point and/or an Xexponent. In general a float consists of an optional sign, digits Xincluding an optional decimal point, and an optional exponent consisting Xof an @samp{e}, an optional sign, and one to six exponent digits. XFor example, @samp{23.5e-2} is 23.5 times ten to the minus-second power, Xor 0.235. X XFloating-point numbers are normally displayed in decimal notation with Xall significant figures shown. Exceedingly large or small numbers are Xdisplayed in scientific notation. Various other display options are Xavailable. @xref{Float Formats}. X X@cindex Accuracy of computations XFloating-point numbers are stored in decimal, not binary. The result Xof each operation is rounded to the nearest value representable in the Xnumber of significant digits specified by the current precision, Xrounding away from zero in the case of a tie. Thus (in the default Xdisplay mode) what you see is exactly what you get. Some operations such Xas square roots and transcendental functions are performed with several Xdigits of extra precision and then rounded down, in an effort to make the Xfinal result accurate to the full requested precision. However, Xaccuracy is not rigorously guaranteed. If you suspect the validity of a Xresult, try doing the same calculation in a higher precision. The XCalculator's arithmetic is not intended to be IEEE-conformant in any Xway.@refill X X@node Complex Numbers, Vectors and Matrices, Floats, Data Types X@section Complex Numbers X X@cindex Complex numbers XThere are two supported formats for complex numbers: rectangular and Xpolar. The default format is rectangular, displayed in the form X@samp{(@var{real},@var{imag})} where @var{real} is the real part and X@var{imag} is the imaginary part, each of which may be any real number. XRectangular complex numbers can also be displayed in @samp{@var{a}+@var{b}i} Xnotation; @pxref{Complex Formats}.@refill X XPolar complex numbers are displayed in the form @samp{(@var{r};@var{theta})} Xwhere @var{r} is the nonnegative magnitude and @var{theta} is the argument Xor phase angle. The range of @var{theta} depends on the current angular Xmode (@pxref{Angular Modes}); it is generally between -180 and +180 degrees Xor the equivalent range in radians.@refill X XComplex numbers are entered in stages using incomplete objects. X@xref{Incomplete Objects}. X XOperations on rectangular complex numbers yield rectangular complex Xresults, and similarly for polar complex numbers. Where the two types Xare mixed, or where new complex numbers arise (as for the square root of Xa negative real), the current @dfn{Polar Mode} is used to determine the Xtype. @xref{Polar Mode}. X XA complex result in which the imaginary part is zero (or the phase angle Xis 0 or 180 degrees or @samp{pi} radians) is automatically converted to a real Xnumber. X X@node Vectors and Matrices, Strings, Complex Numbers, Data Types X@section Vectors and Matrices X X@cindex Vectors X@cindex Plain vectors X@cindex Matrices XThe @dfn{vector} data type is flexible and general. A vector is simply a Xlist of zero or more data objects. When these objects are numbers, the Xwhole is a vector in the mathematical sense. When these objects are Xthemselves vectors of equal (nonzero) length, the whole is a @dfn{matrix}. XA vector which is not a matrix is referred to here as a @dfn{plain vector}. X XA vector is displayed as a list of comma-separated values enclosed in Xsquare brackets: @samp{[1, 2, 3]}. Thus the following is a 2 row by X3 column matrix: @samp{[[1, 2, 3], [4, 5, 6]]}. Vectors, like complex Xnumbers, are entered as incomplete objects. @xref{Incomplete Objects}. XDuring algebraic entry, vectors are entered all at once in the usual Xbrackets-and-commas form. Matrices may be entered algebraically as nested Xvectors, or using the shortcut notation @samp{[1, 2, 3; 4, 5, 6]}, Xwith rows separated by semicolons. The commas may usually be omitted Xwhen entering vectors: @samp{[1 2 3]}. Curly braces may be used in Xplace of brackets: @samp{@{1, 2, 3@}}, but the commas are required in Xthis case. X XTraditional vector and matrix arithmetic is supported; X@pxref{Basic Arithmetic} and @pxref{Matrix Functions}. XMany other operations are applied to vectors element-wise. For example, Xthe complex conjugate of a vector is a vector of the complex conjugates Xof its elements.@refill X X@node Strings, HMS Forms, Vectors and Matrices, Data Types X@section Strings X X@kindex " X@cindex Strings X@cindex Character strings XCharacter strings are not a special data type in the Calculator. XRather, a string is represented simply as a vector all of whose Xelements are integers in the range 0 to 255. You can enter a string Xat any time by pressing the @kbd{"} key. Quotation marks and Xbackslashes are written @samp{\"} and @samp{\\}, respectively, Xinside strings. (In fact, all the standard Emacs Lisp conventions Xfor strings are allowed.) X X@kindex d " X@pindex calc-display-strings XStrings are normally displayed in vector-of-integers form. The X@kbd{d "} (@code{calc-display-strings}) command toggles a mode in Xwhich any vectors of the appropriate form are displayed as quoted Xstrings instead. X XThe Calculator does not use strings in any of its built-in features. XThey are provided mainly as a convenient way to do conversions Xbetween ASCII characters and integers. X X@node HMS Forms, Modulo Forms, Strings, Data Types X@section HMS Forms X X@cindex Hours-minutes-seconds forms X@cindex Degrees-minutes-seconds forms X@dfn{HMS} stands for Hours-Minutes-Seconds; when used as an angular Xargument, the interpretation is Degrees-Minutes-Seconds. All functions Xthat operate on angles accept HMS forms. These are interpreted as Xdegrees regardless of the current angular mode. It is also possible to Xuse HMS as the angular mode so that calculated angles are expressed in Xdegrees, minutes, and seconds. X XThe default format for HMS values is X@samp{@var{hours}@@ @var{mins}' @var{secs}"}. During entry, the letters X@samp{h} (for ``hours'') or X@samp{o} (approximating the ``degrees'' symbol) are accepted as well as X@samp{@@}, @samp{m} is accepted in place of @samp{'}, and @samp{s} is Xaccepted in place of @samp{"}. XThe @var{hours} value is an integer (or integer-valued float). XThe @var{mins} value is an integer or integer-valued float between 0 and 59. XThe @var{secs} value is a real number between 0 (inclusive) and 60 X(exclusive). A positive HMS form is interpreted as @var{hours} + X@var{mins}/60 + @var{secs}/3600. A negative HMS form is interpreted Xas - @var{hours} - @var{mins}/60 - @var{secs}/3600. XDisplay format for HMS forms is quite flexible. @xref{HMS Formats}.@refill X XHMS forms can be added and subtracted. When they are added to numbers, Xthe numbers are interpreted according to the current angular mode. HMS Xforms can also be multiplied and divided by real numbers. Dividing Xtwo HMS forms produces a real-valued ratio of the two angles. X X@pindex calc-time X@cindex Time of day XJust for kicks, @code{calc-time} pushes the current time of day on Xthe stack as an HMS form. X X@node Modulo Forms, Error Forms, HMS Forms, Data Types X@section Modulo Forms X X@cindex Modulo forms XA @dfn{modulo form} is a real number which is taken modulo (i.e., within Xan integer multiple of) some value @samp{M}. Arithmetic modulo @samp{M} Xoften arises in number theory. Modulo forms are written X@samp{@var{a} mod @var{M}}, Xwhere @var{a} and @var{M} are real numbers or HMS forms, and X@samp{0 <= @var{a} < @var{M}}. XIn many applications @var{a} and @var{M} will be Xintegers but this is not required.@refill X XModulo forms are not to be confused with the modulo operator @samp{%}. XThe expression @samp{27 % 10} means to compute 27 modulo 10 to produce Xthe result 7. Further computations treat this 7 as just a regular integer. XThe expression @samp{27 mod 10} produces the result @samp{7 mod 10}; Xfurther computations with this value are again reduced modulo 10 so that Xthe result always lies in the desired range. X XWhen two modulo forms with identical @var{M}'s are added or multiplied, Xthe Calculator simply adds or multiplies the values, then reduces modulo X@var{M}. If one argument is a modulo form and the other a plain number, Xthe plain number is treated like a compatible modulo form. It is also Xpossible to raise modulo forms to powers; the result is the value raised Xto the power, then reduced modulo @var{M}. (When all values involved Xare integers, this calculation is done much more efficiently than Xactually computing the power and then reducing.) X X@cindex Modulo division XTwo modulo forms @samp{@var{a} mod @var{M}} and @samp{@var{b} mod X@var{M}} can be divided if @var{a}, @var{b}, and @var{M} are all Xintegers. The result is the modulo form which, when multiplied by X@samp{@var{b} mod @var{M}}, produces @samp{@var{a} mod @var{M}}. If Xthere is no solution to this equation (which can happen only when X@var{M} is non-prime), or if any of the arguments are non-integers, the Xdivision is left in symbolic form. Other operations, such as square Xroots, are not yet supported for modulo forms. (Note that, although X@samp{(@var{a} mod @var{M})^.5} will compute a ``modulo square root'' in Xthe sense of reducing @samp{sqrt(@var{a})} modulo @var{M}, this is not a Xuseful definition from the number-theoretical point of view.)@refill X XTo create a modulo form during numeric entry, press the shift-@kbd{M} Xkey to enter the word @samp{mod}. As a special convenience, pressing Xshift-@kbd{M} a second time automatically enters the value of @var{M} Xthat was most recently used before. During algebraic entry, either Xtype @samp{mod} by hand or press @kbd{M-m} (that's @kbd{@key{META}-m}). XOnce again, pressing this a second time enters the current modulo.@refill X XIt is possible to mix HMS forms and modulo forms. For example, an XHMS form modulo 24 could be used to manipulate clock times; an HMS Xform modulo 360 would be suitable for angles. Making the modulo @var{M} Xalso be an HMS form eliminates troubles that would arise if the angular Xmode were inadvertently set to Radians, in which case @samp{2@@ 0' 0" mod 24} Xwould be interpreted as two degrees modulo 24 radians! X X@node Error Forms, Interval Forms, Modulo Forms, Data Types X@section Error Forms X X@cindex Error forms X@cindex Standard deviations XAn @dfn{error form} is a real number with an associated standard Xdeviation, as in @samp{2.3 +/- 0.12}. The notation X@samp{@var{x} +/- @var{sigma}} Xstands for an uncertain value which follows a normal or XGaussian distribution of mean @var{x} and standard deviation or X``error'' @var{sigma}. Both the mean and the error are real numbers X(or algebraic expressions which are treated like real numbers); the Xerror must be positive. A value with zero error is converted to a Xregular number by the Calculator.@refill X XAll arithmetic and transcendental functions accept error forms as input. XOperations on the mean-value part work just like operations on regular Xnumbers. The error part for any function @samp{f(x)} (such as @samp{sin(x)}) Xis defined by the error of @samp{x} times the derivative of @samp{f} Xevaluated at the mean value of @samp{x}. For a two-argument function X@samp{f(x,y)} (such as addition) the error is the square root of the sum Xof the squares of the errors due to @samp{x} and @samp{y}. Note that this Xdefinition assumes the errors in @samp{x} and @samp{y} are uncorrelated. XA side effect of this definition is that @samp{(2 +/- 1) * (2 +/- 1)} Xis not the same as @samp{(2 +/- 1)^2}; the former represents the product Xof two independent values which happen to have the same probability Xdistributions, and the product of one random value with itself. The Xform will produce an answer with less error, since on the average the Xtwo indepdent errors can be expected to cancel out.@refill X XConsult a good text on error analysis for a discussion of the proper use Xof standard deviations. Actual errors often are neither Gaussian-distributed Xnor uncorrelated, and the above formulas are valid only when errors Xare small. As an example, the error arising from @samp{sin(x +/- dx)} is X@samp{dx * abs(cos(x))}. When @samp{x} is close to zero, @samp{cos(x)} is Xclose to one so the error in the sine is close to @samp{dx}; this makes Xsense, since @samp{sin(x)} is approximately @samp{x} near zero, so a given Xerror in @samp{x} will produce about the same error in the sine. Likewise, Xnear 90 degrees @samp{cos(x)} is nearly zero and so the computed error is Xsmall: The sine curve is nearly flat in that region, so an error in @samp{x} Xhas relatively little effect on the value of @samp{sin(x)}. However, consider X@samp{sin(90 +/- 1000)}. The cosine of 90 is zero, so Calc will report Xzero error! We get an obviously wrong result because we have violated Xthe small-error approximation underlying the error analysis. If the error Xin @samp{x} had been small, the error in @code{sin(x)} would indeed have Xbeen negligible.@refill X XTo enter an error form during regular numeric entry, use the @samp{p} X(``plus-or-minus'') key to type the @samp{+/-} symbol. (If you try actually Xtyping @samp{+/-} the @kbd{+} key will be interpreted as the Calculator's X@kbd{+} command!) Within an algebraic formula, you can press @kbd{M-p} to Xtype the @samp{+/-} symbol, or type it out by hand. X XError forms and complex numbers cannot be mixed. For example, @samp{sqrt(-9)} Xproduces the complex result @samp{(0,3)}, but @samp{sqrt(-9 +/- 1)} is left Xunevaluated by the Calculator. However, error forms whose arguments are XHMS forms are allowed. X X@node Interval Forms, Incomplete Objects, Error Forms, Data Types X@section Interval Forms X X@cindex Interval forms XAn @dfn{interval} is a subset of consecutive real numbers. For example, Xthe interval @samp{[2 .. 4]} represents all the numbers from 2 to 4, Xinclusive. If you multiply it by the interval @samp{[0.5 .. 2]} you Xobtain @samp{[1 .. 6]}. This calculation represents the fact that if Xyou multiply some number in the range @samp{[2 .. 4]} by some other Xnumber in the range @samp{[0.5 .. 2]}, your result will lie in the range Xfrom 1 to 6. Interval arithmetic is used to get a worst-case estimate Xof the possible range of values a computation will produce, given the Xset of possible values of the input. X XCalc supports several varieties of intervals, including @dfn{closed} Xintervals of the type shown above, @dfn{open} intervals such as X@samp{(2 .. 4)}, which represents the range of numbers from 2 to 4 X@emph{exclusive}, and @dfn{semi-open} intervals in which one end Xuses a round parenthesis and the other a square bracket. In mathematical Xterms, @samp{[2 .. 4]} means @samp{2 <= x <= 4}, whereas @samp{(2 .. 4)} Xrepresents @samp{2 < x < 4}, @samp{[2 .. 4)} represents @samp{2 <= x < 4}, Xand @samp{(2 .. 4]} represents @samp{2 < x <= 4}.@refill X XThe lower and upper limits of an interval must be either real numbers X(or HMS forms), or symbolic expressions which are assumed to be real-valued. XIn general the lower limit must be less than the upper limit. A closed Xinterval containing only one value, @samp{[3 .. 3]}, is converted to a Xplain number (3) automatically. An interval containing no values at all X(such as @samp{[3 .. 2]} or @samp{[2 .. 2)}) can be represented but is not Xguaranteed to behave well when used in arithmetic. X XIntervals are entered in the notation shown here, either as algebraic Xformulas, or using incomplete forms. (@xref{Incomplete Objects}.) XIn algebraic formulas, multiple periods in a row are collected from Xleft to right, so that @samp{1....1e2} is interpreted as @samp{1 .. .. 1e2} X(a syntax error) rather than @samp{1. .. .1e2}. Use spaces or type X@samp{1.0..0.1e2} to make the notation unambiguous. X XWhile it may seem that intervals and error forms are similar, they are Xbased on entirely different concepts of inexact quantities. An error Xform @samp{x +/- sigma} means a variable is random, and its value could Xbe anything but is ``probably'' within one @code{sigma} of the mean Xvalue @code{x}. An interval @samp{[lo .. hi]} means a variable's value Xis unknown, but guaranteed to lie in the specified range. Error forms Xare statistical or ``average case'' approximations; interval arithmetic Xtends to produce ``worst case'' bounds on an answer.@refill X X@node Incomplete Objects, Variables, Interval Forms, Data Types X@section Incomplete Objects X X@kindex [ X@kindex ] X@kindex ( X@kindex ) X@kindex , X@kindex ; X@cindex Incomplete vectors X@cindex Incomplete complex numbers X@cindex Incomplete interval forms XWhen @kbd{(} or @kbd{[} is typed to begin entering a complex number or Xvector, respectively, the effect is to push an @dfn{incomplete} complex Xnumber or vector onto the stack. The @kbd{,} key adds the value(s) at Xthe top of the stack onto the current incomplete object. The @kbd{)} Xand @kbd{]} keys ``close'' the incomplete object after adding any values Xon the top of the stack in front of the incomplete object. X XAs a result, the sequence of keystrokes @kbd{[ 2 , 3 @key{RET} 2 * , 9 ]} Xpushes the vector @samp{[2, 6, 9]} onto the stack. Likewise, @kbd{( 1 , 2 Q )} Xpushes the complex number @samp{(1, 1.414)} (approximately). X XIf several values lie on the stack in front of the incomplete object, Xall are collected and appended to the object. Thus the @kbd{,} key Xis redundant: @kbd{[ 2 @key{RET} 3 @key{RET} 2 * 9 ]}. Some people Xprefer the equivalent @key{SPC} key to @key{RET}.@refill X XAs a special case, typing @kbd{,} immediately after @kbd{(}, @kbd{[}, or X@kbd{,} adds a zero or duplicates the preceding value in the list being Xformed. Typing @key{DEL} during incomplete entry removes the last item Xfrom the list. X XThe @kbd{;} key is used in the same way as @kbd{,} to create polar complex Xnumbers: @kbd{( 1 ; 2 )}. When entering a vector, @kbd{;} is useful for Xcreating a matrix. In particular, @kbd{[ [ 1 , 2 ; 3 , 4 ; 5 , 6 ] ]} is Xequivalent to @kbd{[ [ 1 , 2 ] , [ 3 , 4 ] , [ 5 , 6 ] ]}. X X@pindex calc-dots XIncomplete entry is also used to enter intervals. For example, X@kbd{[ 2 .. 4 )} enters a semi-open interval. Note that when you type Xthe first period, it will be interpreted as a decimal point, but when Xyou type a second period immediately afterward, it is re-interpreted as Xpart of the interval symbol. Typing @kbd{..} corresponds to executing Xthe @code{calc-dots} command. X XIf you find incomplete entry distracting, you may wish to enter vectors Xand complex numbers as algebraic formulas by pressing the apostrophe key. X X@node Variables, Formulas, Incomplete Objects, Data Types X@section Variables X X@cindex Variables, in formulas XA @dfn{variable} is somewhere between a storage register on a conventional Xcalculator, and a variable in a programming language. (In fact, a Calc Xvariable is really just an Emacs Lisp variable that contains a Calc number Xor formula.) A variable's name is normally composed of letters and digits. XCalc also allows apostrophes and underscores in variable names. XThe Calc variable @code{foo} corresponds to the Emacs Lisp variable X@code{var-foo}. The @code{calc-store} and @code{calc-recall} commands can Xbe made to use any arbitrary Lisp variable simply by backspacing over the X@samp{var-} prefix in the minibuffer.@refill X XIn a command that takes a variable name, you can either type the full Xname of a variable, or type a single digit to use one of the special Xconvenience variables @code{var-0} through @code{var-9}. For example, X@kbd{3 s 2} stores the number 3 in variable @code{var-2}, and X@kbd{3 s foo @key{RET}} stores that number in variable @code{var-foo}.@refill X XTo push a variable itself (as opposed to the variable's value) on the Xstack, enter its name as an algebraic expression using the apostrophe X(@key{'}) key. Variable names in algebraic formulas implicitly have X@samp{var-} prefixed to their names. The underscore @samp{_} character Xis changed to a dash @samp{-} in variable names used in algebraic Xformulas. If the name contains an underscore, the prefix @samp{var-} is X@emph{not} automatically added. Thus the two formulas @samp{foo+1} and X@samp{var_foo+1} are equivalent. X X@kindex = X@pindex calc-evaluate X@cindex Evaluation of variables in a formula X@cindex Variables, evaluation X@cindex Formulas, evaluation XThe @kbd{=} (@code{calc-evaluate}) key ``evaluates'' a formula by Xreplacing all variables in the formula which have been given values by a X@code{calc-store} or @code{calc-let} command by their stored values. XOther variables are left alone. Thus a variable that has not been Xstored acts like an abstract variable in algebra; a variable that has Xbeen stored acts more like a register in a traditional calculator. X X@cindex @code{e} variable X@cindex @code{pi} variable X@cindex @code{i} variable XA few variables are called @dfn{special constants}. Their names are X@samp{e}, @samp{pi}, and @samp{i}. When they are evaluated with @kbd{=}, Xtheir values are calculated if necessary according to the current precision Xor complex polar mode. If you wish to use these symbols for other purposes, Xsimply undefine or redefine them using @code{calc-store}.@refill X X@xref{Store and Recall}, for a discussion of commands dealing with variables. X X@node Formulas, , Variables, Data Types X@section Formulas X X@cindex Formulas X@cindex Operators in formulas X@cindex Precedence of operators XWhen you press the apostrophe key you may enter any expression or formula Xin algebraic form. (Calc uses the terms ``expression'' and ``formula'' Xinterchangeably.) An expression is built up of numbers, variable names, Xand function calls, combined with various arithmetic operators. XParentheses may Xbe used to indicate grouping. Spaces are ignored within formulas, except Xthat spaces are not permitted within variable names or numbers. XArithmetic operators, in order from highest to lowest precedence, and Xwith their equivalent function names, are: X X@display Xprefix @samp{+} and @samp{-} [@code{neg}] (as in @samp{-x}) X and prefix @samp{!} [@code{lnot}] (logical ``not,'' as in @samp{!x}); X X@samp{+/-} [@code{sdev}] (the standard deviation symbol) and X @samp{mod} [@code{makemod}] (the symbol for modulo forms); X Xpostfix @samp{!} [@code{fact}] (factorial, as in @samp{n!}); X X@samp{^} [@code{pow}] (raised-to-the-power-of); X X@samp{*} [@code{mul}]; X X@samp{/} [@code{div}], @samp{%} [@code{mod}] (modulo), and X @samp{\} [@code{idiv}] (integer division); X Xinfix @samp{+} [@code{add}] and @samp{-} [@code{sub}] (as in @samp{x-y}); X X@samp{|} [@code{vconcat}] (vector concatenation); X Xrelations @samp{=} [@code{eq}], @samp{!=} [@code{neq}], @samp{<} [@code{lt}], @samp{>} [@code{gt}], X @samp{<=} [@code{leq}], and @samp{>=} [@code{geq}]; X X@samp{&&} [@code{land}] (logical ``and''); X X@samp{||} [@code{lor}] (logical ``or''); X Xthe C-style ``if'' operator @samp{a?b:c} [@code{if}]. X@end display X XNote that, unlike in usual computer notation, multiplication binds more Xstrongly than division: @samp{a*b/c*d} is equivalent to @samp{(a*b)/(c*d)}. X X@cindex Multiplication, implicit X@cindex Implicit multiplication XThe multiplication sign @samp{*} may be omitted in many cases. In particular, Xif the righthand side is a number, variable name, or parenthesized Xexpression, the @samp{*} may be omitted. Implicit multiplication has the Xsame precedence as the explicit @samp{*} operator. The one exception to Xthe rule is that a variable name followed by a parenthesized expression, Xas in @samp{f(x)}, Xis interpreted as a function call, not an implicit @samp{*}. In many Xcases you must use a space if you omit the @samp{*}: @samp{2a} is the Xsame as @samp{2*a}, and @samp{a b} is the same as @samp{a*b}, but @samp{ab} Xis a variable called @code{ab}, @emph{not} the product of @samp{a} and X@samp{b}!@refill X X@cindex Implicit comma in vectors XThe rules are slightly different for vectors written with square brackets. XThere, the space character is interpreted (like the comma) as a separator Xof elements of the vector. Thus @samp{[ 2a b+c d ]} is equivalent to X@samp{[2*a, b+c, d]}, whereas @samp{2a b+c d} is equivalent to X@samp{2*a*b + c*d}. XNote that spaces around the brackets, and around explicit commas, are Xignored. To force spaces to be interpreted as multiplication you can Xenclose a formula in parentheses as in @samp{[(a b) 2(c d)]}, which is Xinterpreted as @samp{[a*b, 2*c*d]}. An implicit comma is also inserted Xbetween @samp{][}, as in the matrix @samp{[[1 2][3 4]]}.@refill X XVectors that contain commas (not embedded within nested parentheses or Xbrackets) do not treat spaces specially: @samp{[a b, 2 c d]} is a vector Xof two elements. Also, vectors entered with curly braces instead of Xsquare brackets, do not give spaces any special treatment. X X@cindex Function call notation XA function call is, e.g., @samp{sin(1+x)}. Function names follow the same Xrules as variable names except that the default prefix @samp{calcFunc-} is Xused (instead of @samp{var-}) for the internal Lisp form. XMost mathematical Calculator commands like X@code{calc-sin} have function equivalents like @code{sin}. XIf no Lisp function is defined for a function called by a formula, the Xcall is left as it is during algebraic manipulation: @samp{f(x+y)} is Xleft alone. Beware that many innocent-looking short names like @code{in} Xand @code{re} have predefined meanings which could surprise you; however, Xsingle letters or single letters followed by digits are always safe. X@xref{Function Index}.@refill X XIn the documentation for particular commands, the notation @kbd{H S} X(@code{calc-sinh}) [@code{sinh}] means that the key sequence @kbd{H S}, the Xcommand @kbd{M-x calc-sinh}, and the algebraic function @code{sinh(x)} all Xrepresent the same operation.@refill X X@xref{Algebra}, for commands for manipulating formulas Xsymbolically. X X@node Stack and Trail, Mode Settings, Data Types, Top X@chapter Stack and Trail Commands X XThis chapter describes the Calc commands for manipulating objects in the Xstack and in the trail buffer. (These commands operate on objects of any Xtype, such as numbers, vectors, formulas, and incomplete objects.) X X@menu X* Stack Manipulation:: X* Trail Commands:: X@end menu X X@node Stack Manipulation, Trail Commands, Stack and Trail, Stack and Trail X@section Stack Manipulation Commands X X@kindex RET X@kindex SPC X@pindex calc-enter X@cindex Duplicating stack entries XTo duplicate the top object on the stack, press @key{RET} or @key{SPC} X(two equivalent keys for the @code{calc-enter} command). XGiven a positive numeric prefix argument, these commands duplicate Xseveral elements at the top of the stack. XGiven a negative argument, Xthese commands duplicate the specified element of the stack. XGiven an argument of zero, they duplicate the entire stack. XFor example, with @samp{10 20 30} on the stack, X@key{RET} creates @samp{10 20 30 30}, X@kbd{C-u 2 @key{RET}} creates @samp{10 20 30 20 30}, X@kbd{C-u - 2 @key{RET}} creates @samp{10 20 30 20}, and X@kbd{C-u 0 @key{RET}} creates @samp{10 20 30 10 20 30}.@refill X X@kindex LFD X@pindex calc-over XThe @key{LFD} (@code{calc-over}) command (on a key marked Line-Feed if you Xhave it, else on @kbd{C-j}) is like @code{calc-enter} Xexcept that the sign of the numeric prefix argument is interpreted Xoppositely. Also, with no prefix argument the default argument is 2. XThus with @samp{10 20 30} on the stack, @key{LFD} and @kbd{C-u 2 @key{LFD}} Xare both equivalent to @kbd{C-u - 2 @key{RET}}, producing X@samp{10 20 30 20}.@refill X X@kindex DEL X@kindex C-d X@pindex calc-pop X@cindex Removing stack entries X@cindex Deleting stack entries XTo remove the top element from the stack, press @key{DEL} (@code{calc-pop}). XThe @kbd{C-d} key is a synonym for @key{DEL}. X(If the top element is an incomplete object with at least one element, the Xlast element is removed from it.) Given a positive numeric prefix argument, Xseveral elements are removed. Given a negative argument, the specified Xelement of the stack is deleted. Given an argument of zero, the entire Xstack is emptied. XFor example, with @samp{10 20 30} on the stack, X@key{DEL} creates @samp{10 20}, X@kbd{C-u 2 @key{DEL}} creates @samp{10}, X@kbd{C-u - 2 @key{DEL}} creates @samp{10 30}, and X@kbd{C-u 0 @key{DEL}} creates an empty stack.@refill X X@kindex TAB X@pindex calc-roll-down XTo exchange the top two elements of the stack, press @key{TAB} X(@code{calc-roll-down}). Given a positive numeric prefix argument, the Xspecified number of elements at the top of the stack are rotated downward. XGiven a negative argument, the entire stack is rotated downward the specified Xnumber of times. Given an argument of zero, the entire stack is reversed Xtop-for-bottom. XFor example, with @samp{10 20 30 40 50} on the stack, X@key{TAB} creates @samp{10 20 30 50 40}, X@kbd{C-u 3 @key{TAB}} creates @samp{10 20 50 30 40}, X@kbd{C-u - 2 @key{TAB}} creates @samp{40 50 10 20 30}, and X@kbd{C-u 0 @key{TAB}} creates @samp{50 40 30 20 10}.@refill X X@kindex M-TAB X@pindex calc-roll-up XThe command @key{M-TAB} (@code{calc-roll-up}) is analogous to @key{TAB} Xexcept that it rotates upward instead of downward. Also, the default Xwith no prefix argument is to rotate the top 3 elements. XFor example, with @samp{10 20 30 40 50} on the stack, X@key{M-TAB} creates @samp{10 20 40 50 30}, X@kbd{C-u 4 @key{M-TAB}} creates @samp{10 30 40 50 20}, X@kbd{C-u - 2 @key{M-TAB}} creates @samp{30 40 50 10 20}, and X@kbd{C-u 0 @key{M-TAB}} creates @samp{50 40 30 20 10}.@refill X X@node Trail Commands, , Stack Manipulation, Stack and Trail X@section Trail Commands X X@cindex Trail buffer XThe commands for manipulating the Calc Trail buffer are two-key sequences Xbeginning with the @kbd{t} prefix. X X@kindex t d X@pindex calc-trail-display XThe @kbd{t d} (@code{calc-trail-display}) command turns display of the Xtrail on and off. Normally the trail display is toggled on if it was off, Xoff if it was on. With a numeric prefix of zero, this command always Xturns the trail off; with a prefix of one, it always turns the trail on. XThe other trail-manipulation commands described here automatically turn Xthe trail on. Note that when the trail is off values are still recorded Xthere; they are simply not displayed. To set Emacs to turn the trail Xoff by default, turn it off with @kbd{t d}, then save the mode settings Xwith @kbd{m m} (@code{calc-save-modes}). X X@kindex t i X@pindex calc-trail-in X@kindex t o X@pindex calc-trail-out XThe @kbd{t i} (@code{calc-trail-in}) and @kbd{t o} X(@code{calc-trail-out}) commands switch the cursor into and out of the XCalc Trail window. In practice they are rarely used, since the commands Xshown below are a more convenient way to move around in the Xtrail, and they work ``by remote control'' when the cursor is still Xin the Calculator window.@refill X X@cindex Trail pointer XThere is a @dfn{trail pointer} which selects some entry of the trail at Xany given time. The trail pointer looks like a @samp{>} symbol right Xbefore the selected number. The following commands operate on the Xtrail pointer in various ways. X X@kindex t y X@pindex calc-trail-yank X@cindex Retrieving previous results XThe @kbd{t y} (@code{calc-trail-yank}) command reads the selected value in Xthe trail and pushes it onto the Calculator stack. It allows you to Xre-use any previously computed value without retyping. X X@kindex t < X@pindex calc-trail-scroll-left X@kindex t > X@pindex calc-trail-scroll-right XThe @kbd{t <} (@code{calc-trail-scroll-left}) and @kbd{d >} X(@code{calc-trail-scroll-right}) commands horizontally scroll the trail Xwindow left or right by one half of its width.@refill X X@kindex t n X@pindex calc-trail-next X@kindex t p X@pindex calc-trail-previous X@kindex t f X@pindex calc-trail-forward X@kindex t b X@pindex calc-trail-backward XThe @kbd{t n} (@code{calc-trail-next}) and @kbd{t p} X(@code{calc-trail-previous)} commands move the trail pointer down or up Xone line. The @kbd{t f} (@code{calc-trail-forward}) and @kbd{t b} X(@code{calc-trail-backward}) commands move the trail pointer down or up Xone screenful at a time. All of these commands accept numeric prefix Xarguments to move several lines or screenfuls at a time.@refill X X@kindex t [ X@pindex calc-trail-first X@kindex t ] X@pindex calc-trail-last X@kindex t h X@pindex calc-trail-here XThe @kbd{t [} (@code{calc-trail-first}) and @kbd{t ]} X(@code{calc-trail-last}) commands move the trail pointer to the first or Xlast line of the trail. The @kbd{t h} (@code{calc-trail-here}) command Xmoves the trail pointer to the cursor position; unlike the other trail Xcommands, @kbd{t h} works only when Calc Trail is the selected window.@refill X X@kindex t s X@pindex calc-trail-isearch-forward X@kindex t r X@pindex calc-trail-isearch-backward XThe @kbd{t s} (@code{calc-trail-isearch-forward}) and @kbd{t r} X(@code{calc-trail-isearch-backward}) commands perform an incremental Xsearch forward and backward through the trail. When you terminate the Xsearch (typically by pressing @key{ESC}) the trail pointer moves to the Xcurrent line. If you cancel the search with @kbd{C-g}, the trail pointer Xdoes not move.@refill X X@kindex t m X@pindex calc-trail-marker XThe @kbd{t m} (@code{calc-trail-marker}) command allows you to enter a Xline of text of your own choosing into the trail. The text is inserted Xafter the line containing the trail pointer; this usually means it is Xadded to the end of the trail. Trail markers are useful mainly as the Xtargets for later incremental searches in the trail. X X@kindex t k X@pindex calc-trail-kill XThe @kbd{t k} (@code{calc-trail-kill}) command removes the selected line Xfrom the trail. The line is saved in the Emacs kill ring suitable for Xyanking into another buffer, but it is not easy to yank the text back Xinto the trail buffer. With a numeric prefix argument, this command Xkills the @samp{N} lines below or above the selected one. X X@node Mode Settings, Arithmetic, Stack and Trail, Top X@chapter Mode Settings X XThis chapter describes commands that set modes in the Calculator. XThey do not affect the contents of the stack, although they may change Xthe @emph{appearance} of the stack's contents. X X@kindex m m X@pindex calc-save-modes X@cindex Continuous memory X@cindex Saving mode settings X@cindex Permanent mode settings X@cindex @file{.emacs} file, mode settings XYou can save all of the current mode settings in your @file{.emacs} file Xwith the @kbd{m m} (@code{calc-save-modes}) command. This will cause XEmacs to reestablish these modes each time it starts up. The modes saved Xin the file include everything controlled by the @kbd{m} and @kbd{d} Xprefix keys, the current precision and binary word size, whether or not Xthe trail is displayed, and the current height of the Calc window. X(You can change which file this uses; @pxref{Installation}.)@refill X X@kindex m x X@pindex calc-always-load-extensions XThe @kbd{m x} (@code{calc-always-load-extensions}) command enables a mode Xin which the first use of Calc loads the entire program, including the Xextensions module. Otherwise, the extensions module will not be loaded Xuntil the first advanced Calc feature is used. Since this mode only Xhas effect when Calc is first loaded, @kbd{m x} is usually followed Xby @kbd{m m} to make the mode-setting permanent. X X@menu X* Precision:: X* Inverse and Hyperbolic:: X* Calculation Modes:: X* Simplification Modes:: X* Display Modes:: X* Language Modes:: X@end menu X X@node Precision, Inverse and Hyperbolic, Mode Settings, Mode Settings X@section Precision X X@kindex p X@pindex calc-precision X@cindex Precision of calculations XThe @kbd{p} (@code{calc-precision}) command controls the precision to Xwhich floating-point calculations are carried. The precision must be Xat least 3 digits and may be arbitrarily high, within the limits of Xmemory and time. This affects only floats: Integer and rational Xcalculations are always carried out with as many digits as necessary. X XMany internal calculations are carried to one or two digits higher Xprecision than normal. Results are rounded down afterward to the Xcurrent precision. Unless a special display mode has been selected, Xfloats are always displayed with their full stored precision, i.e., Xwhat you see is what you get. Reducing the current precision does not Xround values already on the stack, but those values will be rounded Xdown before being used in any calculation. The @kbd{c c} (@code{calc-clean}) Xcommand (@pxref{Conversions}) can be used to round an existing value to Xa new precision.@refill X XThe @kbd{p} key prompts for the current precision. If you wish you Xcan instead give the precision as a numeric prefix argument. X X@node Inverse and Hyperbolic, Calculation Modes, Precision, Mode Settings SHAR_EOF echo "End of part 14" echo "File calc.texinfo is continued in part 15" echo "15" > s2_seq_.tmp exit 0