Delila Program: calc

calc program

Documentation for the calc program is below, with links to related programs in the "see also" section.

{   version = 2.71; (* of calc.p 2014 Oct 03}

(* begin module describe.calc *)
   calc: a calculator that propagates errors

   calc(input: in, output: out)

   input: reverse polish calculator input
   output: results


   The program is based on the idea of the dc program under UNIX.  That
   program takes input as reverse polish and calculates values.  This program
   does the same, but values have estimates so one may calculate and
   propagate errors.  Tokens (commands and numbers) are usually separated by
   spaces or carriage returns.  Tokens that begin with a digit or a dash (-)
   are numbers.  Numbers always come in pairs, the first is the estimate and
   the second is the error.

   Some of the commands are:
     '?' or 'h' give current list of all commands and functions
     numbers (as pairs) are entered on the stack
             5 2
          means 5 +/- 2
          means 5 +/- 0, so you can avoid giving the estimate if you want.
          any other legal command may replace the single quote as "5p".
     + add the top two numbers on the stack together
     _ (UNDERSCORE) subtract the top number from the next number
       on the stack (underscore is used to be distinct from minus sign, -)
     * multiply the top two numbers on the stack together
     / divide the top number on the stack by the next number on the stack
     s print the stack, top down
     p print the top number on the stack
     . do not show error ranges and do not read new ones
     : do show and do error ranges

   Note:  When the program is asked to do calculations silently,
   (using the t command) it immediately shuts up and does not say that it
   is doing so.  This makes it easier to write programs without having them
   announce in the output that they are doing silent calculations.

   If one has turned on showing error ranges with the ":" command, then
   numbers must be input as pairs, the estimate and the error.  However, if a
   second number is not found during reading, the error is set to zero.

   An Introduction to Error Analysis,  John R. Taylor
   University Science Books, Mill Valley, CA. 1982.

see also

   Tcsh script to call calc from the command line:

   Thomas Schneider

   Pascal numeric input is used, so anything that can make Pascal
   bomb will bomb this program.  For example, "- ", will cause
   the program to think there is a number after the dash, and (our)
   Pascal will object.  This should be protected against now,
   so the program should never bomb (famous last words).
   2008 Jul 25
   ... Indeed famous.  A simple string like '31.' causes the GPCC
   compiler to stop with:
   "calc: digit expected after decimal point (error #554 at 186db)"
   As this is done by a direct read of the number,
   it cannot be prevented without writing additional protective code.

   The u (uncertainty) function error estimate is set to zero when
   the probability is zero.  This is a guess.

   Version 2.59, 2000 Apr 12: major bug found! computation of error for logs
   was WRONG.  For base 2 logs, for example, the error should have been
   divided by 1/ln(2).  All computations of log errors based on versions less
   than 2.59 MUST BE REDONE.

technical notes
   The Gaussian integration function will create a real number
   that is too large if the Z value is larger than constant zbound.
   The program returns zero in these cases, to avoid bombing.

(* end module describe.calc *)
{This manual page was created by makman 1.45}

{created by htmlink 1.62}