PiMath API
    Preparing search index...

    Class Equation

    An equation or an inequality left <sign> right, where both members are Polynoms and the sign is =, <, >, <= or >=. Built from a string with a sign ("2x+3=7"), from two members, or from a Polynom read as polynom = 0. Operations modify the equation and return it; clone() keeps the original. A failing operation leaves it unchanged.

    new Equation("x^2-5x+6=0").solve().map(s => s.display) // [ "2", "3" ]
    

    Implements

    Index
    • get sign(): string

      Sign of the equation: =, <, >, <= or >=. Setting it accepts the other notations (\leq, geq, =>...).

      Returns string

    • set sign(value: string): void

      Parameters

      • value: string

      Returns void

    • get signAsTex(): string

      The sign written for LaTeX: \leq and \geq for the non-strict inequalities.

      Returns string

    • Add one or more values to the equation. An Equation operand is added member by member; any other value (Polynom, Monom, Fraction, number, or a sign-less string) is added to both members. Atomic: a failing operand leaves the receiver intact.

      Parameters

      Returns this

    • Whether the equation can be linearly isolated for the given variable: it must be of the first degree and free of any cross-term monom. Pure query (no mutation); use it to guard isolate.

      Parameters

      • Optionalvariable: string

      Returns boolean

    • Divide both members of the equation by a value (coerced to a Fraction). A zero divisor is a no-op (the equation is returned unchanged). For an inequality, a negative divisor reverses the sign.

      8x+10=6x | 2  ->  4x+5=3x
      

      Parameters

      Returns this

    • Evaluate the equation as a predicate: substitute the given variable values into both members and return whether the relation left <sign> right holds (the equation sign is honoured, including inequalities). Distinct from the value-producing evaluate of Polynom/Monom (which returns a number).

      Parameters

      • values: InputValue<Fraction> | LiteralType<number | Fraction>

        variable values to substitute (e.g. {x: 3})

      • asNumeric: boolean = false

        compare as numbers (approximate) rather than exact Fractions; defaults to false (exact), like Polynom/Monom's evaluate

      Returns boolean

    • Whether the equation contains a cross-term monom (a single monom carrying more than one variable, such as xy), which prevents isolating a variable linearly. A linear equation in several distinct variables (e.g. ax+by+c=0) has no cross-term and stays isolable.

      Returns boolean

    • Equivalence: the two (in)equations share the same solution set. All terms are moved left and the resulting polynoms are compared up to a scalar factor (3x=5, 3x-5=0 and 6x=10 are all equivalent). For inequalities a negative factor mirrors the equation, so the sign must reverse accordingly. Looser than isEqual.

      Parameters

      Returns boolean

    • Reorder the equation to keep a single variable on the left and the rest on the right, with a coefficient of 1. For an inequality, a negative coefficient reverses the sign. Atomic: on failure the receiver is left unchanged.

      Parameters

      • Optionalvariable: string

      Returns this

      when the equation cannot be isolated (guard with canIsolate).

    • Reorder will move all monoms containing a variable on the left, all the other on the right.

      Returns this

    • Multiply both members of the equation by one or more fraction values. A negative factor reverses the inequality sign. Atomic: a failing operand leaves the receiver intact.

      Parameters

      Returns this

    • Multiply both members by -1. For an inequality the direction is reversed (x < 3 becomes -x > -3), so the equation keeps the same solutions.

      Returns this

    • Raise both members to the power value. The sign is left as it is, so squaring an inequality does not keep its solutions.

      Parameters

      • value: number

      Returns this

      if value is not a non-negative integer.

    • Put the equation in a canonical form: every term on the left (the right member is zero), integer coefficients without common divisor, and a positive leading coefficient. A negative factor reverses the sign of an inequality.

      Returns this

    • Move the terms with a variable to the left and the constants to the right. With allLeft, move everything to the left instead. The sign does not change.

      Parameters

      • OptionalallLeft: boolean

      Returns this

    • Replace a variable by a polynom in both members (in place).

      Parameters

      Returns this

      if the variable appears with a negative power.

    • Multiply by the lcm denominator and divide by the gcm numerators.

      Returns this

    • Build the equation from a complete equation string (containing a sign).

      Parameters

      • equationString: string

      Returns Equation

      when the string carries no equation sign.

    • True when the string contains an equation sign (=, < or >).

      Parameters

      • equationString: string

      Returns boolean