PiMath API
    Preparing search index...

    Class Factor

    Represents a single factor P(x)^n in a factored polynomial expression.

    Factor is designed to be used as a building block inside PolyFactor, not as a standalone expression type. Several IExpression operations (add, subtract, opposite, reduce, primitive, derivative) are structurally unsupported at this level and will throw UnsupportedOperationError.

    Implements

    Index
    • get asPower(): this

      Display option (default): a power is written (P)^{n}, a negative one with a negative exponent. Chainable, kept by clone.

      Returns this

    • get asRoot(): this

      Display option: a fractional power is written as a radical (sqrt(P)) and a negative power as a fraction (1/(P)). Chainable, kept by clone.

      Returns this

    • get asSingle(): this

      Display option: do not wrap the polynom in parentheses when the power is 1. PolyFactor sets it on a lone factor. Chainable, kept by clone.

      Returns this

    • Copy the mathematical state of another instance into this (display state is NOT transferred — the receiver keeps its own formatting). Entry point used when constructing/parsing from a same-type input. Distinct from clone. Classes without a real implementation throw NotImplementedError.

      Parameters

      Returns this

    • Chain-rule decomposition of P(x)^n: returns the factors whose product equals d/dx[P^n].

      • n = 0 → [0] (constant)
      • n = 1 → [P'(x)]
      • otherwise → [n, P'(x), P(x)^(n−1)]

      Intended for use by PolyFactor.derivative, not for standalone consumption.

      Returns Factor[]

    • True when the string has no + or - outside the parentheses, so it reads as a product of factors.

      Parameters

      • str: string

      Returns boolean

    • Parse a product string into an array of Factor instances.

      Supported format: parenthesised terms with optional powers and implicit multiplication, e.g. "(3x+2)^2*(x-1)" or "(x+1)(x-1)^(1/2)". Non-parenthesised tokens (e.g. "3x") are treated as a single factor with implicit power ±1.

      Parameters

      • value: string
      • isNumerator: boolean = true

        when false, all parsed powers are negated (denominator use).

      Returns Factor[]