Poly

Poly

Poly Class Represents a Polynomial or a Truncated Power Series using sparse storage.

Storage Strategy:

  • Sparse representation: Two parallel arrays, degs (degrees) and coefs (coefficients).
  • Coefficients are generic types (BigFloat, Complex) supporting arithmetic interfaces.
  • order (property o): The truncation order O(X^n).
    • If Infinity, it represents an exact polynomial.
    • If a number n, terms with degree >= n are discarded.

Constructor

new Poly(degs, coefs, orderopt, coefTypeopt)

Source:
Properties:
Name Type Description
degs Array.<number>

Array of degrees (integers).

coefs Array.<any>

Array of coefficients corresponding to degrees.

o number

Truncation order O(X^n).

coefType function

The coefficient type constructor.

Parameters:
Name Type Attributes Default Description
degs Array.<number>

Array of degrees (integers).

coefs Array.<any>

Array of coefficients corresponding to degrees.

order number <optional>
Infinity

Truncation order O(X^n).

coefType function <optional>
bf

the coef type

Classes

Poly

Members

denseCoefs

Description:
  • Returns a dense array of coefficients up to the highest degree. Note: Throws if polynomial contains negative powers. Use offsetCoefs for Laurent series.

Source:

Returns a dense array of coefficients up to the highest degree. Note: Throws if polynomial contains negative powers. Use offsetCoefs for Laurent series.

offsetCoefs

Description:
  • Returns a dense array of coefficients along with the valuation offset. Supports negative degrees.

Source:

Returns a dense array of coefficients along with the valuation offset. Supports negative degrees.

Methods

acos() → {Poly}

Description:
  • Arccosine: acos(P(x)) acos(P) = PI/2 - asin(P)

Source:
Returns:
Type
Poly

add(other) → {Poly}

Description:
  • Adds two polynomials.

Source:
Parameters:
Name Type Description
other Poly | number | any
Returns:
Type
Poly

asin() → {Poly}

Description:
  • Arcsine: asin(P(x)) asin(P) = int( P' / sqrt(1 - P^2) ) + asin(P(0))

Source:
Returns:
Type
Poly

atan() → {Poly}

Description:
  • Arctangent: atan(P(x)) atan(P) = int( P' / (1 + P^2) ) + atan(P(0))

Source:
Returns:
Type
Poly

cos() → {Poly}

Description:
  • Cosine: cos(P(x)) cos(c0 + V) = cos(c0)cos(V) - sin(c0)sin(V)

Source:
Returns:
Type
Poly

degree() → {number}

Description:
  • Returns the Degree (highest non-zero term).

Source:
Returns:
  • -1 if zero polynomial.
Type
number

deriv() → {Poly}

Description:
  • Derivative d/dx ( c * x^k ) = (c*k) * x^(k-1)

Source:
Returns:
Type
Poly

div(other, defaultLimitopt) → {Poly}

Description:
  • Division: A / B Supports Exact Polynomials (Euclidean/Laurent) and Truncated Series.

    Logic: Uses "Synthetic Division" from lowest degree upwards (Series Division).

    • If both A and B are Exact (Order=Infinity):
      • Tries to divide exactly.
      • If remainder becomes 0, returns Exact result (Order=Infinity).
      • If infinite expansion (e.g. 1/(1-x)), stops at defaultLimit and returns Series (Order=Limit).
    • If one/both are Series (Finite Order):
      • Calculates terms up to the theoretical precision limit.
Source:
Parameters:
Name Type Attributes Default Description
other Poly
defaultLimit number <optional>
100

Max terms to calculate for infinite exact expansions.

Returns:
Type
Poly

equals(other, cmpopt) → {boolean}

Description:
  • Checks equality with another polynomial or scalar.

Source:
Parameters:
Name Type Attributes Description
other Poly | number | BigFloat | Complex

The object to compare with.

cmp function <optional>

Optional comparator (a, b) => boolean. Defaults to checking a.equals(b) or strict equality.

Returns:
Type
boolean

eval(x) → {any}

Description:
  • Evaluates the polynomial at x. P(x) = sum( c_i * x^i )

Source:
Parameters:
Name Type Description
x number | BigFloat | Complex
Returns:
Type
any

exp() → {Poly}

Description:
  • Exponential Function: e^P(x) e^(c0 + V) = e^c0 * e^V e^V = 1 + V + V^2/2! + V^3/3! + ...

Source:
Returns:
Type
Poly

integ() → {Poly}

Description:
  • Formal Integration int ( c * x^k ) = (c / (k+1)) * x^(k+1) Constant term set to 0.

Source:
Returns:
Type
Poly

log() → {Poly}

Description:
  • Natural Logarithm: ln(P(x)) Uses Derivative-Integration method: ln(P) = int( P' / P ) dx + ln(P(0))

Source:
Returns:
Type
Poly

mul(other) → {Poly}

Description:
  • Multiplies two polynomials.

Source:
Parameters:
Name Type Description
other Poly | number | any
Returns:
Type
Poly

neg() → {Poly}

Description:
  • Negates the polynomial.

Source:
Returns:
Type
Poly

operatorAdd()

Source:

operatorDiv()

Source:

operatorMul()

Source:

operatorNeg()

Source:

operatorPow()

Source:

operatorSub()

Source:

pow(n, dopt) → {Poly}

Description:
  • Power: P(x)^n

Source:
Parameters:
Name Type Attributes Default Description
n number

The exponent.

d number <optional>
1

The denominator of the exponent.

Returns:
Type
Poly

powSeries(n, dopt) → {Poly}

Description:
  • Power for Series: P(x)^(n/d) Supports negative and fractional powers.

    Requirements:

    1. Must be a Series (Order != Infinity).
    2. Resulting valuation must be integer.
Source:
Parameters:
Name Type Attributes Default Description
n number

Numerator

d number <optional>
1

Denominator

Returns:
Type
Poly

sin() → {Poly}

Description:
  • Sine: sin(P(x)) sin(c0 + V) = sin(c0)cos(V) + cos(c0)sin(V)

Source:
Returns:
Type
Poly

sub(other) → {Poly}

Description:
  • Subtracts two polynomials.

Source:
Parameters:
Name Type Description
other Poly | number | any
Returns:
Type
Poly

tan() → {Poly}

Description:
  • Tangent: tan(P(x)) tan(P) = sin(P) / cos(P)

Source:
Returns:
Type
Poly

toString(radixopt, precisionopt, prettyopt) → {string}

Description:
  • Converts the polynomial to a string representation.

Source:
Parameters:
Name Type Attributes Default Description
radix number <optional>
10
precision number <optional>
20
pretty boolean <optional>
true

pretty print

Returns:
Type
string

valuation() → {number}

Description:
  • Returns the "Valuation" (degree of the lowest non-zero term).

Source:
Returns:
  • Infinity if Exact Zero, or n if O(X^n).
Type
number

(static) O(n, coefTypeopt) → {Poly}

Description:
  • Creates a Big-O term O(X^n).

Source:
Parameters:
Name Type Attributes Default Description
n number

The order of the truncation.

coefType function <optional>
BigFloat

The coefficient type.

Returns:
Type
Poly

(static) X(nopt, coefTypeopt) → {Poly}

Description:
  • Creates a polynomial representing X^n.

Source:
Parameters:
Name Type Attributes Default Description
n number <optional>
1

The degree of X.

coefType function <optional>
BigFloat

The coefficient type.

Returns:
Type
Poly