home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hall of Fame
/
HallofFameCDROM.cdr
/
util2
/
scieqs11.lzh
/
SCIEQS.DOC
< prev
next >
Wrap
Text File
|
1988-11-18
|
17KB
|
459 lines
SCIENTIFIC EQUATION SOLVER
==========================
Scientific Equation Solver (SCIEQS) acts as a sophisticated scientific
calculator. It can perform double precision floating point arithmetic
using an assignment statement syntax similar to BASIC or FORTRAN.
Variables may be assigned values in one statement and then used on the
right-hand side of another statement.
Almost every built-in function found on scientific calculators has
been included: trigonometric, hyperbolic, exponential, logarithmic,
factorial, and square/cube root functions. Even advanced functions
such as erf(x) and gamma(x) have been included. You can also define
your own functions with any number of arguments.
There is also an equation solver built into the program. This feature
allows the program to solve for any variable in a given equation.
Suppose you needed to solve for the variable 'x', where
(3 * x) + exp(x+1) = 99 .
By entering the command
!solve x, [0,100] : (3 * x) + exp(x+1) = 99 ,
the solution 3.483559695247 comes up on your screen in seconds.
SCIEQS also supports numerical integration (also known as quadrature).
This feature allows the program to approximate the values of definite
integrals. Suppose you needed to evaluate the following integral:
2
⌠
│ (x^2 * sqrt(x^3 + 1)) dx .
⌡
0
By entering the command
!quad x, [0,2] : x^2 * sqrt(x^3 + 1) ,
the value 5.7777777777778 comes up on your screen in seconds.
HOW TO START SCIEQS
===================
To begin SCIEQS, type the following command at the MS-DOS command
prompt:
SCIEQS
The program reads its input from the standard input and writes its
output to the standard output so you may use the data redirection
symbols >, >>, <, and | from the MS-DOS command line. For example,
the following command reads commands from file POLY.EQS and writes the
results to file RESULTS.TXT:
SCIEQS <POLY.EQS >RESULTS.TXT
EXPRESSIONS IN SCIEQS
=====================
SCIEQS is an expression oriented language. Expressions typed by the
user are interpreted, evaluated, and displayed immediately by SCIEQS.
Most commands are of the form
variable = expression
or simply
expression
The first form is the assignment statement. It assigns the expression
on the right side of the equals sign to the variable named on the left
side and also displays the value of the expression. The second form
simply evaluates the expression and displays its value.
Examples: 2+3 area = pi()*R^2 b = c*d
x^2 sqrt(2) (2+3)!
Expressions are composed of numbers, variables, function references,
and arithmetic operators. Following are the rules for forming
expressions.
Numbers follow a conventional decimal notation, with optional decimal
point. A power-of-ten scale factor can be included as a suffix. This
is similar to the number notations used in the computer languages
BASIC and FORTRAN. The range of numbers is approximately 1E-308 to
1E+308 with approximately 15 significant digits.
Examples: 1.2 +.8 -788 1E6
4. 1256 -7.3E-5
Variable names and function names must start with a letter and may be
followed by any number of letters, digits, and underscores. However,
only the first 31 characters of the name are remembered. SCIEQS is
not case-sensitive so it treats upper and lower case letters as the
same character. The variable names "Answer" and "answer" refer to the
same variable.
Examples: SUM x days_in_month xYzzY
An arithmetic expression can be any expression preceded by unary + or
-, two expressions linked by a binary operator (+ - * / % ^), or any
expression followed by unary !.
Arithmetic operators are (from high to low precedence):
Factorial !
Unary plus and minus + -
Exponentiation ^
Mult, Div, and Modulus * / %
Addition and Subtraction + -
Examples: x+3 -t^2 tan(x)/y 6! 4^2^3 (evaluates to 65536)
Operations at the same precedence level are performed from left to
right except for series of exponentiations, which are performed from
right to left. The factorial operator appears on the right of the
expression on which it operates. The order of operations may be
controlled by enclosing expressions in parentheses.
There are two main categories of functions in SCIEQS: built-in and
user-defined functions. Built-in functions are automatically provided
every time you run SCIEQS. User-defined functions are defined by you
to handle your specific problem. To invoke a function, refer to the
function in an expression.
Example: a = tan(x)/d
Following is a list of the built-in functions.
Mathematical Constants
PI() = 3.141592653589793 ratio of circumference to diameter
E() = 2.718281828459045 base of natural logarithms
Trigonometric and Inverse Trigonometric Functions in Radians
SIN(x) Sine of x
COS(x) Cosine of x
TAN(x) Tangent of x
ASIN(x) Arc sine of x
ACOS(x) Arc cosine of x
ATAN(x) 2-quadrant arc tangent of x
ATAN2(y,x) 4-quadrant arc tangent of y/x
ANGL(x,y) Angle to point (x,y)
HYPOT(x,y) Hypotenuse of right triangle
Trigonometric and Inverse Trigonometric Functions in Degrees
SIND(x) Sine of x
COSD(x) Cosine of x
TAND(x) Tangent of x
ASIND(x) Arc sine of x
ACOSD(x) Arc cosine of x
ATAND(x) 2-quadrant arc tangent of x
ATAN2D(y,x) 4-quadrant arc tangent of y/x
ANGLD(x,y) Angle to point (x,y)
Hyperbolic and Inverse Hyperbolic Functions
SINH(x) Hyperbolic sine of x
COSH(x) Hyperbolic cosine of x
TANH(x) Hyperbolic tangent of x
ASINH(x) Hyperbolic arc sine of x
ACOSH(x) Hyperbolic arc cosine of x
ATANH(x) Hyperbolic arc tangent of x
Exponential and Logarithmic Functions
EXP(x) Number e, 2.718281828459045, raised to the xth power
LN(x) Natural (base e) logarithm of x
LOG(x) Common (base 10) logarithm of x
LOG2(x) Base 2 logarithm of x
Other Mathematical Functions
ABS(x) Absolute value of x
SQRT(x) Positive square root of x
CBRT(x) Cube root of x
ERF(x) Error function associated with normal distribution curve
ERFC(x) Complementary error function, 1 - erf(x)
GAMMA(x) Gamma function, x-1 factorial for integer x>0
RTOD(x) Convert x in radians to degrees
DTOR(x) Convert x in degrees to radians
PERM(n,r) Permutations of n items taken r at a time
COMB(n,r) Combinations of n items taken r at a time
SGN(x) Sign (-1, +1 or 0) of x
INT(x) Integer part of x
ROUND(x) Nearest integer to x
CEIL(x) Smallest integer >= x
FLOOR(x) Largest integer <= x
STEP(x,y) Returns 1 if x >= y, 0 if x < y
ASSIGNMENT STATEMENTS AND USER-DEFINED FUNCTIONS
================================================
The assignment statement is used to define variables and user-defined
functions. They have the following formats:
variable = expression
function(arguments) = expression
Once the assignment has been done, the variable or function is
associated with the given expression. For a user-defined function,
the right-side expression should use the arguments listed in the
function's argument list. If a variable or function is used in an
expression before it is defined in an assignment statement, an error
message will be displayed.
Examples:
a = 2
b = sqrt(a)
area_circle(radius) = pi() * radius ^ 2
c = area_circle(a)
Assignment in SCIEQS assigns the expression, not the value of the
expression. What this means is the value of variables can change if
the variables they depend on change. For example, after the four
assignments in the above example have been done, the values of the
variables are:
A = 2
B = 1.4142135623731
C = 12.566370614359
But suppose we change the value of variable A by assigning it the
value 3. Now the values of variables B and C change automatically
because they were defined in terms of variable A.
A = 3
B = 1.7320508075689
C = 28.274333882308
This feature is important when you want to play "What happens if..."
games. You can build a mathematical model using different formulas
and see what happens when you start changing the values of some of the
variables.
COMMANDS IN SCIEQS
==================
Commands in SCIEQS begin with the character "!". Following is a list
of available commands and what they do.
SOLVE COMMAND
-------------
The solve command uses a numerical approximation method to solve
equations. It has the form
!solve variable , [ low, high ] : equation
Example: Solve for x where x^3 - 11*x^2 + 39*x = 27.
> !solve x, [-100,100]: x^3 - 11*x^2 + 39*x = 27
= 0.90375019315913
The variable x now has the value 0.90375019315913 for use in later
calculations.
The values in brackets [ ] represent the low and high bounds of an
interval in which to look for a solution. The approximation method
first takes a trial value at the midpoint of the specified interval
and iterates until the trial values converge on a solution. If the
equation to be solved has singularity points, choose the intervals to
avoid the singularities. SCIEQS may not be able to find a solution if
you include singularity points within the intervals.
If the equation has multiple solutions within the given interval,
SCIEQS will usually find one of them. To find multiple solutions, you
must narrow the search interval to include only one solution at a
time. You can narrow down the search intervals by plotting the
equations to find the vicinity of the solutions.
QUAD COMMAND
------------
The quadrature command uses a numerical approximation method to
evaluate definite integrals. It has the form
!quad variable , [ low, high ] : integrand
The variable indicates the "variable of integration." The values in
brackets [ ] represent the low and high limits of integration. The
integrand is the expression to be integrated. SCIEQS will integrate
the integrand from low to high limits with respect to the specified
variable of integration.
π
⌠
Example: Evaluate the definite integral │ sin(x) dx .
⌡
0
> !quad x, [0,pi()] : sin(x)
estimated error = 4.206476E-016
= 2
An estimate of the size of the actual error in the result is first
listed. If the approximation method encounters problems during the
integration, it may execute much longer than usual in an attempt to
achieve enough accuracy in the result. If the accuracy can not be
achieved, a warning message will be shown indicating the result may be
unreliable. The result of the integration is then listed below the
estimated error. The variable of integration will now have the result
of the integration for use in later calculations. In the above
example, the variable x will now contain the result.
SCIEQS may not be able to evaluate the integral if there are
singularity points within the limits of integration which cause
floating point overflows. If a floating point overflow occurs, the
program may terminate unexpectedly.
LIST COMMAND
------------
The list command is used to display the values of all the variables
used. The command has the following forms:
!list
!list filename
The first form displays the variables on the standard output. The
second form stores the output in the named file.
ECHO/NOECHO COMMANDS
--------------------
The echo and noecho commands control the echoing of the input commands
to the output destination. They have the following forms:
!echo
!noecho
The echo command turns on input command echoing while the noecho
command turns it off. SCIEQS starts out with echoing turned off. You
may wish to turn on echoing when sending output to a file so the
output file will contain a record of the input as well as the results.
SYS COMMAND
-----------
The sys command allows you to execute MS-DOS commands from within
SCIEQS. It has the following forms:
!sys
!sys MS-DOS_command
The first form starts the MS-DOS command shell underneath SCIEQS. You
must type "EXIT" at the MS-DOS command prompt to return to SCIEQS.
The second form executes the given MS-DOS command and automatically
returns to SCIEQS after the command finishes.
EXIT/QUIT COMMANDS
------------------
Both commands terminate SCIEQS execution. They have the forms
!exit
!quit
COMMAND FILES IN SCIEQS
=======================
SCIEQS supports the inclusion of input from command files. These
command files are ASCII text files which contain data, numerical
operations, and commands for SCIEQS to interpret. You may think of
them as "include" files. To include a file, give the following
command:
@filename
SCIEQS will open the file named after the "@" character and start
getting its input from that file. When the end of file is reached,
SCIEQS will resume getting its input from the original source. You
may specify a directory pathname if the file is not in the current
directory. You may nest command files within other command files, but
MS-DOS may limit you in the number of files you may open at any one
time.
COMMENTS IN SCIEQS
==================
Comments can be included in the input to help document your work. A
comment begins with a semicolon and continues to end of the line. You
can put a comment after an expression to explain the operation on that
line. You can also start a line with a comment in which case the
entire line is a comment.
Examples: cbrt(x) ;taking the cube root of variable x
; This entire line is a comment.
DISCLAIMER
==========
The SCIEQS program and associated files are provided "as is" without
any warranty or guarantee, including no warranty of fitness for a
particular purpose. You assume the entire risk as to the results
generated through your use of this software.
DISTRIBUTION
============
The shareware version of SCIEQS is distributed on electronic bulletin
boards and by computer clubs. You may use the software and make
multiple backup copies. Versions of SCIEQS designated as "shareware"
may be given to friends and uploaded to electronic bulletin boards
provided no changes have been made to the distribution package. Do
not distribute copies of the program which do not have the initial
screen explaining the shareware concept.
If you find this program useful, please feel free to give consideration
for my time and effort in developing this tool. Please send $6.00 to
the address below and ask for SCIEQS registration. The file ORDER.ME
contains a registration form that can be printed on your printer if
you wish. In return, you will receive a floppy disk with the latest
version of SCIEQS. The introductory screen along with its keyboard
entry will NOT appear in the copy of the program you will receive upon
registration. There will be no advertising in your registered copy.
Please upload the shareware version of this program onto as many local
bulletin boards as possible. You will be helping me make this tool
available to many more people giving me incentive to make further
improvements to the program.
Send contributions to: George Yee
1847 N. Frances Blvd.
Tucson, AZ 85712