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

Polynomial : ArrayedCollection : SequenceableCollection : Collection : Object

various methods for polynomial math operations


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


From superclass: Collection

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



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


Expands an array of first degree binomial factors.



Factors to expand.


Instance a reverse Bessel polynomial of the given degree.1

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



Polynomial degree

Inherited class methods

Instance Methods


Synomyn for Object: -class.


Returns the degree of the polynomial.


Returns true if the polynomial is a monomial.


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.


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)


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


Evaluate the polynomial at the (complex) point x.


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


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.



Root finding method.

\laguerreLaguerre's method
\eigenvalueEigenvalue algorithm


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




Michael Dzjaparidze, 2010. Joseph Anderson, 2019.