# Category : C Source Code

Archive : ASOLVER.ZIP

Filename : ASOLVER.DOC

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

Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/