Optionalsign: EquationSignASCIIMath rendering of the current state (terminal output, not chainable).
Number of distinct variables in both members.
Sign of the equation: =, <, >, <= or >=. Setting it accepts the other notations (\leq, geq, =>...).
The sign written for LaTeX: \leq and \geq for the non-strict inequalities.
LaTeX rendering of the current state (terminal output, not chainable).
The variables of both members, without duplicates.
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.
the values to add
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.
Optionalvariable: stringCopy the mathematical state (left, right and sign) of another equation into this one. Entry point used by the constructor for an Equation input.
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
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).
variable values to substitute (e.g. {x: 3})
compare as numbers (approximate) rather than exact
Fractions; defaults to false (exact), like Polynom/Monom's evaluate
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.
Determine if the equation contains a variable.
Strict equality: both members are identical as written and the sign
matches. Sensitive to how terms are split and to the side order
(3x=5 is not isEqual to 5=3x). For "same solutions", use
isEquivalentTo.
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.
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.
Optionalvariable: stringReorder will move all monoms containing a variable on the left, all the other on the right.
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.
the factors to multiply by
Multiply both members by -1. For an inequality the direction is reversed
(x < 3 becomes -x > -3), so the equation keeps the same solutions.
Router: dispatch an input to the matching from*** method.
A same-type input goes through copy, a string is a full equation
(strict: fromString throws if it carries no sign), and a bare
algebraic expression is read as <expr> = 0.
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.
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.
OptionalallLeft: booleanReplace a variable by a polynom in both members (in place).
Multiply by the lcm denominator and divide by the gcm numerators.
Solve left - right = 0, whatever the sign, and return the roots as Solutions sorted by value.
An inequality has the roots of its equality: use TableOfSigns to study its sign.
Subtract one or more values from the equation (member by member for an Equation operand, from both members otherwise). Atomic: a failing operand leaves the receiver intact.
the values to subtract
True when both members have the same value for the given values of the variables. The sign is ignored: use evaluate to test an inequality.
StaticfromBuild the equation from its two members and an optional sign
(defaults to =).
Optionalsign: EquationSignStaticfromBuild the equation from a complete equation string (containing a sign).
StaticisTrue when the string contains an equation sign (=, < or >).
Staticmake
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 aPolynomread aspolynom = 0. Operations modify the equation and return it;clone()keeps the original. A failing operation leaves it unchanged.Example