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

Polynomial
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

.newFrom

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

.expandBinomialFactors

Expands an array of first degree binomial factors.

Arguments:

factors

Factors to expand.

.newReverseBessel

Instance a reverse Bessel polynomial of the given degree.1

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

Arguments:

degree

Polynomial degree

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.

*

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

/

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

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

Evaluate the polynomial at the (complex) point x.

.evalDerivs

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

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.

Examples

Authors

Michael Dzjaparidze, 2010. Joseph Anderson, 2019.