v15i042: Patch for GNU Emacs Calc, version 1.04 -> 1.05, part 15/20

David Gillespie daveg at csvax.cs.caltech.edu
Mon Oct 15 11:19:49 AEST 1990


Posting-number: Volume 15, Issue 42
Submitted-by: daveg at csvax.cs.caltech.edu (David Gillespie)
Archive-name: calc-1.05/part15

#!/bin/sh
# this is part 15 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file calc.patch continued
#
CurArch=15
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+ 2:  1             2:  1:6            3:  1:6          1:  2.3148e-3
X+ 1:  20            1:  2              2:  2                .
X+     .                 .              1:  36.
X+                                          .
X+ 
X+    2 RET 40        Z ( RET k b TAB     RET r 1 TAB ^      * /
X+ @end example
X+ @end group
X+ 
X+ @group
X+ @example
X+ 3:  -0.5749       3:  -0.5772      2:  -0.5772     1:  -0.577215664892
X+ 2:  -0.5749       2:  -0.5772      1:  0               .
X+ 1:  2.3148e-3     1:  -0.5749          .
X+     .                 .
X+ 
X+   TAB RET M-TAB       - RET M-TAB      a =     Z /    2  Z )  Z ' C-x )
X+ @end example
X+ @end group
X+ 
X+ This is the value of @samp{- gamma}, with a slight bit of roundoff error.
X+ To get a full 12 digits, let's use a higher precision:
X+ 
X+ @group
X+ @example
X+ 2:  -0.577215664892      2:  -0.577215664892
X+ 1:  1.                   1:  -0.577215664901532
X+ 
X+     1.                       p 16 K
X+ @end example
X+ @end group
X+ 
X+ Here's the complete sequence of keystrokes:
X+ 
X+ @group
X+ @example
X+ C-x ( Z `  s 1  0 s 2 DEL
X+            RET 5 a <  Z [  5 Z (  & s + 2 DEL 1 s + 1  Z ) r 1  Z ]
X+            L r 1 2 * & - r 2 -
X+            2 RET 40  Z (  RET k b TAB RET r 1 TAB ^ * /
X+                           TAB RET M-TAB - RET M-TAB a = Z /
X+                   2  Z )
X+       Z '
X+ C-x )
X+ @end example
X+ @end group
X+ 
X+ @node Programming Answer 9, Programming Answer 10, Programming Answer 8, Answers to Exercises
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+ While you are entering a @samp{Z ` Z '} body in a macro, Calc simply
X+ collects keystrokes without executing them.  In the following diagrams
X+ we'll pretend Calc actually executed the keystrokes as you typed them,
X+ just for purposes of illustration.)
X+ 
X+ @group
X+ @example
X+ 2:  5 x^4 + (x + 1)^2          3:  5 x^4 + (x + 1)^2
X+ 1:  6                          2:  0
X+     .                          1:  6
X+                                    .
X+ 
X+   ' 5 x^2 + (x+1)^2 RET 6        C-x Z `  [ ] s 1 DEL 0 TAB
X+ @end example
X+ @end group
X+ 
X+ Variable 1 will accumulate the vector of coefficients.
X+ 
X+ @group
X+ @example
X+ 2:  0              3:  0                  2:  5 x^4 + ...
X+ 1:  5 x^4 + ...    2:  5 x^4 + ...        1:  1
X+     .              1:  1                      .
X+                        .
X+ 
X+    Z ( TAB         RET 0 l x RET              M-TAB ! /  s | 1    DEL
X+ @end example
X+ @end group
X+ 
X+ Note that @kbd{s | 1} appends the top-of-stack value to the vector
X+ in a variable; it is completely analogous to @kbd{s + 1}.  We could
X+ have written instead, @kbd{r 1 TAB | s 1}.
X+ 
X+ @group
X+ @example
X+ 1:  20 x^3 + 2 x + 2      1:  0         1:  [1, 2, 1, 0, 5, 0, 0]
X+     .                         .             .
X+ 
X+     a d x RET                 1 Z )         DEL r 1  Z ' C-x )
X+ @end example
X+ @end group
X+ 
X+ To convert back, a simple method is just to map the coefficients
X+ against a table of powers of @samp{x}.
X+ 
X+ @group
X+ @example
X+ 2:  [1, 2, 1, 0, 5, 0, 0]    2:  [1, 2, 1, 0, 5, 0, 0]
X+ 1:  6                        1:  [0, 1, 2, 3, 4, 5, 6]
X+     .                            .
X+ 
X+     6 RET                        1 + 0 RET 1 C-u v x
X+ @end example
X+ @end group
X+ 
X+ @group
X+ @example
X+ 2:  [1, 2, 1, 0, 5, 0, 0]    2:  1 + 2 x + x^2 + 5 x^4
X+ 1:  [1, x, x^2, x^3, ... ]       .
X+     .
X+ 
X+     ' x RET TAB V M ^            *
X+ @end example
X+ @end group
X+ 
X+ Once again, here are the whole polynomial to/from vector programs:
X+ 
X+ @group
X+ @example
X+ C-x ( Z `  [ ] s 1 DEL 0 TAB
X+            Z (  TAB RET 0 l x RET M-TAB ! /  s | 1 DEL
X+                 a d x RET
X+          1 Z ) r 1
X+       Z '
X+ C-x )
X+ 
X+ C-x (  1 + 0 RET 1 C-u v x ' x RET TAB V M ^ *  C-x )
X+ @end example
X+ @end group
X+ 
X+ @node Programming Answer 10, , Programming Answer 9, Answers to Exercises
X+ @subsection Programming Tutorial Exercise 10
X+ 
X+ First we define a dummy program to go on the @kbd{z s} key.  The true
X+ @kbd{z s} key is supposed to take two numbers from the stack and
X+ return one number, so @kbd{DEL} as a dummy definition will make
X+ sure the stack comes out right.
X+ 
X+ @group
X+ @example
X+ 2:  4          1:  4                         2:  4
X+ 1:  2              .                         1:  2
X+     .                                            .
X+ 
X+   4 RET 2       C-x ( DEL C-x )  Z K s RET       2
X+ @end example
X+ @end group
X+ 
X+ The last step replaces the 2 that was eaten during the creation
X+ of the dummy @kbd{z s} command.  Now we move on to the real
X+ definition.  The recurrence needs to be rewritten slightly,
X+ to the form @samp{s(n,m) = s(n-1,m-1) - (n-1) s(n-1,m)}.
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+ @group
X+ @example
X+ 2:  4        4:  4       3:  4       2:  4
X+ 1:  2        3:  2       2:  2       1:  2
X+     .        2:  4       1:  0           .
X+              1:  2           .
X+                  .
X+ 
X+   C-x (       M-2 RET        a =         Z [  DEL DEL 1  Z :
X+ @end example
X+ @end group
X+ 
X+ @group
X+ @example
X+ 4:  4       2:  4                     2:  3      4:  3    4:  3    3:  3
X+ 3:  2       1:  2                     1:  2      3:  2    3:  2    2:  2
X+ 2:  2           .                         .      2:  3    2:  3    1:  3
X+ 1:  0                                            1:  2    1:  1        .
X+     .                                                .        .
X+ 
X+   RET 0   a = Z [  DEL DEL 0  Z :  TAB 1 - TAB   M-2 RET     1 -      z s
X+ @end example
X+ @end group
X+ 
X+ (Note that the value 3 that @kbd{z s} ``produces'' is not correct;
X+ it is merely a placeholder that will do just as well for now.)
X+ 
X+ @group
X+ @example
X+ 3:  3               4:  3           3:  3       2:  3      1:  -6
X+ 2:  3               3:  3           2:  3       1:  9          .
X+ 1:  2               2:  3           1:  3           .
X+     .               1:  2               .
X+                         .
X+ 
X+  M-TAB M-TAB     TAB RET M-TAB         z s          *          -
X+ @end example
X+ @end group
X+ 
X+ @group
X+ @example
X+ 1:  -6                          2:  4          1:  11      2:  11
X+     .                           1:  2              .       1:  11
X+                                     .                          .
X+ 
X+   Z ] Z ] C-x )   Z K s RET      DEL 4 RET 2       z s         X k s
X+ @end example
X+ @end group
X+ 
X+ Even though the result that we got during the definition was highly
X+ bogus, once the definition is complete the @kbd{z s} command gets
X+ the right answers.
X+ 
X+ Here's the full program once again:
X+ 
X+ @group
X+ @example
X+ C-x (  M-2 RET a =
X+        Z [  DEL DEL 1
X+        Z :  RET 0 a =
X+             Z [  DEL DEL 0
X+             Z :  TAB 1 - TAB M-2 RET 1 - z s
X+                  M-TAB M-TAB TAB RET M-TAB z s * -
X+             Z ]
X+        Z ]
X+ C-x )
X+ @end example
X+ @end group
X+ 
X  @iftex
X  @chapter Calculator Basics
X  This chapter covers basic concepts such as the stack, algebraic and
X***************
X*** 3586,3591 ****
X--- 6155,6168 ----
X  whether these numbers appear.  (Line numbers may be turned off since they
X  slow the Calculator down a bit and also clutter the display.)
X  
X+ @kindex o
X+ @kindex d `
X+ @pindex calc-realign
X+ The unshifted letter @kbd{o} (@code{calc-realign}) command (also on the
X+ @kbd{d `} key) repositions the cursor to its top-of-stack ``home''
X+ position.  If you give it a numeric prefix argument, it instead moves
X+ the cursor to the specified stack element.
X+ 
X  The @key{RET} (or equivalent @key{SPC}) key is only required to separate
X  two consecutive numbers.
X  (After all, if you typed @kbd{1 2} by themselves the Calculator
X***************
X*** 3652,3657 ****
X--- 6229,6238 ----
X  would be to use the full Emacs cursor motion and editing keys, which are
X  available during algebraic entry but not during numeric entry.
X  
X+ In the same vein, during either numeric or algebraic entry you can
X+ press @kbd{`} to switch to @code{calc-edit} mode, where you complete
X+ your half-finished entry in a separate buffer.  @xref{Editing Stack Entries}.
X+ 
X  @kindex m a
X  @pindex calc-algebraic-mode
X  @cindex Algebraic mode
X***************
X*** 3665,3670 ****
X--- 6246,6257 ----
X  @kbd{2 @key{RET} 3 @key{RET} * 4 @key{RET} +} would accomplish the same
X  thing as @kbd{2*3+4 @key{RET}}. at refill
X  
X+ @cindex Incomplete algebraic mode
X+ If you give a numeric prefix argument like @kbd{C-u} to the @kbd{m a}
X+ command, it enables Incomplete Algebraic mode; this is like regular
X+ Algebraic mode except that it applies to the @kbd{(} and @kbd{[} keys
X+ only.  Numeric keys still begin a numeric entry in this mode.
X+ 
X  Pressing @kbd{'} (the apostrophe) a second time re-enters the previous
X  algebraic formula.  You can then use the normal Emacs editing keys to
X  modify this formula to your liking before pressing @key{RET}.
X***************
X*** 3722,3727 ****
X--- 6309,6317 ----
X  Calculator uses, simply run the full Calculator momentarily and use
X  the regular @kbd{p} command.
X  
X+ If you use @code{quick-calc} from inside the Calculator buffer, the
X+ effect is the same as pressing the apostrophe key (algebraic entry).
X+ 
X  Please note that the Quick Calculator is not any faster at loading
X  or computing the answer than the full Calculator; the name ``quick''
X  merely refers to the fact that it's much less hassle to use for
X***************
X*** 4221,4226 ****
X--- 6811,6819 ----
X  type @samp{mod} by hand or press @kbd{M-m} (that's @kbd{@key{META}-m}).
X  Once again, pressing this a second time enters the current modulo. at refill
X  
X+ You can also use @code{calc-pack} and @kbd{%} to modify modulo forms.
X+ @xref{Building Vectors}.  @xref{Basic Arithmetic}.
X+ 
X  It is possible to mix HMS forms and modulo forms.  For example, an
X  HMS form modulo 24 could be used to manipulate clock times; an HMS
X  form modulo 360 would be suitable for angles.  Making the modulo @var{M}
X***************
X*** 4620,4625 ****
X--- 7213,7221 ----
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}. at refill
X  
X+ @xref{Selecting Subformulas}, for a way to apply these commands to
X+ any portion of a vector or formula on the stack.
X+ 
X  @node Trail Commands, , Stack Manipulation, Stack and Trail
X  @section Trail Commands
X  
X***************
X*** 4704,4713 ****
X  @pindex calc-trail-isearch-backward
X  The @kbd{t s} (@code{calc-trail-isearch-forward}) and @kbd{t r}
X  (@code{calc-trail-isearch-backward}) commands perform an incremental
X! search forward and backward through the trail.  When you terminate the
X! search (typically by pressing @key{ESC}) the trail pointer moves to the
X! current line.  If you cancel the search with @kbd{C-g}, the trail pointer
X! does not move. at refill
X  
X  @kindex t m
X  @pindex calc-trail-marker
X--- 7300,7309 ----
X  @pindex calc-trail-isearch-backward
X  The @kbd{t s} (@code{calc-trail-isearch-forward}) and @kbd{t r}
X  (@code{calc-trail-isearch-backward}) commands perform an incremental
X! search forward and backward through the trail.  You can press @key{RET}
X! to terminate the search; the trail pointer moves to the current line.
X! If you cancel the search with @kbd{C-g}, the trail pointer does not
X! move. at refill
X  
X  @kindex t m
X  @pindex calc-trail-marker
X***************
X*** 4725,4736 ****
X  into the trail buffer.  With a numeric prefix argument, this command
X  kills 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  
X  This chapter describes commands that set modes in the Calculator.
X  They do not affect the contents of the stack, although they may change
X! the @emph{appearance} of the stack's contents.
X  
X  @kindex m m
X  @pindex calc-save-modes
X--- 7321,7335 ----
X  into the trail buffer.  With a numeric prefix argument, this command
X  kills the @samp{N} lines below or above the selected one.
X  
X+ The @kbd{t .} (@code{calc-full-trail-vectors}) command is described
X+ elsewhere; @pxref{Vector and Matrix Formats}.
X+ 
X  @node Mode Settings, Arithmetic, Stack and Trail, Top
X  @chapter Mode Settings
X  
X  This chapter describes commands that set modes in the Calculator.
X  They do not affect the contents of the stack, although they may change
X! the @emph{appearance} or @emph{interpretation} of the stack's contents.
X  
X  @kindex m m
X  @pindex calc-save-modes
X***************
X*** 4753,4762 ****
X  The @kbd{m x} (@code{calc-always-load-extensions}) command enables a mode
X  in which the first use of Calc loads the entire program, including the
X  extensions module.  Otherwise, the extensions module will not be loaded
X! until the first advanced Calc feature is used.  Since this mode only
X! has effect when Calc is first loaded, @kbd{m x} is usually followed
X! by @kbd{m m} to make the mode-setting permanent.
X  
X  @menu
X  * Precision::
X  * Inverse and Hyperbolic::
X--- 7352,7377 ----
X  The @kbd{m x} (@code{calc-always-load-extensions}) command enables a mode
X  in which the first use of Calc loads the entire program, including the
X  extensions module.  Otherwise, the extensions module will not be loaded
X! until the first advanced Calc feature is used.  (This will not work very
X! well if you used @code{calc-split} when installing the Calculator.)
X! Since this mode only has effect when Calc is first loaded, @kbd{m x} is
X! usually followed by @kbd{m m} to make the mode-setting permanent.
X  
X+ @kindex m S
X+ @pindex calc-shift-prefix
X+ The @kbd{m S} (@code{calc-shift-prefix}) command enables a mode in which
X+ the @kbd{a}, @kbd{b}, @kbd{d}, @kbd{f}, @kbd{g}, @kbd{j}, @kbd{k}, and @kbd{m}
X+ prefix keys may be typed shifted as well as unshifted.  If you are
X+ typing, say, @kbd{a D} (@code{calc-derivative}) quite often you might
X+ find it easier to turn this mode on so that you can type @kbd{A D} instead.
X+ When this mode is enabled, the commands that used to be on those
X+ single shifted letters (e.g., @kbd{A} (@code{calc-abs})) can now be
X+ invoked by pressing the shifted letter twice:  @kbd{A A}.  Note that
X+ the @kbd{v} prefix key always works both shifted and unshifted, the
X+ @kbd{c}, @kbd{t}, and @kbd{u} prefixes must always be typed unshifted,
X+ and the @kbd{z} and @kbd{Z} prefix keys are always distinct.  Press
X+ @kbd{m S} again to disable this mode.
X+ 
X  @menu
X  * Precision::
X  * Inverse and Hyperbolic::
X***************
X*** 4826,4832 ****
X  the @kbd{m} prefix.  (That's the letter @kbd{m}, not the @key{META} key.)
X  
X  The @samp{m a} (@code{calc-algebraic-mode}) command is described elsewhere
X! (@pxref{Algebraic Entry}.)
X  
X  @menu
X  * Angular Modes::
X--- 7441,7449 ----
X  the @kbd{m} prefix.  (That's the letter @kbd{m}, not the @key{META} key.)
X  
X  The @samp{m a} (@code{calc-algebraic-mode}) command is described elsewhere
X! (@pxref{Algebraic Entry}).  The @samp{m @}} (@code{calc-use-selections})
X! command is described along with other selection commands (@pxref{Selecting
X! Subformulas}).
X  
X  @menu
X  * Angular Modes::
X***************
X*** 4933,4940 ****
X  of the command. at refill
X  
X  To evaluate a formula numerically without expanding the variables it
X! contains, you can use the key sequence @kbd{m a c c m a} (@code{calc-clean}
X! resimplifies but doesn't evaluate variables).
X  
X  @node Working Message, , Symbolic Mode, Calculation Modes
X  @subsection Working Messages
X--- 7550,7558 ----
X  of the command. at 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  @node Working Message, , Symbolic Mode, Calculation Modes
X  @subsection Working Messages
X***************
X*** 5041,5047 ****
X  (@code{calc-line-breaking}) commands are described elsewhere;
X  @pxref{Stack Basics} and @pxref{Normal Language Modes}, respectively.
X  Display formats for vectors and matrices are also covered elsewhere;
X! @pxref{Vector and Matrix Formats}. at refill
X  
X  @menu
X  * Radix Modes::
X--- 7659,7667 ----
X  (@code{calc-line-breaking}) commands are described elsewhere;
X  @pxref{Stack Basics} and @pxref{Normal Language Modes}, respectively.
X  Display formats for vectors and matrices are also covered elsewhere;
X! @pxref{Vector and Matrix Formats}.  The @samp{d @}}
X! (@code{calc-use-selections}) command is described along with other
X! selection commands (@pxref{Selecting Subformulas}). at refill
X  
X  @menu
X  * Radix Modes::
X***************
X*** 5193,5199 ****
X  as a decimal point.  Normally this is a period; users in some countries
X  may wish to change this to a comma.  Note that this is only a display
X  style; on entry, periods must always be used to denote floating-point
X! numbers, and commas to seperate elements in a list.
X  
X  @node Complex Formats, Fraction Formats, Float Formats, Display Modes
X  @subsection Complex Formats
X--- 7813,7819 ----
X  as a decimal point.  Normally this is a period; users in some countries
X  may wish to change this to a comma.  Note that this is only a display
X  style; on entry, periods must always be used to denote floating-point
X! numbers, and commas to separate elements in a list.
X  
X  @node Complex Formats, Fraction Formats, Float Formats, Display Modes
X  @subsection Complex Formats
X***************
X*** 5530,5535 ****
X--- 8150,8181 ----
X  @samp{\hbox@{@var{name}@}}.  The @samp{\hbox@{ @}} notation is ignored
X  during reading.
X  
X+ During reading, text of the form @samp{\matrix@{ ... @}} is replaced
X+ by @samp{[ ... ]}.  The same also applies to @code{\pmatrix} and
X+ @code{\bmatrix}.  The symbol @samp{&} is interpreted as a comma,
X+ and the symbols @samp{\cr} and @samp{\\} are interpreted as semicolons.
X+ During output, matrices are displayed in @samp{\matrix@{ a & b \\ c & d@}}
X+ format; you may need to edit this afterwards to change @code{\matrix}
X+ to @code{\pmatrix} or @code{\\} to @code{\cr}.
X+ 
X+ The complete set of @TeX{} control sequences that are ignored during
X+ reading is:
X+ 
X+ @example
X+ \hbox  \mbox  \text  \left  \right
X+ \,  \>  \:  \;  \!  \quad  \qquad  \hfil  \hfill
X+ \displaystyle  \textstyle  \dsize  \tsize
X+ \scriptstyle  \scriptscriptstyle  \ssize  \ssize
X+ \rm  \bf  \it  \sl  \roman  \bold  \italic  \slanted
X+ \cal  \mit  \Cal  \Bbb  \frak  \goth
X+ @end example
X+ 
X+ Note that, because these symbols are ignored, reading a @TeX{} formula
X+ into Calc and writing it back out may lose spacing and font information.
X+ 
X+ Also, the ``discretionary multiplication sign'' @samp{\*} is read
X+ the same as @samp{*}.
X+ 
X  @node Mathematica Language Mode, , TeX Language Mode, Language Modes
X  @subsection Mathematica Language Mode
X  
X***************
X*** 5561,5566 ****
X--- 8207,8216 ----
X  formula instead of a number, such as @samp{2/0} (because division by zero
X  is illegal) or @samp{sqrt(x)} (because the argument @samp{x} is a formula).
X  
X+ Most of the commands described here can be invoked by a single keystroke.
X+ Some of the more obscure ones are two-letter sequences beginning with
X+ the @kbd{f} (``functions'') prefix key.
X+ 
X  @xref{Prefix Arguments}, for a discussion of the effect of numeric
X  prefix arguments on commands in this chapter which do not otherwise
X  interpret a prefix argument.
X***************
X*** 5677,5686 ****
X  @pindex calc-power
X  The @kbd{^} (@code{calc-power}) command raises a number to a power.  If
X  the power is an integer, an exact result is computed using repeated
X! multiplications.  For non-integer powers, Calc uses logarithms and
X! exponentials.  Square matrices can be raised to integer powers.  If either
X! argument is an error (or interval or modulo) form, the result is also an
X! error (or interval or modulo) form.
X  
X  @kindex %
X  @pindex calc-mod
X--- 8327,8342 ----
X  @pindex calc-power
X  The @kbd{^} (@code{calc-power}) command raises a number to a power.  If
X  the power is an integer, an exact result is computed using repeated
X! multiplications.  For non-integer powers, Calc uses Newton's method or
X! logarithms and exponentials.  Square matrices can be raised to integer
X! powers.  If either argument is an error (or interval or modulo) form,
X! the result is also an error (or interval or modulo) form.
X! 
X! @kindex I ^
X! @tindex nroot
X! If you press the @kbd{I} (inverse) key first, the @kbd{I ^} command
X! computes an Nth root:  @kbd{125 RET 3 I ^} computes the number 5.
X! (This is entirely equivalent to @kbd{125 RET 1:3 ^}.)
X  
X  @kindex %
X  @pindex calc-mod
X***************
X*** 5732,5745 ****
X  the mean part with its absolute value and leaving the error part the same.
X  The absolute value of a modulo form is undefined.
X  
X  @pindex calc-abssqr
X  @tindex abssqr
X! The @code{calc-abssqr} [@code{abssqr}] command computes the absolute
X! value squared of a number, vector or matrix, or error form.
X  
X  @tindex sign
X! The @code{sign} algebraic function returns 1 if its argument is positive,
X! -1 if its argument is negative, or 0 if its argument is zero.
X  
X  @kindex &
X  @pindex calc-inv
X--- 8388,8405 ----
X  the mean part with its absolute value and leaving the error part the same.
X  The absolute value of a modulo form is undefined.
X  
X+ @kindex f A
X  @pindex calc-abssqr
X  @tindex abssqr
X! The @kbd{f A} (@code{calc-abssqr}) [@code{abssqr}] command computes the
X! absolute value squared of a number, vector or matrix, or error form.
X  
X+ @kindex f s
X+ @pindex calc-sign
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***************
X*** 5746,5753 ****
X  @tindex inv
X  @cindex Reciprocal
X  The @kbd{&} (@code{calc-inv}) [@code{inv}] command computes the
X! reciprocal of a number.  It is also available as the @kbd{V I}
X! key sequence, where it would normally be used to invert a matrix.
X  
X  @kindex Q
X  @pindex calc-sqrt
X--- 8406,8413 ----
X  @tindex inv
X  @cindex Reciprocal
X  The @kbd{&} (@code{calc-inv}) [@code{inv}] command computes the
X! reciprocal of a number.  Operating on a square matrix, it computes
X! the inverse of that matrix.
X  
X  @kindex Q
X  @pindex calc-sqrt
X***************
X*** 5756,5801 ****
X  root of a number.  For a negative real argument, the result will be a
X  complex number whose form is determined by the current Polar Mode.
X  
X  @pindex calc-hypot
X  @tindex hypot
X! The @code{calc-hypot} [@code{hypot}] command computes the square root of
X! the sum of the squares of two numbers.  That is, @samp{hypot(a,b)} is the
X! length of the hypotenuse of a right triangle with sides @samp{a} and @samp{b}.
X  
X  @pindex calc-min
X  @tindex min
X  @pindex calc-max
X  @tindex max
X! The @code{calc-min} [@code{min}] and @code{calc-max} [@code{max}] commands
X! take the minimum or maximum of two real numbers, respectively.  These
X! commands also work on HMS forms.  (In algebraic expressions, these functions
X! take any number of arguments and return the maximum or minimum among all
X! the arguments.)@refill
X  
X  @pindex calc-mant-part
X  @tindex mant
X  @pindex calc-xpon-part
X  @tindex xpon
X! The @code{calc-mant-part} [@code{mant}] function extracts the ``mantissa''
X! part @var{m} of its floating-point argument; @code{calc-xpon-part}
X! [@code{xpon}] extracts the ``exponent'' part @var{e}.  The original
X! number is equal to @samp{@var{m} * 10^@var{e}}, where @var{m} is in
X! the interval @samp{[1.0 .. 10.0)} except that @samp{@var{m}=@var{e}=0}
X! if the original number is zero.  For integers and fractions,
X! @code{mant} returns the number unchanged and @code{xpon} returns zero.
X! The @kbd{v u} (@code{calc-unpack}) command can also be used to ``unpack''
X! a floating-point number; this produces an integer mantissa and exponent,
X! with the constraint that the mantissa is either zero or a non-multiple
X! of ten. at refill
X  
X  @pindex calc-scale-float
X  @tindex scf
X! The @code{calc-scale-float} [@code{scf}] function scales a number by
X! a given power of ten.  Thus, @samp{scf(mant(x), xpon(x)) = x} for any
X  real @var{x}.  The second argument must be an integer, but the first
X  may actually be any numeric value.  For example, @samp{scf(5,-2) = 0.05}
X  or @samp{1:20} depending on the current Fraction Mode. at refill
X  
X  @node Integer Truncation, Complex Number Functions, Basic Arithmetic, Arithmetic
X  @section Integer Truncation
X  
X--- 8416,8500 ----
X  root of a number.  For a negative real argument, the result will be a
X  complex number whose form is determined by the current Polar Mode.
X  
X+ @kindex f h
X  @pindex calc-hypot
X  @tindex hypot
X! The @kbd{f h} (@code{calc-hypot}) [@code{hypot}] command computes the square
X! root of the sum of the squares of two numbers.  That is, @samp{hypot(a,b)}
X! is the length of the hypotenuse of a right triangle with sides @samp{a}
X! and @samp{b}.
X  
X+ @kindex f Q
X+ @pindex calc-isqrt
X+ @tindex isqrt
X+ The @kbd{f Q} (@code{calc-isqrt}) [@code{isqrt}] command computes the
X+ integer square root of an integer.  This is the true square root of the
X+ number, rounded down to an integer.  For example, @samp{isqrt(10)}
X+ produces 3.
X+ 
X+ @kindex f n
X+ @kindex f x
X  @pindex calc-min
X  @tindex min
X  @pindex calc-max
X  @tindex max
X! The @kbd{f n} (@code{calc-min}) [@code{min}] and @kbd{f x} (@code{calc-max})
X! [@code{max}] commands take the minimum or maximum of two real numbers,
X! respectively.  These commands also work on HMS forms.  (In algebraic
X! expressions, these functions take any number of arguments and return the
X! maximum or minimum among all the arguments.)@refill
X  
X+ @kindex f M
X+ @kindex f X
X  @pindex calc-mant-part
X  @tindex mant
X  @pindex calc-xpon-part
X  @tindex xpon
X! The @kbd{f M} (@code{calc-mant-part}) [@code{mant}] function extracts
X! the ``mantissa'' part @var{m} of its floating-point argument; @kbd{f X}
X! (@code{calc-xpon-part}) [@code{xpon}] extracts the ``exponent'' part
X! @var{e}.  The original number is equal to @samp{@var{m} * 10^@var{e}},
X! where @var{m} is in the interval @samp{[1.0 .. 10.0)} except that
X! @samp{@var{m}=@var{e}=0} if the original number is zero.  For integers
X! and fractions, @code{mant} returns the number unchanged and @code{xpon}
X! returns zero.  The @kbd{v u} (@code{calc-unpack}) command can also be
X! used to ``unpack'' a floating-point number; this produces an integer
X! mantissa and exponent, with the constraint that the mantissa is either
X! zero or a non-multiple of ten. at refill
X  
X+ @kindex f S
X  @pindex calc-scale-float
X  @tindex scf
X! The @kbd{f S} (@code{calc-scale-float}) [@code{scf}] function scales a number
X! by a given power of ten.  Thus, @samp{scf(mant(x), xpon(x)) = x} for any
X  real @var{x}.  The second argument must be an integer, but the first
X  may actually be any numeric value.  For example, @samp{scf(5,-2) = 0.05}
X  or @samp{1:20} depending on the current Fraction Mode. at refill
X  
X+ @kindex f [
X+ @kindex f ]
X+ @pindex calc-decrement
X+ @pindex calc-increment
X+ @tindex decr
X+ @tindex incr
X+ The @kbd{f [} (@code{calc-decrement}) [@code{decr}] and @kbd{f ]}
X+ (@code{calc-increment}) [@code{incr}] functions decrease or increase
X+ a number by one unit.  For integers, the effect is obvious.  For
X+ floating-point numbers, the change is by one unit in the last place.
X+ For example, incrementing @samp{12.3456} when the current precision
X+ is 6 digits yields @samp{12.3457}.  If the current precision had been
X+ 8 digits, the result would have been @samp{12.345601}.  Incrementing
X+ @samp{0.0} produces @samp{10^- at var{p}}, where @var{p} is the current
X+ precision.  These operations are defined only on integers and floats.
X+ With numeric prefix arguments, they change the number by @var{n} units.
X+ 
X+ Note that incrementing followed by decrementing, or vice-versa, will
X+ almost but not quite always cancel out.  Suppose the precision is
X+ 6 digits and the number @samp{9.99999} is on the stack.  Incrementing
X+ will produce @samp{10.0000}; decrementing will produce @samp{9.9999}.
X+ One digit has been dropped.  This is an unavoidable consequence of the
X+ way floating-point numbers work.
X+ 
X  @node Integer Truncation, Complex Number Functions, Basic Arithmetic, Arithmetic
X  @section Integer Truncation
X  
X***************
X*** 5858,5863 ****
X--- 8557,8567 ----
X  added to @samp{floor(N)}, will produce @samp{N}) just take @samp{N} modulo 1
X  using the @code{%} command. at refill
X  
X+ Note also the @kbd{f I} (integer logarithm) and @kbd{f Q} (integer square
X+ root) commands, which are analogous to @kbd{B} and @kbd{Q}, respectively,
X+ except that they take integer arguments and return the result rounded
X+ down to an integer.
X+ 
X  @node Complex Number Functions, Conversions, Integer Truncation, Arithmetic
X  @section Complex Number Functions
X  
X***************
X*** 5884,5901 ****
X  The @code{calc-imaginary} command multiplies the number on the
X  top of the stack by the imaginary number @samp{i = (0,1)}.
X  
X  @pindex calc-re
X  @tindex re
X! The @code{calc-re} [@code{re}] command replaces a complex number by
X! its real part.  This command has no effect on real numbers.  (As an
X  added convenience, @code{re} applied to an error or modulo form extracts
X  the value part.)@refill
X  
X  @pindex calc-im
X  @tindex im
X! The @code{calc-im} [@code{im}] command replaces a complex number by its
X! imaginary part; real numbers are converted to zero.  With a vector or
X! matrix argument, these functions operate element-wise. at refill
X  
X  @kindex v p (complex)
X  @pindex calc-pack
X--- 8588,8607 ----
X  The @code{calc-imaginary} command multiplies the number on the
X  top of the stack by the imaginary number @samp{i = (0,1)}.
X  
X+ @kindex f r
X  @pindex calc-re
X  @tindex re
X! The @kbd{f r} (@code{calc-re}) [@code{re}] command replaces a complex number
X! by its real part.  This command has no effect on real numbers.  (As an
X  added convenience, @code{re} applied to an error or modulo form extracts
X  the value part.)@refill
X  
X+ @kindex f i
X  @pindex calc-im
X  @tindex im
X! The @kbd{f i} (@code{calc-im}) [@code{im}] command replaces a complex number
X! by its imaginary part; real numbers are converted to zero.  With a vector
X! or matrix argument, these functions operate element-wise. at refill
X  
X  @kindex v p (complex)
X  @pindex calc-pack
X***************
X*** 6002,6011 ****
X  least 3) sets the precision to the specified value; a negative prefix
X  decreases the precision by the specified amount.
X  
X! @kindex c 1
X! @kindex c 2
X! @kindex c 3
X! The keystroke sequences @kbd{c 1}, @kbd{c 2} and @kbd{c 3} are equivalent
X  to @kbd{c c} with the corresponding negative prefix argument.  If roundoff
X  errors have changed 2.0 into 1.999999, typing @kbd{c 1} to clip off one
X  decimal place often conveniently does the trick.
X--- 8708,8716 ----
X  least 3) sets the precision to the specified value; a negative prefix
X  decreases the precision by the specified amount.
X  
X! @kindex c 1-9
X! @pindex calc-clean-num
X! The keystroke sequences @kbd{c 1} through @kbd{c 9} are equivalent
X  to @kbd{c c} with the corresponding negative prefix argument.  If roundoff
X  errors have changed 2.0 into 1.999999, typing @kbd{c 1} to clip off one
X  decimal place often conveniently does the trick.
X***************
X*** 6040,6048 ****
X--- 8745,8755 ----
X  @menu
X  * Logarithmic Functions::
X  * Trigonometric and Hyperbolic Functions::
X+ * Advanced Math Functions::
X  * Branch Cuts::
X  * Random Numbers::
X  * Combinatorial Functions::
X+ * Probability Distribution Functions::
X  @end menu
X  
X  @node Logarithmic Functions, Trigonometric and Hyperbolic Functions, Scientific Functions, Scientific Functions
X***************
X*** 6081,6106 ****
X  natural logarithm and dividing by @samp{ln(10)}.
X  
X  @kindex B
X  @pindex calc-log
X  @tindex log
X! @tindex ilog
X  The @kbd{B} (@code{calc-log}) [@code{log}] command computes a logarithm
X  to any base.  For example, @kbd{1024 @key{RET} 2 B} produces 10, since
X! @samp{2^10 = 1024}.  With the Inverse flag [@code{ilog}], this is similar
X! to @kbd{^} except that the order of the arguments is reversed.
X  
X  @pindex calc-expm1
X  @tindex expm1
X! The @code{calc-expm1} [@code{expm1}] command computes @samp{exp(x)-1}, but
X! using an algorithm that produces a more accurate answer when the result
X! is close to zero, i.e., when @samp{exp(x)} is close to one.
X  
X  @pindex calc-lnp1
X  @tindex lnp1
X! The @code{calc-lnp1} [@code{lnp1}] command computes @samp{ln(x+1)},
X! producing a more accurate answer when @samp{x} is close to zero.
X  
X! @node Trigonometric and Hyperbolic Functions, Branch Cuts, Logarithmic Functions, Scientific Functions
X  @section Trigonometric and Hyperbolic Functions
X  
X  @kindex S
X--- 8788,8829 ----
X  natural logarithm and dividing by @samp{ln(10)}.
X  
X  @kindex B
X+ @kindex I B
X  @pindex calc-log
X  @tindex log
X! @tindex alog
X  The @kbd{B} (@code{calc-log}) [@code{log}] command computes a logarithm
X  to any base.  For example, @kbd{1024 @key{RET} 2 B} produces 10, since
X! @samp{2^10 = 1024}.  In certain cases like @samp{log(3,9)}, the result
X! will be either @samp{1:2} or @samp{0.5} depending on the current Fraction
X! Mode setting.  With the Inverse flag [@code{alog}], this command is
X! similar to @kbd{^} except that the order of the arguments is reversed.
X! 
X! @kindex f I
X! @pindex calc-ilog
X! @tindex ilog
X! The @kbd{f I} (@code{calc-ilog}) [@code{ilog}] command computes the
X! integer logarithm of a number to any base.  The number and the base must
X! themselves be positive integers.  This is the true logarithm, rounded
X! down to an integer.  Thus @kbd{ilog(x,10)} is 3 for all @samp{x} in the
X! range from 1000 to 9999.
X  
X+ @kindex f E
X  @pindex calc-expm1
X  @tindex expm1
X! The @kbd{f E} (@code{calc-expm1}) [@code{expm1}] command computes
X! @samp{exp(x)-1}, but using an algorithm that produces a more accurate
X! answer when the result is close to zero, i.e., when @samp{exp(x)} is close
X! to one.
X  
X+ @kindex f L
X  @pindex calc-lnp1
X  @tindex lnp1
X! The @kbd{f L} (@code{calc-lnp1}) [@code{lnp1}] command computes
X! @samp{ln(x+1)}, producing a more accurate answer when @samp{x} is close
X! to zero.
X  
X! @node Trigonometric and Hyperbolic Functions, Advanced Math Functions, Logarithmic Functions, Scientific Functions
X  @section Trigonometric and Hyperbolic Functions
X  
X  @kindex S
X***************
X*** 6160,6170 ****
X  computes the tangent, along with all the various inverse and hyperbolic
X  variants of these functions.
X  
X  @pindex calc-arctan2
X  @tindex arctan2
X! The @code{calc-arctan2} [@code{arctan2}] command takes two numbers from
X! the stack and computes the arc tangent of their ratio.  The result is in
X! the full range from -180 (exclusive) to +180 (inclusive) degrees, or the
X  analogous range in radians.  A similar result would be obtained with
X  @kbd{/} followed by @kbd{I T}, but the value would only be in the range
X  from -90 to 90 degrees since the division loses information about the
X--- 8883,8894 ----
X  computes the tangent, along with all the various inverse and hyperbolic
X  variants of these functions.
X  
X+ @kindex f T
X  @pindex calc-arctan2
X  @tindex arctan2
X! The @kbd{f T} (@code{calc-arctan2}) [@code{arctan2}] command takes two numbers
X! from the stack and computes the arc tangent of their ratio.  The result is
X! in the full range from -180 (exclusive) to +180 (inclusive) degrees, or the
X  analogous range in radians.  A similar result would be obtained with
X  @kbd{/} followed by @kbd{I T}, but the value would only be in the range
X  from -90 to 90 degrees since the division loses information about the
X***************
X*** 6182,6188 ****
X  vector as an argument and computes @code{arctan2} of the elements.
X  (This command does not accept the Hyperbolic flag.)@refill
X  
X! @node Branch Cuts, Random Numbers, Trigonometric and Hyperbolic Functions, Scientific Functions
X  @section Branch Cuts and Principal Values
X  
X  @cindex Branch cuts
X--- 8906,9005 ----
X  vector as an argument and computes @code{arctan2} of the elements.
X  (This command does not accept the Hyperbolic flag.)@refill
X  
X! @node Advanced Math Functions, Branch Cuts, Trigonometric and Hyperbolic Functions, Scientific Functions
X! @section Advanced Mathematical Functions
X! 
X! Calc can compute a variety of less common functions that arise in
X! various branches of mathematics.  All of the functions described in
X! this section allow arbitrary complex arguments and, except as noted,
X! will work to arbitrarily large precisions.  They can not at present
X! handle error forms or intervals as arguments.
X! 
X! NOTE:  These functions are still experimental.  In particular, their
X! accuracy is not guaranteed in all domains.  It is advisable to set the
X! current precision comfortably higher than you actually need when
X! using these functions.  Also, these functions may be impractically
X! slow for some values of the arguments.
X! 
X! @kindex f g
X! @pindex calc-gamma
X! @tindex gamma
X! The @kbd{f g} (@code{calc-gamma}) [@code{gamma}] command computes the Euler
X! gamma function.  For positive integer arguments, this is related to the
X! factorial function:  @samp{gamma(n+1) = fact(n)}.  For general complex
X! arguments the gamma function can be defined by the following definite
X! integral:  @samp{gamma(a) = integ(t^(a-1) exp(t), t, 0, infinity)}.
X! (The actual implementation uses far more efficient computational methods.)
X! 
X! @kindex f G
X! @pindex calc-inc-gamma
X! @tindex gammaP
X! @tindex gammaQ
X! @tindex gammag
X! @tindex gammaG
X! The @kbd{f G} (@code{calc-inc-gamma}) [@code{gammaP}] command computes
X! the incomplete gamma function @samp{P(a,x)}.  This is defined by the
X! integral, @samp{gammaP(a,x) = integ(t^(a-1) exp(t), t, 0, x) / gamma(a)}.
X! Thus the limit is one as @samp{x} goes to infinity (see the definition
X! of the normal gamma function).
X! 
X! Several other varieties of incomplete gamma function are defined.
X! The complement of @samp{P(a,x)}, called @samp{Q(a,x) = 1-P(a,x)} by
X! some authors, is computed by the @kbd{I f G} [@code{gammaQ}] command.
X! You can think of this as taking the other half of the integral, from
X! @samp{x} to infinity.
X! 
X! The functions corresponding to the integrals that define @samp{P(a,x)}
X! and @samp{Q(a,x)} but without the normalizing @samp{1/gamma(a)}
X! factor are called @samp{g(a,x)} and @samp{G(a,x)}, respectively
X! (where @samp{g} and @samp{G} represent the lower- and upper-case
X! Greek letter gamma.)  You can obtain these using the @kbd{H f G}
X! [@code{gammag}] and @kbd{I H f G} [@code{gammaG}] commands.
X! 
X! @kindex f b
X! @pindex calc-beta
X! @tindex beta
X! The @kbd{f b} (@code{calc-beta}) [@code{beta}] command computes the
X! Euler beta function, which is defined in terms of the gamma function as
X! @samp{beta(a,b) = gamma(a) gamma(b) / gamma(a+b)}, or by the integral
X! @samp{beta(a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, 1)}.
X! 
X! @kindex f B
X! @pindex calc-inc-beta
X! @tindex betaI
X! @tindex betaB
X! The @kbd{f B} (@code{calc-inc-beta}) [@code{betaI}] command computes
X! the incomplete beta function @samp{I(x,a,b)}.  This is defined by
X! @samp{betaI(x,a,b) = integ(t^(a-1) (1-t)^(b-1), t, 0, x) / beta(a,b)}.
X! Once again, the @kbd{H} (hyperbolic) prefix gives the corresponding
X! un-normalized version [@code{betaB}].
X! 
X! @kindex f e
X! @pindex calc-erf
X! @tindex erf
X! @tindex erfc
X! The @kbd{f e} (@code{calc-erf}) [@code{erf}] command computes the
X! error function @samp{erf(x) = 2 integ(exp(-(t^2)), t, 0, x) / sqrt(pi))}.
X! The complementary error function @kbd{I f e} (@code{calc-erfc}) [@code{erfc}]
X! is the corresponding integral from @samp{x} to infinity; the sum
X! @samp{erf(x) + erfc(x) = 1}.
X! 
X! @kindex f j
X! @kindex f y
X! @pindex calc-bessel-J
X! @pindex calc-bessel-Y
X! @tindex besJ
X! @tindex besY
X! The @kbd{f j} (@code{calc-bessel-J}) [@code{besJ}] and @kbd{f y}
X! (@code{calc-bessel-Y}) [@code{besY}] commands compute the Bessel
X! functions of the first and second kinds, respectively.  Note that
X! in @samp{besJ(n,x)} and @samp{besY(n,x)} the ``order'' parameter
X! @samp{n} is often an integer, but is not required to be one.
X! Calc's implementation of the Bessel functions currently limits the
X! precision to 8 digits, and may not be exact even to that precision.
X! Use with care!
X! 
X! @node Branch Cuts, Random Numbers, Advanced Math Functions, Scientific Functions
X  @section Branch Cuts and Principal Values
X  
X  @cindex Branch cuts
X***************
X*** 6229,6234 ****
X--- 9046,9055 ----
X  Again this differs from the HP-28C in that the values exactly on the branch
X  cuts are continuous with the opposite sides.
X  
X+ The ``advanced math'' functions (gamma, Bessel, etc.) are also defined
X+ for general complex arguments, but their branch cuts and principal values
X+ are not rigorously specified at present.
X+ 
X  @node Random Numbers, Combinatorial Functions, Branch Cuts, Scientific Functions
X  @section Random Numbers
X  
X***************
X*** 6246,6252 ****
X  from the stack instead.  Once again, if this is a positive integer @samp{M}
X  the result is a random integer less than @samp{M}.  However, note that
X  while numeric prefix arguments are limited to six digits or so, an @samp{M}
X! taken from the stack can be arbitrarily large.
X  
X  If the value on the stack is a real number @samp{M}, the result is a
X  random real number @samp{N} in the range @samp{0 <= N < M} or
X--- 9067,9074 ----
X  from the stack instead.  Once again, if this is a positive integer @samp{M}
X  the result is a random integer less than @samp{M}.  However, note that
X  while numeric prefix arguments are limited to six digits or so, an @samp{M}
X! taken from the stack can be arbitrarily large.  If @samp{M} is negative,
X! the result is a random integer in the range @samp{M < N <= 0}.
X  
X  If the value on the stack is a real number @samp{M}, the result is a
X  random real number @samp{N} in the range @samp{0 <= N < M} or
X***************
X*** 6253,6261 ****
X  @samp{M < N <= 0}, according to the sign of @samp{M}.
X  
X  If @samp{M} is zero, the result is a Gaussian-distributed random real
X! number; the distribution has a mean of zero and a variance of one.
X! The algorithm used generates random numbers in pairs; thus, every other
X! call to this function will be especially fast.
X  
X  If @samp{M} is an interval form, the lower and upper bounds specify the
X  acceptable limits of the random numbers.  If both bounds are integers,
X--- 9075,9087 ----
X  @samp{M < N <= 0}, according to the sign of @samp{M}.
X  
X  If @samp{M} is zero, the result is a Gaussian-distributed random real
X! number; the distribution has a mean of zero and a standard deviation
X! of one.  The algorithm used generates random numbers in pairs; thus,
X! every other call to this function will be especially fast.
X! 
X! If @samp{M} is an error form @samp{@var{m} +/- @var{s}}, the result
X! uses a Gaussian distribution with mean @var{m} and standard deviation
X! @var{s}.
X  
X  If @samp{M} is an interval form, the lower and upper bounds specify the
X  acceptable limits of the random numbers.  If both bounds are integers,
X***************
X*** 6263,6268 ****
X--- 9089,9097 ----
X  is floating-point, the result is a random real number in the specified
X  range.
X  
X+ If @samp{M} is a vector, the result is one element taken at random from
X+ the vector.  All elements of the vector are given equal probabilities.
X+ 
X  @pindex calc-rrandom
X  The @code{calc-rrandom} command produces a random real number between
X  zero and one.  It is equivalent to @samp{random(1.0)}.
X***************
X*** 6270,6278 ****
X  @kindex k a
X  @pindex calc-random-again
X  The @kbd{k a} (@code{calc-random-again}) command produces another random
X! number, re-using the most recent value of @samp{M}.
X  
X! @node Combinatorial Functions, , Random Numbers, Scientific Functions
X  @section Combinatorial Functions
X  
X  Commands relating to combinatorics and number theory begin with the
X--- 9099,9144 ----
X  @kindex k a
X  @pindex calc-random-again
X  The @kbd{k a} (@code{calc-random-again}) command produces another random
X! number, re-using the most recent value of @samp{M}.  With a numeric
X! prefix argument @var{n}, it produces @var{n} more random numbers.
X! 
X! @kindex k h
X! @pindex calc-shuffle
X! The @kbd{k h} (@code{calc-shuffle}) command produces a vector of several
X! random values with no duplicates.  The value on the top of the stack
X! specifies the set from which the random values are drawn, and may be any
X! of the @samp{M} formats described above.  The numeric prefix argument
X! gives the length of the desired list.  (If you do not provide a numeric
X! prefix argument, the length of the list is taken from the top of the
X! stack, and @samp{M} from second-to-top.)
X! 
X! If @samp{M} is a floating-point number, zero, or an error form (so
X! that the random values are being drawn from the set of real numbers)
X! there is little practical difference between using @kbd{k h} and using
X! @kbd{k r} several times.  But if the set of possible values consists
X! of just a few integers, or the elements of a vector, then there is
X! a very real chance that multiple @kbd{k r}'s will produce the same
X! number more than once.  The @kbd{k h} command produces a vector whose
X! elements are always distinct.  (Actually, there is a slight exception:
X! If @samp{M} is a vector, no given vector element will be drawn more
X! than once, but if several elements of @samp{M} are equal, they may
X! each make it into the result vector.)
X! 
X! One use of @kbd{k h} is to rearrange a list at random.  This happens
X! if the prefix argument is equal to the number of values in the list:
X! @kbd{[1, 1.5, 2, 2.5, 3] 5 k h} might produce the permuted list
X! @samp{[2.5, 1, 1.5, 3, 2]}.  As a convenient feature, if the argument
X! @var{n} is negative it is replaced by the size of the set represented
X! by @samp{M}.  Naturally, this is allowed only when @samp{M} specifies
X! a small discrete set of possibilities.
X! 
X! To do the equivalent of @kbd{k h} but with duplications allowed,
X! given @samp{M} on the stack and with @var{n} just entered as a numeric
X! prefix, use @kbd{v b} to build a vector of copies of @samp{M}, then use
X! @kbd{V M k r} to ``map'' the normal @kbd{k r} function over the
X! elements of the vector.  @xref{Matrix Functions}.
X  
X! @node Combinatorial Functions, Probability Distribution Functions, Random Numbers, Scientific Functions
X  @section Combinatorial Functions
X  
X  Commands relating to combinatorics and number theory begin with the
X***************
X*** 6292,6301 ****
X  Least Common Multiple of two integers.  The product of the LCM and GCD
X  of two integers is equal to the product of the integers. at refill
X  
X! @kindex k G
X  @pindex calc-extended-gcd
X  @tindex egcd
X! The @kbd{k G} (@code{calc-extended-gcd}) [@code{egcd}] command computes
X  the GCD of two integers @samp{x} and @samp{y} and returns a vector
X  @samp{[g, a, b]} where @samp{g = gcd(x,y) = a x + b y}.
X  
X--- 9158,9167 ----
X  Least Common Multiple of two integers.  The product of the LCM and GCD
X  of two integers is equal to the product of the integers. at refill
X  
X! @kindex k E
X  @pindex calc-extended-gcd
X  @tindex egcd
X! The @kbd{k E} (@code{calc-extended-gcd}) [@code{egcd}] command computes
X  the GCD of two integers @samp{x} and @samp{y} and returns a vector
X  @samp{[g, a, b]} where @samp{g = gcd(x,y) = a x + b y}.
X  
X***************
X*** 6309,6321 ****
X  the number is a non-integral real number, the generalized factorial is used,
X  as defined by the Euler Gamma function.  Please note that computation of
X  large factorials can be slow; using floating-point format will help
X! since fewer digits must be maintained. at refill
X  
X- @pindex calc-gamma
X- @tindex gamma
X- The @code{calc-gamma} [@code{gamma}] command computes the Euler Gamma
X- function explicitly, according to the rule @samp{gamma(x+1) = fact(x)}.
X- 
X  @kindex k d
X  @pindex calc-double-factorial
X  @tindex dfact
X--- 9175,9183 ----
X  the number is a non-integral real number, the generalized factorial is used,
X  as defined by the Euler Gamma function.  Please note that computation of
X  large factorials can be slow; using floating-point format will help
X! since fewer digits must be maintained.  The same is true of many of
X! the commands in this section. at refill
X  
X  @kindex k d
X  @pindex calc-double-factorial
X  @tindex dfact
X***************
X*** 6326,6335 ****
X  the argument is an integer-valued float, the result is a floating-point
X  approximation. at refill
X  
X! @kindex k b
X  @pindex calc-choose
X  @tindex choose
X! The @kbd{k b} (@code{calc-choose}) [@code{choose}] command computes the
X  binomial coefficient @samp{N}-choose- at samp{M}, where @samp{M} is the number
X  on the top of the stack and @samp{N} is second-to-top.  If both arguments
X  are integers, the result is an exact integer.  Otherwise, the result is a
X--- 9188,9197 ----
X  the argument is an integer-valued float, the result is a floating-point
X  approximation. at refill
X  
X! @kindex k c
X  @pindex calc-choose
X  @tindex choose
X! The @kbd{k c} (@code{calc-choose}) [@code{choose}] command computes the
X  binomial coefficient @samp{N}-choose- at samp{M}, where @samp{M} is the number
X  on the top of the stack and @samp{N} is second-to-top.  If both arguments
X  are integers, the result is an exact integer.  Otherwise, the result is a
X***************
X*** 6336,6347 ****
X  floating-point approximation.  The binomial coefficient is defined for all
X  real numbers by @samp{N! / M! (N-M)!}.
X  
X! @kindex H k b
X  @pindex calc-perm
X  @tindex perm
X! The @kbd{H k b} (@code{calc-perm}) [@code{perm}] command computes the
X! number-of-permutations function @samp{N! / M!}.
X  
X  @kindex k p
X  @pindex calc-prime-test
X  @cindex Primes
X--- 9198,9240 ----
X  floating-point approximation.  The binomial coefficient is defined for all
X  real numbers by @samp{N! / M! (N-M)!}.
X  
X! @kindex H k c
X  @pindex calc-perm
X  @tindex perm
X! The @kbd{H k c} (@code{calc-perm}) [@code{perm}] command computes the
X! number-of-permutations function @samp{N! / (N-M)!}.
X  
X+ @kindex k b
X+ @pindex calc-bernoulli-number
X+ @tindex bern
X+ The @kbd{k b} (@code{calc-bernoulli-number}) [@code{bern}] command
X+ computes a given Bernoulli number.  The value at the top of the stack
X+ is a nonnegative integer @samp{n} that specifies which Bernoulli number
X+ is desired.  The @kbd{H k b} command computes a Bernoulli polynomial,
X+ taking @samp{n} from the second-to-top position and @samp{x} from the
X+ top of the stack.  If @samp{x} is a variable or formula the result is
X+ a polynomial in @samp{x}; if @samp{x} is a number the result is a number.
X+ 
X+ @kindex k e
X+ @pindex calc-euler-number
X+ @tindex euler
X+ The @kbd{k e} (@code{calc-euler-number}) [@code{euler}] command similarly
X+ computes an Euler number, and @kbd{H k e} computes an Euler polynomial.
X+ Bernoulli and Euler numbers occur in the Taylor expansions of several
X+ functions.
X+ 
X+ @kindex k s
X+ @pindex calc-stirling-number
X+ @tindex stir1
X+ @tindex stir2
X+ The @kbd{k s} (@code{calc-stirling-number}) [@code{stir1}] command
X+ computes a Stirling number of the first kind, given two integers
X+ @samp{n} and @samp{m} on the stack.  The @kbd{H k s} [@code{stir2}]
X+ command computes a Stirling number of the second kind.  These are
X+ the number of @samp{m}-cycle permutations of @samp{n} objects, and
X+ the number of ways to partition @samp{n} objects into @samp{m}
X+ non-empty sets, respectively.
X+ 
X  @kindex k p
X  @pindex calc-prime-test
X  @cindex Primes
X***************
X*** 6359,6368 ****
X  as definitely prime or non-prime if possible, or otherwise ``probably''
X  prime with a certain probability of error.
X  
X  The normal @kbd{k p} command performs one iteration of the primality
X  test.  Pressing @kbd{k p} repeatedly for the same integer will perform
X  additional iterations.  Also, @kbd{k p} with a numeric prefix performs
X! the specified number of iterations.
X  
X  @kindex k f
X  @pindex calc-prime-factors
X--- 9252,9264 ----
X  as definitely prime or non-prime if possible, or otherwise ``probably''
X  prime with a certain probability of error.
X  
X+ @tindex prime
X  The normal @kbd{k p} command performs one iteration of the primality
X  test.  Pressing @kbd{k p} repeatedly for the same integer will perform
X  additional iterations.  Also, @kbd{k p} with a numeric prefix performs
X! the specified number of iterations.  There is also an algebraic function
X! @samp{prime(n)} or @samp{prime(n,iters)} which returns 1 if @code{n}
X! is prime and 0 if not.
X  
X  @kindex k f
X  @pindex calc-prime-factors
X***************
X*** 6412,6417 ****
X--- 9308,9402 ----
X  duplicate factors (i.e., can be divided by the same prime more than once),
X  the result is zero.
X  
X+ @node Probability Distribution Functions, , Combinatorial Functions, Scientific Functions
X+ @section Probability Distribution Functions
X+ 
X+ The functions in this section compute various probability distributions.
X+ For continuous distributions, this is the integral of the probability
X+ density function from @samp{x} to infinity.  (These are the ``upper
X+ tail'' distribution functions; there are also corresponding ``lower
X+ tail'' functions which integrate from minus infinity to @samp{x}.)
X+ For discrete distributions, the upper tail function gives the sum
X+ from @samp{x} to infinity; the lower tail function gives the sum
X+ from minus infinity up to, but not including, @samp{x}.
X+ 
X+ To integrate from @samp{x} to @samp{y}, just use the distribution
X+ function twice and subtract.  For example, the probability that a
X+ Gaussian random variable with mean 2 and standard deviation 1 will
X+ lie in the range from 2.5 to 2.8 is @samp{utpn(2.5,2,1) - utpn(2.8,2,1)}
X+ (``the probability that it is greater than 2.5, but not greater than 2.8''),
X+ or equivalently @samp{ltpn(2.8,2,1) - ltpn(2.5,2,1)}.
X+ 
X+ @kindex k B
X+ @pindex calc-utpb
X+ @tindex utpb
X+ @tindex ltpb
X+ The @kbd{k B} (@code{calc-utpb}) [@code{utpb}] function uses the
X+ binomial distribution.  Push the parameters @var{n}, @var{p}, and
X+ then @var{x} onto the stack; the result (@samp{utpb(x,n,p)}) is the
X+ probability that an event will occur @var{x} or more times out
X+ of @var{n} trials, if its probability of occurring in any given
X+ trial is @var{p}.  The @kbd{I k B} [@code{ltpb}] function is
X+ the probability that the event will occur fewer than @var{x} times.
X+ 
X+ The other probability density functions similarly take the
SHAR_EOF
echo "End of part 15, continue with part 16"
echo "16" > s2_seq_.tmp
exit 0



More information about the Comp.sources.misc mailing list