dummy-link

MultivariatePolynomials

Multivariate polynomials and measures of commutative and non-commutative variables

Readme

Multivariate Polynomials

PackageEvaluator Build Status
Build Status Build Status
Coveralls branch Codecov branch

Basic arithmetic, integration, differentiation and evaluation over sparse multivariate polynomials and sparse multivariate moments. Both commutative and non-commutative variables are supported. The following types are defined:

  • PolyVar{C}: A variable which is commutative with * when C is true. Commutative variables are created using the @polyvar macro, e.g. @polyvar x y, @polyvar x[1:8] and non-commutative variables are created likewise using the @ncpolyvar macro.
  • Monomial{C}: A product of variables: e.g. x*y^2.
  • Term{C, T}: A product between an element of type T and a Monomial{C}, e.g 2x, 3.0x*y^2.
  • Polynomial{C, T}: A sum of Term{C, T}, e.g. 2x + 3.0x*y^2 + y.
  • Moment{C, T}: The multivariate moment of type T of a measure, e.g. E_μ[x*y^2] is the moment of μ corresponding to the monomial x*y^2.
  • Measure{C, T}: A combination of Moment{C, T} of a measure, e.g. the moments of x, x*y^2 and y.

All common algebraic operations between those types are designed to be as efficient as possible without doing any assumption on T. Typically, one imagine T to be a subtype of Number but it can be anything. This is useful for example in the package PolyJuMP where T is often an affine expression of JuMP decision variables. The commutativity of T with * is not assumed, even if it is the coefficient of a monomial of commutative variables. However, commutativity of T and of the variables + is always assumed. This allows to keep the terms and moments always sorted (Graded Lexicographic order is used) in polynomial and measure which enables more efficient operations.

Below is a simple usage example

@polyvar x y
p = 2x + 3.0x*y^2 + y
differentiate(p, x) # compute the derivative of p with respect to x
differentiate(p, [x, y]) # compute the gradient of p
p([y, x], [x, y]) # replace any x by y and y by x
subs(p, [x^2], [y]) # replace any occurence of y by x^2
p([1, 2], [x, y]) # evaluate p at [1, 2]

Below is an example with @polyvar x[1:n]

n = 3
A = rand(3, 3)
@polyvar x[1:n]
p = dot(x, x) # x_1^2 + x_2^2 + x_3^2
p(A*x, x) # corresponds to dot(A*x, A*x)
subs(p, [2, 3], [x[1], x[3]]) # x_2^2 + 13

Note that, when doing substitution, it is required to give the PolyVar ordering that is meant. Indeed, the ordering between the PolyVar is not alphabetical but rather by order of creation which can be undeterministic with parallel computing. Therefore, this order cannot be used for substitution, even as a default (see here for a discussion about this).

See also

  • Nemo for generic polynomial rings, matrix spaces, fraction fields, residue rings, power series

  • Polynomials for univariate polynomials

  • PolynomialRoots for a fast complex polynomial root finder

First Commit

10/28/2016

Last Touched

about 1 month ago

Commits

153 commits

Requires: