home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 52
/
Amiga_Dream_52.iso
/
Amiga
/
Applications
/
Mathematiques
/
Newton.lha
/
Newton
/
README
< prev
next >
Wrap
Text File
|
1988-11-22
|
4KB
|
111 lines
########################################################################
# Newton: Estimate the roots of a polynomial equation.
# Author: Dan Barrett, barrett@cs.jhu.edu (ARPAnet).
# 100% PUBLIC DOMAIN, both source code & executable.
#
# Written for the Commodore Amiga, September 1988.
# Runs from the CLI only.
# Also compiles & runs under Berkeley UNIX 4.2.
########################################################################
What is Newton?
---------------
Given a polynomial equation F(x) = 0, Newton estimates the
roots of the equation. The program uses an algorithm known as
"Newton's Method". You can read about the specifics in any college
textbook on Numerical Analysis.
How is it used?
---------------
From the CLI, type "newton", followed by <RETURN>.
You will be prompted for the degree of the polynomial equation.
The degree is the largest exponent in the equation. The maximum
allowable degree is 20. You can change this in the source code
by changing the value of MAX_DEGREE in decl.h.
Next, you are prompted for the "desired accuracy". Since
Newton's Method is a "numerical" method, the answers you get are
only estimates of the actual value.
The accuracy is a measure of how close an estimate must
be before it is considered "correct". In mathematical language,
the Euclidean distance (in the complex plane) between the current
estimate and the previous estimate must not exceed the "accuracy".
In the source code, the variable "epsilon" represents the
accuracy. See also the function ErrorTooBig(), which actually tests
the accuracy of the latest estimate.
To choose the default accuracy, simply press <RETURN>. Otherwise,
type in your desired accuracy. The smaller the value, the more accurate
your result (and the longer the program will run).
Finally, you are prompted for your polynomial coefficients.
For example, when you are asked:
X^5 coefficient?:
you should type in the coefficient of your X-to-the-5th-power term.
Coefficients may be real or complex numbers. If the coefficient
is real, simply type it in and press <RETURN>. If the coefficient is
complex, type in its real and imaginary parts, separated by spaces
and/or tabs, and press <RETURN>.
"Real" example:
X^5 coefficient?: 6.33 <RETURN>
"Complex" example, for the complex value -5 + 0.43i :
X^5 coefficient?: -5 0.43 <RETURN>
Note that you must type in EVERY coefficient, even if it is a zero.
While you are entering coefficients, you can type "H", "h", or "?"
for a brief "help" message.
Now What Happens?
-----------------
First, "Newton" will display your polynomial, as you typed
it in.
Then, "Newton" will calculate the roots of your polynomial
equation.
This calculation might take some time (a few minutes), depending
on the degree of the equation and the desired accuracy. Higher accuracy
takes more time, as you might guess. Sometimes, the calculation takes
only a few seconds.
Since "Newton" uses a numerical algorithm, there is the possibility
that it will not find a solution. If "Newton" cannot find the value of
a root after 10,000 iterations, it will report failure. (This number
of iterations is set in decl.h as MAX_ITERATIONS... feel free to change
it.)
So, if "Newton" seems to be sitting there not doing anything,
don't panic. After a few minutes, it will either find a solution
or quit automatically.
Compiling Information
---------------------
The enclosed "Makefile" is for use with Aztec Manx C, V3.6a.
"Newton" probably compiles & runs under Lattice C, though I can't
test it.
Math (floating point) calculations can be handled in three
different ways. Edit the Makefile and uncomment the desired
CFLAGS and LIBS parameters. They are explained in the Makefile itself.
See also the "New Options For CC" page (cc.ap.1, V3.4a) in the Manx
C manual.
The enclosed "Makefile.unix" is for compiling "Newton" under
UNIX (Berkeley UNIX 4.2 or Ultrix). It does not use strtok.c; I am
assuming that your UNIX has the strtok() function provided.