Dec 082017
 
A_SOLVER (Algebraic Equation Solver) can be used to create any program from a simple expression parser to a more sophisticated file based mini-interpreter. OBJ suitable for linking with C. Plenty of C examples.
File ASOLVER.ZIP from The Programmer’s Corner in
Category C Source Code
A_SOLVER (Algebraic Equation Solver) can be used to create any program from a simple expression parser to a more sophisticated file based mini-interpreter. OBJ suitable for linking with C. Plenty of C examples.
File Name File Size Zip Size Zip Type
ASOLVER.DOC 15422 3960 deflated
ASOLVER.H 292 142 deflated
ASOLVER.OBJ 7459 3803 deflated
EX1.C 1798 641 deflated
EX1.EXE 29872 18747 deflated
EX2.C 1941 693 deflated
EX3.C 3453 1022 deflated
EX4.C 2563 877 deflated
TEST2A.DAT 99 59 deflated
TEST2B.DAT 676 317 deflated
TEST3A.DAT 256 163 deflated
TEST3B.DAT 402 211 deflated
TEST4.DAT 386 211 deflated

Download File ASOLVER.ZIP Here

Contents of the ASOLVER.DOC file























A_SOLVER

Algebraic Equation Solver

by Ryan Software

Version 1.00




Ryan Software
P.O. Box 1150
Twin Peaks, CA 92391









Copyright (c) 1989 by Ryan Software
All Rights Reserved


























TERMS

Ryan Software is distributing a_solver as shareware.
Ryan Software allows you to use the algebraic equation
solver, a_solver, and the example programs for your own
personal use. Ryan Software does not grant any rights to use
the algebraic equation solver, a_solver, or the example
programs for any commercial use. Commercial users must
contact Ryan Software to receive information regarding
licensing a_solver.

OWNERSHIP


The program and documentation contained with a_solver,
is the sole and exclusive property of Ryan Software. All
users must recognize that these programs are copyrighted by
Ryan Software.

LIMITED WARRANTY

Ryan Software makes no warranty or guarantee, expressed
or implied as the the accuracy or reliability of results
derived from the program. The results from programs derived
from a_solver may require professional interpretation. It is
your responsibility to evaluate the accruacy and
applicability of those results for your particular purpose.


REGISTRATION

Shareware is a term for software that can be freely
copied and shared. The term describes copyrighted software
which the author supports and encourages people to copy and
share. The concept is based upon these principles:


1. People need to try programs to see if they are useful.

2. Software authors can be supported directly by users.

3. Copying and networking of programs can be encouraged.


We encourage you to register your copy of A_SOLVER.
Although there is no cost to register for non-commercial
users, registration has a number of benefits to you. You
will receive information regarding the most current version
of the program if the one you register is not the most
current.

Commercial users must register and contact Ryan
Software regarding licensing for commercial use.














ALGEBRAIC EXPRESSION SOLVER


1. Introduction

A_SOLVER can be used to create any program from a simple
expression parser such as EX1.EXE or a more sophisticated
file based mini-interpreter such as EX3.EXE.

Since a_solver is an obj file, it can be incorporated into
any existing program you may already have. It could be used
to process user input from equations or it could be used to
allow a user to determine their own algorithms by reading
sets of equations from a file.

The examples and data files included here are just meant to
give you an idea of a few possibilities for using a_solver.
The example programs are in no way meant to be complete.


The example programs use the function called a_solver().

int a_solver(mode,expression,value)

int mode;
char *buff;
double *value;


mode = 0 (reserved)
1 processes the expression

expression = the algbraic expression to be processed.
(the expression is case insensitive)


value = the returned value (double)


a_solver() returns a code defined as:

A_S_NOER 0 no error
A_S_SYNT -1 syntax error
A_S_PARG -2 unbalanced parentheses
A_S_NEXP -3 no expression found
A_S_ILLC -4 illegal character in expression
A_S_BLNK -5 expression is a blank line
A_S_DIV0 -6 divison by zero
A_S_LOGA -7 logarithm of a negative number
A_S_FACT -8 factorial of a negative number
A_S_SQRT -9 square root of a negative number

a_solver() can store 26 variables, A-Z.













The current functions it can solve are:

+ addition
- subtraction
* multiplication
/ division
% modulus division
\ integer division
^ exponentiation
** exponentiation (same as ^)
! factorial
rem remainder after division
abs absolute value
mod modulus division (same as %)
sqrt square root
exp exponential
log log base 10
ln natural log
sin sine (default angle in radians)
cos cosine (default angle in radians)
tan tangent (default angle in radians)
asin arcsine (resulting default angle in radians)
acos arccosine (resulting default angle in radians)
atan arctangent (resulting default angle in radians)
pi the constant pi
rad causes angles to be in radians (default)
deg causes angles to be in degrees
grd causes angles to be in grads
rtod converts radians to degrees
dtor converts degrees to radians


It allows (), [], or {} for parentheses as long as they are
in matched pairs.

The expression parser is quite robust. It can solve any of
the following:

sin(0.45)
sin(.45)
sin0.45
sin.45
sin 0.45
sin ( 0.45 )
sin[0.45]
sin{0.45}



2. Using A_SOLVER


EXAMPLE 1













This example reads the expression from the
keyboard and immediately writes the answer.

Type EX1. Then enter expressions such as:

7.9
3*45/9
a = 17
b = 11
sqrt(a) / b

EXAMPLE 2

This example reads the expressions from a file
given on the command line. Other than reading from
a file, it is exactly like Example 1.

EX2 TEST2A.DAT

where TEST2A.DAT is:

a = 1
b = 1
c = -6
x = (-b + sqrt(b*b - 4*a*c)) / (2*a)
x = (-b - sqrt(b*b - 4*a*c)) / (2*a)

EX2 TEST2B.DAT

This example is meant to test each of the
algebraic functions provided in a_solver.



EXAMPLE 3

Example 3 uses its own reserved words to show how
a program can be written around a_solver() to make
a mini-interpreter. Answers are only emitted after
the ANSWER command. The reserved words are:

COMMENT: message message is displayed on the
screen
SAVE: saves the previous value in a
file called SOLVE.ANS
REM: remark a remark in the data file
which is not displayed
ANSWER: text text is displayed on the
screen without a return
STORE: expression expression is stored for later
processing with SOLVE
SOLVE: solves the previously stored
expression












The terminating colon is required after the
reserved words.

These examples read the expressions from a file
given on the command line.



EX3 TEST3A.DAT

REM: These are the constants for the quadratic
equation

a = 1
b = 1
c = -6

REM: The two solutions are given below
ANSWER:x1 =

x = (-b + sqrt(b*b - 4*a*c)) / (2*a)

ANSWER:x2 =

x = (-b - sqrt(b*b - 4*a*c)) / (2*a)

SAVE:




EX3 TEST3B.DAT

where TEST3B.DAT is:

COMMENT: Solution to: ax^2 + bx + c = 0

STORE: x = (-b + sqrt(b*b - 4*a*c)) / (2*a)

REM: These are the first set of constants for
the quadratic equation
a = 1
b = 1
c = -6
ANSWER: First solution
SOLVE:

REM: These are the second set of constants for
the quadratic equation
a = 2
b = 1
c = -6
ANSWER: Second solution
SOLVE:

















EXAMPLE 4

This example shows the various angle modes which
can be used in A_SOLVER.


EX4 TEST4.DAT


REM: Example of angle modifiers which convert
angle usage
REM:
REM: RAD - radians (default)
REM: DEG - causes a_solver to use degrees as
angles
REM: GRD - causes a_solver to use grads as angles
REM:
COMMENT:These are the answers using RAD, DEG and
GRD
sin(pi/4)
rad sin(pi/4)
deg sin(45)
grd sin(50)
cos(50)
deg cos(45)
rad cos(pi/4)

The angle modifiers RAD, DEG and GRD change the
way a_solver processes angles in SIN, COS, TAN,
ASON, ACOS, and ATAN. Once the modifier is used
a_solver will continue to use that angle mode
until another modifier is used.



SOLVE.H contains the necessary error codes.

Compile EX1.C as:

cl -c ex1.c /Lr

Link with asolver.obj.


























A_SOLVER REGISTRATION FORM


Name________________________________________________

Company_____________________________________________

Address_____________________________________________

City, State, Zip____________________________________

Daytime telephone___________________________________


Send registration to:


Ryan Software
P.O. Box 1150
Twin Peaks, CA 92391

Likes, dislikes, features wanted, problems? List
below:


_________________________________________________________


_________________________________________________________


_________________________________________________________


_________________________________________________________


_________________________________________________________


_________________________________________________________













----------------end-of-author's-documentation---------------

Software Library Information:

This disk copy provided as a service of

The Public (Software) Library

We are not the authors of this program, nor are we associated
with the author in any way other than as a distributor of the
program in accordance with the author's terms of distribution.

Please direct shareware payments and specific questions about
this program to the author of the program, whose name appears
elsewhere in this documentation. If you have trouble getting
in touch with the author, we will do whatever we can to help
you with your questions. All programs have been tested and do
run. To report problems, please use the form that is in the
file PROBLEM.DOC on many of our disks or in other written for-
mat with screen printouts, if possible. The P(s)L cannot de-
bug programs over the telephone.

Disks in the P(s)L are updated monthly, so if you did not get
this disk directly from the P(s)L, you should be aware that
the files in this set may no longer be the current versions.

For a copy of the latest monthly software library newsletter
and a list of the 2,000+ disks in the library, call or write

The Public (Software) Library
P.O.Box 35705 - F
Houston, TX 77235-5705
(713) 665-7017



 December 8, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)