polynomial, a C code 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^3
The 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:

        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 MIT license


polynomial is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.

Related Data and Programs:

COMBO, a C code which includes routines for ranking, unranking, enumerating and randomly selecting balanced sequences, cycles, graphs, Gray codes, subsets, partitions, permutations, restricted growth functions, Pruefer codes and trees.

HERMITE_PRODUCT_POLYNOMIAL, a C code which defines Hermite product polynomials, creating a multivariate polynomial as the product of univariate Hermite polynomials.

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

MONOMIAL, a C code 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.


SET_THEORY, a C code which demonstrates MATLAB commands that implement various set theoretic operations.

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

Source Code:

Last modified on 26 July 2019.