Sparse polynomial with bigint coefficients and bigint exponents. The variable count is part of the polynomial rather than inferred from its support. Exponent vectors therefore have one exact entry for every variable, including zero polynomials and constants. The internal map key is an encoding detail and is never exposed or parsed by polynomial algorithms.

Members

coefficient(exponents: readonly bigint[]): bigintMethod

Returns the coefficient of one monomial.

Parameters

NameTypeDescription
exponentsreadonly bigint[]Exact exponent vector for the requested monomial.

Returns

bigint

coefficientIn(variableIndex: number, exponent: bigint): SparsePolynomialMethod

Returns the coefficient polynomial at one exact power of a selected variable. The selected variable remains in the ring with exponent zero so recursive algorithms can preserve the original coordinate layout.

Parameters

NameTypeDescription
variableIndexnumber—
exponentbigint—

Returns

SparsePolynomial

compareMonomials(a: readonly bigint[], b: readonly bigint[], order: MonomialOrder): numberMethod

Compares exponent vectors using the three global monomial orders required by the polynomial algorithms.

Parameters

NameTypeDescription
areadonly bigint[]—
breadonly bigint[]—
orderMonomialOrder—

Returns

number

constant(variableCount: number, coefficient: bigint): SparsePolynomialMethod

Creates a constant polynomial in a ring with variableCount variables.

Parameters

NameTypeDescription
variableCountnumber—
coefficientbigint—

Returns

SparsePolynomial

constantTerm(): bigintMethod

Returns the constant coefficient, or zero when the constant monomial is absent.

Returns

bigint

SparsePolynomial(variableCount: number, terms: Iterable<Readonly<{ … }>>): SparsePolynomialConstructor

Creates a sparse polynomial in a ring with a fixed number of variables. Duplicate monomials are combined and zero coefficients are removed.

Parameters

NameTypeDescription
variableCountnumberNumber of variables in the polynomial ring.
termsIterable<Readonly<{ … }>>Terms with exponent vectors of exactly variableCount entries.

Returns

SparsePolynomial

content(): bigintMethod

Returns the positive greatest common divisor of all coefficients. The zero polynomial has coefficient content zero.

Returns

bigint

degree(variableIndex: number): bigint | nullMethod

Returns the degree in one variable. The zero polynomial has no degree and returns null.

Parameters

NameTypeDescription
variableIndexnumber—

Returns

bigint | null

derivative(variableIndex: number): SparsePolynomialMethod

Differentiates with respect to one ring variable. Coefficients and exponents stay in bigint arithmetic, including exponents above JavaScript's safe-integer range.

Parameters

NameTypeDescription
variableIndexnumber—

Returns

SparsePolynomial

divideByScalarExact(divisor: bigint): SparsePolynomialMethod

Divides all coefficients by an integer scalar.

throws

RangeError When the scalar is zero or does not divide every coefficient.

Parameters

NameTypeDescription
divisorbigint—

Returns

SparsePolynomial

divideExact(divisor: SparsePolynomial, order: MonomialOrder): SparsePolynomial | nullMethod

Divides by one polynomial using exact integer coefficient arithmetic. Returns null as soon as the current leading term is not exactly divisible by the divisor leading term. A successful result therefore has zero remainder in the selected monomial order.

Parameters

NameTypeDescription
divisorSparsePolynomial—
orderMonomialOrder—

Returns

SparsePolynomial | null

equals(other: SparsePolynomial): booleanMethod

Returns whether both polynomials have the same ring and exact nonzero terms.

Parameters

NameTypeDescription
otherSparsePolynomial—

Returns

boolean

evaluateVariable(variableIndex: number, value: bigint): SparsePolynomialMethod

Substitutes one variable with an exact integer while retaining the same ring. Terms that become like terms after substitution are combined in the result.

Parameters

NameTypeDescription
variableIndexnumber—
valuebigint—

Returns

SparsePolynomial

evaluateVariables(variableIndices: readonly number[], values: readonly bigint[]): SparsePolynomialMethod

Substitutes several variables with exact integers in one sparse traversal. The selected coordinates remain in the polynomial ring with exponent zero.

Parameters

NameTypeDescription
variableIndicesreadonly number[]—
valuesreadonly bigint[]—

Returns

SparsePolynomial

isConstant(): booleanMethod

Returns whether the polynomial is zero or contains only a constant term.

Returns

boolean

isZero(): booleanMethod

Returns whether the polynomial has no nonzero terms.

Returns

boolean

leadingCoefficientIn(variableIndex: number): SparsePolynomial | nullMethod

Returns the coefficient polynomial of the highest power of one variable. The selected coordinate remains present with exponent zero.

Parameters

NameTypeDescription
variableIndexnumber—

Returns

SparsePolynomial | null

leadingTerm(order: MonomialOrder): Readonly<{ … }> | nullMethod

Returns the leading term under the requested monomial order. Variable priority follows exponent-vector index order.

Parameters

NameTypeDescription
orderMonomialOrder—

Returns

Readonly<{ … }> | null

mapCoefficients(mapper: (coefficient: bigint): bigint): SparsePolynomialMethod

Applies an exact bigint transformation to every stored coefficient while preserving the existing monomial keys and exponent vectors.

Parameters

NameTypeDescription
mapper(coefficient: bigint): bigint—

Returns

SparsePolynomial

maxAbsoluteCoefficient(): bigintMethod

Returns the largest absolute coefficient, or zero for the zero polynomial.

Returns

bigint

monomial(variableCount: number, coefficient: bigint, exponents: readonly bigint[]): SparsePolynomialMethod

Creates a one-term polynomial.

Parameters

NameTypeDescription
variableCountnumber—
coefficientbigint—
exponentsreadonly bigint[]—

Returns

SparsePolynomial

monomialScaleSubtract(leftScalar: bigint, leftMonomialExponents: readonly bigint[], other: SparsePolynomial, rightScalar: bigint, rightMonomialExponents: readonly bigint[]): SparsePolynomialMethod

Computes the difference of two monomial-scaled polynomials in one sparse traversal. This avoids constructing the monomial factors and multiplication results used by fraction-free S-polynomials.

Parameters

NameTypeDescription
leftScalarbigint—
leftMonomialExponentsreadonly bigint[]—
otherSparsePolynomial—
rightScalarbigint—
rightMonomialExponentsreadonly bigint[]—

Returns

SparsePolynomial

multiply(other: SparsePolynomial): SparsePolynomialMethod

Multiplies by another polynomial in the same ring. Monomial exponents are added as bigints. The constructor combines products that land on the same monomial and removes coefficients that cancel to zero.

Parameters

NameTypeDescription
otherSparsePolynomial—

Returns

SparsePolynomial

pow(exponent: bigint): SparsePolynomialMethod

Raises the polynomial to a non-negative exact integer power.

Parameters

NameTypeDescription
exponentbigint—

Returns

SparsePolynomial

scale(scalar: bigint): SparsePolynomialMethod

Multiplies every coefficient by an exact integer scalar.

Parameters

NameTypeDescription
scalarbigint—

Returns

SparsePolynomial

scaleSubtractMonomial(leftScalar: bigint, other: SparsePolynomial, rightScalar: bigint, monomialExponents: readonly bigint[]): SparsePolynomialMethod

Computes a scaled subtraction where the right polynomial is also multiplied by one monomial. This avoids constructing the two scaled intermediate polynomials used by fraction-free reduction.

Parameters

NameTypeDescription
leftScalarbigint—
otherSparsePolynomial—
rightScalarbigint—
monomialExponentsreadonly bigint[]—

Returns

SparsePolynomial

termCount(): numberAPI

Number of stored nonzero terms.

Returns

number

terms(): readonly Readonly<{ … }>[]Method

Returns a copy of the stored terms. The exponent arrays themselves are frozen so callers cannot alter polynomial storage.

Returns

readonly Readonly<{ … }>[]

totalDegree(): bigint | nullMethod

Returns the largest total degree among the stored monomials. The zero polynomial has no total degree and returns null.

Returns

bigint | null

variable(variableCount: number, variableIndex: number): SparsePolynomialMethod

Creates the variable at variableIndex with coefficient one.

Parameters

NameTypeDescription
variableCountnumber—
variableIndexnumber—

Returns

SparsePolynomial

variableCount: numberProperty

No description is available yet.

variables(): readonly number[]Method

Returns the variable indices that occur with a positive exponent.

Returns

readonly number[]

zero(variableCount: number): SparsePolynomialMethod

Creates the zero polynomial in a ring with variableCount variables.

Parameters

NameTypeDescription
variableCountnumber—

Returns

SparsePolynomial