[gnu.emacs.sources] Patch for Gnu Emacs Calc, 1.05 -> 1.06, part 4/5

daveg@near.cs.caltech.edu (Dave Gillespie) (10/24/90)

#!/bin/sh
# this is part 4 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file calc.patch continued
#
CurArch=4
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
sed 's/^X//' << 'SHAR_EOF' >> calc.patch
X  @subsection Algebra Tutorial Exercise 2
X  
X! Using @kbd{a S x RET} on the formula @samp{17 x^2 - 6 x^4 + 3 = 0} shows
X! that Calc isn't smart enough to solve this directly.  But this is a
X! quadratic equation in @samp{x^2}, so let's rewrite it in terms of a
X! new variable @samp{y = x^2}.  We can do this by replacing @samp{x}
X! with @samp{sqrt(y)}.
X! 
X! @group
X! @example
X! 1:  17 x^2 - 6 x^4 + 3 = 0       1:  17 y - 6 y^2 + 3 = 0
X! 2:  sqrt(y)                          .
X! 
X!     ' sqrt(y) RET                    l x RET
X! @end example
X! @end group
X! 
X! Now we can solve for the values of @samp{y} that satisfy the equation.
X  
X  @group
X  @example
X! 1:  y = 1.41667 + 1.58333 s1     1:  y = [-0.16667, 3.]
X!     .                                .
X  
X!     H a S y RET                      [ 1 RET 1 n ] l s1 RET
X  @end example
X  @end group
X  
X! We now rewrite in terms of @samp{x = sqrt(y)}.
X  
X  @group
X  @example
X! 2:  y                  2:  y
X! 1:  [-0.16667, 3.]     1:  [(0., 0.408248), 1.73205]
X!     .                      .
X  
X!     v u                    V M Q
X  @end example
X  @end group
X  
X- These are two solutions to the original equation.  We can find the
X- other two by noticing that @samp{x = -sqrt(y)} is another solution
X- to @samp{y = x^2}.
X- 
X  @group
X  @example
X! 1:  [(0., 0.408248), 1.73205, (0., -0.408248), -1.73205]
X      .
X  
X!     RET n |
X  @end example
X  @end group
X  
X  @node Algebra Answer 3, Algebra Answer 4, Algebra Answer 2, Answers to Exercises
X  @subsection Algebra Tutorial Exercise 3
X  
X--- 5497,5542 ----
X  @node Algebra Answer 2, Algebra Answer 3, Algebra Answer 1, Answers to Exercises
X  @subsection Algebra Tutorial Exercise 2
X  
X! It is easiest to use @kbd{a P x RET} to get a list of solutions.
X  
X  @group
X  @example
X! 1:  17 x^2 - 6 x^4 + 3 = 0   2:  17 y - 6 y^2 + 3 = 0
X! 2:  17 x^2 - 6 x^4 + 3 = 0   1:  [(0., 0.408), (0., -0.408), 1.732, -1.732]
X!     .                            .
X  
X!     RET                          a P x RET
X  @end example
X  @end group
X  
X! Now we can substitute these into the original formula.
X  
X  @group
X  @example
X! 4:  17 x^2 - 6 x^4 + 3 = 0
X! 3:  [(0., 0.408), (0., -0.408), 1.732, -1.732]
X! 2:  [(0., 0.408), (0., -0.408), 1.732, -1.732]
X! 1:  17 x^2 - 6 x^4 + 3
X!     .
X  
X!     M-2 RET TAB   v u DEL
X  @end example
X  @end group
X  
X  @group
X  @example
X! 3:  17 x^2 - 6 x^4 + 3 = 0
X! 2:  [(0., 0.408), (0., -0.408), 1.732, -1.732]
X! 1:  [1.6e-10, 1e-11, -1e-10, -1e-10]
X      .
X  
X!     V M $ RET
X  @end example
X  @end group
X  
X+ These numbers are reasonable approximations to zero, considering
X+ the precision to which we computed the solutions.
X+ 
X  @node Algebra Answer 3, Algebra Answer 4, Algebra Answer 2, Answers to Exercises
X  @subsection Algebra Tutorial Exercise 3
X  
X***************
X*** 5644,5652 ****
X  @node Programming Answer 2, Programming Answer 3, Programming Answer 1, Answers to Exercises
X  @subsection Programming Tutorial Exercise 2
X  
X! Using the stack:  @kbd{C-x ( RET S TAB / C-x )}.
X  
X! Using algebraic entry:  @kbd{C-x ( ' sin($)/$ RET C-x )}.
X  
X  @node Programming Answer 3, Programming Answer 4, Programming Answer 2, Answers to Exercises
X  @subsection Programming Tutorial Exercise 3
X--- 5669,5700 ----
X  @node Programming Answer 2, Programming Answer 3, Programming Answer 1, Answers to Exercises
X  @subsection Programming Tutorial Exercise 2
X  
X! Each of these functions can be computed using the stack, or using
X! algebraic entry, whichever way you prefer:
X! 
X! Computing @samp{sin(x) / x}:
X! 
X! Using the stack:  @kbd{C-x (  RET S TAB /  C-x )}.
X! 
X! Using algebraic entry:  @kbd{C-x (  ' sin($)/$ RET  C-x )}.
X! 
X! Computing the logarithm:
X! 
X! Using the stack:  @kbd{C-x (  TAB B  C-x )}
X! 
X! Using algebraic entry:  @kbd{C-x (  ' log($,$$) RET  C-x )}.
X! 
X! Computing the vector of integers:
X! 
X! Using the stack:  @kbd{C-x (  1 RET 1  C-u v x  C-x )}.  (Recall that
X! @kbd{C-u v x} takes the vector size, starting value, and increment
X! from the stack.)
X! 
X! Alternatively:  @kbd{C-x (  ~ v x  C-x )}.  (The @kbd{~} key pops a
X! number from the stack and uses it as the prefix argument for the
X! next command.)
X  
X! Using algebraic entry:  @kbd{C-x (  ' index($) RET  C-x )}.
X  
X  @node Programming Answer 3, Programming Answer 4, Programming Answer 2, Answers to Exercises
X  @subsection Programming Tutorial Exercise 3
X***************
X*** 5936,5945 ****
X  @subsection Programming Tutorial Exercise 9
X  
X  Taking the derivative of a term of the form @samp{x^n} will produce
X! a term like @samp{n x^(n-1)}.  Taking the derivative of a constant.
X! From this it is easy to see that the @var{n}th derivative of a
X! polynomial, evaluated at @samp{x = 0}, will equal the coefficient
X! on the @samp{x^n} term divided by @samp{n!}.
X  
X  (Because this definition is long, it will be repeated in concise form
X  below.  You can use @code{read-kbd-macro} to load it from there.
X--- 5984,5993 ----
X  @subsection Programming Tutorial Exercise 9
X  
X  Taking the derivative of a term of the form @samp{x^n} will produce
X! a term like @samp{n x^(n-1)}.  Taking the derivative of a constant
X! produces zero.  From this it is easy to see that the @var{n}th
X! derivative of a polynomial, evaluated at @samp{x = 0}, will equal the
X! coefficient on the @samp{x^n} term divided by @samp{n!}.
X  
X  (Because this definition is long, it will be repeated in concise form
X  below.  You can use @code{read-kbd-macro} to load it from there.
X***************
X*** 6179,6187 ****
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
X--- 6227,6233 ----
X***************
X*** 6207,6212 ****
X--- 6253,6264 ----
X  number @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  
X+ The @kbd{#}, @kbd{@@}, @kbd{'}, @kbd{"}, @kbd{p}, and @kbd{M} keys are
X+ also active during numeric entry.  They are used for entering
X+ non-decimal numbers, HMS forms, and so on; these notations are
X+ described later in this manual with the corresponding data types.
X+ @xref{Data Types}.
X+ 
X  During numeric entry, the only editing key available is @kbd{DEL}.
X  
X  @node Algebraic Entry, Quick Calculator, Numeric Entry, Introduction
X***************
X*** 6282,6288 ****
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--- 6334,6340 ----
X  @samp{$,$$} exchanges the top two elements of the stack, just like the
X  @key{TAB} key.
X  
X! @node Quick Calculator, Keypad Mode, Algebraic Entry, Introduction
X  @section ``Quick Calculator'' Mode
X  
X  @pindex quick-calc
X***************
X*** 6320,6326 ****
X  You may wish to use @code{global-set-key} to bind @code{quick-calc}
X  to some convenient keystroke.
X  
X! @node Prefix Arguments, Undo, Quick Calculator, Introduction
X  @section Numeric Prefix Arguments
X  
X  Many Calculator commands use numeric prefix arguments.  Some, such as
X--- 6372,6726 ----
X  You may wish to use @code{global-set-key} to bind @code{quick-calc}
X  to some convenient keystroke.
X  
X! @node Keypad Mode, Prefix Arguments, Quick Calculator, Introduction
X! @section ``Keypad'' Mode
X! 
X! @pindex calc-keypad
X! The @code{calc-keypad} command starts the Calculator and displays
X! a picture of a Calculator-style keypad.  If you are using the
X! X window system, you can click on any of the ``keys'' in the
X! keypad using the left mouse button to operate the calculator.
X! The original window remains the selected window; in keypad mode
X! you can type in your file while simultaneously performing
X! calculations with the mouse.
X! 
X! The @kbd{M-#} key with a numeric prefix argument of -2 is the
X! same as @code{calc-keypad}.  You may wish to bind it to another
X! key on your system.
X! 
X! If you aren't using the X window system, you must switch into
X! the @samp{*Calc Keypad*} window, place the cursor on the desired
X! ``key,'' and type @kbd{M-x calc-keypad-press}.  If you think this
X! is easier than using Calc normally, go right ahead.
X! 
X! Calc commands are more or less the same in keypad mode.  Certain
X! keypad keys differ slightly from the corresponding normal Calc
X! keystrokes; all such deviations are described below.
X! 
X! Keypad Mode includes many more commands than will fit on the keypad
X! at once.  Click the right mouse button [@code{calc-keypad-menu}]
X! to switch to the next next.  The bottom five rows of the keypad
X! stay the same; the top three rows change to a new set of commands.
X! To return to earlier menus, click the middle mouse button
X! [@code{calc-keypad-menu-back}] or simple advance through the menus
X! until you wrap around.
X! 
X! You can always click the @key{EXEC} button and type any normal
X! Calc key sequence.  This is equivalent to switching into the
X! Calc buffer, typing the keys, then switching back to your
X! original buffer.
X! 
X! @menu
X! * Keypad Main Menu::
X! * Keypad Functions Menu::
X! * Keypad Binary Menu::
X! * Keypad Vectors Menu::
X! * Keypad Modes Menu::
X! @end menu
X! 
X! @node Keypad Main Menu, Keypad Functions Menu, Keypad Mode, Keypad Mode
X! 
X! @group
X! @example
X! |----+-----Calc 1.06-----+----1
X! |FLR |CEIL|RND |TRNC|CLN2|FLT |
X! |----+----+----+----+----+----|
X! | LN |EXP |    |ABS |IDIV|MOD |
X! |----+----+----+----+----+----|
X! |SIN |COS |TAN |SQRT|y^x |1/x |
X! |----+----+----+----+----+----|
X! |  ENTER  |+/- |EEX |UNDO| <- |
X! |-----+---+-+--+--+-+---++----|
X! | INV |  7  |  8  |  9  |  /  |
X! |-----+-----+-----+-----+-----|
X! | HYP |  4  |  5  |  6  |  *  |
X! |-----+-----+-----+-----+-----|
X! |EXEC |  1  |  2  |  3  |  -  |
X! |-----+-----+-----+-----+-----|
X! | OFF |  0  |  .  | PI  |  +  |
X! |-----+-----+-----+-----+-----+
X! @end example
X! @end group
X! 
X! This is the menu that appears the first time you start Keypad Mode.
X! It will show up in a vertical window on the right side of your screen.
X! Above this menu is the traditional Calc stack display.  On a 24-line
X! screen you will be able to see the top three stack entries.
X! 
X! The ten digit keys, decimal point, and @key{EEX} key are used for
X! entering numbers in the obvious way.  @key{EEX} begins entry of an
X! exponent in scientific notation.  Just as with regular Calc, the
X! number is pushed onto the stack as soon as you press @key{ENTER}
X! or any other function key.
X! 
X! The @key{+/-} key corresponds to normal Calc's @kbd{n} key.  During
X! numeric entry it changes the sign of the number or of the exponent.
X! At other times it changes the sign of the number on the top of the
X! stack.
X! 
X! The @key{INV} and @key{HYP} keys modify other keys.  As well as
X! having the effects described elsewhere in this manual, Keypad Mode
X! defines several other ``inverse'' operations.  These are described
X! below and in the following sections.
X! 
X! The @key{ENTER} key finishes the current numeric entry, or otherwise
X! duplicates the top entry on the stack.
X! 
X! The @key{UNDO} key undoes the most recent Calc operation.
X! @kbd{INV UNDO} is the ``redo'' command, and @kbd{HYP UNDO} is
X! ``last X.''
X! 
X! The @key{<-} key acts as a ``backspace'' during numeric entry.
X! At other times it removes the top stack entry.  @kbd{INV <-}
X! clears the entire stack.  @kbd{HYP <-} takes an integer from
X! the stack, then removes that many additional stack elements.
X! 
X! The @key{EXEC} key prompts you to enter any keystroke sequence
X! that would normally work in Calc mode.  This can include a
X! numeric prefix if you wish.  It is also possible simply to
X! switch into the Calc window and type commands in it; there is
X! nothing ``magic'' about this window when Keypad Mode is active.
X! 
X! The other keys in this display perform their obvious calculator
X! functions.  @key{CLN2} rounds the top-of-stack by temporarily
X! reducing the precision by 2 digits.  @key{FLT} converts an
X! integer or fraction on the top of the stack to floating-point.
X! 
X! The @key{INV} and @key{HYP} keys combined with several of these keys
X! give you access to some common functions even if the appropriate menu
X! is not displayed.  Obviously you don't need to learn these keys
X! unless you find yourself wasting time switching among the menus.
X! 
X! @kbd{INV +/-} is the same as @key{1/x}.
X! @kbd{INV +} is the same as @key{SQRT}.
X! @kbd{INV -} is the same as @key{CONJ}.
X! @kbd{INV *} is the same as @key{y^x}.
X! @kbd{INV /} is the same as @key{INV y^x} (the @samp{x}th root of @samp{y}).
X! @kbd{HYP 1} and @kbd{INV 1} are the same as @key{SIN} and @kbd{INV SIN}.
X! @kbd{HYP 2} and @kbd{INV 2} are the same as @key{COS} and @kbd{INV COS}.
X! @kbd{HYP 3} and @kbd{INV 3} are the same as @key{TAN} and @kbd{INV TAN}.
X! @kbd{INV 4} and @kbd{HYP 4} are the same as @key{LN} and @kbd{HYP LN}.
X! @kbd{INV 5} and @kbd{HYP 5} are the same as @key{EXP} and @kbd{HYP EXP}.
X! @kbd{INV 6} is the same as @key{ABS}.
X! @kbd{INV 7} is the same as @key{RND} (@code{calc-round}).
X! @kbd{INV 8} is the same as @key{CLN2}.
X! @kbd{INV 9} is the same as @key{FLT} (@code{calc-float}).
X! @kbd{INV 0} is the same as @key{IMAG}.
X! @kbd{INV .} is the same as @key{PREC}.
X! @kbd{INV ENTER} is the same as @key{SWAP}.
X! @kbd{HYP ENTER} is the same as @key{RLL3}.
X! @kbd{INV HYP ENTER} is the same as @key{OVER}.
X! 
X! Use @kbd{HYP +/-} to pack the top two stack entries as an error form.
X! Use @kbd{HYP EEX} to pack the top two stack entries as a modulo form.
X! Use @kbd{INV EEX} to create an interval form; this removes an integer
X! which is one of 0 @samp{[]}, 1 @samp{[)}, 2 @samp{(]} or 3 @samp{()},
X! followed by the two limits of the interval.
X! 
X! The @kbd{OFF} key turns Calc off; typing @kbd{M-x calc-keypad}
X! again has the same effect.  This is analogous to typing @kbd{q}
X! or hitting @kbd{M-#} again in the normal calculator.
X! 
X! @node Keypad Functions Menu, Keypad Binary Menu, Keypad Main Menu, Keypad Mode
X! 
X! @group
X! @example
X! |----+----+----+----+----+----2
X! |IGAM|BETA|IBET|ERF |BESJ|BESY|
X! |----+----+----+----+----+----|
X! |IMAG|CONJ| RE |ATN2|RAND|RAGN|
X! |----+----+----+----+----+----|
X! |GCD |FACT|DFCT|BNOM|PERM|NXTP|
X! |----+----+----+----+----+----|
X! @end example
X! @end group
X! 
X! This menu provides various operations from the @kbd{f} and @kbd{k}
X! prefix keys.
X! 
X! @key{IMAG} multiplies the number on the stack by the imaginary
X! number @samp{i = (0, 1)}.
X! 
X! @key{RE} extracts the real part a complex number.  @kbd{INV RE}
X! extracts the imaginary part.
X! 
X! @key{RAND} takes a number from the top of the stack and computes
X! a random number greater then or equal to zero but less than that
X! number.  (@xref{Random Numbers}.)  @key{RAGN} is the ``random
X! again'' command; it computes another random number using the
X! same limit as last time.
X! 
X! @key{INV GCD} computes the LCM (least common multiple) function
X! 
X! @key{INV FACT} is the gamma function.  @samp{gamma(x) = (x-1)!}.
X! 
X! @key{PERM} is the number-of-permutations function, which is on the
X! @kbd{H k c} key in normal Calc.
X! 
X! @key{NXTP} finds the next prime after a number.  @kbd{INV NXTP}
X! finds the previous prime.
X! 
X! @node Keypad Binary Menu, Keypad Vectors Menu, Keypad Functions Menu, Keypad Mode
X! 
X! @group
X! @example
X! |----+----+----+----+----+----3
X! |AND | OR |XOR |NOT |LSH |RSH |
X! |----+----+----+----+----+----|
X! |DEC |HEX |OCT |BIN |WSIZ|ARSH|
X! |----+----+----+----+----+----|
X! | A  | B  | C  | D  | E  | F  |
X! |----+----+----+----+----+----|
X! @end example
X! @end group
X! 
X! The keys in this menu perform operations on binary integers.
X! Note that the both logical and arithmetic right-shifts are provided.
X! @key{INV LSH} rotates one bit to the left.
X! 
X! The ``difference'' function (normally on @kbd{b d}) is on @key{INV AND}.
X! The ``clip'' function (normally on @kbd{b c}) is on @key{INV NOT}.
X! 
X! The @key{DEC}, @key{HEX}, @key{OCT}, and @key{BIN} keys select the
X! current radix for display and entry of numbers:  Decimal, hexadecimal,
X! octal, or binary.  The six letter keys @key{A} through @key{F} are used
X! for entering hexadecimal numbers.
X! 
X! The @key{WSIZ} key sets the current word size for binary operations.
X! The default is 32 bits.  You can respond to the prompt using either
X! the keyboard or the digits and @key{ENTER} from the keypad.  Use
X! @key{INV WSIZ} to see the current word size.
X! 
X! @node Keypad Vectors Menu, Keypad Modes Menu, Keypad Binary Menu, Keypad Mode
X! 
X! @group
X! @example
X! |----+----+----+----+----+----4
X! |SUM |PROD|MAX |MAP*|MAP^|MAP$|
X! |----+----+----+----+----+----|
X! |MINV|MDET|MTRN|IDNT|CRSS|"x" |
X! |----+----+----+----+----+----|
X! |PACK|UNPK|INDX|BLD |LEN |... |
X! |----+----+----+----+----+----|
X! @end example
X! @end group
X! 
X! The keys in this menu operate on vectors and matrices.
X! 
X! @key{PACK} removes an integer @var{n} from the top of the stack;
X! the next @var{n} stack elements are removed and packed into a vector,
X! which is replaced onto the stack.  Thus the sequence
X! @kbd{1 ENTER 3 ENTER 5 ENTER 3 PACK} enters the vector
X! @samp{[1, 3, 5]} onto the stack.  To enter a matrix, build each row
X! on the stack as a vector, then use a final @key{PACK} to collect the
X! rows into a matrix.  Note that the equivalent command in normal
X! Calc, @kbd{v p}, takes @var{n} from a numeric prefix argument instead
X! of from the stack.
X! 
X! @key{UNPK} unpacks the vector on the stack, pushing each of its
X! components separately.
X! 
X! @key{INDX} removes an integer @var{n}, then builds a vector of
X! integers from 1 to @var{n}.  @kbd{INV INDX} takes three numbers
X! from the stack:  The vector size @var{n}, the starting number,
X! and the increment.  @kbd{BLD} takes any value @var{x} and an
X! integer @var{n} and builds a vector of @var{n} copies of @var{x}.
X! 
X! @key{IDNT} removes an integer @var{n}, then builds an @var{n}-by-@var{n}
X! identity matrix.
X! 
X! @key{LEN} replaces a vector by its length, an integer.
X! 
X! @key{...} turns on or off ``abbreviated'' display mode for large vectors.
X! 
X! @key{MINV}, @key{MDET}, @key{MTRN}, and @key{CROSS} are the matrix
X! inverse, determinant, and transpose, and vector cross product.
X! 
X! @key{SUM} replaces a vector by the sum of its elements.  It is
X! equivalent to @kbd{V R +} in normal Calc.  @key{PROD} computes the
X! product of the elements of a vector, and @key{MAX} computes the
X! maximum of all the elements of a vector.
X! 
X! @key{INV SUM} computes the alternating sum of the first element
X! minus the second, plus the third, minus the fourth, and so on.
X! @key{INV MAX} computes the minimum of the vector elements.
X! 
X! @key{MAP*} multiplies two vectors elementwise.  @key{MAP^} computes
X! powers elementwise.  The arguments must be vectors of equal length,
X! or one must be a vector and the other must be a plain number.
X! For example, @kbd{2 MAP^} squares all the elements of a vector.
X! 
X! @key{MAP$} maps the formula on the top of the stack across the
X! vector in the second-to-top position.  If the formula contains
X! several variables, Calc takes that many vectors starting at the
X! second-to-top position and matches them to the variables in
X! alphabetical order.  The result is a vector of the same size as
X! the input vectors, whose elements are the formula evaluated with
X! the variables set to the various sets of numbers in those vectors.
X! 
X! The @key{"x"} key pushes the variable name @samp{x} onto the
X! stack.  To build the formula @samp{x^2 + 6}, you would use the
X! key sequence @kbd{"x" 2 y^x 6 +}.  This formula would then be
X! suitable for use with the @key{MAP$} key described above.
X! With @key{INV}, @key{HYP}, or @key{INV} and @key{HYP}, the
X! @key{"x"} key pushes the variable names @samp{y}, @samp{z}, and
X! @samp{t}, respectively.
X! 
X! @node Keypad Modes Menu, , Keypad Vectors Menu, Keypad Mode
X! 
X! @group
X! @example
X! |----+----+----+----+----+----5
X! |FLT |FIX |SCI |ENG |GRP |    |
X! |----+----+----+----+----+----|
X! |RAD |DEG |FRAC|POLR|SYMB|PREC|
X! |----+----+----+----+----+----|
X! |SWAP|RLL3|RLL4|OVER|STO |RCL |
X! |----+----+----+----+----+----|
X! @end example
X! @end group
X! 
X! The @key{FLT}, @key{FIX}, @key{SCI}, and @key{ENG} keys select
X! floating-point, fixed-point, scientific, or engineering notation.
X! @key{FIX} prompts for the number of digits to display.  You can
X! respond using the keyboard or the keypad digit and @key{ENTER} keys.
X! The other three modes always display full precision.  You can
X! type a numeric prefix using the keyboard, then click on one of
X! these keys, to set a different display precision.
X! 
X! The @key{GRP} key turns grouping of digits with commas on or off.
X! @kbd{INV GRP} enables grouping to the right of decimal points as
X! well as to the left.
X! 
X! The @key{RAD} and @key{DEG} keys switch between radians and degrees
X! for trigonometric functions.
X! 
X! The @key{FRAC} key turns Fraction mode on or off.  This affects
X! whether commands like @kbd{/} with integer arguments produce
X! fractional or floating-point results.
X! 
X! The @key{POLR} key turns Polar mode on or off, determining whether
X! polar or rectangular complex numbers are used by default.
X! 
X! The @key{SYMB} key turns Symbolic mode on or off, in which
X! operations that would produce inexact floating-point results
X! are left unevaluated as algebraic formulas.
X! 
X! The @key{PREC} key selects the current precision.  Answer with
X! the keyboard or with the keypad digit and @key{ENTER} keys.
X! 
X! The @key{SWAP} key exchanges the top two stack elements.
X! The @key{RLL3} key rotates the top three stack elements upwards.
X! The @key{RLL4} key rotates the top four stack elements upwards.
X! The @key{OVER} key duplicates the second-to-top stack element.
X! 
X! The @key{STO} and @key{RCL} keys are analogous to @kbd{s} and @kbd{r}
X! in regular Calc.  @xref{Store and Recall}.  Click the @key{STO} or
X! @key{RCL} key, then one of the ten digits.  (Named variables are
X! not available in Keypad Mode.)  You can also use, for example,
X! @kbd{STO + 3} to add to register 3.
X! 
X! @node Prefix Arguments, Undo, Keypad Mode, Introduction
X  @section Numeric Prefix Arguments
X  
X  Many Calculator commands use numeric prefix arguments.  Some, such as
X***************
X*** 6483,6500 ****
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}
X  Calc uses recursion in many of its calculations.  Emacs Lisp keeps a
X  variable @code{max-lisp-eval-depth} which limits the amount of recursion
X  possible in an attempt to recover from program bugs.  If a calculation
X! ever halts incorrectly because of a
X! ``Lisp nesting exceeds @code{max-lisp-eval-depth}'' error,
X! use the @kbd{M} command (@code{calc-more-recursion-depth}) to increase
X! this limit.@refill
X  
X  The limit is always increased (multiplied) by a factor of two.  There is
X! also a @code{calc-less-recursion-depth} (or @kbd{x less}) command which
X  decreases this limit by a factor of two, down to a minimum value of 200.
X  The default value is 1000.
X  
X--- 6883,6900 ----
X  @pindex calc-more-recursion-depth
X  @pindex calc-less-recursion-depth
X  @cindex Recursion depth
X+ @cindex ``Computation got stuck'' message
X  @cindex @code{max-lisp-eval-depth}
X  @cindex @code{max-specpdl-size}
X  Calc uses recursion in many of its calculations.  Emacs Lisp keeps a
X  variable @code{max-lisp-eval-depth} which limits the amount of recursion
X  possible in an attempt to recover from program bugs.  If a calculation
X! ever halts incorrectly with the message ``Computation got stuck or
X! ran too long,'' use the @kbd{M} command (@code{calc-more-recursion-depth})
X! to increase this limit.@refill
X  
X  The limit is always increased (multiplied) by a factor of two.  There is
X! also a @code{calc-less-recursion-depth} (or @kbd{x less-rec}) command which
X  decreases this limit by a factor of two, down to a minimum value of 200.
X  The default value is 1000.
X  
X***************
X*** 6571,6576 ****
X--- 6971,6977 ----
X  insert a comma at every third digit for display purposes, but such
X  commas are not allowed during the entry of numbers.@refill
X  
X+ @kindex #
X  A non-decimal integer is represented as an optional sign, a radix
X  between 2 and 36, a @samp{#} symbol, and one or more digits.  For radix 11
X  and above, the letters A through Z (upper- or lower-case) count as
X***************
X*** 6738,6743 ****
X--- 7139,7151 ----
X  use HMS as the angular mode so that calculated angles are expressed in
X  degrees, minutes, and seconds.
X  
X+ @kindex @@
X+ @kindex ' (HMS forms)
X+ @kindex " (HMS forms)
X+ @kindex h (HMS forms)
X+ @kindex o (HMS forms)
X+ @kindex m (HMS forms)
X+ @kindex s (HMS forms)
X  The 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***************
X*** 6804,6809 ****
X--- 7212,7218 ----
X  the sense of reducing @samp{sqrt(@var{a})} modulo @var{M}, this is not a
X  useful definition from the number-theoretical point of view.)@refill
X  
X+ @kindex M (modulo forms)
X  To create a modulo form during numeric entry, press the shift-@kbd{M}
X  key to enter the word @samp{mod}.  As a special convenience, pressing
X  shift-@kbd{M} a second time automatically enters the value of @var{M}
X***************
X*** 6868,6873 ****
X--- 7277,7283 ----
X  in @samp{x} had been small, the error in @code{sin(x)} would indeed have
X  been negligible.@refill
X  
X+ @kindex p (error forms)
X  To 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
X  typing @samp{+/-} the @kbd{+} key will be interpreted as the Calculator's
X***************
X*** 7550,7556 ****
X  of the command.@refill
X  
X  To evaluate a formula numerically without expanding the variables it
X! contains, you can use the key sequence @kbd{m a a v m a} (this uses
X  @code{calc-alg-evaluate}, which resimplifies but doesn't evaluate
X  variables.)
X  
X--- 7960,7966 ----
X  of the command.@refill
X  
X  To evaluate a formula numerically without expanding the variables it
X! contains, you can use the key sequence @kbd{m s a v m s} (this uses
X  @code{calc-alg-evaluate}, which resimplifies but doesn't evaluate
X  variables.)
X  
X***************
X*** 7984,7995 ****
X  
X  @menu
X  * Normal Language Modes::
X! * C Fortran Pascal::
X  * Tex Language Mode::
X  * Mathematica Language Mode::
X  @end menu
X  
X! @node Normal Language Modes, C Fortran Pascal, Language Modes, Language Modes
X  @subsection Normal Language Modes
X  
X  @kindex d N
X--- 8394,8405 ----
X  
X  @menu
X  * Normal Language Modes::
X! * C FORTRAN Pascal::
X  * Tex Language Mode::
X  * Mathematica Language Mode::
X  @end menu
X  
X! @node Normal Language Modes, C FORTRAN Pascal, Language Modes, Language Modes
X  @subsection Normal Language Modes
X  
X  @kindex d N
X***************
X*** 8054,8061 ****
X  (except that Mathematica mode expects square brackets instead of
X  parentheses.)
X  
X! @node C Fortran Pascal, Tex Language Mode, Normal Language Modes, Language Modes
X! @subsection C, Fortran, and Pascal Modes
X  
X  @kindex d C
X  @pindex calc-c-language
X--- 8464,8471 ----
X  (except that Mathematica mode expects square brackets instead of
X  parentheses.)
X  
X! @node C FORTRAN Pascal, Tex Language Mode, Normal Language Modes, Language Modes
X! @subsection C, FORTRAN, and Pascal Modes
X  
X  @kindex d C
X  @pindex calc-c-language
X***************
X*** 8094,8108 ****
X  
X  @kindex d F
X  @pindex calc-fortran-language
X! @cindex Fortran language
X! The @kbd{d F} (@code{calc-fortran-language}) command selects Fortran
X! conventions.  Various function names are transformed into Fortran
X  equivalents.  Vectors are written as @samp{/1, 2, 3/}, though they must
X! still be entered using square brackets.  Since Fortran uses round
X  parentheses for both function calls and array subscripts, Calc treats
X  both as if they were function calls.
X  
X! Fortran and Pascal modes normally do not adjust the case of letters in
X  formulas.  All built-in Calc names use lower-case letters.  If you use a
X  positive numeric prefix argument with @kbd{d P} or @kbd{d F}, these
X  modes will use upper-case letters exclusively for display, and will
X--- 8504,8518 ----
X  
X  @kindex d F
X  @pindex calc-fortran-language
X! @cindex FORTRAN language
X! The @kbd{d F} (@code{calc-fortran-language}) command selects FORTRAN
X! conventions.  Various function names are transformed into FORTRAN
X  equivalents.  Vectors are written as @samp{/1, 2, 3/}, though they must
X! still be entered using square brackets.  Since FORTRAN uses round
X  parentheses for both function calls and array subscripts, Calc treats
X  both as if they were function calls.
X  
X! FORTRAN and Pascal modes normally do not adjust the case of letters in
X  formulas.  All built-in Calc names use lower-case letters.  If you use a
X  positive numeric prefix argument with @kbd{d P} or @kbd{d F}, these
X  modes will use upper-case letters exclusively for display, and will
X***************
X*** 8109,8115 ****
X  convert to lower-case on input.  With a negative prefix, these modes
X  convert to lower-case for display and input.
X  
X! @node Tex Language Mode, Mathematica Language Mode, C Fortran Pascal, Language Modes
X  @subsection @TeX{} Language Mode
X  
X  @kindex d T
X--- 8519,8525 ----
X  convert to lower-case on input.  With a negative prefix, these modes
X  convert to lower-case for display and input.
X  
X! @node Tex Language Mode, Mathematica Language Mode, C FORTRAN Pascal, Language Modes
X  @subsection @TeX{} Language Mode
X  
X  @kindex d T
X***************
X*** 8176,8181 ****
X--- 8586,8658 ----
X  Also, the ``discretionary multiplication sign'' @samp{\*} is read
X  the same as @samp{*}.
X  
X+ @ifinfo
X+ The @TeX{} version of this manual includes some printed examples at the
X+ end of this section.
X+ @end ifinfo
X+ @iftex
X+ Here are some examples of how various Calc formulas are formatted in @TeX{}:
X+ 
X+ @example
X+ sin(a^2 / subscr(b,i))
X+ \sin\left( {a^2 \over b_i} \right)
X+ @end example
X+ @tex
X+ \def\sin{\hbox{sin}}
X+ $$ \sin\left( a^2 \over b_i \right) $$
X+ @end tex
X+ 
X+ @example
X+ [(3, 4), 3 +/- 4, [3 .. 4)]
X+ [3 + 4i, 3 \pm 4, [3 \dots 4)]
X+ @end example
X+ @tex
X+ $$ [3 + 4i, 3 \pm 4, [ 3 \dots 4)] $$
X+ @end tex
X+ 
X+ @example
X+ [abs(a), abs(a / b), floor(a), ceil(a / b)]
X+ [|a|, \left| a \over b \right|,
X+  \lfloor a \rfloor, \left\lceil a \over b \right\rceil]
X+ @end example
X+ @tex
X+ $$ [|a|, \left| a \over b \right|,
X+     \lfloor a \rfloor, \left\lceil a \over b \right\rceil] $$
X+ @end tex
X+ 
X+ @example
X+ [sin(a), sin(2 a), sin(2 + a), sin(a / b)]
X+ [\sin{a}, \sin{2 a}, \sin(2 + a), \sin\left( {a \over b} \right)]
X+ @end example
X+ @tex
X+ \def\sin{\hbox{sin}}
X+ $$ [\sin{a}, \sin{2 a}, \sin(2 + a), \sin\left( {a \over b} \right)] $$
X+ @end tex
X+ 
X+ First with plain @kbd{d T}, then with @kbd{C-u d T}:
X+ 
X+ @example
X+ [f(a), foo(bar), sin(pi)]
X+ [f(a), foo(bar), \sin{\pi}]
X+ [f(a), \hbox{foo}(\hbox{bar}), \sin{\pi}]
X+ @end example
X+ @tex
X+ \def\sin{\hbox{sin}}
X+ $$ [f(a), foo(bar), \sin{\pi}] $$
X+ $$ [f(a), \hbox{foo}(\hbox{bar}), \sin{\pi}] $$
X+ @end tex
X+ 
X+ @example
X+ [ [ a / b, 0 ], [ 0, 2^(x + 1) ] ]
X+ \matrix{ {a \over b} & 0 \\ 0 & 2^{(x + 1)} }
X+ \pmatrix{ {a \over b} & 0 \\ 0 & 2^{(x + 1)} }
X+ @end example
X+ @tex
X+ $$ \matrix{ {a \over b} & 0 \cr 0 & 2^{(x + 1)} } $$
X+ $$ \pmatrix{ {a \over b} & 0 \cr 0 & 2^{(x + 1)} } $$
X+ @end tex
X+ @end iftex
X+ 
X  @node Mathematica Language Mode, , TeX Language Mode, Language Modes
X  @subsection Mathematica Language Mode
X  
X***************
X*** 8399,8405 ****
X  @tindex sign
X  The @kbd{f s} (@code{calc-sign}) [@code{sign}] command returns 1 if its
X  argument is positive, -1 if its argument is negative, or 0 if its argument
X! is zero.
X  
X  @kindex &
X  @pindex calc-inv
X--- 8876,8884 ----
X  @tindex sign
X  The @kbd{f s} (@code{calc-sign}) [@code{sign}] command returns 1 if its
X  argument is positive, -1 if its argument is negative, or 0 if its argument
X! is zero.  In algebraic form, you can also write @samp{sign(a,x)} which
X! evaluates to @samp{x * sign(a)}, i.e., either @samp{x}, @samp{-x}, or
X! zero depending on the sign of @samp{a}.
X  
X  @kindex &
X  @pindex calc-inv
X***************
X*** 8932,8937 ****
X--- 9411,9419 ----
X  (The actual implementation uses far more efficient computational methods.)
X  
X  @kindex f G
X+ @kindex I f G
X+ @kindex H f G
X+ @kindex I H f G
X  @pindex calc-inc-gamma
X  @tindex gammaP
X  @tindex gammaQ
X***************
X*** 8965,8970 ****
X--- 9447,9453 ----
X  @samp{beta(a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, 1)}.
X  
X  @kindex f B
X+ @kindex H f B
X  @pindex calc-inc-beta
X  @tindex betaI
X  @tindex betaB
X***************
X*** 8975,8980 ****
X--- 9458,9464 ----
X  un-normalized version [@code{betaB}].
X  
X  @kindex f e
X+ @kindex I f e
X  @pindex calc-erf
X  @tindex erf
X  @tindex erfc
X***************
X*** 9205,9210 ****
X--- 9689,9695 ----
X  number-of-permutations function @samp{N! / (N-M)!}.
X  
X  @kindex k b
X+ @kindex H k b
X  @pindex calc-bernoulli-number
X  @tindex bern
X  The @kbd{k b} (@code{calc-bernoulli-number}) [@code{bern}] command
X***************
X*** 9216,9221 ****
X--- 9701,9707 ----
X  a polynomial in @samp{x}; if @samp{x} is a number the result is a number.
X  
X  @kindex k e
X+ @kindex H k e
X  @pindex calc-euler-number
X  @tindex euler
X  The @kbd{k e} (@code{calc-euler-number}) [@code{euler}] command similarly
X***************
X*** 9224,9229 ****
X--- 9710,9716 ----
X  functions.
X  
X  @kindex k s
X+ @kindex H k s
X  @pindex calc-stirling-number
X  @tindex stir1
X  @tindex stir2
X***************
X*** 9328,9333 ****
X--- 9815,9821 ----
X  or equivalently @samp{ltpn(2.8,2,1) - ltpn(2.5,2,1)}.
X  
X  @kindex k B
X+ @kindex I k B
X  @pindex calc-utpb
X  @tindex utpb
X  @tindex ltpb
X***************
X*** 9352,9357 ****
X--- 9840,9846 ----
X  original arguments but substitute a new value for @samp{x}.)
X  
X  @kindex k C
X+ @kindex I k C
X  @pindex calc-utpc
X  @tindex utpc
X  @tindex ltpc
X***************
X*** 9360,9365 ****
X--- 9849,9855 ----
X  correct if its chi-square statistic is @samp{x}.
X  
X  @kindex k F
X+ @kindex I k F
X  @pindex calc-utpf
X  @tindex utpf
X  @tindex ltpf
X***************
X*** 9369,9374 ****
X--- 9859,9865 ----
X  respectively, used in computing the statistic @samp{F}.
X  
X  @kindex k N
X+ @kindex I k N
X  @pindex calc-utpn
X  @tindex utpn
X  @tindex ltpn
X***************
X*** 9378,9383 ****
X--- 9869,9875 ----
X  exceed @samp{x}.
X  
X  @kindex k P
X+ @kindex I k P
X  @pindex calc-utpp
X  @tindex utpp
X  @tindex ltpp
X***************
X*** 9386,9391 ****
X--- 9878,9884 ----
X  Poisson random events will occur.
X  
X  @kindex k T
X+ @kindex I k T
X  @pindex calc-ltpt
X  @tindex utpt
X  @tindex ltpt
X***************
X*** 9549,9554 ****
X--- 10042,10048 ----
X  * Extracting Elements::
X  * Manipulating Vectors::
X  * Vector and Matrix Arithmetic::
X+ * Set Operations::
X  * Reducing and Mapping::
X  * Vector and Matrix Formats::
X  @end menu
X***************
X*** 9578,9583 ****
X--- 10072,10085 ----
X  matrix and the other is a plain vector, the vector is treated as a
X  one-row matrix.
X  
X+ @kindex H |
X+ @tindex append
X+ The @kbd{H |} (@code{calc-append}) [@code{append}] command concatenates
X+ two vectors without any special cases.  Both inputs must be vectors.
X+ Whether or not they are matrices is not taken into account.  If either
X+ argument is a scalar, the @code{append} function is left in symbolic form.
X+ See also @code{cons} and @code{rcons} below.
X+ 
X  @kindex v p (vectors)
X  @pindex calc-pack (vectors)
X  The @kbd{v p} (@code{calc-pack}) command collects several elements from
X***************
X*** 9665,9671 ****
X  to build a matrix of copies of that row.)
X  
X  @pindex calc-head
X! @pindex caic-tail
X  @tindex head
X  @tindex tail
X  The @code{calc-head} [@code{head}] function returns the first element
X--- 10167,10173 ----
X  to build a matrix of copies of that row.)
X  
X  @pindex calc-head
X! @pindex calc-tail
X  @tindex head
X  @tindex tail
X  The @code{calc-head} [@code{head}] function returns the first element
X***************
X*** 9681,9686 ****
X--- 10183,10199 ----
X  if @var{h} is itself a vector, @kbd{|} will concatenate the two vectors
X  whereas @code{cons} will insert @var{h} at the front of the vector @var{t}.
X  
X+ @tindex rhead
X+ @tindex rtail
X+ @tindex rcons
X+ Each of these three functions also accepts the Inverse flag [@code{rhead},
X+ @code{rtail}, @code{rcons}] in which case @var{t} represents the
X+ @emph{last} element of the vector instead of the first, with @var{h}
X+ representing the remainder of the vector.  Thus the vector
X+ @samp{[a, b, c, d] = cons(a, [b, c, d]) = rcons([a, b, c], d)}.
X+ Also, @samp{head([a, b, c, d]) = a}, @samp{tail([a, b, c, d]) = [b, c, d]},
X+ @samp{rhead([a, b, c, d]) = [a, b, c]}, and @samp{rtail([a, b, c, d]) = d}.
X+ 
X  @node Extracting Elements, Manipulating Vectors, Building Vectors, Matrix Functions
X  @section Extracting Vector and Matrix Elements
X  
X***************
X*** 9749,9754 ****
X--- 10262,10275 ----
X  is taken as zero, i.e., elements from the starting element to the
X  end of the vector are used.
X  
X+ @kindex I v s
X+ @tindex rsubvec
X+ With the Inverse flag, @kbd{I v s} [@code{rsubvec}] removes a subvector
X+ from a vector.  The arguments are interpreted the same as for the
X+ normal @kbd{v s} command.  Thus, @samp{rsubvec([a, b, c, d, e], 2, 4)}
X+ produces @samp{[a, d, e]}.  It is always true that @code{subvec} and
X+ @code{rsubvec} return complementary parts of the input vector.
X+ 
X  @xref{Selecting Subformulas}, for an alternative way to operate on
X  vectors one element at a time.
X  
X***************
X*** 9927,9933 ****
X  the @code{? :} operation also discussed there allows other types of
X  masking using vectors.
X  
X! @node Vector and Matrix Arithmetic, Reducing and Mapping, Manipulating Vectors, Matrix Functions
X  @section Vector and Matrix Arithmetic
X  
X  Basic arithmetic operations like addition and multiplication are defined
X--- 10448,10454 ----
X  the @code{? :} operation also discussed there allows other types of
X  masking using vectors.
X  
X! @node Vector and Matrix Arithmetic, Set Operations, Manipulating Vectors, Matrix Functions
X  @section Vector and Matrix Arithmetic
X  
X  Basic arithmetic operations like addition and multiplication are defined
X***************
X*** 10019,10025 ****
X  trace of a square matrix.  This is defined as the sum of the diagonal
X  elements of the matrix.
X  
X! @node Reducing and Mapping, Vector and Matrix Formats, Vector and Matrix Arithmetic, Matrix Functions
X  @section Reducing and Mapping Vectors
X  
X  The commands in this section allow for more general operations on the
X--- 10540,10624 ----
X  trace of a square matrix.  This is defined as the sum of the diagonal
X  elements of the matrix.
X  
X! @node Set Operations, Reducing and Mapping, Vector and Matrix Arithmetic, Matrix Functions
X! @section Set Operations using Vectors
X! 
X! @cindex Sets, as vectors
X! Calc includes several commands which interpret vectors as @dfn{sets} of
X! objects.  A set is a collection of objects; any given object can appear
X! only once in the set.  For efficiency Calc stores sets as vectors in
X! sorted order.  Objects in a Calc set can be any of the usual things,
X! such as numbers, variables, or formulas.  Two set objects are considered
X! equal if they are identical, except that numerically equal numbers like
X! the integer 4 and the float 4.0 are considered equal even though they
X! are not ``identical.''
X! 
X! @kindex V +
X! @pindex calc-remove-duplicates
X! @tindex rdup
X! The @kbd{V +} (@code{calc-remove-duplicates}) [@code{rdup}] command
X! converts an arbitrary vector into set notation.  It works by sorting
X! the vector as if by @kbd{V S}, then removing duplicates.  (For example,
X! @kbd{[a, 5, 4, a, 4.0]} is sorted to @samp{[4, 4.0, 5, a, a]} and then
X! reduced to @samp{[4, 5, a]}.  You rarely need to do this explicitly,
X! since all the other set-based commands do this on their inputs before
X! using them.
X! 
X! @kindex V V
X! @pindex calc-set-union
X! @tindex vunion
X! The @kbd{V V} (@code{calc-set-union}) [@code{vunion}] command computes
X! the union of two sets.  An object is in the union of two sets if and
X! only if it is in either (or both) of the input sets.  (You could
X! accomplish the same thing by concatenating the sets with @kbd{|},
X! then using @kbd{V +}.)
X! 
X! @kindex V ^
X! @pindex calc-set-intersect
X! @tindex vint
X! The @kbd{V ^} (@code{calc-set-intersect}) [@code{vint}] command computes
X! the intersection of two sets.  An object is in the intersection if
X! and only if it is in both of the input sets.  Thus if the input
X! sets are disjoint, i.e., if they share no common elements, the result
X! will be the empty vector @samp{[]}.  Note that the characters @kbd{V}
X! and @kbd{^} were chosen to be close to the conventional mathematical
X! notation for set union and intersection.
X! 
X! @kindex V -
X! @pindex calc-set-difference
X! @tindex vdiff
X! The @kbd{V -} (@code{calc-set-difference}) [@code{vdiff}] command computes
X! the difference between two sets.  An object is in the difference
X! @samp{A - B} if and only if it is in @samp{A} but not in @samp{B}.
X! Thus subtracting @samp{[y,z]} from a set will remove the elements
X! @samp{y} and @samp{z} if they are present.  You can also think of this
X! as a @dfn{set complement} operator; if @samp{A} is the set of all
X! possible values, then @samp{A - B} is the ``complement'' of @samp{B}.
X! Obviously this only makes sense if the set of all possible values in
X! your problem is finite and reasonably small.
X! 
X! @kindex V X
X! @pindex calc-set-xor
X! @tindex vxor
X! The @kbd{V X} (@code{calc-set-xor}) [@code{vxor}] command computes
X! the ``exclusive-or,'' or ``symmetric difference'' of two sets.
X! An object is in the symmetric difference of two sets if and only
X! if it is in one, but @emph{not} both, of the sets.  Objects that
X! occur in both sets ``cancel out.''
X! 
X! @cindex Sets, as binary numbers
X! Another representation for sets that may be more appropriate in some
X! cases is binary numbers.  If you are dealing with sets of integers
X! in the range 0 to 49, you can use a 50-bit binary number where a
X! particular bit is 1 if the corresponding element is in the set.
X! @xref{Binary Functions}, for a list of commands that operate on
X! binary numbers.  Note that all the above set operations have
X! direct equivalents in binary arithmetic:  @kbd{b o} (@code{calc-or}),
X! @kbd{b a} (@code{calc-and}), @kbd{b d} (@code{calc-diff}), and
X! @kbd{b x} (@code{calc-xor}), respectively.  You can use whatever
X! representation for sets is most convenient to you.
X! 
X! @node Reducing and Mapping, Vector and Matrix Formats, Set Operations, Matrix Functions
X  @section Reducing and Mapping Vectors
X  
X  The commands in this section allow for more general operations on the
X***************
X*** 10095,10107 ****
X  In general, reducing @code{f} over the vector @samp{[a, b, c, d]} produces
X  @samp{f(f(f(a, b), c), d)}.
X  
X  @kindex H V R
X  @tindex accum
X! The @kbd{H V R} command does an accumulation operation.  Here Calc does
X  the corresponding reduction operation, but instead of producing only
X  the final result, it produces a vector of all the intermediate results.
X  Accumulating @code{+} over the vector @samp{[a, b, c, d]} produces the
X! vector @samp{[a, a + b, a + b + c, a + b + c + d]}.
X  
X  @kindex V M
X  @pindex calc-map
X--- 10694,10723 ----
X  In general, reducing @code{f} over the vector @samp{[a, b, c, d]} produces
X  @samp{f(f(f(a, b), c), d)}.
X  
X+ @kindex I V R
X+ @tindex rreduce
X+ The @kbd{I V R} command is similar to @kbd{V R} except that works
X+ from right to left through the vector.  For example, plain @kbd{V R -}
X+ on the vector @samp{[a, b, c, d]} produces @samp{a - b - c - d} but
X+ @kbd{I V R -} on the same vector produces @samp{a - (b - (c - d))},
X+ or @samp{a - b + c - d}.  This ``alternating sum'' occurs frequently
X+ in power series expansions.
X+ 
X+ @kindex V U
X  @kindex H V R
X  @tindex accum
X! The @kbd{V U} command does an accumulation operation.  Here Calc does
X  the corresponding reduction operation, but instead of producing only
X  the final result, it produces a vector of all the intermediate results.
X  Accumulating @code{+} over the vector @samp{[a, b, c, d]} produces the
X! vector @samp{[a, a + b, a + b + c, a + b + c + d]}.  (The obsolete key
X! sequence @kbd{H V R} is also recognized for this command.)
X! 
X! @kindex I V U
X! @tindex raccum
X! The @kbd{I V U} command does a right-to-left accumulation.  For example,
X! @kbd{I V U -} on the vector @samp{[a, b, c, d]} produces the vector
X! @samp{[a - b + c - d, b - c + d, c - d, d]}.
X  
X  @kindex V M
X  @pindex calc-map
X***************
X*** 10153,10159 ****
X--- 10769,10777 ----
X  @example
X  apply(@var{oper}, @var{vec})
X  reduce(@var{oper}, @var{vec})
X+ rreduce(@var{oper}, @var{vec})
X  accum(@var{oper}, @var{vec})
X+ raccum(@var{oper}, @var{vec})
X  map(@var{oper}, @var{v1}, @var{v2}, ...)
X  outer(@var{oper}, @var{vec1}, @var{vec2})
X  inner(@var{mul-oper}, @var{add-oper}, @var{vec1}, @var{vec2})
X***************
X*** 10225,10233 ****
X  The default mode is map-by-elements.  The mapping mode is also used by
X  the @code{calc-reduce} command, as described in the next section.
X  The mapping mode has no effect if the arguments are plain vectors,
X! and it also has no effect on @kbd{V A}, @kbd{H V R}, @kbd{V O}, or
X  @kbd{V I} commands.
X  
X  Use @kbd{m e} to select map-by-elements mode.  In this mode, the operator
X  is applied to each element of the argument matrix, or to corresponding
X  elements of the argument matrices.  For example, mapping by elements
X--- 10843,10856 ----
X  The default mode is map-by-elements.  The mapping mode is also used by
X  the @code{calc-reduce} command, as described in the next section.
X  The mapping mode has no effect if the arguments are plain vectors,
X! and it also has no effect on @kbd{V A}, @kbd{V U}, @kbd{V O}, or
X  @kbd{V I} commands.
X  
X+ Once again, the following key sequences are recognized only after
X+ @kbd{V M} or @kbd{V R}; elsewhere they have unrelated meanings
X+ (like @code{calc-algebraic-mode} for @kbd{m a}).
X+ 
X+ @kindex m e (mapping modes)
X  Use @kbd{m e} to select map-by-elements mode.  In this mode, the operator
X  is applied to each element of the argument matrix, or to corresponding
X  elements of the argument matrices.  For example, mapping by elements
X***************
X*** 10237,10242 ****
X--- 10860,10866 ----
X  of the other matrix.
X  
X  @tindex mapr
X+ @kindex m r (mapping modes)
X  Use @kbd{m r} to select map-by-rows mode.  In this mode, the operator is
X  applied to each row of the argument matrix, or to corresponding rows of
X  the argument matrices.  Rows are presented to the operator as plain vectors.
X***************
X*** 10247,10256 ****
X--- 10871,10882 ----
X  every row of the matrix.
X  
X  @tindex mapc
X+ @kindex m c (mapping modes)
X  Use @kbd{m c} to select map-by-columns mode.  Essentially, this transposes
X  all matrix arguments, maps by rows, then transposes the result.
X  
X  @tindex mapa
X+ @kindex m a (mapping modes)
X  Use @kbd{m a} to select map-across mode.  In this mode, the input is a
X  single matrix with as many columns as the operator takes arguments.
X  The columns of the matrix are treated as arguments in a regular vector
X***************
X*** 10258,10263 ****
X--- 10884,10890 ----
X  @samp{[[a, b], [c, d], [e, f]]} produces the vector @samp{[a*b, c*d, e*f]}.
X  
X  @tindex mapd
X+ @kindex m d (mapping modes)
X  Use @kbd{m d} to select map-down mode.  This mode is analogous to map-across,
X  except that it treats the rows of the matrix as arguments to the mapping
X  operation.
X***************
X*** 10281,10286 ****
X--- 10908,10917 ----
X  for example, reducing subtraction by elements over the matrix
X  @samp{[[a, b], [c, d]]} produces @samp{(((a - b) - c) - d)}.
X  
X+ All the mapping modes support reverse reduction in the obvious way.
X+ Reducing backwards by elements, for example, works in a right-to-left,
X+ bottom-to-top order through the matrix.
X+ 
X  @tindex reducer
X  Use @kbd{m r} to select reduce-by-rows mode.  In this mode, the rows of
X  the matrix are treated as vectors; the operator is applied to these
X***************
X*** 10778,10783 ****
X--- 11409,11431 ----
X  or @kbd{g V} when the relevant buffer is already displayed, the
X  buffer is hidden again.
X  
X+ One reason to use @kbd{g v} is to add your own commands to the
X+ @samp{*Gnuplot Commands*} buffer.  Press @kbd{g v}, then use
X+ @kbd{C-x o} to switch into that window.  For example, GNUPLOT has
X+ @samp{set label} and @samp{set arrow} commands that allow you to
X+ annotate your plots.  Since Calc doesn't understand these commands,
X+ you have to add them to the @samp{*Gnuplot Commands*} buffer
X+ yourself, then use @kbd{g p} to replot using these commands.  Note
X+ that your commands must appear @emph{before} the @code{plot} command.
X+ To get help on any GNUPLOT feature, type, e.g., @kbd{g C help set label}.
X+ You may have to type @kbd{g C RET} a few times to clear the
X+ ``press return for more'' or ``subtopic of @dots{}'' requests.
X+ Note that Calc always sends commands (like @samp{set nolabel}) to
X+ reset all plotting parameters to the defaults before each plot, so
X+ to delete a label all you need to do is delete the @samp{set label}
X+ line you added (or comment it out with @samp{#}) and then replot
X+ with @kbd{g p}.
X+ 
X  @kindex g K
X  @pindex calc-graph-kill
X  If something goes wrong, you can use @kbd{g K} (@code{calc-graph-kill})
X***************
X*** 10904,10911 ****
X  
X  If you supply a numeric prefix argument @var{n}, the selection is
X  expanded to the @var{n}th enclosing sub-formula.  Thus, positioning
X! the cursor on the @samp{b} and typing @kbd{C-u 1 g s} will select
X! @samp{a + b}; typing @kbd{C-u 2 g s} will select @samp{(a + b)^3},
X  and so on.
X  
X  If the cursor is not on any part of the formula, or if you give a
X--- 11552,11559 ----
X  
X  If you supply a numeric prefix argument @var{n}, the selection is
X  expanded to the @var{n}th enclosing sub-formula.  Thus, positioning
X! the cursor on the @samp{b} and typing @kbd{C-u 1 j s} will select
X! @samp{a + b}; typing @kbd{C-u 2 j s} will select @samp{(a + b)^3},
X  and so on.
X  
X  If the cursor is not on any part of the formula, or if you give a
X***************
X*** 11085,11094 ****
X  by @samp{#} signs:
X  
X  @example
X!            3                          #               
X!     (a + b)  . .......         ## # ##  + sqrt(c)     
X! 1:  ..................     1:  ------------------     
X!          . . . .                    2 x + 1           
X  @end example
X  
X  @node Operating on Selections, Rearranging with Selections, Displaying Selections, Selecting Subformulas
X--- 11733,11742 ----
X  by @samp{#} signs:
X  
X  @example
X!            3                          #
X!     (a + b)  . .......         ## # ##  + sqrt(c)
X! 1*  ..................     1*  ------------------
X!          . . . .                    2 x + 1
X  @end example
X  
X  @node Operating on Selections, Rearranging with Selections, Displaying Selections, Selecting Subformulas
X***************
X*** 11173,11179 ****
X  and resimplifies.
X  
X  If you select an element of a vector and press @key{DEL}, that
X! element is deleted from the vector.
X  
X  @kindex j DEL
X  @pindex calc-del-selection
X--- 11821,11828 ----
X  and resimplifies.
X  
X  If you select an element of a vector and press @key{DEL}, that
X! element is deleted from the vector.  If you delete one side of
X! an equation or inequality, only the opposite side remains.
X  
X  @kindex j DEL
X  @pindex calc-del-selection
X***************
X*** 11194,11200 ****
X  press @kbd{Q} to take the square root.
X  
X  @example
X!      .. .           .. .           .. .              .. .     
X  1*  .......    1*  .......    1*  .......    1*  .............
X      2 x + 1        2 x - 4        4 - 2 x        sqrt(4 - 2 x)
X  @end example
X--- 11843,11849 ----
X  press @kbd{Q} to take the square root.
X  
X  @example
X!      .. .           .. .           .. .              .. .
X  1*  .......    1*  .......    1*  .......    1*  .............
X      2 x + 1        2 x - 4        4 - 2 x        sqrt(4 - 2 x)
X  @end example
X***************
X*** 11427,11437 ****
X  previous selection-related operations, or turned off altogether
X  by the @kbd{m O} command.
X  
X! With a numeric prefix argument of 2, @kbd{C-u 2 g v} applies
X  the @kbd{a s} (@code{calc-simplify}) command to the selected
X! sub-formula.  With a prefix argument of 3 or more, e.g., @kbd{C-u g v}
X  applies the @kbd{a e} (@code{calc-simplify-extended}) command.
X! @xref{Algebraic Manipulation}.
X  
X  You can use the @kbd{j r} (@code{calc-rewrite-selection}) command
X  to define other algebraic operations on sub-formulas.  @xref{Rewrite Rules}.
X--- 12076,12089 ----
X  previous selection-related operations, or turned off altogether
X  by the @kbd{m O} command.
X  
X! With a numeric prefix argument of 2, @kbd{C-u 2 j v} applies
X  the @kbd{a s} (@code{calc-simplify}) command to the selected
X! sub-formula.  With a prefix argument of 3 or more, e.g., @kbd{C-u j v}
X  applies the @kbd{a e} (@code{calc-simplify-extended}) command.
X! @xref{Algebraic Manipulation}.  With a negative prefix argument
X! it simplifies at the top level only, just as with @kbd{a v}.
X! Here the ``top'' level refers to the top level of the selected
X! sub-formula.
X  
X  You can use the @kbd{j r} (@code{calc-rewrite-selection}) command
X  to define other algebraic operations on sub-formulas.  @xref{Rewrite Rules}.
X***************
X*** 11458,11463 ****
X--- 12110,12140 ----
X  you have turned default simplifications off with an @kbd{m O}
X  command.  @xref{Simplification Modes}.
X  
X+ If you give a numeric prefix argument of 2 to @kbd{a v}, it simplifies
X+ as if in algebraic simplification mode; this is equivalent to typing
X+ @kbd{a s} as described below.  If you give a numeric prefix of 3 or
X+ more, it uses extended simplification mode (@kbd{a e}).
X+ 
X+ If you give a negative prefix argument -1, -2, or -3, it simplifies
X+ in the corresponding mode but only works on the top-level function
X+ call of the formula.  For example, @samp{(2 + 3) * (2 + 3)} will
X+ simplify to @samp{(2 + 3)^2}, without simplifying the sub-formulas
X+ @samp{2 + 3}.  This mode is not always as useful as it might seem;
X+ you would think that applying @kbd{C-u - a v} to @samp{1 + 2 + 3 + 4}
X+ would simplify the sum to, say, @samp{1 + 2 + 7}.  But it doesn't:
X+ This sum is @samp{((1 + 2) + 3) + 4} in Calc's memory; Calc leaves
X+ the arguments of the top-level @samp{+} alone (@samp{(1 + 2) + 3}
X+ and @samp{7}), then tries to simplify their sum and fails.  Calc's
X+ evaluation rules are designed on the assumption that the arguments
SHAR_EOF
echo "End of part 4, continue with part 5"
echo "5" > s2_seq_.tmp
exit 0
--
Dave Gillespie
  256-80 Caltech Pasadena CA USA 91125
  daveg@csvax.cs.caltech.edu, ...!cit-vax!daveg