EVLLIBC.DOC : Description of EVLLIB.H and EVLLIB.C
===========

Title   : EVLLIB
Version : 4.0
Date	: Nov 23,1996
Author	: J.R. Ferguson
Language: Borland Turbo C 2.0, Turbo C++ 3.1 for Windows

EVLLIB is a library consisting of a single function, eval, which enables you
to execute an arithmetic function that was entered interactively at run-time
in a C program.

Some useful applications are equation solving, drawing function plots,
integration and differentiation, etc.

  float eval(const char *expr, float x, int *error)

The expression string may have any length.

Function eval evaluates the expression expr, which can be a constant
function or a function with one float variable, x. If the expression is
syntactically correct, the parameter error will be set to FALSE and the
function result yields the value of the expression. If a syntax error is
detected, the parameter error will be set to TRUE and the function result
is left undefined.

Warning: If the function result is arithmetically undefined, for instance
when a division by zero occurs or when the logarithm is taken from a 
negative value, a run-time error will occur.

The expression syntax rules are close to those for a Pascal arithmetic
expression. The exact rules are as follows:
 expression           ::= <term> { <add oper> <term> }
 sign                 ::= '+' | '-'
 add oper             ::= '+' | '-'
 term                 ::= <factor> { <mult oper> <factor> }
 mult oper            ::= '*' | '/'
 factor               ::= <unsigned factor> | <sign> <unsigned factor>
 unsigned factor      ::= <unsigned number> | <variable> |
                          <func ident> '(' <expression> ')' |
                          '(' <expression> ')'
 variable             ::= 'x'
 func ident           ::= 'sin' | 'cos' | 'tan' | 'cot' | 'arctan' |
                          'abs' | 'exp' | 'ln' | 'sqrt' | 'sqr'
 unsigned number      ::= <fpnumber> | <fpnumber> 'e' <exponent part>
 fpnumber             ::= <unsigned integer> |
                          <unsigned integer> '.' <fraction part>
 fraction part        ::= <unsigned integer>
 exponent part        ::= <unsigned integer> |
                          <sign> <unsigned integer>
 unsigned integer     ::= { <digit> }
 digit                ::= '0' | '1' | '2' | '3' | '4' |
                          '5' | '6' | '7' | '8' | '9'

 Remarks:
 1. The notation used here is in the so-called Backus-Naur form. 
    It has the following symbols:
      ::=       may be replaced by
      |         or
      { ... }   0 or more times
      < ... >   the name of a symbol that is defined in another rule
      ' ... '   literal text
 2. Upper and lower case letters are considered to be the same.
 3. Spaces may be used as separators. There is no way to insert comment.
 4. The syntax for an "unsigned number" is less strict than it is in 
    standard Pascal. For instance the number ".3" is accepted as equivalent
    to "0.3".
 5. If the expression does not contain a variable x, function eval still
    needs a second parameter of type float. 


Examples of valid expressions:
  'sqr(x)'
  '1+2*sin(x)'
  '2.03E-5 + ln(x)'
  'exp(1)'
  'exp(-sqr(x-.5))/sqrt(2)'
  '4.0*arctan(1.0)'
