Stores coefficients indexed by the power or multidegree collected from an expression.

remarks

Expression.coeffs and Polynomial.coeffs use string keys. A univariate coefficient uses a key such as

`"2"`

; multivariate collection uses a comma-separated degree tuple such as

`"1,0"`

, in the same order as CoeffObject.variables. The object is mutable. The constructor retains the supplied

`variables`

array, and the public

`coeffs`

record exposes the stored expression references directly. Methods such as CoeffObject.toArray are intended for univariate numeric power keys; a multidegree key cannot be represented by that dense array form.

Members

add(key: string, value: Expression): voidMethod

Adds an expression to the coefficient stored at a degree key. A new key retains

`value`

by reference. An existing key is replaced with the expression returned by symbolic addition.

Parameters

NameTypeDescription
keystringPower or comma-separated multidegree key.
valueExpressionCoefficient contribution to accumulate.

Returns

void

coeffs: { … }Property

Mutable coefficient expressions keyed by power or comma-separated multidegree.

CoeffObject(variables: string[]): CoeffObjectConstructor

Creates an empty coefficient collection for the requested variable order.

Parameters

NameTypeDescription
variablesstring[]Variables used to interpret coefficient degree keys. The array is retained by reference.

Returns

CoeffObject

each(fn: (e: Expression, p: string): void): CoeffObjectMethod

Visits each stored coefficient and its degree key.

Parameters

NameTypeDescription
fn(e: Expression, p: string): voidCallback receiving the stored expression reference and key.

Returns

CoeffObject — This coefficient object for chaining.

getPower(p: string | number): ExpressionMethod

Returns the stored coefficient for a power or multidegree key.

Parameters

NameTypeDescription
pstring | numberKey to look up.

Returns

Expression — The internal expression reference, or `undefined` when the key is absent.

hasPower(p: string | number): booleanMethod

Tests whether a power or multidegree key is present, including an explicit zero.

Parameters

NameTypeDescription
pstring | numberKey to test.

Returns

boolean

max(): numberMethod

Returns the greatest numeric power key, or

`NaN`

when any key is non-numeric.

Returns

number

text(formatted: boolean): stringMethod

Formats the sparse coefficient record for inspection.

Parameters

NameTypeDescription
formattedbooleanAdd line breaks and indentation between entries.

Returns

string

toArray(): Expression[]Method

Converts univariate coefficients to a dense array indexed by power. Missing powers are filled with new zero expressions. With

`asNumber: true`

, each coefficient is converted using JavaScript numeric conversion, which may lose exact precision. The method does not remove or copy coefficients already stored here.

throws

NaNError Thrown when a key, such as a multidegree tuple, cannot be interpreted as a numeric univariate power.

Parameters

NameTypeDescription
asNumberfalse

Returns

Expression[]

toExpression(): ExpressionMethod

Reconstructs the stored coefficients as a native symbolic expression.

Returns

Expression

toParsableString(): stringMethod

Builds parser text representing the stored coefficient terms. Each degree key is interpreted using the configured variable order, including comma-separated multidegrees such as

`"2,1"`

for

`x^2*y`

.

Returns

string

toPolynomial(): PolynomialMethod

Reconstructs the coefficients as a Polynomial without reparsing ordinary terms. Coefficients that contain one of the configured polynomial variables are passed through the normal constructor so overlapping coefficient and monomial powers are canonicalized.

Returns

Polynomial — A new polynomial with independent terms and a synchronized expression.

toString(): stringMethod

No description is available yet.

Returns

string

toVector(): VectorMethod

Converts univariate coefficients to a dense Vector ordered by ascending power. Missing powers are represented by zero expressions.

Returns

Vector

variables: string[]Property

Variables whose order defines the degree keys in coeffs.