home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff388.lzh / Calc / Calc.doc < prev    next >
Text File  |  1990-10-23  |  19KB  |  397 lines

  1. #3zq(Bpwv"z
  2.  
  3.  
  4.     CALC 2.0    by Bill Dimm
  5.            Amiga Version    August 7, 1990
  6.  
  7.          The Amiga version of Calc may be distributed freely as long as no
  8.     charge beyond a reasonable copying fee is made.  This program is
  9.     shareware - if you like it, you are encouraged to send me (a starving
  10.     grad student :-) ) a donation.  If you have any bugs to report, or any
  11.     requests for features for the next version, please send them also.
  12.  
  13.          Bill Dimm
  14.          Box 385
  15.          Springfield, PA. 19064-0385
  16.  
  17.          DIMM@ANLPNS.BITNET
  18.          DIMM@ANLPNS.PNS.ANL.GOV
  19.      
  20.  
  21.     USAGE
  22.  
  23.          Usage1: CALC [options]
  24.          Usage2: CALC [options] expression1 expression2 ...
  25.          Usage3: CALC [options] -v var expression [file1 file2 ...]
  26.  
  27.     DESCRIPTION
  28.  
  29.          Calc is a shell style calculator.  Calc does not have a fancy
  30.     keypad display as many other calculator programs do.  Instead, it is
  31.     capable of taking its input from a file, the keyboard (stdin), or a
  32.     command line and outputting its results to a file or the screen
  33.     (stdout).  It can also apply a single equation to all of the values
  34.     stored in a file (or files).  It handles all common mathematical
  35.     expressions, can optionally predefine physical constants (see the
  36.     options -m and -g and the commands mks and gaussian), and allows you to
  37.     store values in the 26 variables a-z. 
  38.          If Calc is invoked using the format in Usage1, it will read
  39.     mathematical expressions and commands from the keyboard or the input
  40.     file (see option -i and command infile) and execute them until it
  41.     encounters the exit command, or finds the end of the input file.  If
  42.     Calc is reading from the keyboard, it will display a prompt CALC> when
  43.     it is waiting for a command or mathematical expression.  The command or
  44.     expression is evaluated when the return key is pressed.  Expressions
  45.     may be of any length, and case is ignored.  The result of the
  46.     evaluation of all mathematical expressions is displayed on the screen,
  47.     or stored in a file (see option -o and the command outfile).  When an
  48.     error occurs, an error message is printed to the screen, or to a file
  49.     (see option -e and the command errorfile), and Calc ignores the rest of
  50.     the line and continues (unless the error is critical, in which case it
  51.     exits).  Calc can be told to exit automatically when any error occurs
  52.     (see option -a and command aborterron).  Comments can be added to a
  53.     line by preceding them with a # .  All input is buffered (unless
  54.     buffering is turned off using the option -b or the command bufferoff)
  55.     so that you can save your work at any point by using the save command.
  56.          The format in Usage2 tells Calc to evaluate the
  57.     commands/expressions on the command line instead of reading a file or
  58.     the keyboard for commands/expressions.  The commands/expressions used
  59.     in this mode are not buffered, so they cannot be saved.
  60.          Using Usage3 puts Calc in column mode.  In this mode it will
  61.  
  62.  
  63.                                      Page 1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.     evaluate the given expression once for each value stored in the
  71.     specified files.  var tells Calc what variable name to assign to the
  72.     values in file1.  var must be a single alphabetic character.  The next
  73.     alphabetic letter is assigned to the contents of file2, etc.  If no
  74.     files are specified, values are read from the keyboard (stdin) and
  75.     assigned to var (you must terminate the input with an end of file which
  76.     is generated by typing CTRL Z on VMS).  Calc reads a value from each of
  77.     the files, sets the corresponding variable, then evaluates the
  78.     expression, and outputs the result.  This process is repeated until
  79.     Calc finds the end of one of the input files.  Each value in the files
  80.     must be separated from the others by whitespace (spaces, tabs, or
  81.     carriage returns).
  82.  
  83.     MATHEMATICAL EXPRESSIONS
  84.  
  85.          Expressions conform to normal mathematical notation (note: you
  86.     must use a * for multiplication, you cannot simply use parenthesis).
  87.     They may be of any length, and case is ignored.  All spaces and tabs
  88.     are ignored.  You can also store the results of a calculation by typing
  89.     var=expression where var is any letter from a to z.  For example,
  90.          x = 4*sin(pi/3)/cosh(gamma(5))
  91.     Calc keeps track of the current value of each of the 26 variables, and
  92.     the expressions which were used to define them.  Normally, when a
  93.     variable is defined, the expression is evaluated immediately and the
  94.     result is stored as the current value of the variable.  Calc can be
  95.     told not to evaluate the expression immediately by using the -d or the
  96.     command definitionevaloff.  You may use any of the 26 variables in a
  97.     mathematical expression.  If you use a variable which has not been
  98.     defined, a warning is printed and the value 0 is used.  When a variable
  99.     is used in an expression, Calc checks the definition of the variable
  100.     and automatically updates the current value of the variable if
  101.     necessary.  For example:
  102.          CALC> x=1    # This is a comment.
  103.                             1
  104.          CALC> y=2
  105.                             2
  106.          CALC> r=sqrt(x^2+y^2)
  107.             2.236067977499789
  108.          CALC> 1/r
  109.             0.447213595499958
  110.          CALC> x=2
  111.                             2
  112.          CALC> 1/r
  113.             0.353553390593274
  114.     When a variable's definition includes a reference to itself, it's
  115.     current value is used to compute a new value.  For example:
  116.          CALC> x=1
  117.                             1
  118.          CALC> x=x+.5
  119.                           1.5
  120.          CALC> x
  121.                             2
  122.          CALC> x
  123.                           2.5
  124.     To list the definitions and current values of all variables, use the
  125.     list command.  The following is a list of expressions which are
  126.     supported by the FUNC library, which is responsible for evaluating
  127.  
  128.  
  129.                                      Page 2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.     mathematical expressions in Calc.  Any required explanation of the
  137.     function/operator/constant is given.  'x' and 'y' are used to represent
  138.     any legal expressions (or constants).  All angles are in radians.
  139.  
  140.     x-y         Binary minus
  141.     -x          Unary minus
  142.     x+y         Binary plus
  143.     x%y         Modulus - gives the remainder that results from 
  144.                 dividing x by y
  145.     x&y         Logical AND - returns 1 if absolute value of 
  146.                 both x & y is > EPS (ie. x and y are non-zero).  0 is 
  147.                 returned otherwise.
  148.     x*y         Product of x and y
  149.     x/y         x divided by y
  150.     x<y         Returns 1 if x < y and 0 if x >= y
  151.     x=y         Returns 1 if the difference between x and y is < EPS
  152.     x>y         Returns 1 if x > y and 0 if x <= y
  153.     x^y         Gives x raised to the power y
  154.     abs(x)      Absolute value
  155.     acos(x)     Inverse cosine of x 
  156.     acosh(x)    Inverse hyperbolic cosine
  157.     acot(x)     Inverse cotangent 
  158.     acoth(x)    Inverse hyperbolic cotangent
  159.     acsc(x)     Inverse cosecant 
  160.     acsch(x)    Inverse hyperbolic cosecant
  161.     asec(x)     Inverse secant 
  162.     asin(x)     Inverse sine 
  163.     asinh(x)    Inverse hyperbolic sine
  164.     atan(x)     Inverse tangent 
  165.     cos(x)      Cosine 
  166.     cosh(x)     Hyperbolic cosine
  167.     cot(x)      Cotangent
  168.     coth(x)     Hyperbolic cotangent
  169.     csc(x)      Cosecant
  170.     csch(x)     Hyperbolic cosecant
  171.     eps         Epsilon - a small number
  172.     exp(x)      Exponential:  exp(x) = e^x
  173.     gamma(x)    Gamma function: gamma(x) = integral from t = 0 to infinity
  174.                 of t^(x-1)exp(-t)dt.  Note that for positive integers,
  175.                 gamma(n+1) = n factorial, also denoted n!.  Due to the fact
  176.                 that gamma(x) is computed by different methods for
  177.                 different values of x, gamma(x) may be discontinuous in
  178.                 places.
  179.     lg(x)       Base 2 logarithm
  180.     ln(x)       Natural logarithm (base e)
  181.     log(x)      Base 10 logarithm
  182.     pi          Pi
  183.     sec(x)      Secant
  184.     sech(x)     Hyperbolic secant
  185.     sin(x)      Sine
  186.     sinh(x)     Hyperbolic sine
  187.     sqr(x)      x squared (x*x)
  188.     sqrt(x)     Square root
  189.     tan(x)      Tangent
  190.     tanh(x)     Hyperbolic tangent
  191.     x|y         Logical OR.  Gives 1 if the absolute value of either 
  192.                 x or y is > eps.  Gives 0 otherwise.
  193.  
  194.  
  195.                                      Page 3
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.     Note that there is some ambiguity about an expression such as x=2.  Is
  204.     this a definition, or an application of the equality operator?  If Calc
  205.     finds a variable as the first character on a line, and an = following
  206.     it, it assumes that it is a definition.  Thus, to force it to view the
  207.     = as an equality operator instead of a definition, you could use (x=2).
  208.  
  209.     COMMANDS
  210.  
  211.     The following commands are recognized by Calc.
  212.  
  213.     aborterroff
  214.                 Tells Calc not to abort when it is capable of recovering
  215.     from an error (this is the default).
  216.  
  217.     aborterron
  218.                 Tells Calc to abort when ANY error occurs.
  219.  
  220.     bufferoff
  221.                 Turns off the buffering of user input.  Previously buffered
  222.     input is not lost.  The save command only saves input which has been
  223.     buffered.
  224.  
  225.     bufferon
  226.                 Turns the buffering of user input on (this is the default).
  227.     The save command only saves input which has been buffered.
  228.  
  229.     definitionevaloff
  230.                 Causes calc not to immediately update a variable when it is
  231.     defined.  This is useful when the definition relies on variables which
  232.     have not been defined yet.
  233.  
  234.     definitionevalon
  235.                 Causes Calc to evaluate variable definitions immediately &
  236.     update the current value of the variable (this is the default).
  237.  
  238.     errfile
  239.                 Prompts for the name of a file in which all error messages
  240.     are deposited.
  241.  
  242.     exit
  243.                 Exits from Calc.
  244.  
  245.     gaussian
  246.                 Defines several of the variables with useful constants in
  247.     the gaussian (centimeter, gram, second) system of units.  Be warned
  248.     that previous definitions of these variables will be destroyed.
  249.  
  250.     infile
  251.                 Prompts for the name of a file which will be used for
  252.     input.
  253.  
  254.     list
  255.                 Lists the current values and definitions of all variables.
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                      Page 4
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.     mks
  269.                 Defines several of the variables with useful constants in
  270.     the mks (meter, kilogram, second) system of units.  Be warned that
  271.     previous definitions of these variables will be destroyed.
  272.  
  273.     outfile
  274.                 Prompts for the name of a file in which output is stored.
  275.  
  276.     promptoff
  277.                 Discontinues the displaying of CALC> when waiting for
  278.     commands/expressions from the keyboard (stdin).
  279.  
  280.     prompton
  281.                 Tells Calc to display the prompt CALC> when it is waiting
  282.     for commands/expressions from the keyboard (stdin).  This is the
  283.     default.
  284.  
  285.     quit
  286.                 Same as exit.
  287.  
  288.     repeatoff
  289.                 Tells Calc not to echo the input to the output channel
  290.     (this is the default).
  291.  
  292.     repeaton
  293.                 Tells Calc to echo the input to the output channel.  This
  294.     is useful when the output is being directed to a file so that you can
  295.     see both the expressions and their values.
  296.  
  297.     save
  298.                 Prompts for the name of a file in which the
  299.     commands/expressions which have been entered previously are stored.
  300.  
  301.     OPTIONS
  302.  
  303.     -o NAME
  304.                 Stores all output in a file called NAME.
  305.  
  306.     -i NAME
  307.                 Uses the contents of the file NAME as input.
  308.  
  309.     -e NAME
  310.                 Stores all error messages in the file NAME.
  311.  
  312.     -a
  313.                 Same as the command aborterron.
  314.  
  315.     -b
  316.                 Same as the command bufferoff.
  317.  
  318.     -d
  319.                 Same as the command definitionevaloff.
  320.  
  321.     -g
  322.                 Same as the command gaussian.
  323.  
  324.  
  325.  
  326.  
  327.                                      Page 5
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.     -m
  335.                 Same as the command mks.
  336.  
  337.     -p
  338.                 Same as the command promptoff.
  339.  
  340.     -r
  341.                 Same as the command repeaton.
  342.  
  343.     EXAMPLES
  344.  
  345.     An example of Usage1:
  346.                 CALC
  347.                 CALC> x=5
  348.                                    5
  349.                 CALC> y=2
  350.                                    2
  351.                 CALC> sin(x)*y^4
  352.                  -15.342788394610217
  353.                 CALC> exit
  354.  
  355.     An example of Usage2:
  356.                 CALC 1+2/3 4/5 pi
  357.                    1.666666666666667
  358.                                  0.8
  359.                    3.141592653589793
  360.  
  361.     As an example of Usage3, consider the two files:
  362.     file1:
  363.                 1
  364.                 2
  365.                 3
  366.                 4
  367.     file2:
  368.                 2
  369.                 2.5
  370.                 3
  371.                 3.5
  372.     Then, envoking calc as follows:
  373.                 CALC -v x x^y file1 file2
  374.                                    1
  375.                    5.656854249492377
  376.                                   27
  377.                    127.9999999999999
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                      Page 6
  394.  
  395.  
  396.  
  397.