Multivariate Polynomials

**POLYNOMIAL**,
a Python library which
adds, multiplies, differentiates, evaluates and prints multivariate
polynomials in a space of M dimensions.

Any polynomial in M variables can be written as a linear combination of monomials in M variables. The "total degree" of the polynomial is the maximum of the degrees of the monomials that it comprises. For instance, a polynomial in M = 2 variables of total degree 3 might have the form:

p(x,y) = c(0,0) x^0 y^0 + c(1,0) x^1 y^0 + c(0,1) x^0 y^1 + c(2,0) x^2 y^0 + c(1,1) x^1 y^1 + c(0,2) x^0 y^2 + c(3,0) x^3 y^0 + c(2,1) x^2 y^1 + c(1,2) x^1 y^2 + c(0,3) x^0 y^3The monomials in M variables can be regarded as a natural basis for the polynomials in M variables.

When listing the monomials that form a polynomial, it is useful to have an ordering that organizes them. One natural ordering can be illustrated for the 3-dimensional case:

1 x, y, z x^2, xy, xz, y^2, yz, z^2 x^3, x^2y, x^2z, xy^2, xyz, xz^2, y^3, y^2z, yz^2, z^3 x^4, x^3y, ...Here, a monomial precedes another if it has a lower degree. If the monomials have the same degree, then a monomial precedes another if its exponent vector lexically precedes that of the other. In other words, we compare the two exponent vectors, reading from left to right, looking for the first location where the exponents differ. The monomial with the higher exponent at this point precedes the other.

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

**POLYNOMIAL** is available in
a C version and
a C++ version and
a FORTRAN77 version and
a FORTRAN90 version and
a MATLAB version and
a Python version.

LEGENDRE_PRODUCT_POLYNOMIAL, a Python library which defines Legendre product polynomials, creating a multivariate polynomial as the product of univariate Legendre polynomials.

MONOMIAL, a Python library which enumerates, lists, ranks, unranks and randomizes multivariate monomials in a space of M dimensions, with total degree less than N, equal to N, or lying within a given range.

SUBSET, a Python library which enumerates, generates, ranks and unranks combinatorial objects including combinations, compositions, Gray codes, index sets, partitions, permutations, subsets, and Young tables.

- i4_choose.py, computes the binomial coefficient C(N,K) as an I4.
- i4_fall.py, computes the falling factorial function.
- i4_fall_values.py, some values of the falling factorial function.
- i4_uniform_ab.py, returns a scaled uniform I4 between A and B.
- i4vec_concatenate.py, concatenates two I4VEC's.
- i4vec_permute.py, applies a 0-based permutation to an I4VEC.
- i4vec_print.py, prints an I4VEC.
- i4vec_sort_heap_index_a.py, returns an index vector to ascending sort an I4VEC.
- i4vec_sum.py, sums the elements of an I4VEC.
- i4vec_uniform_ab.py, returns an I4VEC whose entries are uniformly random between A and B.
- mono_next_grlex.py, computes, one by one in grlex order, the monomials of D variables of successively higher degrees.
- mono_print.py, prints a monomial.
- mono_rank_grlex.py, ranks a monomial in grlex order.
- mono_total_next_grlex.py, next monomial in grlex order, total degree equals N.
- mono_unrank_grlex.py, unranks a monomial in grlex order.
- mono_upto_enum.py, enumerates the monomials of D variables of total degree up to N.
- mono_upto_next_grlex.py, next monomial in grlex order, total degree up to N.
- mono_upto_random.py, random monomial with total degree up to N.
- mono_value.py, evaluates a monomial.
- perm0_check.py, checks a 0-based permutation.
- perm0_uniform.py, randomly selects a permutation of the integers 0 through N-1.
- polynomial_add.py, adds two polynomials.
- polynomial_axpy.py, adds a multiple of one polynomial to another.
- polynomial_compress.py, "compresses" a polynomial by merging coefficients associated with the same monomial.
- polynomial_dif.py, differentiates a polynomial several times with respect to several variables.
- polynomial_mul.py, multiplies two polynomials.
- polynomial_print.py, prints a polynomial.
- polynomial_scale.py, scales a polynomial.
- polynomial_sort.py, sorts a polynomial.
- polynomial_value.py, evaluates a polynomial.
- r8vec_concatenate.py, concatenates two R8VEC's.
- r8vec_permute.py, permutes an R8VEC.
- r8vec_print.py, prints an R8VEC.
- timestamp.py, prints the YMDHMS date as a timestamp.

- polynomial_test.py, calls all the tests;
- polynomial_test.sh, runs all the tests;
- polynomial_test_output.txt, the output file.

You can go up one level to the Python source codes.