home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / misc / icalc.lzh / icalc / icalc.doc < prev    next >
Text File  |  1992-01-29  |  29KB  |  859 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.                               ¢3micalc ¢0m¢1mversion 1¢0m.¢1m1a 
  16.  
  17.  
  18.  
  19.                       ¢0mA complex-number expression parser 
  20.  
  21.                                by Martin W.Scott 
  22.  
  23.  
  24.  
  25.                                   User Guide 
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.      icalc                         User Guide                         icalc
  69.  
  70.  
  71.      ¢1mIntroduction 
  72.  
  73.           ¢0m¢3micalc  ¢0mis  a  terminal-based  calculator;  the  ¢1mi ¢0mstands for
  74.           ¢1mimaginary¢0m, denoting the fact that the calculator works  with
  75.           complex numbers.  There are many calculator programs for the
  76.           Amiga, but  to  my knowledge, none with this ability.  ¢3micalc
  77.           ¢0malso performs real (normal) calculations too,  and  you  can
  78.           completely ignore the complex number facility if you wish.  
  79.  
  80.  
  81.      ¢1mComplex Numbers 
  82.  
  83.           ¢0mA  complex number is made up of two components: a real part,
  84.           and an imaginary part.  The imaginary part is  just  a  real
  85.           number  multiplied by the special number i, which is defined
  86.           to be the square root of -1.  Thus, i*i = -1. This  may  all
  87.           seem very artificial, but it's not; complex numbers exist as
  88.           surely  as  real  numbers  do  (or  don't, depending on your
  89.           mathematical philosophy).  It's just that our notion of real
  90.           numbers is based upon  our  experience  of  measurement  and
  91.           arithmetic.  However, it is not the purpose of this guide to
  92.           teach  the  basics  of  complex  numbers - if you don't know
  93.           about them, you probably don't need to, but  you  may  still
  94.           find ¢3micalc ¢0museful, because real numbers are just a subset of
  95.           complex numbers, and can thus be manipulated by this program
  96.           as in an ordinary calculator-type program.  Don't be put off
  97.           - I hardly ever need to use complex numbers; I just like the
  98.           facility  to  be  there  for  the odd occasion when I do use
  99.           them.  
  100.  
  101.  
  102.      ¢1mExpressions 
  103.  
  104.           ¢0m¢3micalc ¢0maccepts expressions in the  usual  form  for  computer
  105.           expressions, i.e.    multiplication must be explicitly shown
  106.           by '*', and function arguments enclosed within  parentheses.
  107.           The  exception  to  this is the method of inputing imaginary
  108.           parts of complex numbers.  If you want to enter the number 3
  109.           + 4i, you can type either 
  110.  
  111.               3 + 4i 
  112.  
  113.           or 
  114.  
  115.               3 + 4*i 
  116.  
  117.           but ¢3mnot 
  118.  
  119.               ¢0m3 + i4 
  120.  
  121.           since this would give an ambiguous grammar - is  it  i*4  or
  122.           the variable "i4"?  
  123.  
  124.           In   almost   all   circumstances,  the  algebraic  "4i"  is
  125.           preferred, but there is one exception, exponentation "^". If
  126.           you want 3*i^3, you must type 
  127.  
  128.               3*i^3 
  129.  
  130.  
  131.      icalc                            -2-                      version 1.1a
  132.  
  133.  
  134.      icalc                         User Guide                         icalc
  135.  
  136.  
  137.           and not 
  138.  
  139.               3i^3 
  140.  
  141.           The former gives the correct result, -3i, whilst the  latter
  142.           gives  -27i.  This  is  because  the  grammar sees "3i" as a
  143.           number   in   its   own   right,   and   not   an   implicit
  144.           multiplication.  
  145.  
  146.           See  the  appendices  for  the  complete  list  of commands,
  147.           operators,  constants  and  builtin  functions  that   ¢3micalc
  148.           ¢0msupports.  
  149.  
  150.           Expressions  are  separated  by newlines or semi-colons ';'.
  151.           You may also split an expression over multiple lines using a
  152.           backslash '\' to indicate continuation  to  the  next  input
  153.           line.   Comments  are introduced by '#', and the rest of the
  154.           input line is ignored.  You may also  place  comments  after
  155.           backslashes.  
  156.  
  157.  
  158.      ¢1mSample Expressions 
  159.  
  160.  
  161.               ¢0mx=1-iá# an assignment statement 
  162.  
  163.           assigns to variable x the value 1-i.  
  164.  
  165.               # and now, two statements separated by a semi-colon 
  166.  
  167.               sqr(x); x*sqr(x); 
  168.  
  169.           displays   the  values  -2i  and  -2-2i.  The  next  example
  170.           demonstrates a problem inherent in machine calculations: 
  171.  
  172.               2*sin(x)*cos(x) - sin(2*x) 
  173.  
  174.           displays the value 4.4408920985e-16  +  4.4408920985e-16  i.
  175.           The  answer  should  be 0, and indeed is very close to that.
  176.           The inaccuracy results because each  term  has  a  value  as
  177.           close  to  the  actual  value  as  the  computer's  internal
  178.           representation of numbers can hold.  
  179.  
  180.  
  181.      ¢1mStarting icalc 
  182.  
  183.           ¢0m¢3micalc ¢0mmay be started from either the CLI  or  Workbench.  It
  184.           will  process  the  the  file  "s:icalc.init"  if it exists,
  185.           before doing anything else.  It is recommended that you  use
  186.           NEWCON:   or   ConMan   to   provide   editing  and  history
  187.           facilities.  
  188.  
  189.        CLI Usage 
  190.  
  191.           The synopsis for icalc is 
  192.  
  193.               icalc [file-list] 
  194.  
  195.  
  196.  
  197.      icalc                            -3-                      version 1.1a
  198.  
  199.  
  200.      icalc                         User Guide                         icalc
  201.  
  202.  
  203.           where file-list is a list of input files.  ¢3micalc  ¢0mwill  read
  204.           (process) the files in the list and exit.  If a file-list is
  205.           specified, ¢3micalc ¢0mwill assume that you do not wish to use the
  206.           program interactively.  If you do, you should specify one of
  207.           the files as a dash "-"; this is taken to mean "use standard
  208.           input".    If   no  file-list  is  given,  ¢3micalc  ¢0mstarts  an
  209.           interactive session.  You can obviously redirect output to a
  210.           file if you wish (and redirect input from a file,  but  this
  211.           is generally  unnecessary).    For example, if you wanted to
  212.           use definitions contained in a file called "stat.icalc", and
  213.           then type some expressions in at the terminal, you would use 
  214.  
  215.               icalc stat.icalc - 
  216.  
  217.           to start the program.  Because the program  makes  extensive
  218.           use  of recursion, I recommend you use a stack size of about
  219.           20K when running ¢3micalc.  
  220.  
  221.        ¢0mWorkbench Usage 
  222.  
  223.           To start ¢3micalc ¢0mfrom the Workbench, simply  double-click  its
  224.           icon.   You  may  also  pass  arguments  (definition/command
  225.           files) to ¢3micalc ¢0min the usual Workbench manner  (shift-select
  226.           etc.).   ¢3micalc  ¢0mwill  then  open  a  window on the Workbench
  227.           screen for an interactive session.    You  can  specify  the
  228.           window  to be opened by modifying the WINDOW tooltype (click
  229.           once on the ¢3micalc ¢0micon, and select "Info" from the Workbench
  230.           menu).  By default, this is a NEWCON: window.  
  231.  
  232.           You may also set the default tool  of  a  definition  file's
  233.           project icon  to  be ¢3micalc.  ¢0mThen simply double clicking the
  234.           project icon will  launch  ¢3micalc  ¢0mand  read  the  definition
  235.           file.  Remember, however, to set the project icon's stack to
  236.           20000, or you may get a stack overflow error.  
  237.  
  238.        Exiting icalc 
  239.  
  240.           To  end  an interactive session of ¢3micalc ¢0m(from either CLI or
  241.           Workbench) use the commands "quit" or "exit".  You can  also
  242.           type ^\ (press the control key and '\' simultaneously).  
  243.  
  244.  
  245.      ¢1mVariables 
  246.  
  247.           ¢0mVariables  in  ¢3micalc ¢0mcan be named arbitrarily, as long as no
  248.           name conflicts with a pre-defined symbol name, such  as  sin
  249.           or  PI.  The standard conventions apply: the first character
  250.           must be a letter or underscore,  followed  by  a  string  of
  251.           letters, digits and underscores.  Case is significant.  
  252.  
  253.           Variables  are  introduced  by  using them; If a variable is
  254.           used before it has been initialized (i.e. has  had  a  value
  255.           assigned  to it), ¢3micalc ¢0mwill warn the user and use the value
  256.           zero.  Assignments can appear anywhere in an expression, and
  257.           are in fact expressions  in  their  own  right  (as  in  the
  258.           programming language C).  So, you can do things like 
  259.  
  260.               apple = banana = apricot = 34 
  261.  
  262.  
  263.      icalc                            -4-                      version 1.1a
  264.  
  265.  
  266.      icalc                         User Guide                         icalc
  267.  
  268.  
  269.           to assign   the   value   34  to  these  variables.    Since
  270.           assignments  are  expressions,   their   value   being   the
  271.           assignment value, you can also do 
  272.  
  273.               apple = sqr(banana = 12) 
  274.  
  275.           which  assigns the value 12 to "banana", and 144 to "apple".
  276.           You can of course assign new values to existing variables.  
  277.  
  278.  
  279.      ¢1mConstants and ans 
  280.  
  281.           ¢0m¢3micalc ¢0mcomes with several predefined  constants,  e.g.    PI,
  282.           GAMMA etc,  which  by convention are all in upper-case.  You
  283.           cannot assign a new value to a constant.  There is a special
  284.           constant, "ans", which isn't really a constant at  all,  but
  285.           is made so to prevent assignments to it.  "ans" contains the
  286.           value  of  the  previously  evaluated  expression, and so is
  287.           useful when splitting a calculation up into smaller chunks.  
  288.  
  289.               1 + 2 + 3 
  290.                           6 
  291.  
  292.               ans * 12 
  293.                           72 
  294.  
  295.           You can also use it for recursive formulas.    For  example,
  296.           the logistic equation xnext = rx(1-x) for parameter r = 3.5,
  297.           initial x = 0.4 could be iterated as follows: 
  298.  
  299.               rá=á3.5;á0.4á# initialize r and ans 
  300.                           3.5 
  301.                           0.4 
  302.  
  303.               r*ans*(1-ans) 
  304.                           0.84 
  305.  
  306.               r*ans*(1-ans) 
  307.                           0.4704 
  308.  
  309.               r*ans*(1-ans) 
  310.                           0.87193344 
  311.  
  312.               r*ans*(1-ans) 
  313.                           0.390829306734 
  314.  
  315.           and so on.  Of course, you needn't use "ans" here; you could
  316.           just  use  assignments to "x", but it illustrates the point.
  317.           Note  that  once   the   necessary   variables   have   been
  318.           initialised,  the  same  expression is evaluated repeatedly.
  319.           Thus, if you are using a window  with  history  capabilities
  320.           (such as NEWCON:) you can save a lot of typing.  
  321.  
  322.           There  are  other  ways  to perform repeated calculations in
  323.           ¢3micalc.   ¢0mThese  are  explained  in  the   section   "Special
  324.           Functions".  
  325.  
  326.  
  327.  
  328.  
  329.      icalc                            -5-                      version 1.1a
  330.  
  331.  
  332.      icalc                         User Guide                         icalc
  333.  
  334.  
  335.      ¢1mBuiltin Functions 
  336.  
  337.           ¢0m¢3micalc  ¢0mcomes  with  many builtin functions, for example sin,
  338.           cos, sqrt, exp, ln etc.  There are  some  special  functions
  339.           for complex  numbers  too,  namely  Im,  Re, arg, norm.  All
  340.           functions take real or complex arguments, which can  be  any
  341.           expression.  Consider 
  342.  
  343.               sin(12-3i) 
  344.                           -5.40203477 - 8.45362342 i 
  345.  
  346.               asin(ans) 
  347.                           -0.56637061 - 3 i 
  348.  
  349.               sin(ans) 
  350.                           -5.40203477 - 8.45362342 i 
  351.  
  352.           Here  we  see a property of inverse trigonometric functions,
  353.           their many-valuedness, due to their periodicity on the  real
  354.           line.   The  function  asin  returns  a  value  in  its  PVR
  355.           (principal value range) as do all many-valued  functions  in
  356.           ¢3micalc.   ¢0mSee  the  file 'TechNotes' for exact definitions of
  357.           PVRs of the inverse trigonometric functions used in ¢3micalc.  
  358.  
  359.           ¢0mOther functions owe their many-valuedness to the  fact  that
  360.           the  argument of a complex number is 2*PI-periodic. In ¢3micalc
  361.           ¢0mthe argument always falls in the range -PI < arg <= PI.  
  362.  
  363.           Another thing to bear in mind if  you  intend  working  with
  364.           reals is that things like 
  365.  
  366.               ln(-1) 
  367.  
  368.           return a value, 3.14159265359*i (PI*i) in this case.  
  369.  
  370.  
  371.      ¢1mUser¢0m-¢1mdefined Functions 
  372.  
  373.           ¢0mUser-defined   functions  give  ¢3micalc  ¢0mits  flexibility  and
  374.           power.   Any  function  that  can  be  stated  as  a  normal
  375.           expression  (or  list  of expressions) may easily be defined
  376.           and used like a builtin function.  Functions are defined  in
  377.           the following manner: 
  378.  
  379.               func <name> ( <parameter-list> ) = <expr> 
  380.  
  381.           so to define the function f(z) = sin(sqrt(z)), simply type 
  382.  
  383.               func f(z) = sin(sqrt(z)) 
  384.  
  385.           Note  that  z  is  ¢3mlocal  ¢0mto  the  function,  not  a  global
  386.           variable.  Thus, if z has been defined as a variable  before
  387.           defining f(z),  it  is  unaltered when you call f(z).  There
  388.           are a  number  of  sample  definition  files  included  with
  389.           ¢3micalc.  ¢0mYou may find it instructive to examine them.  
  390.  
  391.           Multi-parameter functions may also be defined.  For example,
  392.           the volume of a right-circular cone is given by the formula 
  393.  
  394.  
  395.      icalc                            -6-                      version 1.1a
  396.  
  397.  
  398.      icalc                         User Guide                         icalc
  399.  
  400.  
  401.               volume = 1/3*PI*sqr(r)*h 
  402.           where  r  is  the radius of the base, and h is the height of
  403.           the cone.  We can define a function to compute the volume as
  404.           follows: 
  405.  
  406.               func conevol(r,h) = 1/3*PI*sqr(r)*h 
  407.  
  408.               conevol(1,3) 
  409.                           3.14159265 
  410.  
  411.           It is also possible  (though  of  limited  use)  to  declare
  412.           functions that    take   no   parameters.      Examples   of
  413.           multi-parameter functions are given in the sample definition
  414.           files.  
  415.  
  416.           As with most programming  languages,  don't  write  circular
  417.           definitions;  ¢3micalc  ¢0mdoes  not detect them, and will swiftly
  418.           run out of stack space.  Recursive functions fall into  this
  419.           category, as there is no way to specify terminal cases.  
  420.  
  421.  
  422.      ¢1mSpecial Functions 
  423.  
  424.           ¢0mCertain  builtin  functions  in  ¢3micalc  ¢0mare  called  ¢3mspecial
  425.           ¢0mbecause of the way they use their arguments.  Normally, when
  426.           you `call' a function, its arguments are first evaluated and
  427.           then the  function  is  called.    With  special   functions
  428.           however,  the  arguments  are not evaluated; this means that
  429.           the expressions themselves (and not just their  values)  can
  430.           be used  by  the function in a number of ways.  Some special
  431.           functions take integers  as  arguments;  if  you  supply  an
  432.           expression  with  a  non-integral  value, this value will be
  433.           stripped of it's imaginary component, and the remaining real
  434.           number rounded to  the  nearest  integer.    Currently,  the
  435.           special functions are as follows.  
  436.  
  437.        Sum(var,upto,expr) 
  438.  
  439.           This command  calculates finite sums.  The variable `var' is
  440.           the index of summation, with an optional assignment.   While
  441.           the value of the index is less than or equal to the value of
  442.           the upto argument, the value of expr is added to an internal
  443.           summation variable,  which is initially zero.  Examples will
  444.           help to clarify usage.  
  445.  
  446.           To evaluate  the  sum  of  the  first  100  natural  numbers
  447.           (naively) we could do 
  448.  
  449.               Sum(n=1,100,n) 
  450.  
  451.           which  gives  the  answer  as 5050 (which is 100/2*(100+1)).
  452.           Note the initial assignment of 1 to n.  If no initial  value
  453.           is  specified,  a  value of zero is assumed (and the user is
  454.           notified of this).  When a summation is complete, the  index
  455.           variable holds a value 1 greater than the value of upto.  We
  456.           can  also  use  Sum()  to provide approximations to infinite
  457.           sums.  
  458.  
  459.  
  460.  
  461.      icalc                            -7-                      version 1.1a
  462.  
  463.  
  464.      icalc                         User Guide                         icalc
  465.  
  466.  
  467.               Sum(n=1, 100, 1/sqr(n)) 
  468.                           1.6349839 
  469.  
  470.           Using the fact that n will now hold the value  101,  we  can
  471.           continue the summation to 200 by the following: 
  472.  
  473.               ans + Sum(n, n+99, 1/sqr(n)) 
  474.                           1.63994655 
  475.  
  476.           and  continue to obtain closer answers by repeating the last
  477.           line, 
  478.  
  479.               ans + Sum(n, n+99, 1/sqr(n)) 
  480.                           1.64160628 
  481.  
  482.           which is getting there (the infinite series sums to PI^2/6 =
  483.           1.64493407).  One last example, to evaluate the sum  of  the
  484.           all even numbers upto 100.  
  485.  
  486.               Sum(n=1, 50, 2*n) 
  487.                           2550 
  488.  
  489.        Prod(var,upto,expr) 
  490.  
  491.           This command calculates finite products, in an analogous way
  492.           to the  Sum()  special  function.  Examples will demonstrate
  493.           its use.  
  494.  
  495.               Prod(n=1, 10, n) 
  496.  
  497.           calculates 10!, which is 3628800. We can also use Prod()  to
  498.           investigate  infinite  products,  although  care  should  be
  499.           taken.  Consider Wallis's product for PI/2: 
  500.  
  501.           PIááá   2╫2╫4╫4╫6╫6╫...
  502.           --   =  ---------------
  503.           2áááá   1╫3╫3╫5╫5╫7╫...
  504.  
  505.           Here the product is 2/1 * 2/3 * 4/3 * 4/5 * ...  and  so  we
  506.           must   find   a  method  of  producing  the  numerators  and
  507.           denominators from an index.  It is easiest to  evaluate  the
  508.           product in  pairs  of  terms.    Thus,  for  each  term  our
  509.           numerator will be sqr(2*n),  and  our  denominator  will  be
  510.           (2*n-1)*(2*n+1) = sqr(2*n)-1.  Note that sqr(2*n) appears in
  511.           both the  numerator  and  denominator.    We  can  therefore
  512.           optimise the calculation by using a  temporary  variable  to
  513.           hold this value.  We proceed as follows: 
  514.  
  515.               Prod(n=1, 100, (t = sqr(2*n))/(t-1)) 
  516.                           1.56689375 
  517.  
  518.               ans * Prod(n, n+99, (t = sqr(2*n))/(t-1)) 
  519.                           1.56883895 
  520.  
  521.               ans * Prod(n, n+99, (t = sqr(2*n))/(t-1)) 
  522.                           1.56949005 
  523.  
  524.  
  525.  
  526.  
  527.      icalc                            -8-                      version 1.1a
  528.  
  529.  
  530.      icalc                         User Guide                         icalc
  531.  
  532.  
  533.        every(var,upto,expr) and vevery(var,upto,expr) 
  534.  
  535.           These  functions  preform more general iterations than Sum()
  536.           and Prod().  They return the value of  the  last  expression
  537.           evaluated, ie.   expr  evaluated  when  var  =  upto.    The
  538.           difference between every() and vevery() is that  the  latter
  539.           produces  verbose  output - it prints the value of the index
  540.           and the result of the expression for every iteration.  
  541.  
  542.           Example:  evaluate   sin(sin(...(sin(z))...))   with   sin()
  543.           applied 10 times.  Here we'll take z to be 1-i.  
  544.  
  545.               last = 1-i; every(n=1, 10, last = sin(last)) 
  546.                           0.51856952 - 0.01039404 i 
  547.  
  548.           Although every() and vevery() are useful in some situations,
  549.           most iterations are more easily performed by using Sum() and
  550.           Prod(). 
  551.  
  552.        multi(expr1, expr2, ... , exprN) 
  553.  
  554.           This   special   function   takes  an  arbitrary  number  of
  555.           arguments, and evaluates each of them from  left  to  right.
  556.           It returns  the value of it's last argument, exprN.  multi()
  557.           was added to make the  addition  of  certain  user-functions
  558.           possible.    For   example,   the  one-variable  statistical
  559.           analysis suite given in the file "stat.icalc"  uses  multi()
  560.           to  update  the  values  of many variables with one function
  561.           call.  If output has not been switched off with  the  silent
  562.           command,  a  call  to  multi() will print the result of it's
  563.           last argument.  In order  to  print  the  results  of  other
  564.           arguments,   the   builtin  function  print()  is  supplied.
  565.           print() takes one argument, prints it to  the  display,  and
  566.           returns its  argument as a result.  In this way, expressions
  567.           can appear to return more than one result.  
  568.  
  569.           An  example:  write  a  function  that  converts   Cartesian
  570.           coordinates  into polar form, returning the radius and angle
  571.           in degrees, and setting the variables r and theta  to  these
  572.           values.  
  573.  
  574.  
  575.               func rec2pol(x,y) = multi(r = print(sqrt(x*x+y*y)), \ 
  576.                           theta = DEG*arg(x+i*y) ) 
  577.  
  578.  
  579.               rec2pol(3,4) 
  580.                           5 
  581.                           53.13010235 
  582.  
  583.           Note  the  use  of  complex  argument  to obtain the correct
  584.           quadrant.  
  585.  
  586.           Examples of the many uses of these special functions can  be
  587.           found  in the example icalc script file "stat.icalc" and the
  588.           startup file "icalc.init".  
  589.  
  590.  
  591.  
  592.  
  593.      icalc                            -9-                      version 1.1a
  594.  
  595.  
  596.      icalc                         User Guide                         icalc
  597.  
  598.  
  599.      ¢1mCommands 
  600.  
  601.           ¢0m¢3micalc ¢0mhas a few commands to make life easier.  
  602.  
  603.        quit 
  604.        exit 
  605.           not surprisingly, these commands terminate ¢3micalc.  
  606.  
  607.        ¢0msilent 
  608.           stops generation of any further output.  However, errors and
  609.           warnings are  still   displayed.      It   is   useful   for
  610.           initialization files containing lots of definitions.  
  611.  
  612.        verbose 
  613.           restores generation of output.  
  614.  
  615.        help 
  616.           reminds you what other commands are available.  
  617.  
  618.        vars 
  619.           lists all currently defined variables and their values.  
  620.  
  621.        consts 
  622.           lists all predefined constants and their values.  
  623.  
  624.        builtins 
  625.           lists  all  built-in  functions available, including special
  626.           functions.  
  627.  
  628.        functions 
  629.           lists  all  user-defined  functions,  with  their  parameter
  630.           lists.  
  631.  
  632.  
  633.      ¢1mBugs 
  634.  
  635.           ¢0mOne  major  bug  has been fixed in this release - the sqrt()
  636.           builtin was not returning values in  the  correct  quadrant.
  637.           Consequently, the inverse trigonometric functions, which are
  638.           defined using  sqrt(),  broke.  This has now been corrected.
  639.           Thanks to Pierre Ardichvili for pointing this out.  
  640.  
  641.           I hope that's all the major bugs ironed out, but  there  may
  642.           be the odd little bug in there somewhere -- if you find any,
  643.           PLEASE let me know and I'll try to fix them.  
  644.  
  645.           If  there's  something  you  hate about ¢3micalc ¢0mand would like
  646.           changed, or something you'd love that's not in,  drop  me  a
  647.           line (at the address below), or email me.  
  648.  
  649.  
  650.      ¢1mCompiling 
  651.  
  652.           ¢0m¢3micalc ¢0mwas written using Lattice C (version 5.10a) but should
  653.           compile  with  no problems with Manx C. I use the version of
  654.           bison on Fish #136; if you're using a later version or Yacc,
  655.           you may need to change the makefile.  
  656.  
  657.  
  658.  
  659.      icalc                            -10-                     version 1.1a
  660.  
  661.  
  662.      icalc                         User Guide                         icalc
  663.  
  664.  
  665.           The code is meant to be  portable,  so  Amiga-specific  code
  666.           (there's  not  much)  is  #ifdef'd.  Also,  to implement the
  667.           WINDOW tooltype, I've used a slightly  modified  version  of
  668.           Lattice's  _main  function; since I'm probably not permitted
  669.           to distribute the modified source, I've  included  just  the
  670.           compiled module, myumain.o.  
  671.  
  672.  
  673.      ¢1mCredits 
  674.  
  675.           ¢0mThanks  to  the GNU team for bison (it makes these things so
  676.           much easier to write and modify) and to William  Loftus  for
  677.           the Amiga port.  
  678.  
  679.           Thanks  also  to  Steve Koren for Sksh, and Mike Meyer et al
  680.           for  Mg3;   together   they   make   a   great   development
  681.           environment.  
  682.  
  683.           This  is  my  first  bison-based project, and I learnt a lot
  684.           from "The Unix Programming Environment" by  Brian  Kernighan
  685.           and Rob Pike. Their "hoc" taught me a lot about using Yacc.  
  686.  
  687.  
  688.      ¢1mDistribution 
  689.  
  690.           ¢0m¢3micalc ¢0mis not public domain.  You are permitted to distribute
  691.           it at  only  a  nominal  charge  to  cover costs.  All files
  692.           should be included, with the exception of the  source  files
  693.           (in the  "src"  directory).  Under no circumstances should a
  694.           modified version of ¢3micalc  ¢0mbe  distributed.    If  you  make
  695.           modifications  which  you feel may be useful, send a copy to
  696.           me and I'll (probably) include them with the next release.  
  697.  
  698.  
  699.      ¢1mThe Bottom Line 
  700.  
  701.           ¢0mAlthough contributions are not required, they would be  most
  702.           welcome (I'm  a  poor  student).  Don't let that inhibit you
  703.           from sending bug reports, praise, suggestions, neat programs
  704.           etc.  I'd get most pleasure from hearing if anyone  actually
  705.           uses this  bloody  program!  And thanks to those kind people
  706.           (small in number) who have written to me.  
  707.  
  708.           I can be contacted via snail mail at: 
  709.  
  710.               Martin W. Scott,
  711.               23 Drum Brae North,
  712.               Edinburgh, EH4 8AT
  713.               SCOTLAND.
  714.  
  715.           or you can email me - my address is mws@castle.ed.ac.uk
  716.  
  717.           Thanks for reading this far. The appendices follow.
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.      icalc                            -11-                     version 1.1a
  726.  
  727.  
  728.      icalc                         User Guide                         icalc
  729.  
  730.  
  731.      ¢1mAppendix 1 ¢0m- ¢1mOperators ¢0m(¢1min increasing order of precedence¢0m)     
  732.  
  733.           =áááá    assignment
  734.           +áááá    addition
  735.           -áááá    subtraction, unary minus
  736.           *áááá    multiplication
  737.           /áááá    division
  738.           ^áááá    exponentation
  739.           'áááá    conjugate: z' = conjugate of z
  740.  
  741.  
  742.      ¢1mAppendix 2 ¢0m- ¢1mConstants      
  743.  
  744.           ¢0mPIááá    4*atan(1) (that's one definition)
  745.           Eáááá    exp(1)
  746.           GAMMA    Euler's constant, 0.57721566...
  747.           DEGáá    Number of degrees in one radian
  748.           PHIáá    Golden ratio 1.61803398...
  749.           LOG10    ln(10)
  750.           LOG2á    ln(2)
  751.  
  752.  
  753.      ¢1mAppendix 3 ¢0m- ¢1mBuiltin functions     
  754.  
  755.           ¢0mSingle-argument functions: (* = new in version 1.1a)
  756.  
  757.           sináá    trigonometric functions
  758.           cos
  759.           tan
  760.           asiná    inverse trigonometric functions
  761.           acos 
  762.           atan
  763.           sinhá    hyperbolic trigonometric functions
  764.           cosh
  765.           tanh
  766.           expáá    exponential function
  767.           lnááá    natural logarithm
  768.           sqráá    square
  769.           sqrtá    square root
  770.           conjá    conjugate (see also ' operator)
  771.           absáá    absolute value (sqrt(norm(z))
  772.           normá    not really norm; if z=x+iy, norm(z) = x▓+y▓
  773.           argáá    principal argument (in [-PI,PI))
  774.           Reááá    real part of complex number
  775.           Imááá    imaginary part of complex number
  776.           min *    returns minimum real part in args (eg. min(1,2,3-i) = 1)
  777.           max *    returns maximum real part in args (eg. min(1+4i,2,3) = 3)
  778.           intáá    return real part rounded to nearest integer
  779.           ceilá    ceil of real part (eg. ceil(1.2) = 2)
  780.           floor    floor of real part (eg. floor(1.2) = 1)
  781.           sgn *    sign of real part (eg. sgn(-1.6) = -1)
  782.           time *    returns system time in seconds, less its argument
  783.           print    prints and returns the value of its argument
  784.           precá    adjust number of decimal places displayed
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.      icalc                            -12-                     version 1.1a
  792.  
  793.  
  794.      icalc                         User Guide                         icalc
  795.  
  796.  
  797.           Special functions (for more details, see the section  headed
  798.           "Special Functions" above): 
  799.  
  800.           Sumáá    calculate a finite sum
  801.           Prodá    calculate a finite product
  802.           every    perform a general iteration quietly
  803.           vevery   perform a general iteration verbosely
  804.           multi    evaluate many expressions
  805.  
  806.  
  807.  
  808.  
  809.  
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.      icalc                            -13-                     version 1.1a
  858.  
  859.