Polynomial.Mesa
Copyright Ó 1985, 1992 by Xerox Corporation. All rights reserved.
Operations for dealing with univariate polynomials with real coefficients.
Michael Plass, August 18, 1983 3:20 pm
Tim Diebert May 21, 1985 5:52:03 pm PDT
Polynomial: CEDAR DEFINITIONS = BEGIN
Ref: TYPE = REF PolynomialRec;
PolynomialRec: TYPE = RECORD
[Coeff: SEQUENCE maxDegreePlusOne:NAT OF REAL];
RealRootRec: TYPE = RECORD [nRoots: NAT, realRoot: SEQUENCE n:NAT OF REAL];
ShortRealRootRec: TYPE = RECORD [nRoots: NAT, realRoot: ARRAY [0..5) OF REAL];
DivideResult: TYPE = RECORD [quotient, remainder: Ref];
Create: PROC [maxDegree: NAT] RETURNS [Ref]; -- returns a zero polynomial
Degree: PROC [poly: Ref] RETURNS [NAT]; -- for finding what the degree really is
Eval: PROC [f: Ref, x: REAL] RETURNS [REAL];
Copy: PROC [dest, source: Ref]; -- MaxDegree[dest] <= Degree[source]
The following are useful for creating polynomials of low degree.
Constant: PROC[ARRAY [0..0] OF REAL] RETURNS [Ref];
Linear: PROC[ARRAY [0..1] OF REAL] RETURNS [Ref];
Quadratic: PROC[ARRAY [0..2] OF REAL] RETURNS [Ref];
Cubic: PROC[ARRAY [0..3] OF REAL] RETURNS [Ref];
Quartic: PROC[ARRAY [0..4] OF REAL] RETURNS [Ref];
Quintic: PROC[ARRAY [0..5] OF REAL] RETURNS [Ref];
Add: PROC [dest, source: Ref];
Sum: PROC [a, b: Ref] RETURNS [Ref];
Subtract: PROC [dest, source: Ref];
Difference: PROC [a, b: Ref] RETURNS [Ref];
Product: PROC [a, b: Ref] RETURNS [Ref];
Divide: PROC [a, b: Ref] RETURNS [DivideResult];
DivideByLinear: PROC [f: Ref, c: REAL] RETURNS [value: REAL];
replaces f by f DIV (x-c)
Gcd: PROC [a, b: REF] RETURNS [Ref];
Differentiate: PROC [poly: Ref];
Derivative: PROC [poly: Ref] RETURNS [Ref];
EvalDeriv: PROC [f: Ref, x: REAL] RETURNS [REAL];
Integrate: PROC [poly: Ref]; -- watch out for growing degrees
Integral: PROC [poly: Ref] RETURNS [Ref];
EvalIntegral: PROC [f: Ref, x: REAL] RETURNS [REAL]; -- Definite integral from 0 to t
RealRoots: PROC [poly: Ref] RETURNS [REF RealRootRec];
CheapRealRoots: PROC [poly: Ref] RETURNS [ShortRealRootRec];
For when the degree is five or less.
END.