PiMath API
    Preparing search index...

    Class Monom

    A term k · x^a · y^b: a Fraction coefficient and a literal part, a dictionary from each variable to its exponent (a Fraction too, so x^(1/2) is allowed). Built from a string ("3x^2y"), a number or a fraction. A string must be a single term: spaces are ignored, but a sum or a difference ("3x+2"), a missing operand ("3x*") or a negative exponent without parentheses ("x^-1", write "x^(-1)") throws a ParseError.

    new Monom("3x^2y").tex // "3x^{ 2 }y"
    

    Implements

    Index
    • get dividers(): Monom[]

      Every divisor of the monom: each divisor of the absolute value of the coefficient, combined with every exponent from 0 up to the exponent of each variable. A monom with a non-integer coefficient or exponent, or a numerator above 1 000 000, is returned alone.

      Returns Monom[]

    • set literalStr(inputStr: string): void

      Set the literal part of the monom from a string

      Parameters

      • inputStr: string

        String like x^2y^3

      Returns void

    • get plotFunction(): string

      Expression to give to a plotting tool: explicit * between the coefficient and the variables.

      Returns string

    • True when an exponent is not an integer (x^(1/2)).

      Returns boolean

    • Copy the mathematical state (coefficient and literal part) of another monom into this. Display state is not involved (Monom has none). Entry point used to commit the result of an atomic operation.

      Parameters

      Returns this

    • Get the degree of a monom. If no variable is given, the result will be the global degree.

      Parameters

      • Optionalvariable: string

        Letter whose power to return

      Returns Fraction

    • Evaluate a monom. Every variable of the monom must be assigned in values; extra entries in values (variables not present in the monom) are ignored.

      Parameters

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

        Dictionary of <variable: Fraction | number>, or a scalar assigned to the monom's single variable.

      • asNumeric: true

        When true, returns a primitive number instead of a Fraction.

      Returns number

      If a variable of the monom is missing from values.

    • Evaluate a monom. Every variable of the monom must be assigned in values; extra entries in values (variables not present in the monom) are ignored.

      Parameters

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

        Dictionary of <variable: Fraction | number>, or a scalar assigned to the monom's single variable.

      • OptionalasNumeric: false

        When true, returns a primitive number instead of a Fraction.

      Returns Fraction

      If a variable of the monom is missing from values.

    • Evaluate a monom. Every variable of the monom must be assigned in values; extra entries in values (variables not present in the monom) are ignored.

      Parameters

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

        Dictionary of <variable: Fraction | number>, or a scalar assigned to the monom's single variable.

      • OptionalasNumeric: boolean

        When true, returns a primitive number instead of a Fraction.

      Returns number | Fraction

      If a variable of the monom is missing from values.

    • Determine if a monom contains a variable in its literal part

      Parameters

      • variable: string

      Returns boolean

    • Replace the monom by its inverse: inverse the coefficient and negate every exponent. The inverse of zero has an infinite coefficient; it does not throw.

      Returns this

    • True when div divides the monom: each variable of div has at least the same exponent here, and the quotient of the coefficients is an integer (a coefficient with a fractional part is not checked).

      Parameters

      Returns boolean

    • True when every exponent is an even integer (x^4y^2).

      Returns boolean

    • True when the coefficient is a perfect square and every exponent is an even integer.

      Returns boolean

    • Primitive with respect to a variable (integration constant omitted). The primitive of the zero monom is the zero monom.

      Parameters

      • variable: string = 'x'

      Returns Monom

      for a power of -1 of the variable: its primitive is a logarithm, not a monom.

    • Remove a variable from the literal part. Nothing happens when the variable is absent.

      Parameters

      • variable: string

      Returns void

    • Set the exponent of a particular variable.

      Parameters

      • variable: string

        variable whose exponent to change

      • exponent: InputValue<Fraction>

        exponent to assign to the variable; zero removes the variable

      Returns this

    • Return the square root of a monom. The literal part always admits a square root (halving each power, rational powers allowed), so only the coefficient constrains the result.

      Returns this

      If the coefficient is not a perfect square. The receiver is left unchanged (atomic: the guard precedes any mutation).

    • Build a constant monom (empty literal part) from a number.

      Parameters

      • value: number

      Returns Monom

    • Build a monom from a string. A purely numeric string is a constant monom; any other string is parsed as an algebraic expression.

      Parameters

      • value: string

      Returns Monom

      If the string cannot be parsed as a monom.

    • Greatest common divisor of monoms: the gcd of the numerators over the lcm of the denominators, times each variable shared by all the monoms at its lowest exponent.

      Parameters

      Returns Monom

      if a monom has a non-integer exponent.