This class represents Laurent polynomials with terms of integer (positive or negative) powers and rational coefficients.
The polynomial Axn +Bxn+1 + Cxn+2 ....... +Qxn+p is represented by
You can construct LPs explicitly with any of the following constructors.
For example, new LP([1,1]) would define the polynomial 1+x.
new LP(4,[1,3,3,1]) would define the polynomial (1+3x+3x2+x3)/4
The following methods are provided for carrying out arithmetic on LPs. They are expressed as methods of a current LP, and take another LP as argument.
The following functions return useful properties of the polynomial.
A.spread(a) returns the LP which has the same coefficients applied as the polynomial of the ath power of the abscissa. Thus if A is 1+2x+x2, A.spread(3) returns the polynomial 1 +2x3 + x6
A.norm() returns a normalized version of A.
i.e. A is represented with no leading or trailing zero numerator terms (unless it is the zero polynomial, which has a single zero term), and with the smallest possible denominator
All of the arithmetic functions returning LPs return normalised LPs.
A.scalar() returns true if A has only one term.
A.zeropoly() returns true if A is the zero polynomial.
A.print() prints out the representations of the components of A on the output stream. Note that this cannot be used in an applet, but may help in debugging of the java code before it is invoked as an applet.
A.prl(String) prints out the representation of A on the output stream as a single line. The format produced is n: [t]/d, where n is the leading power, [t] is the sequence of numerator coefficients, and d is the denominator. This cannot be used in an applet either.
Rational scalars are represented as polynomials of just one term, with n=0.
The unit polynomial is represented as a rational scalar with its numerator equal to its denominator.
The zero polynomial is represented as a rational scalar with a zero numerator. (not as an empty polynomial with no terms.)
Division is an interesting operation for these polynomials.
We use the version which assumes that often n=0, and we are looking for a remainder which also has n=0. i.e. we repeatedly subtract appropriate multiples of the divisor to zeroise high degree terms of the dividend.
The result satisfies the definition A = Q*F + R where R.p ≤ F.p-1 and R.n = A.n
Most operations (but not the constructors) return a normalised representation, in which there are no leading or trailing zero terms, and the numerators and denominator are reduced by cancelling out any common factors.
The numerators and denominators are held as long integers, capable of holding numbers up to the 63rd power of 2. This is about 8,000,000,000,000,000,000