Polynomial:
Filter:
Classes (extension) | Math | Libraries > MathLib > Polynomials & Special

Polynomial : ArrayedCollection : SequenceableCollection : Collection : Object
ExtensionExtension

various methods for polynomial math operations

Description

A class which makes possible various elementary polynomial math operations. Included are arithmetic methods like multiplication and division, (complex) root finding and evaluation at a specific point for arbitrary degree polynomials. All methods should work for real as well as complex coefficients.

Part of MathLib, a diverse library of mathematical functions.

NOTE: for all binary arithmetic operations to give valid results, it is necessary that both coefficient arrays are of the same size. This means that in some cases it will be necessary to pad a coefficient array with zeros until it matches the other coefficient array in size. See the / operation for an example.

Class Methods

Polynomial.newFrom(aCollection)

From superclass: Collection

Creates a new instance of Polynomial. Returned is a polynomial of a degree equal to the number of coefficients minus one.

Arguments:

aCollection

The coefficients need to be supplied in increasing order: a_0, a_1, a_2 ... a_n-1, a_n

Polynomial.expandBinomialFactors(factors)

Expands an array of first degree binomial factors.

Arguments:

factors

Factors to expand.

Polynomial.newReverseBessel(degree)

Instance a reverse Bessel polynomial of the given degree.1

NOTE: Coefficients are instanced as Float to avoid numerical overflow.

Arguments:

degree

Polynomial degree

Inherited class methods

Instance Methods

.species

Synomyn for Object: -class.

.degree

Returns the degree of the polynomial.

.isMonomial

Returns true if the polynomial is a monomial.

.isBinomial

Returns true if the polynomial is a binomial.

*(c2)

Calculate the product of two polynomials by convolving the original coefficient sequences.

/(c2)

Divide two polynomials using synthetic division. The degree of the numerator polynomial needs to be greater than or equal to the degree of the denominator polynomial.

Returns:

An Array containing the remainder in the first slot and the quotient in the second slot, where: P(z) / D(z) = Q(z) + R(z) / D(z)

.pow(n)

Calculate the n'th power of a polynomial. Negative, complex or fractional powers are allowed for binomials with the a_0 coefficient equal to one in order to calculate the binomial series which converges for: |z| < 1

.eval(x)

Evaluate the polynomial at the (complex) point x.

.evalDerivs(x)

Evaluate the polynomial and all of its derivatives at the (complex) point x.

Returns:

An Array containing the results. Slot zero contains the function value and subsequent slots are filled with the values of all existing derivatives.

.findRoots(method: 'laguerre')

Find all the roots of the polynomial.

Arguments:

method

Root finding method.

\laguerreLaguerre's method
\eigenvalueEigenvalue algorithm

Discussion:

Laguerre's method works for polynomials with real as well as complex coefficients.

Another option is to use the Eigenvalue algorithm to form the companion matrix which eigenvalues coincide with the roots of the polynomial. Although this method is more reliable than the first one, it is considerably slower and only works for polynomials with real coefficients.

Inherited instance methods

Undocumented instance methods

.offLow

Examples

Authors

Michael Dzjaparidze, 2010. Joseph Anderson, 2019.