diff --git a/dev/differentiation/index.html b/dev/differentiation/index.html index 0749eb4e..78211231 100644 --- a/dev/differentiation/index.html +++ b/dev/differentiation/index.html @@ -3,7 +3,7 @@ differentiate(p, x) # should return 6xy + 1 differentiate(p, x, Val{1}()) # equivalent to the above differentiate(p, (x, y)) # should return [6xy+1, 3x^2+1] -differentiate( [x^2+y, z^2+4x], [x, y, z]) # should return [2x 1 0; 4 0 2z]source

Antidifferentiation

Given a polynomial, say p(x, y) = 3x^2y + x + 2y + 1, we can antidifferentiate it by a variable, say x and get $\int_0^x p(X, y)\mathrm{d}X = x^3y + 1/2x^2 + 2xy + x$. We can also antidifferentiate it by both of its variable and get the vector [x^3y + 1/2x^2 + 2xy + x, 3/2x^2y^2 + xy + y^2 + y].

MultivariatePolynomials.antidifferentiateFunction
antidifferentiate(p::AbstractPolynomialLike, v::AbstractVariable, deg::Union{Int, Val}=1)

Antidifferentiate deg times the polynomial p by the variable v. The free constant involved by the antidifferentiation is set to 0.

antidifferentiate(p::AbstractPolynomialLike, vs, deg::Union{Int, Val}=1)

Antidifferentiate deg times the polynomial p by the variables of the vector or tuple of variable vs and return an array of dimension deg. It is recommended to pass deg as a Val instance when the degree is known at compile time, e.g. antidifferentiate(p, v, Val{2}()) instead of antidifferentiate(p, x, 2), as this will help the compiler infer the return type.

Examples

p = 3x^2*y + x + 2y + 1
+differentiate( [x^2+y, z^2+4x], [x, y, z]) # should return [2x 1 0; 4 0 2z]
source

Antidifferentiation

Given a polynomial, say p(x, y) = 3x^2y + x + 2y + 1, we can antidifferentiate it by a variable, say x and get $\int_0^x p(X, y)\mathrm{d}X = x^3y + 1/2x^2 + 2xy + x$. We can also antidifferentiate it by both of its variable and get the vector [x^3y + 1/2x^2 + 2xy + x, 3/2x^2y^2 + xy + y^2 + y].

MultivariatePolynomials.antidifferentiateFunction
antidifferentiate(p::AbstractPolynomialLike, v::AbstractVariable, deg::Union{Int, Val}=1)

Antidifferentiate deg times the polynomial p by the variable v. The free constant involved by the antidifferentiation is set to 0.

antidifferentiate(p::AbstractPolynomialLike, vs, deg::Union{Int, Val}=1)

Antidifferentiate deg times the polynomial p by the variables of the vector or tuple of variable vs and return an array of dimension deg. It is recommended to pass deg as a Val instance when the degree is known at compile time, e.g. antidifferentiate(p, v, Val{2}()) instead of antidifferentiate(p, x, 2), as this will help the compiler infer the return type.

Examples

p = 3x^2*y + x + 2y + 1
 antidifferentiate(p, x) # should return 3x^3* + 1/2*x + 2xy + x
 antidifferentiate(p, x, Val{1}()) # equivalent to the above
-antidifferentiate(p, (x, y)) # should return [3x^3* + 1/2*x + 2xy + x, 3/2x^2*y^2 + xy + y^2 + y]
source
+antidifferentiate(p, (x, y)) # should return [3x^3* + 1/2*x + 2xy + x, 3/2x^2*y^2 + xy + y^2 + y]source diff --git a/dev/division/index.html b/dev/division/index.html index e1622bf8..dbf71694 100644 --- a/dev/division/index.html +++ b/dev/division/index.html @@ -1,2 +1,2 @@ -Division · MultivariatePolynomials

Division

The gcd and lcm functions of Base have been implemented for monomials, you have for example gcd(x^2*y^7*z^3, x^4*y^5*z^2) returning x^2*y^5*z^2 and lcm(x^2*y^7*z^3, x^4*y^5*z^2) returning x^4*y^7*z^3.

Given two polynomials, $p$ and $d$, there are unique $r$ and $q$ such that $p = q d + r$ and the leading term of $d$ does not divide the leading term of $r$. You can obtain $q$ using the div function and $r$ using the rem function. The divrem function returns $(q, r)$.

Given a polynomial $p$ and divisors $d_1, \ldots, d_n$, one can find $r$ and $q_1, \ldots, q_n$ such that $p = q_1 d_1 + \cdots + q_n d_n + r$ and none of the leading terms of $q_1, \ldots, q_n$ divide the leading term of $r$. You can obtain the vector $[q_1, \ldots, q_n]$ using div(p, d) where $d = [d_1, \ldots, d_n]$ and $r$ using the rem function with the same arguments. The divrem function returns $(q, r)$.

MultivariatePolynomials.dividesFunction
divides(t1::AbstractTermLike, t2::AbstractTermLike)

Returns whether the monomial of t1 divides the monomial of t2.

Examples

Calling divides(2x^2y, 3xy) should return false because x^2y does not divide xy since x has a degree 2 in x^2y which is greater than the degree of x on xy. However, calling divides(3xy, 2x^2y) should return true.

source
MultivariatePolynomials.div_multipleFunction
div_multiple(a, b, ma::MA.MutableTrait)

Return the division of a by b assuming that a is a multiple of b. If a is not a multiple of b then this function may return anything.

source
MultivariatePolynomials.pseudo_remFunction
pseudo_rem(f::_APL, g::_APL, algo)

Return the pseudo remainder of f modulo g as defined in [Knu14, Algorithm R, p. 425].

[Knu14] Knuth, D.E., 2014. Art of computer programming, volume 2: Seminumerical algorithms. Addison-Wesley Professional. Third edition.

source
+Division · MultivariatePolynomials

Division

The gcd and lcm functions of Base have been implemented for monomials, you have for example gcd(x^2*y^7*z^3, x^4*y^5*z^2) returning x^2*y^5*z^2 and lcm(x^2*y^7*z^3, x^4*y^5*z^2) returning x^4*y^7*z^3.

Given two polynomials, $p$ and $d$, there are unique $r$ and $q$ such that $p = q d + r$ and the leading term of $d$ does not divide the leading term of $r$. You can obtain $q$ using the div function and $r$ using the rem function. The divrem function returns $(q, r)$.

Given a polynomial $p$ and divisors $d_1, \ldots, d_n$, one can find $r$ and $q_1, \ldots, q_n$ such that $p = q_1 d_1 + \cdots + q_n d_n + r$ and none of the leading terms of $q_1, \ldots, q_n$ divide the leading term of $r$. You can obtain the vector $[q_1, \ldots, q_n]$ using div(p, d) where $d = [d_1, \ldots, d_n]$ and $r$ using the rem function with the same arguments. The divrem function returns $(q, r)$.

MultivariatePolynomials.dividesFunction
divides(t1::AbstractTermLike, t2::AbstractTermLike)

Returns whether the monomial of t1 divides the monomial of t2.

Examples

Calling divides(2x^2y, 3xy) should return false because x^2y does not divide xy since x has a degree 2 in x^2y which is greater than the degree of x on xy. However, calling divides(3xy, 2x^2y) should return true.

source
MultivariatePolynomials.div_multipleFunction
div_multiple(a, b, ma::MA.MutableTrait)

Return the division of a by b assuming that a is a multiple of b. If a is not a multiple of b then this function may return anything.

source
MultivariatePolynomials.pseudo_remFunction
pseudo_rem(f::_APL, g::_APL, algo)

Return the pseudo remainder of f modulo g as defined in [Knu14, Algorithm R, p. 425].

[Knu14] Knuth, D.E., 2014. Art of computer programming, volume 2: Seminumerical algorithms. Addison-Wesley Professional. Third edition.

source
diff --git a/dev/index.html b/dev/index.html index db992de1..363f2fce 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,2 +1,2 @@ -Introduction · MultivariatePolynomials

MultivariatePolynomials

MultivariatePolynomials.jl is an implementation independent library for manipulating multivariate polynomials. It defines abstract types and an API for multivariate monomials, terms, polynomials and gives default implementation for common operations on them using the API.

On the one hand, This packages allows you to implement algorithms on multivariate polynomials that will be independant on the representation of the polynomial that will be chosen by the user. On the other hand, it allows the user to easily switch between different representations of polynomials to see which one is faster for the algorithm that he is using.

Supported operations are : basic arithmetic, rational polynomials, evaluation/substitution, differentiation and division.

The following packages provide representations of multivariate polynomials that implement the interface:

The following packages extend the interface and/or implement algorithms using the interface:

  • SemialgebraicSets : Sets defined by inequalities and equalities between polynomials and algorithms for solving polynomial systems of equations.
  • HomotopyContinuation : Solving systems of polynomials via homotopy continuation.
  • MultivariateBases : Standardized API for multivariate polynomial bases.
  • MultivariateMoments : Moments of multivariate measures and their scalar product with polynomials.
  • PolyJuMP : A JuMP extension for Polynomial Optimization.
  • SumOfSquares : Certifying the nonnegativity of polynomials, minimizing/maximizing polynomials and optimization over sum of squares polynomials using Sum of Squares Programming.

Contents

+Introduction · MultivariatePolynomials

MultivariatePolynomials

MultivariatePolynomials.jl is an implementation independent library for manipulating multivariate polynomials. It defines abstract types and an API for multivariate monomials, terms, polynomials and gives default implementation for common operations on them using the API.

On the one hand, This packages allows you to implement algorithms on multivariate polynomials that will be independant on the representation of the polynomial that will be chosen by the user. On the other hand, it allows the user to easily switch between different representations of polynomials to see which one is faster for the algorithm that he is using.

Supported operations are : basic arithmetic, rational polynomials, evaluation/substitution, differentiation and division.

The following packages provide representations of multivariate polynomials that implement the interface:

The following packages extend the interface and/or implement algorithms using the interface:

  • SemialgebraicSets : Sets defined by inequalities and equalities between polynomials and algorithms for solving polynomial systems of equations.
  • HomotopyContinuation : Solving systems of polynomials via homotopy continuation.
  • MultivariateBases : Standardized API for multivariate polynomial bases.
  • MultivariateMoments : Moments of multivariate measures and their scalar product with polynomials.
  • PolyJuMP : A JuMP extension for Polynomial Optimization.
  • SumOfSquares : Certifying the nonnegativity of polynomials, minimizing/maximizing polynomials and optimization over sum of squares polynomials using Sum of Squares Programming.

Contents

diff --git a/dev/search/index.html b/dev/search/index.html index 12b47748..7097de6a 100644 --- a/dev/search/index.html +++ b/dev/search/index.html @@ -1,2 +1,2 @@ -Search · MultivariatePolynomials

Loading search...

    +Search · MultivariatePolynomials

    Loading search...

      diff --git a/dev/substitution/index.html b/dev/substitution/index.html index fe65434c..baa9b682 100644 --- a/dev/substitution/index.html +++ b/dev/substitution/index.html @@ -3,4 +3,4 @@ p(x => 2, y => 1) # Return type is Int subs(p, x => 2, y => 1) # Return type is Int in TypedPolynomials but is a polynomial of Int coefficients in DynamicPolynomials subs(p, y => x*y^2 + 1) -p(y => 2) # Do not do that, this works fine with TypedPolynomials but it will not return a correct result with DynamicPolynomials since it thinks that the return type is `Int`.source +p(y => 2) # Do not do that, this works fine with TypedPolynomials but it will not return a correct result with DynamicPolynomials since it thinks that the return type is `Int`.source diff --git a/dev/types/index.html b/dev/types/index.html index b9f3dcd4..fa163cf8 100644 --- a/dev/types/index.html +++ b/dev/types/index.html @@ -1,14 +1,14 @@ -Types · MultivariatePolynomials

      Types

      Variables

      MultivariatePolynomials.variableFunction
      variable(p::AbstractPolynomialLike)

      Converts p to a variable. Throws InexactError if it is not possible.

      Examples

      Calling variable(x^2 + x - x^2) should return the variable x and calling variable(1.0y) should return the variable y however calling variable(2x) or variable(x + y) should throw InexactError.

      Note

      This operation is not type stable for the TypedPolynomials implementation if nvariables(p) > 1 but is type stable for DynamicPolynomials.

      source
      MultivariatePolynomials.variable_union_typeFunction
      variable_union_type(p::AbstractPolynomialLike)

      Return the supertype for variables of p. If p is a variable, it should not be the type of p but the supertype of all variables that could be created.

      Examples

      For TypedPolynomials, a variable of name x has type Variable{:x} so variable_union_type should return Variable. For DynamicPolynomials, all variables have the same type Variable{C} where C is true for commutative variables and false for non-commutative ones so variable_union_type should return Variable{C}.

      source
      MultivariatePolynomials.similar_variableFunction
      similar_variable(p::AbstractPolynomialLike, variable::Type{Val{V}})

      Creates a new variable V based upon the the given source polynomial.

      similar_variable(p::AbstractPolynomialLike, v::Symbol)

      Creates a new variable based upon the given source polynomial and the given symbol v. Note that this can lead to type instabilities.

      Examples

      Calling similar_variable(typedpoly, Val{:x}) on a polynomial created with TypedPolynomials results in TypedPolynomials.Variable{:x}.

      source
      MultivariatePolynomials.@similar_variableMacro
      @similar_variable(p::AbstractPolynomialLike, variable)

      Calls similar_variable(p, Val{variable}) and binds the result to a variable with the same name.

      Examples

      Calling @similar_variable typedpoly x on a polynomial created with TypedPolynomials binds TypedPolynomials.Variable{:x} to the variable x.

      source
      Base.conjMethod
      conj(x::AbstractVariable)

      Return the complex conjugate of a given variable if it was declared as a complex variable; else return the variable unchanged.

      See also isreal, isconj.

      source
      Base.realMethod
      real(x::AbstractVariable)

      Return the real part of a given variable if it was declared as a complex variable; else return the variable unchanged.

      See also imag.

      source
      Base.imagMethod
      imag(x::AbstractVariable)

      Return the imaginary part of a given variable if it was declared as a complex variable; else return zero.

      See also isreal, isimagpart, real.

      source
      Base.isrealMethod
      isreal(x::AbstractVariable)

      Return whether a given variable was declared as a real-valued or complex-valued variable (also their conjugates are complex, but their real and imaginary parts are not). By default, all variables are real-valued.

      source
      MultivariatePolynomials.ordinary_variableFunction
      ordinary_variable(x::Union{AbstractVariable, AbstractVector{<:AbstractVariable}})

      Given some (complex-valued) variable that was transformed by conjugation, taking its real part, or taking its imaginary part, return the original variable as it was defined by the user.

      See also conj, real, imag.

      source

      Monomials

      MultivariatePolynomials.AbstractMonomialLikeType
      AbstractMonomialLike

      Abstract type for a value that can act like a monomial. For instance, an AbstractVariable is an AbstractMonomialLike since it can act as a monomial of one variable with degree 1.

      source
      MultivariatePolynomials.monomial_typeFunction
      monomial_type(p::AbstractPolynomialLike)

      Return the type of the monomials of p.

      term_type(::Type{PT}) where PT<:AbstractPolynomialLike

      Returns the type of the monomials of a polynomial of type PT.

      source
      MultivariatePolynomials.variablesFunction
      variables(p::AbstractPolynomialLike)

      Returns the tuple of the variables of p in decreasing order. It could contain variables of zero degree, see the example section.

      Examples

      Calling variables(x^2*y) should return (x, y) and calling variables(x) should return (x,). Note that the variables of m does not necessarily have nonzero degree. For instance, variables([x^2*y, y*z][1]) is usually (x, y, z) since the two monomials have been promoted to a common type.

      source
      MultivariatePolynomials.effective_variablesFunction
      effective_variables(p::AbstractPolynomialLike)

      Return a vector of eltype variable_union_type(p) (see variable_union_type), containing all the variables that has nonzero degree in at least one term. That is, return all the variables v such that maxdegree(p, v) is not zero. The returned vector is sorted in decreasing order.

      source
      MultivariatePolynomials.nvariablesFunction
      nvariables(p::AbstractPolynomialLike)

      Returns the number of variables in p, i.e. length(variables(p)). It could be more than the number of variables with nonzero degree (see the Examples section of variables).

      Examples

      Calling nvariables(x^2*y) should return at least 2 and calling nvariables(x) should return at least 1.

      source
      MultivariatePolynomials.exponentsFunction
      exponents(t::AbstractTermLike)

      Returns the exponent of the variables in the monomial of the term t.

      Examples

      Calling exponents(x^2*y) should return (2, 1).

      source
      MultivariatePolynomials.degreeFunction
      degree(t::AbstractTermLike)

      Returns the total degree of the monomial of the term t, i.e. sum(exponents(t)).

      degree(t::AbstractTermLike, v::AbstractVariable)

      Returns the exponent of the variable v in the monomial of the term t.

      Examples

      Calling degree(x^2*y) should return 3 which is $2 + 1$. Calling degree(x^2*y, x) should return 2 and calling degree(x^2*y, y) should return 1.

      source
      MultivariatePolynomials.powersFunction
      powers(t::AbstractTermLike)

      Returns an iterator over the powers of the monomial of t.

      Examples

      Calling powers(3x^4*y) should return((x, 4), (y, 1))`.

      source
      MultivariatePolynomials.constant_monomialFunction
      constant_monomial(p::AbstractPolynomialLike)

      Returns a constant monomial of the monomial type of p with the same variables as p.

      constant_monomial(::Type{PT}) where {PT<:AbstractPolynomialLike}

      Returns a constant monomial of the monomial type of a polynomial of type PT.

      source
      MultivariatePolynomials.map_exponentsFunction
      map_exponents(f, m1::AbstractMonomialLike, m2::AbstractMonomialLike)

      If $m_1 = \prod x^{\alpha_i}$ and $m_2 = \prod x^{\beta_i}$ then it returns the monomial $m = \prod x^{f(\alpha_i, \beta_i)}$.

      Examples

      The multiplication m1 * m2 is equivalent to map_exponents(+, m1, m2), the unsafe division div_multiple(m1, m2) is equivalent to map_exponents(-, m1, m2), gcd(m1, m2) is equivalent to map_exponents(min, m1, m2), lcm(m1, m2) is equivalent to map_exponents(max, m1, m2).

      source
      MultivariatePolynomials.multiplication_preserves_monomial_orderFunction
      multiplication_preserves_monomial_order(P::Type{<:AbstractPolynomialLike})

      Returns a Bool indicating whether the order is preserved in the multiplication of monomials of type monomial_type(P). That is, if a < b then a * c < b * c for any monomial c. This returns true by default. This is used by Polynomial so a monomial type for which the multiplication does not preserve the monomial order can still be used with Polynomial if it implements a method for this function that returns false.

      source

      Ordering

      MultivariatePolynomials.AbstractMonomialOrderingType
      abstract type AbstractMonomialOrdering end

      Abstract type for monomial ordering as defined in [CLO13, Definition 2.2.1, p. 55]

      [CLO13] Cox, D., Little, J., & OShea, D. Ideals, varieties, and algorithms: an introduction to computational algebraic geometry and commutative algebra. Springer Science & Business Media, 2013.

      source
      MultivariatePolynomials.compareFunction
      compare(a, b, order::Type{<:AbstractMonomialOrdering})

      Returns a negative number if a < b, a positive number if a > b and zero if a == b. The comparison is done according to order.

      source
      MultivariatePolynomials.LexOrderType
      struct LexOrder <: AbstractMonomialOrdering end

      Lexicographic (Lex for short) Order often abbreviated as lex order as defined in [CLO13, Definition 2.2.3, p. 56]

      The Graded version is often abbreviated as grlex order and is defined in [CLO13, Definition 2.2.5, p. 58]

      [CLO13] Cox, D., Little, J., & OShea, D. Ideals, varieties, and algorithms: an introduction to computational algebraic geometry and commutative algebra. Springer Science & Business Media, 2013.

      source
      MultivariatePolynomials.InverseLexOrderType
      struct InverseLexOrder <: AbstractMonomialOrdering end

      Inverse Lex Order defined in [CLO13, Exercise 2.2.6, p. 61] where it is abbreviated as invlex. It corresponds to LexOrder but with the variables in reverse order.

      The Graded version can be abbreviated as grinvlex order. It is defined in [BDD13, Definition 2.1] where it is called Graded xel order.

      [CLO13] Cox, D., Little, J., & OShea, D. Ideals, varieties, and algorithms: an introduction to computational algebraic geometry and commutative algebra. Springer Science & Business Media, 2013. [BDD13] Batselier, K., Dreesen, P., & De Moor, B. The geometry of multivariate polynomial division and elimination. SIAM Journal on Matrix Analysis and Applications, 34(1), 102-125, 2013.

      source
      MultivariatePolynomials.GradedType
      struct Graded{O<:AbstractMonomialOrdering} <: AbstractMonomialOrdering
      +Types · MultivariatePolynomials

      Types

      Variables

      MultivariatePolynomials.variableFunction
      variable(p::AbstractPolynomialLike)

      Converts p to a variable. Throws InexactError if it is not possible.

      Examples

      Calling variable(x^2 + x - x^2) should return the variable x and calling variable(1.0y) should return the variable y however calling variable(2x) or variable(x + y) should throw InexactError.

      Note

      This operation is not type stable for the TypedPolynomials implementation if nvariables(p) > 1 but is type stable for DynamicPolynomials.

      source
      MultivariatePolynomials.variable_union_typeFunction
      variable_union_type(p::AbstractPolynomialLike)

      Return the supertype for variables of p. If p is a variable, it should not be the type of p but the supertype of all variables that could be created.

      Examples

      For TypedPolynomials, a variable of name x has type Variable{:x} so variable_union_type should return Variable. For DynamicPolynomials, all variables have the same type Variable{C} where C is true for commutative variables and false for non-commutative ones so variable_union_type should return Variable{C}.

      source
      MultivariatePolynomials.similar_variableFunction
      similar_variable(p::AbstractPolynomialLike, variable::Type{Val{V}})

      Creates a new variable V based upon the the given source polynomial.

      similar_variable(p::AbstractPolynomialLike, v::Symbol)

      Creates a new variable based upon the given source polynomial and the given symbol v. Note that this can lead to type instabilities.

      Examples

      Calling similar_variable(typedpoly, Val{:x}) on a polynomial created with TypedPolynomials results in TypedPolynomials.Variable{:x}.

      source
      MultivariatePolynomials.@similar_variableMacro
      @similar_variable(p::AbstractPolynomialLike, variable)

      Calls similar_variable(p, Val{variable}) and binds the result to a variable with the same name.

      Examples

      Calling @similar_variable typedpoly x on a polynomial created with TypedPolynomials binds TypedPolynomials.Variable{:x} to the variable x.

      source
      Base.conjMethod
      conj(x::AbstractVariable)

      Return the complex conjugate of a given variable if it was declared as a complex variable; else return the variable unchanged.

      See also isreal, isconj.

      source
      Base.realMethod
      real(x::AbstractVariable)

      Return the real part of a given variable if it was declared as a complex variable; else return the variable unchanged.

      See also imag.

      source
      Base.imagMethod
      imag(x::AbstractVariable)

      Return the imaginary part of a given variable if it was declared as a complex variable; else return zero.

      See also isreal, isimagpart, real.

      source
      Base.isrealMethod
      isreal(x::AbstractVariable)

      Return whether a given variable was declared as a real-valued or complex-valued variable (also their conjugates are complex, but their real and imaginary parts are not). By default, all variables are real-valued.

      source
      MultivariatePolynomials.ordinary_variableFunction
      ordinary_variable(x::Union{AbstractVariable, AbstractVector{<:AbstractVariable}})

      Given some (complex-valued) variable that was transformed by conjugation, taking its real part, or taking its imaginary part, return the original variable as it was defined by the user.

      See also conj, real, imag.

      source

      Monomials

      MultivariatePolynomials.AbstractMonomialLikeType
      AbstractMonomialLike

      Abstract type for a value that can act like a monomial. For instance, an AbstractVariable is an AbstractMonomialLike since it can act as a monomial of one variable with degree 1.

      source
      MultivariatePolynomials.monomial_typeFunction
      monomial_type(p::AbstractPolynomialLike)

      Return the type of the monomials of p.

      term_type(::Type{PT}) where PT<:AbstractPolynomialLike

      Returns the type of the monomials of a polynomial of type PT.

      source
      MultivariatePolynomials.variablesFunction
      variables(p::AbstractPolynomialLike)

      Returns the tuple of the variables of p in decreasing order. It could contain variables of zero degree, see the example section.

      Examples

      Calling variables(x^2*y) should return (x, y) and calling variables(x) should return (x,). Note that the variables of m does not necessarily have nonzero degree. For instance, variables([x^2*y, y*z][1]) is usually (x, y, z) since the two monomials have been promoted to a common type.

      source
      MultivariatePolynomials.effective_variablesFunction
      effective_variables(p::AbstractPolynomialLike)

      Return a vector of eltype variable_union_type(p) (see variable_union_type), containing all the variables that has nonzero degree in at least one term. That is, return all the variables v such that maxdegree(p, v) is not zero. The returned vector is sorted in decreasing order.

      source
      MultivariatePolynomials.nvariablesFunction
      nvariables(p::AbstractPolynomialLike)

      Returns the number of variables in p, i.e. length(variables(p)). It could be more than the number of variables with nonzero degree (see the Examples section of variables).

      Examples

      Calling nvariables(x^2*y) should return at least 2 and calling nvariables(x) should return at least 1.

      source
      MultivariatePolynomials.exponentsFunction
      exponents(t::AbstractTermLike)

      Returns the exponent of the variables in the monomial of the term t.

      Examples

      Calling exponents(x^2*y) should return (2, 1).

      source
      MultivariatePolynomials.degreeFunction
      degree(t::AbstractTermLike)

      Returns the total degree of the monomial of the term t, i.e. sum(exponents(t)).

      degree(t::AbstractTermLike, v::AbstractVariable)

      Returns the exponent of the variable v in the monomial of the term t.

      Examples

      Calling degree(x^2*y) should return 3 which is $2 + 1$. Calling degree(x^2*y, x) should return 2 and calling degree(x^2*y, y) should return 1.

      source
      MultivariatePolynomials.powersFunction
      powers(t::AbstractTermLike)

      Returns an iterator over the powers of the monomial of t.

      Examples

      Calling powers(3x^4*y) should return((x, 4), (y, 1))`.

      source
      MultivariatePolynomials.constant_monomialFunction
      constant_monomial(p::AbstractPolynomialLike)

      Returns a constant monomial of the monomial type of p with the same variables as p.

      constant_monomial(::Type{PT}) where {PT<:AbstractPolynomialLike}

      Returns a constant monomial of the monomial type of a polynomial of type PT.

      source
      MultivariatePolynomials.map_exponentsFunction
      map_exponents(f, m1::AbstractMonomialLike, m2::AbstractMonomialLike)

      If $m_1 = \prod x^{\alpha_i}$ and $m_2 = \prod x^{\beta_i}$ then it returns the monomial $m = \prod x^{f(\alpha_i, \beta_i)}$.

      Examples

      The multiplication m1 * m2 is equivalent to map_exponents(+, m1, m2), the unsafe division div_multiple(m1, m2) is equivalent to map_exponents(-, m1, m2), gcd(m1, m2) is equivalent to map_exponents(min, m1, m2), lcm(m1, m2) is equivalent to map_exponents(max, m1, m2).

      source
      MultivariatePolynomials.multiplication_preserves_monomial_orderFunction
      multiplication_preserves_monomial_order(P::Type{<:AbstractPolynomialLike})

      Returns a Bool indicating whether the order is preserved in the multiplication of monomials of type monomial_type(P). That is, if a < b then a * c < b * c for any monomial c. This returns true by default. This is used by Polynomial so a monomial type for which the multiplication does not preserve the monomial order can still be used with Polynomial if it implements a method for this function that returns false.

      source

      Ordering

      MultivariatePolynomials.AbstractMonomialOrderingType
      abstract type AbstractMonomialOrdering end

      Abstract type for monomial ordering as defined in [CLO13, Definition 2.2.1, p. 55]

      [CLO13] Cox, D., Little, J., & OShea, D. Ideals, varieties, and algorithms: an introduction to computational algebraic geometry and commutative algebra. Springer Science & Business Media, 2013.

      source
      MultivariatePolynomials.compareFunction
      compare(a, b, order::Type{<:AbstractMonomialOrdering})

      Returns a negative number if a < b, a positive number if a > b and zero if a == b. The comparison is done according to order.

      source
      MultivariatePolynomials.LexOrderType
      struct LexOrder <: AbstractMonomialOrdering end

      Lexicographic (Lex for short) Order often abbreviated as lex order as defined in [CLO13, Definition 2.2.3, p. 56]

      The Graded version is often abbreviated as grlex order and is defined in [CLO13, Definition 2.2.5, p. 58]

      [CLO13] Cox, D., Little, J., & OShea, D. Ideals, varieties, and algorithms: an introduction to computational algebraic geometry and commutative algebra. Springer Science & Business Media, 2013.

      source
      MultivariatePolynomials.InverseLexOrderType
      struct InverseLexOrder <: AbstractMonomialOrdering end

      Inverse Lex Order defined in [CLO13, Exercise 2.2.6, p. 61] where it is abbreviated as invlex. It corresponds to LexOrder but with the variables in reverse order.

      The Graded version can be abbreviated as grinvlex order. It is defined in [BDD13, Definition 2.1] where it is called Graded xel order.

      [CLO13] Cox, D., Little, J., & OShea, D. Ideals, varieties, and algorithms: an introduction to computational algebraic geometry and commutative algebra. Springer Science & Business Media, 2013. [BDD13] Batselier, K., Dreesen, P., & De Moor, B. The geometry of multivariate polynomial division and elimination. SIAM Journal on Matrix Analysis and Applications, 34(1), 102-125, 2013.

      source
      MultivariatePolynomials.GradedType
      struct Graded{O<:AbstractMonomialOrdering} <: AbstractMonomialOrdering
           same_degree_ordering::O
      -end

      Monomial ordering defined by:

      • degree(a) == degree(b) then the ordering is determined by same_degree_ordering,
      • otherwise, it is the ordering between the integers degree(a) and degree(b).
      source
      MultivariatePolynomials.ReverseType
      struct Reverse{O<:AbstractMonomialOrdering} <: AbstractMonomialOrdering
      +end

      Monomial ordering defined by:

      • degree(a) == degree(b) then the ordering is determined by same_degree_ordering,
      • otherwise, it is the ordering between the integers degree(a) and degree(b).
      source
      MultivariatePolynomials.ReverseType
      struct Reverse{O<:AbstractMonomialOrdering} <: AbstractMonomialOrdering
           reverse_order::O
      -end

      Monomial ordering defined by compare(a, b, ::Type{Reverse{O}}) where {O} = compare(b, a, O).

      Reverse Lex Order defined in [CLO13, Exercise 2.2.9, p. 61] where it is abbreviated as rinvlex. can be obtained as Reverse(InverseLexOrder()).

      The Graded Reverse Lex Order often abbreviated as grevlex order defined in [CLO13, Definition 2.2.6, p. 58] can be obtained as Graded(Reverse(InverseLexOrder())).

      [CLO13] Cox, D., Little, J., & OShea, D. Ideals, varieties, and algorithms: an introduction to computational algebraic geometry and commutative algebra. Springer Science & Business Media, 2013.

      source

      Terms

      MultivariatePolynomials.AbstractTermLikeType
      AbstractTermLike{T}

      Abstract type for a value that can act like a term. For instance, an AbstractMonomial is an AbstractTermLike{Int} since it can act as a term with coefficient 1.

      source
      MultivariatePolynomials.TermType
      struct Term{CoeffType,M<:AbstractMonomial} <: AbstractTerm{CoeffType}
      +end

      Monomial ordering defined by compare(a, b, ::Type{Reverse{O}}) where {O} = compare(b, a, O).

      Reverse Lex Order defined in [CLO13, Exercise 2.2.9, p. 61] where it is abbreviated as rinvlex. can be obtained as Reverse(InverseLexOrder()).

      The Graded Reverse Lex Order often abbreviated as grevlex order defined in [CLO13, Definition 2.2.6, p. 58] can be obtained as Graded(Reverse(InverseLexOrder())).

      [CLO13] Cox, D., Little, J., & OShea, D. Ideals, varieties, and algorithms: an introduction to computational algebraic geometry and commutative algebra. Springer Science & Business Media, 2013.

      source

      Terms

      MultivariatePolynomials.AbstractTermLikeType
      AbstractTermLike{T}

      Abstract type for a value that can act like a term. For instance, an AbstractMonomial is an AbstractTermLike{Int} since it can act as a term with coefficient 1.

      source
      MultivariatePolynomials.TermType
      struct Term{CoeffType,M<:AbstractMonomial} <: AbstractTerm{CoeffType}
           coefficient::CoeffType
           monomial::M
      -end

      A representation of the multiplication between a coefficient and a monomial.

      Note

      The coefficient does not need to be a Number. It can be for instance a multivariate polynomial. When computing a multivariate gcd, it is actually reformulated as a univariate gcd in one of the variable with coefficients being multivariate polynomials in the other variables. To create such a term, use term instead of *. For instance, if p is a polynomial and m is a monomial, p * m will multiply each term of p with m but term(p, m) will create a term with p as coefficient and m as monomial.

      source
      MultivariatePolynomials.termFunction
      term(coef, mono::AbstractMonomialLike)

      Returns a term with coefficient coef and monomial mono. There are two key difference between this and coef * mono:

      • term(coef, mono) does not copy coef and mono so modifying this term with MutableArithmetics may modifying the input of this function. To avoid this, call term(MA.copy_if_mutable(coef), MA.copy_if_mutable(mono)) where MA = MutableArithmetics.

      • Suppose that coef = (x + 1) and mono = x^2, coef * mono gives the polynomial with integer coefficients x^3 + x^2 which term(x + 1, x^2) gives a term with polynomial coefficient x + 1.

        term(p::AbstractPolynomialLike)

      Converts the polynomial p to a term. When applied on a polynomial, it throws an InexactError if it has more than one term. When applied to a term, it is the identity and does not copy it. When applied to a monomial, it create a term of type AbstractTerm{Int}.

      source
      MultivariatePolynomials.term_typeFunction
      term_type(p::AbstractPolynomialLike)

      Returns the type of the terms of p.

      term_type(::Type{PT}) where PT<:AbstractPolynomialLike

      Returns the type of the terms of a polynomial of type PT.

      term_type(p::AbstractPolynomialLike, ::Type{T}) where T

      Returns the type of the terms of p but with coefficient type T.

      term_type(::Type{PT}, ::Type{T}) where {PT<:AbstractPolynomialLike, T}

      Returns the type of the terms of a polynomial of type PT but with coefficient type T.

      source
      MultivariatePolynomials.coefficientFunction
      coefficient(t::AbstractTermLike)

      Returns the coefficient of the term t.

      coefficient(p::AbstractPolynomialLike, m::AbstractMonomialLike)

      Returns the coefficient of the monomial m in p.

      Examples

      Calling coefficient on $4x^2y$ should return $4$. Calling coefficient(2x + 4y^2 + 3, y^2) should return $4$. Calling coefficient(2x + 4y^2 + 3, x^2) should return $0$.

      source
      MultivariatePolynomials.coefficient_typeFunction
      coefficient_type(p::AbstractPolynomialLike)

      Returns the coefficient type of p.

      coefficient_type(::Type{PT}) where PT

      Returns the coefficient type of a polynomial of type PT.

      Examples

      Calling coefficient_type on $(4//5)x^2y$ should return Rational{Int}, calling coefficient_type on $1.0x^2y + 2.0x$ should return Float64 and calling coefficient_type on $xy$ should return Int.

      source
      MultivariatePolynomials.constant_termFunction
      constant_term(α, p::AbstractPolynomialLike)

      Creates a constant term with coefficient α and the same variables as p.

      constant_term(α, ::Type{PT} where {PT<:AbstractPolynomialLike}

      Creates a constant term of the term type of a polynomial of type PT.

      source
      MultivariatePolynomials.zero_termFunction
      zero_term(p::AbstractPolynomialLike{T}) where T

      Equivalent to constant_term(zero(T), p).

      zero_term(α, ::Type{PT} where {T, PT<:AbstractPolynomialLike{T}}

      Equivalent to constant_term(zero(T), PT).

      source
      MultivariatePolynomials.degree_complexFunction
      degree_complex(t::AbstractTermLike)

      Return the total complex degree of the monomial of the term t, i.e., the maximum of the total degree of the declared variables in t and the total degree of the conjugate variables in t. To be well-defined, the monomial must not contain real parts or imaginary parts of variables.

      degree_complex(t::AbstractTermLike, v::AbstractVariable)

      Returns the exponent of the variable v or its conjugate in the monomial of the term t, whatever is larger.

      See also isconj.

      source
      MultivariatePolynomials.halfdegreeFunction
      halfdegree(t::AbstractTermLike)

      Return the equivalent of ceil(degree(t)/2)for real-valued terms ordegree_complex(t)` for terms with only complex variables; however, respect any mixing between complex and real-valued variables.

      source

      Polynomials

      MultivariatePolynomials.PolynomialType
      struct Polynomial{CoeffType,T<:AbstractTerm{CoeffType},V<:AbstractVector{T}} <: AbstractPolynomial{CoeffType}
      +end

      A representation of the multiplication between a coefficient and a monomial.

      Note

      The coefficient does not need to be a Number. It can be for instance a multivariate polynomial. When computing a multivariate gcd, it is actually reformulated as a univariate gcd in one of the variable with coefficients being multivariate polynomials in the other variables. To create such a term, use term instead of *. For instance, if p is a polynomial and m is a monomial, p * m will multiply each term of p with m but term(p, m) will create a term with p as coefficient and m as monomial.

      source
      MultivariatePolynomials.termFunction
      term(coef, mono::AbstractMonomialLike)

      Returns a term with coefficient coef and monomial mono. There are two key difference between this and coef * mono:

      • term(coef, mono) does not copy coef and mono so modifying this term with MutableArithmetics may modifying the input of this function. To avoid this, call term(MA.copy_if_mutable(coef), MA.copy_if_mutable(mono)) where MA = MutableArithmetics.

      • Suppose that coef = (x + 1) and mono = x^2, coef * mono gives the polynomial with integer coefficients x^3 + x^2 which term(x + 1, x^2) gives a term with polynomial coefficient x + 1.

        term(p::AbstractPolynomialLike)

      Converts the polynomial p to a term. When applied on a polynomial, it throws an InexactError if it has more than one term. When applied to a term, it is the identity and does not copy it. When applied to a monomial, it create a term of type AbstractTerm{Int}.

      source
      MultivariatePolynomials.term_typeFunction
      term_type(p::AbstractPolynomialLike)

      Returns the type of the terms of p.

      term_type(::Type{PT}) where PT<:AbstractPolynomialLike

      Returns the type of the terms of a polynomial of type PT.

      term_type(p::AbstractPolynomialLike, ::Type{T}) where T

      Returns the type of the terms of p but with coefficient type T.

      term_type(::Type{PT}, ::Type{T}) where {PT<:AbstractPolynomialLike, T}

      Returns the type of the terms of a polynomial of type PT but with coefficient type T.

      source
      MultivariatePolynomials.coefficientFunction
      coefficient(t::AbstractTermLike)

      Returns the coefficient of the term t.

      coefficient(p::AbstractPolynomialLike, m::AbstractMonomialLike)

      Returns the coefficient of the monomial m in p.

      Examples

      Calling coefficient on $4x^2y$ should return $4$. Calling coefficient(2x + 4y^2 + 3, y^2) should return $4$. Calling coefficient(2x + 4y^2 + 3, x^2) should return $0$.

      source
      MultivariatePolynomials.coefficient_typeFunction
      coefficient_type(p::AbstractPolynomialLike)

      Returns the coefficient type of p.

      coefficient_type(::Type{PT}) where PT

      Returns the coefficient type of a polynomial of type PT.

      Examples

      Calling coefficient_type on $(4//5)x^2y$ should return Rational{Int}, calling coefficient_type on $1.0x^2y + 2.0x$ should return Float64 and calling coefficient_type on $xy$ should return Int.

      source
      MultivariatePolynomials.constant_termFunction
      constant_term(α, p::AbstractPolynomialLike)

      Creates a constant term with coefficient α and the same variables as p.

      constant_term(α, ::Type{PT} where {PT<:AbstractPolynomialLike}

      Creates a constant term of the term type of a polynomial of type PT.

      source
      MultivariatePolynomials.zero_termFunction
      zero_term(p::AbstractPolynomialLike{T}) where T

      Equivalent to constant_term(zero(T), p).

      zero_term(α, ::Type{PT} where {T, PT<:AbstractPolynomialLike{T}}

      Equivalent to constant_term(zero(T), PT).

      source
      MultivariatePolynomials.degree_complexFunction
      degree_complex(t::AbstractTermLike)

      Return the total complex degree of the monomial of the term t, i.e., the maximum of the total degree of the declared variables in t and the total degree of the conjugate variables in t. To be well-defined, the monomial must not contain real parts or imaginary parts of variables.

      degree_complex(t::AbstractTermLike, v::AbstractVariable)

      Returns the exponent of the variable v or its conjugate in the monomial of the term t, whatever is larger.

      See also isconj.

      source
      MultivariatePolynomials.halfdegreeFunction
      halfdegree(t::AbstractTermLike)

      Return the equivalent of ceil(degree(t)/2)for real-valued terms ordegree_complex(t)` for terms with only complex variables; however, respect any mixing between complex and real-valued variables.

      source

      Polynomials

      MultivariatePolynomials.PolynomialType
      struct Polynomial{CoeffType,T<:AbstractTerm{CoeffType},V<:AbstractVector{T}} <: AbstractPolynomial{CoeffType}
           terms::V
      -end

      Representation of a multivariate polynomial as a vector of nonzero terms sorted in ascending monomial order.

      source
      MultivariatePolynomials.polynomialFunction
      polynomial(p::AbstractPolynomialLike)

      Converts p to a value with polynomial type.

      polynomial(p::AbstractPolynomialLike, ::Type{T}) where T

      Converts p to a value with polynomial type with coefficient type T.

      polynomial(a::AbstractVector, mv::AbstractVector{<:AbstractMonomialLike})

      Creates a polynomial equal to dot(a, mv).

      polynomial(terms::AbstractVector{<:AbstractTerm}, s::ListState=MessyState())

      Creates a polynomial equal to sum(terms) where terms are guaranteed to be in state s.

      polynomial(f::Function, mv::AbstractVector{<:AbstractMonomialLike})

      Creates a polynomial equal to sum(f(i) * mv[i] for i in 1:length(mv)).

      Examples

      Calling polynomial([2, 4, 1], [x, x^2*y, x*y]) should return $4x^2y + xy + 2x$.

      source
      MultivariatePolynomials.polynomial_typeFunction
      polynomial_type(p::AbstractPolynomialLike)

      Returns the type that p would have if it was converted into a polynomial.

      polynomial_type(::Type{PT}) where PT<:AbstractPolynomialLike

      Returns the same as polynomial_type(::PT).

      polynomial_type(p::AbstractPolynomialLike, ::Type{T}) where T

      Returns the type that p would have if it was converted into a polynomial of coefficient type T.

      polynomial_type(::Type{PT}, ::Type{T}) where {PT<:AbstractPolynomialLike, T}

      Returns the same as polynomial_type(::PT, ::Type{T}).

      source
      MultivariatePolynomials.termsFunction
      terms(p::AbstractPolynomialLike)

      Returns an iterator over the nonzero terms of the polynomial p sorted in the decreasing monomial order.

      Examples

      Calling terms on $4x^2y + xy + 2x$ should return an iterator of $[4x^2y, xy, 2x]$.

      source
      MultivariatePolynomials.ntermsFunction
      nterms(p::AbstractPolynomialLike)

      Returns the number of nonzero terms in p, i.e. length(terms(p)).

      Examples

      Calling nterms on $4x^2y + xy + 2x$ should return 3.

      source
      MultivariatePolynomials.coefficientsFunction
      coefficients(p::AbstractPolynomialLike)

      Returns an iterator over the coefficients of p of the nonzero terms of the polynomial sorted in the decreasing monomial order.

      coefficients(p::AbstractPolynomialLike, X::AbstractVector)

      Returns an iterator over the coefficients of the monomials of X in p where X is a monomial vector not necessarily sorted but with no duplicate entry.

      Examples

      Calling coefficients on $4x^2y + xy + 2x$ should return an iterator of $[4, 1, 2]$. Calling coefficients(4x^2*y + x*y + 2x + 3, [x, 1, x*y, y]) should return an iterator of $[2, 3, 1, 0]$.

      source
      MultivariatePolynomials.coefficientMethod
      coefficient(p::AbstractPolynomialLike, m::AbstractMonomialLike, vars)::AbstractPolynomialLike

      Returns the coefficient of the monomial m of the polynomial p considered as a polynomial in variables vars.

      Example

      Calling coefficient((a+b)x^2+2x+y*x^2, x^2, [x,y]) should return a+b. Calling coefficient((a+b)x^2+2x+y*x^2, x^2, [x]) should return a+b+y.

      source
      MultivariatePolynomials.monomialsFunction
      monomials(p::AbstractPolynomialLike)

      Returns an iterator over the monomials of p of the nonzero terms of the polynomial sorted in the decreasing order.

      monomials(vars::Tuple, degs::AbstractVector{Int}, filter::Function = m -> true)

      Builds the vector of all the monomial_vector m with variables vars such that the degree degree(m) is in degs and filter(m) is true.

      Examples

      Calling monomials on $4x^2y + xy + 2x$ should return an iterator of $[x^2y, xy, x]$.

      Calling monomials((x, y), [1, 3], m -> degree(m, y) != 1) should return [x^3, x*y^2, y^3, x] where x^2*y and y have been excluded by the filter.

      source
      MultivariatePolynomials.mindegreeFunction
      mindegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractPolynomialLike}})

      Returns the minimal total degree of the monomials of p, i.e. minimum(degree, terms(p)).

      mindegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractPolynomialLike}}, v::AbstractVariable)

      Returns the minimal degree of the monomials of p in the variable v, i.e. minimum(degree.(terms(p), v)).

      Examples

      Calling mindegree on on $4x^2y + xy + 2x$ should return 1, mindegree(4x^2y + xy + 2x, x) should return 1 and mindegree(4x^2y + xy + 2x, y) should return 0.

      source
      MultivariatePolynomials.maxdegreeFunction
      maxdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}})

      Returns the maximal total degree of the monomials of p, i.e. maximum(degree, terms(p)).

      maxdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}}, v::AbstractVariable)

      Returns the maximal degree of the monomials of p in the variable v, i.e. maximum(degree.(terms(p), v)).

      Examples

      Calling maxdegree on $4x^2y + xy + 2x$ should return 3, maxdegree(4x^2y + xy + 2x, x) should return 2 and maxdegree(4x^2y + xy + 2x, y) should return 1.

      source
      MultivariatePolynomials.extdegreeFunction
      extdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractPolynomialLike}})

      Returns the extremal total degrees of the monomials of p, i.e. (mindegree(p), maxdegree(p)).

      extdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractPolynomialLike}}, v::AbstractVariable)

      Returns the extremal degrees of the monomials of p in the variable v, i.e. (mindegree(p, v), maxdegree(p, v)).

      Examples

      Calling extdegree on $4x^2y + xy + 2x$ should return (1, 3), extdegree(4x^2y + xy + 2x, x) should return (1, 2) and maxdegree(4x^2y + xy + 2x, y) should return (0, 1).

      source
      MultivariatePolynomials.leading_termFunction
      leading_term(p::AbstractPolynomialLike)

      Returns the leading term, i.e. last(terms(p)).

      Examples

      Calling leading_term on $4x^2y + xy + 2x$ should return $4x^2y$.

      source
      MultivariatePolynomials.leading_coefficientFunction
      leading_coefficient(p::AbstractPolynomialLike)

      Returns the coefficient of the leading term of p, i.e. coefficient(leading_term(p)).

      Examples

      Calling leading_coefficient on $4x^2y + xy + 2x$ should return $4$ and calling it on $0$ should return $0$.

      source
      MultivariatePolynomials.leading_monomialFunction
      leading_monomial(p::AbstractPolynomialLike)

      Returns the monomial of the leading term of p, i.e. monomial(leading_term(p)) or last(monomials(p)).

      Examples

      Calling leading_monomial on $4x^2y + xy + 2x$ should return $x^2y$.

      source
      MultivariatePolynomials.remove_leading_termFunction
      remove_leading_term(p::AbstractPolynomialLike)

      Returns a polynomial with the leading term removed in the polynomial p.

      Examples

      Calling remove_leading_term on $4x^2y + xy + 2x$ should return $xy + 2x$.

      source
      MultivariatePolynomials.remove_monomialsFunction

      Returns a polynomial with the terms having their monomial in the monomial vector mv removed in the polynomial p.

      Examples

      Calling remove_monomials(4x^2*y + x*y + 2x, [x*y]) should return $4x^2*y + 2x$.

      source
      MultivariatePolynomials.filter_termsFunction
      function filter_terms(f::Function, p::AbstractPolynomialLike)

      Filter the polynomial p by only keep the terms t such that f(p) is true.

      See also OfDegree.

      Examples

      julia> p = 1 - 2x + x * y - 3y^2 + x^2 * y
      +end

      Representation of a multivariate polynomial as a vector of nonzero terms sorted in ascending monomial order.

      source
      MultivariatePolynomials.polynomialFunction
      polynomial(p::AbstractPolynomialLike)

      Converts p to a value with polynomial type.

      polynomial(p::AbstractPolynomialLike, ::Type{T}) where T

      Converts p to a value with polynomial type with coefficient type T.

      polynomial(a::AbstractVector, mv::AbstractVector{<:AbstractMonomialLike})

      Creates a polynomial equal to dot(a, mv).

      polynomial(terms::AbstractVector{<:AbstractTerm}, s::ListState=MessyState())

      Creates a polynomial equal to sum(terms) where terms are guaranteed to be in state s.

      polynomial(f::Function, mv::AbstractVector{<:AbstractMonomialLike})

      Creates a polynomial equal to sum(f(i) * mv[i] for i in 1:length(mv)).

      Examples

      Calling polynomial([2, 4, 1], [x, x^2*y, x*y]) should return $4x^2y + xy + 2x$.

      source
      MultivariatePolynomials.polynomial_typeFunction
      polynomial_type(p::AbstractPolynomialLike)

      Returns the type that p would have if it was converted into a polynomial.

      polynomial_type(::Type{PT}) where PT<:AbstractPolynomialLike

      Returns the same as polynomial_type(::PT).

      polynomial_type(p::AbstractPolynomialLike, ::Type{T}) where T

      Returns the type that p would have if it was converted into a polynomial of coefficient type T.

      polynomial_type(::Type{PT}, ::Type{T}) where {PT<:AbstractPolynomialLike, T}

      Returns the same as polynomial_type(::PT, ::Type{T}).

      source
      MultivariatePolynomials.termsFunction
      terms(p::AbstractPolynomialLike)

      Returns an iterator over the nonzero terms of the polynomial p sorted in the decreasing monomial order.

      Examples

      Calling terms on $4x^2y + xy + 2x$ should return an iterator of $[4x^2y, xy, 2x]$.

      source
      MultivariatePolynomials.ntermsFunction
      nterms(p::AbstractPolynomialLike)

      Returns the number of nonzero terms in p, i.e. length(terms(p)).

      Examples

      Calling nterms on $4x^2y + xy + 2x$ should return 3.

      source
      MultivariatePolynomials.coefficientsFunction
      coefficients(p::AbstractPolynomialLike)

      Returns an iterator over the coefficients of p of the nonzero terms of the polynomial sorted in the decreasing monomial order.

      coefficients(p::AbstractPolynomialLike, X::AbstractVector)

      Returns an iterator over the coefficients of the monomials of X in p where X is a monomial vector not necessarily sorted but with no duplicate entry.

      Examples

      Calling coefficients on $4x^2y + xy + 2x$ should return an iterator of $[4, 1, 2]$. Calling coefficients(4x^2*y + x*y + 2x + 3, [x, 1, x*y, y]) should return an iterator of $[2, 3, 1, 0]$.

      source
      MultivariatePolynomials.coefficientMethod
      coefficient(p::AbstractPolynomialLike, m::AbstractMonomialLike, vars)::AbstractPolynomialLike

      Returns the coefficient of the monomial m of the polynomial p considered as a polynomial in variables vars.

      Example

      Calling coefficient((a+b)x^2+2x+y*x^2, x^2, [x,y]) should return a+b. Calling coefficient((a+b)x^2+2x+y*x^2, x^2, [x]) should return a+b+y.

      source
      MultivariatePolynomials.monomialsFunction
      monomials(p::AbstractPolynomialLike)

      Returns an iterator over the monomials of p of the nonzero terms of the polynomial sorted in the decreasing order.

      monomials(vars::Tuple, degs::AbstractVector{Int}, filter::Function = m -> true)

      Builds the vector of all the monomial_vector m with variables vars such that the degree degree(m) is in degs and filter(m) is true.

      Examples

      Calling monomials on $4x^2y + xy + 2x$ should return an iterator of $[x^2y, xy, x]$.

      Calling monomials((x, y), [1, 3], m -> degree(m, y) != 1) should return [x^3, x*y^2, y^3, x] where x^2*y and y have been excluded by the filter.

      source
      MultivariatePolynomials.mindegreeFunction
      mindegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractPolynomialLike}})

      Returns the minimal total degree of the monomials of p, i.e. minimum(degree, terms(p)).

      mindegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractPolynomialLike}}, v::AbstractVariable)

      Returns the minimal degree of the monomials of p in the variable v, i.e. minimum(degree.(terms(p), v)).

      Examples

      Calling mindegree on on $4x^2y + xy + 2x$ should return 1, mindegree(4x^2y + xy + 2x, x) should return 1 and mindegree(4x^2y + xy + 2x, y) should return 0.

      source
      MultivariatePolynomials.maxdegreeFunction
      maxdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}})

      Returns the maximal total degree of the monomials of p, i.e. maximum(degree, terms(p)).

      maxdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}}, v::AbstractVariable)

      Returns the maximal degree of the monomials of p in the variable v, i.e. maximum(degree.(terms(p), v)).

      Examples

      Calling maxdegree on $4x^2y + xy + 2x$ should return 3, maxdegree(4x^2y + xy + 2x, x) should return 2 and maxdegree(4x^2y + xy + 2x, y) should return 1.

      source
      MultivariatePolynomials.extdegreeFunction
      extdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractPolynomialLike}})

      Returns the extremal total degrees of the monomials of p, i.e. (mindegree(p), maxdegree(p)).

      extdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractPolynomialLike}}, v::AbstractVariable)

      Returns the extremal degrees of the monomials of p in the variable v, i.e. (mindegree(p, v), maxdegree(p, v)).

      Examples

      Calling extdegree on $4x^2y + xy + 2x$ should return (1, 3), extdegree(4x^2y + xy + 2x, x) should return (1, 2) and maxdegree(4x^2y + xy + 2x, y) should return (0, 1).

      source
      MultivariatePolynomials.leading_termFunction
      leading_term(p::AbstractPolynomialLike)

      Returns the leading term, i.e. last(terms(p)).

      Examples

      Calling leading_term on $4x^2y + xy + 2x$ should return $4x^2y$.

      source
      MultivariatePolynomials.leading_coefficientFunction
      leading_coefficient(p::AbstractPolynomialLike)

      Returns the coefficient of the leading term of p, i.e. coefficient(leading_term(p)).

      Examples

      Calling leading_coefficient on $4x^2y + xy + 2x$ should return $4$ and calling it on $0$ should return $0$.

      source
      MultivariatePolynomials.leading_monomialFunction
      leading_monomial(p::AbstractPolynomialLike)

      Returns the monomial of the leading term of p, i.e. monomial(leading_term(p)) or last(monomials(p)).

      Examples

      Calling leading_monomial on $4x^2y + xy + 2x$ should return $x^2y$.

      source
      MultivariatePolynomials.remove_leading_termFunction
      remove_leading_term(p::AbstractPolynomialLike)

      Returns a polynomial with the leading term removed in the polynomial p.

      Examples

      Calling remove_leading_term on $4x^2y + xy + 2x$ should return $xy + 2x$.

      source
      MultivariatePolynomials.remove_monomialsFunction

      Returns a polynomial with the terms having their monomial in the monomial vector mv removed in the polynomial p.

      Examples

      Calling remove_monomials(4x^2*y + x*y + 2x, [x*y]) should return $4x^2*y + 2x$.

      source
      MultivariatePolynomials.filter_termsFunction
      function filter_terms(f::Function, p::AbstractPolynomialLike)

      Filter the polynomial p by only keep the terms t such that f(p) is true.

      See also OfDegree.

      Examples

      julia> p = 1 - 2x + x * y - 3y^2 + x^2 * y
       1 - 2x - 3y² + xy + x²y
       
       julia> filter_terms(OfDegree(2), p)
      @@ -21,6 +21,6 @@
       x²y
       
       julia> filter_terms(iseven ∘ coefficient, p)
      --2x
      source
      MultivariatePolynomials.monicFunction
      monic(p::AbstractPolynomialLike)

      Returns p / leading_coefficient(p) where the leading coefficient of the returned polynomials is made sure to be exactly one to avoid rounding error.

      source
      MultivariatePolynomials.map_coefficientsFunction
      map_coefficients(f::Function, p::AbstractPolynomialLike, nonzero = false)

      Returns a polynomial with the same monomials as p but each coefficient α is replaced by f(α). The function may return zero in which case the term is dropped. If the function is known to never return zero for a nonzero input, nonzero can be set to true to get a small speedup.

      See also map_coefficients! and map_coefficients_to!.

      Examples

      Calling map_coefficients(α -> mod(3α, 6), 2x*y + 3x + 1) should return 3x + 3.

      source
      MultivariatePolynomials.map_coefficients!Function
      map_coefficients!(f::Function, p::AbstractPolynomialLike, nonzero = false)

      Mutate p by replacing each coefficient α by f(α). The function may return zero in which case the term is dropped. If the function is known to never return zero for a nonzero input, nonzero can be set to true to get a small speedup. The function returns p, which is identically equal to the second argument.

      See also map_coefficients and map_coefficients_to!.

      Examples

      Let p = 2x*y + 3x + 1, after map_coefficients!(α -> mod(3α, 6), p), p is equal to 3x + 3.

      source
      MultivariatePolynomials.map_coefficients_to!Function
      map_coefficients_to!(output::AbstractPolynomialLike, f::Function, p::AbstractPolynomialLike, nonzero = false)

      Mutate output by replacing each coefficient α of p by f(α). The function may return zero in which case the term is dropped. If the function is known to never returns zero for a nonzero input, nonzero can be set to true to get a small speedup. The function returns output, which is identically equal to the first argument.

      See also map_coefficients! and map_coefficients.

      source
      Base.conjMethod
      conj(x::AbstractPolynomialLike)

      Return the complex conjugate of x by applying conjugation to all coefficients and variables.

      source
      Base.realMethod
      real(x::AbstractPolynomialLike)

      Return the real part of x by applying real to all coefficients and variables; for this purpose, every complex-valued variable is decomposed into its real- and imaginary parts.

      See also imag.

      source
      Base.imagMethod
      imag(x::AbstractPolynomialLike)

      Return the imaginary part of x by applying imag to all coefficients and variables; for this purpose, every complex-valued variable is decomposed into its real- and imaginary parts.

      See also real.

      source
      Base.isrealMethod
      isreal(p::AbstractPolynomialLike)

      Returns true if and only if no single variable in p was declared as a complex variable (in the sense that isreal applied on them would be true) and no coefficient is complex-valued.

      source
      MultivariatePolynomials.mindegree_complexFunction
      mindegree_complex(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}})

      Return the minimal total complex degree of the monomials of p, i.e., minimum(degree_complex, terms(p)).

      mindegree_complex(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}}, v::AbstractVariable)

      Return the minimal complex degree of the monomials of p in the variable v, i.e., minimum(degree_complex.(terms(p), v)).

      source
      MultivariatePolynomials.minhalfdegreeFunction
      minhalfdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}})

      Return the minmal half degree of the monomials of p, i.e., minimum(halfdegree, terms(p))

      source
      MultivariatePolynomials.maxdegree_complexFunction
      maxdegree_complex(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}})

      Return the maximal total complex degree of the monomials of p, i.e., maximum(degree_complex, terms(p)).

      maxdegree_complex(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}}, v::AbstractVariable)

      Return the maximal complex degree of the monomials of p in the variable v, i.e., maximum(degree_complex.(terms(p), v)).

      source
      MultivariatePolynomials.maxhalfdegreeFunction
      maxhalfdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}})

      Return the maximal half degree of the monomials of p, i.e., maximum(halfdegree, terms(p))

      source
      MultivariatePolynomials.extdegree_complexFunction
      extdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}})

      Returns the extremal total complex degrees of the monomials of p, i.e., (mindegree_complex(p), maxdegree_complex(p)).

      extdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}}, v::AbstractVariable)

      Returns the extremal complex degrees of the monomials of p in the variable v, i.e., (mindegree_complex(p, v), maxdegree_complex(p, v)).

      source
      MultivariatePolynomials.exthalfdegreeFunction
      exthalfdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}})

      Return the extremal half degree of the monomials of p, i.e., (minhalfdegree(p), maxhalfdegree(p))

      source

      Rational Polynomial Function

      A rational polynomial function can be constructed with the / operator. Common operations such as +, -, *, - have been implemented between rational functions. The numerator and denominator polynomials can be retrieved by the numerator and denominator functions.

      Monomial Vectors

      MultivariatePolynomials.monomial_vectorFunction
      monomial_vector(X::AbstractVector{MT}) where {MT<:AbstractMonomialLike}

      Returns the vector of monomials X in increasing order and without any duplicates.

      Examples

      Calling monomial_vector on $[xy, x, xy, x^2y, x]$ should return $[x^2y, xy, x]$.

      source
      monomial_vector(a, X::AbstractVector{MT}) where {MT<:AbstractMonomialLike}

      Returns b, Y where Y is the vector of monomials of X in increasing order and without any duplicates and b is the vector of corresponding coefficients in a, where coefficients of duplicate entries are summed together.

      Examples

      Calling monomial_vector on $[2, 1, 4, 3, -1], [xy, x, xy, x^2y, x]$ should return $[3, 6, 0], [x^2y, xy, x]$.

      source
      MultivariatePolynomials.sort_monomial_vectorFunction
      sort_monomial_vector(X::AbstractVector{MT}) where {MT<:AbstractMonomialLike}

      Returns σ, the orders in which one must take the monomials in X to make them sorted and without any duplicate and the sorted vector of monomials, i.e. it returns (σ, X[σ]).

      Examples

      Calling sort_monomial_vector on $[xy, x, xy, x^2y, x]$ should return $([4, 1, 2], [x^2y, xy, x])$.

      source
      MultivariatePolynomials.merge_monomial_vectorsFunction
      merge_monomial_vectors{MT<:AbstractMonomialLike, MVT<:AbstractVector{MT}}(X::AbstractVector{MVT}}

      Returns the vector of monomials in the entries of X in increasing order and without any duplicates, i.e. monomial_vector(vcat(X...))

      Examples

      Calling merge_monomial_vectors on $[[xy, x, xy], [x^2y, x]]$ should return $[x^2y, xy, x]$.

      source
      Base.conjMethod
      conj(x::AbstractVector{<:AbstractMonomial})

      Return the complex conjugate of x by applying conjugation to monomials.

      source
      Base.realMethod
      real(x::AbstractVector{<:AbstractMonomial})

      Return the real part of x by applying real to all monomials; for this purpose, every complex-valued variable is decomposed into its real- and imaginary parts. Note that the result will no longer be a monomial vector.

      See also imag.

      source
      Base.imagMethod
      imag(x::AbstractVector{<:AbstractMonomial})

      Return the imaginary part of x by applying imag to all monomials; for this purpose, every complex-valued variable is decomposed into its real- and imaginary parts. Note that the result will no longer be a monomial vector.

      See also real.

      source
      Base.isrealMethod
      isreal(p::AbstractVector{<:AbstractMonomial})

      Returns true if and only if every single monomial in p would is real-valued.

      source
      +end

      A function d::OfDegree is such that d(t) returns degree(t) == d.degree. Note that !d creates the negation. See also filter_terms.

      source
      MultivariatePolynomials.monicFunction
      monic(p::AbstractPolynomialLike)

      Returns p / leading_coefficient(p) where the leading coefficient of the returned polynomials is made sure to be exactly one to avoid rounding error.

      source
      MultivariatePolynomials.map_coefficientsFunction
      map_coefficients(f::Function, p::AbstractPolynomialLike, nonzero = false)

      Returns a polynomial with the same monomials as p but each coefficient α is replaced by f(α). The function may return zero in which case the term is dropped. If the function is known to never return zero for a nonzero input, nonzero can be set to true to get a small speedup.

      See also map_coefficients! and map_coefficients_to!.

      Examples

      Calling map_coefficients(α -> mod(3α, 6), 2x*y + 3x + 1) should return 3x + 3.

      source
      MultivariatePolynomials.map_coefficients!Function
      map_coefficients!(f::Function, p::AbstractPolynomialLike, nonzero = false)

      Mutate p by replacing each coefficient α by f(α). The function may return zero in which case the term is dropped. If the function is known to never return zero for a nonzero input, nonzero can be set to true to get a small speedup. The function returns p, which is identically equal to the second argument.

      See also map_coefficients and map_coefficients_to!.

      Examples

      Let p = 2x*y + 3x + 1, after map_coefficients!(α -> mod(3α, 6), p), p is equal to 3x + 3.

      source
      MultivariatePolynomials.map_coefficients_to!Function
      map_coefficients_to!(output::AbstractPolynomialLike, f::Function, p::AbstractPolynomialLike, nonzero = false)

      Mutate output by replacing each coefficient α of p by f(α). The function may return zero in which case the term is dropped. If the function is known to never returns zero for a nonzero input, nonzero can be set to true to get a small speedup. The function returns output, which is identically equal to the first argument.

      See also map_coefficients! and map_coefficients.

      source
      Base.conjMethod
      conj(x::AbstractPolynomialLike)

      Return the complex conjugate of x by applying conjugation to all coefficients and variables.

      source
      Base.realMethod
      real(x::AbstractPolynomialLike)

      Return the real part of x by applying real to all coefficients and variables; for this purpose, every complex-valued variable is decomposed into its real- and imaginary parts.

      See also imag.

      source
      Base.imagMethod
      imag(x::AbstractPolynomialLike)

      Return the imaginary part of x by applying imag to all coefficients and variables; for this purpose, every complex-valued variable is decomposed into its real- and imaginary parts.

      See also real.

      source
      Base.isrealMethod
      isreal(p::AbstractPolynomialLike)

      Returns true if and only if no single variable in p was declared as a complex variable (in the sense that isreal applied on them would be true) and no coefficient is complex-valued.

      source
      MultivariatePolynomials.mindegree_complexFunction
      mindegree_complex(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}})

      Return the minimal total complex degree of the monomials of p, i.e., minimum(degree_complex, terms(p)).

      mindegree_complex(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}}, v::AbstractVariable)

      Return the minimal complex degree of the monomials of p in the variable v, i.e., minimum(degree_complex.(terms(p), v)).

      source
      MultivariatePolynomials.minhalfdegreeFunction
      minhalfdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}})

      Return the minmal half degree of the monomials of p, i.e., minimum(halfdegree, terms(p))

      source
      MultivariatePolynomials.maxdegree_complexFunction
      maxdegree_complex(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}})

      Return the maximal total complex degree of the monomials of p, i.e., maximum(degree_complex, terms(p)).

      maxdegree_complex(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}}, v::AbstractVariable)

      Return the maximal complex degree of the monomials of p in the variable v, i.e., maximum(degree_complex.(terms(p), v)).

      source
      MultivariatePolynomials.maxhalfdegreeFunction
      maxhalfdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}})

      Return the maximal half degree of the monomials of p, i.e., maximum(halfdegree, terms(p))

      source
      MultivariatePolynomials.extdegree_complexFunction
      extdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}})

      Returns the extremal total complex degrees of the monomials of p, i.e., (mindegree_complex(p), maxdegree_complex(p)).

      extdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}}, v::AbstractVariable)

      Returns the extremal complex degrees of the monomials of p in the variable v, i.e., (mindegree_complex(p, v), maxdegree_complex(p, v)).

      source
      MultivariatePolynomials.exthalfdegreeFunction
      exthalfdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}})

      Return the extremal half degree of the monomials of p, i.e., (minhalfdegree(p), maxhalfdegree(p))

      source

      Rational Polynomial Function

      A rational polynomial function can be constructed with the / operator. Common operations such as +, -, *, - have been implemented between rational functions. The numerator and denominator polynomials can be retrieved by the numerator and denominator functions.

      Monomial Vectors

      MultivariatePolynomials.monomial_vectorFunction
      monomial_vector(X::AbstractVector{MT}) where {MT<:AbstractMonomialLike}

      Returns the vector of monomials X in increasing order and without any duplicates.

      Examples

      Calling monomial_vector on $[xy, x, xy, x^2y, x]$ should return $[x^2y, xy, x]$.

      source
      monomial_vector(a, X::AbstractVector{MT}) where {MT<:AbstractMonomialLike}

      Returns b, Y where Y is the vector of monomials of X in increasing order and without any duplicates and b is the vector of corresponding coefficients in a, where coefficients of duplicate entries are summed together.

      Examples

      Calling monomial_vector on $[2, 1, 4, 3, -1], [xy, x, xy, x^2y, x]$ should return $[3, 6, 0], [x^2y, xy, x]$.

      source
      MultivariatePolynomials.sort_monomial_vectorFunction
      sort_monomial_vector(X::AbstractVector{MT}) where {MT<:AbstractMonomialLike}

      Returns σ, the orders in which one must take the monomials in X to make them sorted and without any duplicate and the sorted vector of monomials, i.e. it returns (σ, X[σ]).

      Examples

      Calling sort_monomial_vector on $[xy, x, xy, x^2y, x]$ should return $([4, 1, 2], [x^2y, xy, x])$.

      source
      MultivariatePolynomials.merge_monomial_vectorsFunction
      merge_monomial_vectors{MT<:AbstractMonomialLike, MVT<:AbstractVector{MT}}(X::AbstractVector{MVT}}

      Returns the vector of monomials in the entries of X in increasing order and without any duplicates, i.e. monomial_vector(vcat(X...))

      Examples

      Calling merge_monomial_vectors on $[[xy, x, xy], [x^2y, x]]$ should return $[x^2y, xy, x]$.

      source
      Base.conjMethod
      conj(x::AbstractVector{<:AbstractMonomial})

      Return the complex conjugate of x by applying conjugation to monomials.

      source
      Base.realMethod
      real(x::AbstractVector{<:AbstractMonomial})

      Return the real part of x by applying real to all monomials; for this purpose, every complex-valued variable is decomposed into its real- and imaginary parts. Note that the result will no longer be a monomial vector.

      See also imag.

      source
      Base.imagMethod
      imag(x::AbstractVector{<:AbstractMonomial})

      Return the imaginary part of x by applying imag to all monomials; for this purpose, every complex-valued variable is decomposed into its real- and imaginary parts. Note that the result will no longer be a monomial vector.

      See also real.

      source
      Base.isrealMethod
      isreal(p::AbstractVector{<:AbstractMonomial})

      Returns true if and only if every single monomial in p would is real-valued.

      source