PiMath API
    Preparing search index...

    Class LinearSystem

    A system of linear equations. Built from equations or strings (new LinearSystem("x+y=3", "x-y=1")). The variables are found in the equations; solve uses Gauss-Jordan elimination. Operations modify the system and return it; clone() keeps the original.

    new LinearSystem("x+y=3", "x-y=1").solve().map(s => s.display) // [ "2", "1" ]
    

    Implements

    Index
    • Builds the LaTeX \left\{...\right. representation from an explicit equation list.

      Called by tex with the reordered clone. Pass equations directly when generating a step-by-step derivation on a non-standard equation list.

      Parameters

      • equations: Equation[]

        Equations to render (typically from a cloned/reordered system).

      • Optionaloperators: string[][]

        Per-equation multiplier annotations. operators[i] lists the multipliers shown as \cdot k next to equation i; each adds a |l column. Negative values are wrapped in \left(...\right).

      Returns string

    • 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.

      Returns this

    • Replace the equations from rows of numbers: the coefficients of the variables, then the constant of the right member. [[1, 1, 3], [1, -1, 1]] is x+y=3 and x-y=1.

      Parameters

      • matrix: InputValue<Fraction>[][]
      • variables: string = 'xyz'

        the names given to the columns (default xyz).

      Returns this

      if there is no row, or the rows have different lengths.

    • Replace the equations from vectors: each vector is a column, the last one holds the constants.

      Parameters

      Returns this

    • True when the system has exactly one solution: it is consistent and its rank equals the number of variables.

      Returns boolean

    • A new equation: the first equation times its factor, plus the second equation times its factor. The system is not modified.

      Parameters

      • equation1: { factor: InputValue<Fraction>; id: number }

        id is the position of the equation, factor its multiplier.

      • equation2: { factor: number; id: number }

      Returns Equation

    • Replace the equations with strings or equations.

      Parameters

      Returns this

      if a string has no equation sign.

    • Solves the system by Gauss-Jordan elimination on the augmented matrix.

      • Unique solution: one Solution per variable, in variables order.
      • No solution: returns [].
      • Infinite solutions: one Solution per variable with .value === Infinity.

      Returns Solution[]

    • For each pair of equations (i, j), computes LCM-based multipliers that eliminate variable by linear combination. The factors satisfy f_i·coeff_i + f_j·coeff_j = 0.

      Pairs are sorted by |f_i| + |f_j| (smallest multipliers first). Requires that all variable terms are on the left side of each equation.

      Parameters

      • variable: string

      Returns [{ factor: number; id: number }, { factor: number; id: number }][]

    • Builds the augmented matrix [A|b] for this system and marks the partition at the variable count, enabling isConsistent() and reducedRowEchelonForm() to interpret the coefficient vs. constant parts.

      Returns Matrix