ASCIIMath rendering of the current state (terminal output, not chainable).
Number of monoms.
Number of distinct variables.
Expression to give to a plotting tool: explicit * between a coefficient and its variables.
LaTeX rendering of the current state (terminal output, not chainable).
Numeric value of a constant polynom, or undefined when the degree is not zero.
The variables of the polynom, sorted alphabetically.
Add polynoms, monoms, numbers or strings, then reduce. Modifies and returns the receiver.
A string is read as a polynom ("2x+1").
Every operand is built before the receiver is touched: an invalid value throws and leaves it unchanged.
Greatest monom dividing every term: gcd of the numerators over gcd of the denominators, and the lowest
exponent of each variable (2x^3+6x^2 gives 2x^2).
Degree of the polynom as a fraction. Without variable, the highest total degree of a term; with one, the
highest exponent of that variable.
Optionalvariable: stringDerivative with respect to variable (default x), as a new reduced polynom.
Optionalvariable: stringDivide in place. Polynom division is only defined when it is exact.
Remove every monom. Unlike zero, which holds the monom 0, the polynom then has no term at all.
Euclidean division of this polynom by P.
the quotient and the remainder.
Value of the polynom for given values of its variables.
a dictionary {x: 2, y: 3}, or one value for a single-variable polynom.
true returns a number, otherwise the exact Fraction.
Value of the polynom for given values of its variables.
a dictionary {x: 2, y: 3}, or one value for a single-variable polynom.
OptionalasNumeric: false
true returns a number, otherwise the exact Fraction.
Value of the polynom for given values of its variables.
a dictionary {x: 2, y: 3}, or one value for a single-variable polynom.
OptionalasNumeric: boolean
true returns a number, otherwise the exact Fraction.
Factorize a polynom with respect to a single variable and store the best
results in factors. The variable is the explicit variable, else the sole
variable of a single-variable polynom, else the default variable. Multi-variable factorization (treating other variables as
symbolic constants) is not supported — the numeric solver cannot represent
roots that depend on other variables.
Optionalvariable: stringGreatest common divisor of the denominators of the coefficients.
Greatest common divisor of the numerators of the coefficients.
Coefficients from the highest degree down to the constant term (zeros included). Assumes a single variable.
Denominator of the coefficient of each monom, in the order of the monoms.
Numerator of the coefficient of each monom, in the order of the monoms.
Whether the polynom contains a cross-term monom (a single monom carrying
more than one variable, such as xy).
True when the variable appears in a term with a non-zero exponent.
Definite integral between a and b, as a fraction. The variable is resolved like in limitTo:
the one passed, else the only variable of the polynom, else the default variable.
Optionalvariable: stringTrue when the division by div leaves no remainder. A degree-1 divisor is tested through its root.
True when both polynoms are equal once reduced and sorted: same terms, same coefficients.
True for the constant polynom 1.
True when both polynoms have the same terms, whatever their coefficients (x^2+x and 3x^2-5x).
True for the zero polynom (no term, or the single term 0).
Least common multiple of the denominators of the coefficients.
Least common multiple of the numerators of the coefficients.
Limit of the polynom as its variable approaches value. An infinite
value returns a signed infinite Fraction, determined by the leading term
(and the degree parity at -∞).
Optionalvariable: stringFirst monom that contains variable, or the zero monom when none does.
Multiply by polynoms, monoms, fractions, numbers or strings, then reduce. Modifies and returns the receiver.
A string is read as a polynom ("x+3").
Every operand is built before the receiver is touched: an invalid value throws and leaves it unchanged.
Set the polynom to the constant 1.
Change the sign of every term.
Route an input to the matching from*** builder. This method only
dispatches on the input's type/format; it never inlines construction.
A primitive with respect to variable (default x), without integration constant.
Optionalvariable: stringAdd the similar terms, remove the zero terms, reduce the coefficients and sort by decreasing degree.
Sort the monoms by decreasing degree of variable (default: the default variable of the polynom), or by
increasing degree when revert is true. The other variables break the ties.
Optionalvariable: stringSubtract polynoms, monoms, numbers or strings, then reduce. Modifies and returns the receiver.
A string is read as a polynom ("x-1").
Every operand is built before the receiver is touched: an invalid value throws and leaves it unchanged.
Set the polynom to zero.
StaticfromBuild a polynom from coefficients ordered highest→lowest degree.
The first argument is the variable (e.g. 'x', 't').
StaticfromStaticfromBuild a multivariate linear polynom: 'xyz', a, b, c, d → ax + by + cz + d.
StaticfromBuild a polynom from monoms, or from anything a monom accepts (numbers, strings, fractions). The result is neither reduced nor sorted: call reduce.
StaticfromBuild a polynom from an expression: sums, products, integer powers, and division by a constant.
StaticfromBuild the polynom of degree at most 2 passing through three points, using Newton divided differences.
The result is exact (fractions). When the three points are aligned, the result is a line
(degree 1), or a constant when the three y are equal.
First point {x, y}.
Second point {x, y}.
Third point {x, y}.
Variable of the result, a single lowercase letter (default 'x').
StaticxProduct of the given values, as a new polynom.
A polynomial in one or several variables: a list of Monoms kept reduced and sorted by decreasing degree. Built from a string (
"x^2-5x+6","(x+1)^2"), a number, a monom, or from coefficients (new Polynom("x", 1, -5, 6)). A malformed string throws aParseError. Operations modify the polynom and return it;clone()keeps the original. A failing operation leaves it unchanged.Example