
polynorm(?Expression, -NormPoly, -Residue)

   Extracts and normalises the polynomial part of an arithmetic expression

Arguments
   Expression          Arithmetic expression with constants and variables
   NormPoly            Normalized polynomial
   Residue             Residual nonpolynomial components in the form AuxVar=Expr

Type
   library(linearize)

Description
	This predicate converts a general arithmetic expression into a
	normalized polynomial representation and possibly a nonpolynomial
	residue. The normalized polynomial representation is a follows:

	A monomial is a list of constants and variables and represents
	the product of all the list elements.
	In a normalised monomial, the list is sorted, the first element is
	the (only) constant and the others are variables.

	A normalised polynomial is represented as a list of lists of
	normalised monomials. The sublists represent groups of monomials
	of the same degree in ascending order. If there are no monomials
	for a certain degree, the list element is missing:

	[ConstantMonos, LinearMonos, QuadraticMonos, CubicMonos, ...]

	In a normalised polynomial, all monomials are normalised and
	all monomials with identical variables are merged.

	Non-polynomial components are factored out by introducing an
	auxiliary variable and adding a term Aux=NonPolyExpr to the
	Residue result list.  All variables within Expression (which
	are free at normalization time) are taken to be numerical
	variables.  If you intend to have variables which can be bound
	to symbolic expressions rather than number, they must be
	wrapped into an eval/1 functor.
    

Examples
   
    ?- polynorm(2*5 + 3*(X+5*Y+7)*Z, Poly, Res).
    X = X
    Y = Y
    Z = Z
    Poly = [[[10]], [[21, Z]], [[3, X, Z], [15, Y, Z]]]
    Res = []
    yes.

    ?- polynorm(3*(X+Y),  Poly, Res).
    X = X
    Y = Y
    Poly = [[[3, X], [3, Y]]]
    Res = []
    yes.

    ?- polynorm(3, Poly, Res).
    Poly = [[[3]]]
    Res = []
    yes.
    

See Also
   polydenorm / 2, polyrenorm / 2, linearize / 3
