home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Troubleshooting Netware Systems
/
CSTRIAL0196.BIN
/
attach
/
pcc
/
v08n03
/
math.exe
/
SOLVEQ10.ZIP
/
SOLVEQ.DOC
< prev
next >
Wrap
Text File
|
1992-04-06
|
5KB
|
94 lines
===============================================================================
SOLVEQ.DOC
===============================================================================
SOLVEQ is a Turbo Pascal program that solves algebraic (polynomial)
equations. Its main procedure is called SolveEquation and it is in EQUATION
unit interface. The greatest degree allowed is MaxDegree = 30.
SolveEquation's syntax is
procedure SolveEquation(a: polynomial; option: byte; var answer: solutions)
where polynomial and solutions are the following records defined at
EQUATION interface:
polynomial = record
coef: array[0..MaxDegree + 1] of real; { equation's coefficients }
degree: byte; { equation's degree }
end;
complex = record
Re, Im: real;
method: string[5];
end;
solutions = record
x: array[1..MaxDegree] of complex; { equation's roots }
solved: boolean; { tells whether the resolution was successful }
end;
The value of the option parameter (0 or 1) limits some constants
values used during the resolution. The 0 option defines small values to some
constants and the 1 option greater values. With the 0 option the equation is
solved more quickly, but some equations can only be solved with the 1 option.
The degree and equation's coefficients must be furnished during
the execution of the program. The coefficients must be ordered following the
decreasing powers of 'x'. For example, the equation
8 7 6 4 2
x - 13 x + x - 10 x + 2 x - 5 x + 25 = 0
is solved, furnishing the following numbers as its coefficients
1 -13 1 0 -10 0 2 -5 25
In this case, will be showed an answer like
-----------------------------------------------------------------
# real part imaginary part test method
-----------------------------------------------------------------
1 0.7016937844 0.9499812958 R Brstw
2 0.7016937844 -0.9499812958 R Brstw
3 12.9272681736 0.0000000000 R Brstw
4 1.0083042182 0.0000000000 R Brstw
5 -1.0402275406 0.4352425025 R Brstw
6 -1.0402275406 -0.4352425025 R Brstw
7 -0.1292524396 1.0318542107 R SecDg
8 -0.1292524396 -1.0318542107 R SecDg
-----------------------------------------------------------------
Begin at 11:24:48:38 End at 11:24:49:32
All found solution is tested. If the 'test' column has a 'R' (from
Right) so the found solution was substituted in the equation and the result
is a complex number whose absolute value is less then error = 0.0000000001. If
appears an 'I' (from Inverse) in the test column means that 1/z substituted
n
in x p(1/x) gives a number whose modulus is less then error, and therefore,
z is really a root of p(x). If appears an 'E' (from Error) at the column
test, this means that something is not going well.
The method column shows which method was used to find that root:
Brstw (Bairstow's algorithm), Gauss (root in the form a + bi, a and b
integers), Ratnl (rational root), SecDg (2nd. degree equation), FstDg (1st.
degree equation), Integ (integer root), Subst (some substition of the form
n
y = x was used with some other algorithm).
The time when the resolution begins and finishes is shown in the
format hours:minutes:seconds:cents_seconds.
The program that uses the EQUATION unit must have the compiler direc-
tive {$E+,N+,F+} as one of the initial lines of the program.
See the simple source program EQDEMO.PAS showing how to use the
procedure or type mentionated above.
All the procedures or data types mentionated before are only a
small part of the Computational Linear Algebra Project, that is a colection
of programs in permanent evolution. It's probabily available at the same
place you got these files. Any comment or hint will be apreciated if you
send them to CCENDM03@BRUFPB.BITNET.
===============================================================================