Skip to content

Polynomials

Kleb edited this page Mar 18, 2022 · 3 revisions

The polynomial class allows for storage and manipulation of polynomials.

Back to docs

Initialisation

A polynomial is initialised with polynomial.Polynomial(inputPolynomial, dictInput=False) where inputPolynomial is either a string of arbitrary size in form ax^n + bx + c (the terms can have any exponent and be in any order) or a dictionary in form {exponent1: coefficient1, exponent2: coefficient2}.

Manipulation

Polynomial support the use of the binary arithmetic operators +, -, +=, and -= to add and subtract the polynomials. Polynomial.differentiate() and Polynomial.integrate() return the differentiated and integrated forms of the polynomial respectively. Polynomial.integrateDefinite(upper, lower) returns the definite integral of the polynomial between upper and lower. Polynomial.output(readable=False) returns either the polynomial in the form ax^n + bx + c or the dictionary form of the polynomial, depending on the value of readable.

Back to docs

Clone this wiki locally