math.poly
polynomials written as coefficient lists: evaluate, multiply, divide, differentiate and find roots
Polynomials, like 2x² - 3x + 5, written as a list of coefficients from the highest power down: [2, -3, 5].
good to know
Section titled “good to know”Whole-number and fraction coefficients give exact answers, except for finding roots, which is always numeric.
Tags: algebra
poly_evalthe polynomial’s value at x, from its coefficients highest power firstpoly_multhe product of two polynomialspoly_divdivide polynomial a by b, giving the list [quotient, remainder]poly_derivthe derivative of a polynomial, as a coefficient listpoly_rootsevery root of the polynomial, real or complex, found numerically
Functions
Section titled “Functions”poly_eval
Section titled “poly_eval”poly_eval(p: list, x: any) -> any
the polynomial’s value at x, from its coefficients highest power first
1poly_eval([2, -3, 5], 4)25See also poly_roots, poly_deriv
poly_mul
Section titled “poly_mul”poly_mul(a: list, b: list) -> list
the product of two polynomials
1poly_mul([1, 1], [1, -1])[1, 0, -1]See also poly_div
poly_div
Section titled “poly_div”poly_div(a: list, b: list) -> list
divide polynomial a by b, giving the list [quotient, remainder]
1poly_div([1, 0, -1], [1, -1])[[1, 1], [0]]2poly_div([1, 2, 3], [1, 1])[[1, 1], [2]]See also poly_mul
poly_deriv
Section titled “poly_deriv”poly_deriv(p: list) -> list
the derivative of a polynomial, as a coefficient list
1poly_deriv([3, 2, 1])[6, 2]See also poly_eval
poly_roots
Section titled “poly_roots”poly_roots(p: list) -> list
every root of the polynomial, real or complex, found numerically
Real roots come back as plain numbers
1poly_roots([1, -3, 2])[1, 2]2poly_roots([1, 0, 1])[-1i, 1i]More examples
Section titled “More examples”1# 2x² - 3x + 5 at x = 42poly_eval([2, -3, 5], 4)253# the roots of x² - 3x + 24poly_roots([1, -3, 2])[1, 2]5# (x + 1)(x - 1)6poly_mul([1, 1], [1, -1])[1, 0, -1]7# divide x² - 1 by x - 1, as quotient and remainder8poly_div([1, 0, -1], [1, -1])[[1, 1], [0]]Example results generated on 2026-11-04. Ones using now, today or randomness will differ when you run them.