Polynomial

The domain constructor Polynomial (abbreviation: POLY) provides polynomials with an arbitrary number of unspecified variables. It is used to create the default polynomial domains in Axiom. Here the coefficients are integers.

Here the coefficients have type Float.

And here we have a polynomial in two variables with coefficients which have type Fraction Integer

The representation of objects of domains created by Polynomial is that of recursive univariate polynomials. (The term univariate means "one variable". The term multivariate means "possibly more than one variable".) This recursive structure is sometimes obvious from the display of a polynomial.

In this example, you see that the polynomial is stored as a polynomial in y with coefficients that are polynomials in x with integer coefficients. In fact, you really don't need to worry about the representation unless you are working on an advanced application where it is critical. The polynomial types created from DistributedMultivariatePolynomial and XDistributedPolynomial (discussed in "DistributedMultivariatePolynomial" are stored and displayed in a non-recursive manner. You see a "flat" display of the above polynomial by converting to one of those types.

We will demonstrate many of the polynomial facilities by using two polynomials with integer coefficients. By default, the interpreter expands polynomial expressions, even if they are written in a factored format.

See Factored to see how to create objects in factored form directly.

The fully factored form can be recovered by using factor

This is the same name used for the operation to factor integer. Such reuse of names is called overloading and makes it much easier to think of solving problems in general ways. Axiom facilities for factoring polynomials created with Polynomial are currently restricted to the integer and rational number coefficients cases. There are more complete facilities for factoring univariate polynomials (see Polynomial Factorization) The standard arithmetic operations are available for polynomials.

The operation gcd is used to compute the greated common divisor of two polynomials.

In the case of p and q, the gcd is obvious from their definitions. We factor the gcd to show this relationship better.

The least common multiple is computed by using lcm.

Use content to compute the greatest common divisor of the coefficients of the polynomial.

Many of the operations on polynomials require you to specify a variable. For example, resultant requires you to give the variable in which the polynomials should be expressed. This computes the resultant of the values of p and q, considering them as polynomials in the variable z. They do not share a root when thought of as polynomials in z.

This value is 0 because as polynomials in x the polynomials have a common root.

The data type used for the variables created by Polynomial is Symbol. As mentioned above, the representation used by Polynomial is recursive and so there is a main variable for nonconstant polynomials. The operation makeVariable returns this variable. The return type is actually a union of Symbol and "failed".

The latter branch of the union is used if the polynomial has no variables, that is, is a constant.

The complete list of variables actually used in a particular polynomial is returned by variables. For constant polynomials, this list is empty.

The degree operation returns the degree of a polynomial in a specific variable.

If you give a list of variables for the second argument, a list of the degrees in those variables is returned.

The minimum degree of a variable in a polynomial is computed using minimumDegree.

The total degree of a polynomial is returned by totalDegree.

It is often convenient to think of a polynomial as a leading monomial plus the remaining terms, using the operation leadingMonomial

The reductum operation returns a polynomial consisting of the sum of the monomials after the first.

These have the obvious relationship that the original polynomial is equal to the leading monomial plus the reductum.

The value returned by leadingMonomial includes the coefficient of that term. This is extracted by using leadingCoefficient on the original polynomial.

The operation eval is used to substitute a value for a varialbe in a polynomial.

This value may be another variable, a constant or a polynomial.

Actually, all the things being substituted are just polynomials, some more trivial than others.

Derivatives are computed using the D operation.

The first argument is the polynomial and the second is the variable.

Even if the polynomial has only one variable, you must specify it.

Integration of polynomials is similar and the integrate operation is used. Integration requires that the coefficients support division. Consequently, Axiom converts polynomials over the integers to polynomials over the rational numbers before integrating them.

It is not possible, in general, to divide two polynomials. In our example using polynomials over the integers, the operation monicDivide divides a polynomial by a monic polynomial (that is, a polynomial with leading coefficient equal to 1). The result is a record of the quotient and remainder of the division. You must specify the variable in which to express the polynomial.

The selectors of the components of the record are quotient and remainder. Issue this to extract the remainder:

Now that we can extract the components, we can demonstrate the relationship among them and the arguments to our original expression

      qr:=monicDivide(p,x+1,x)

If the / operator is used with polynomials, a fraction object is created. In this example, the result is an object of type Fraction Polynomial Integer.

If you use rational numbers as polynomial coefficients, the resulting object is of type Polynomial Fraction Integer

This can be converted to a fraction of polynomials and back again, if required.

To convert the coefficients to floating point, map the numeric operation on the coefficients of the polynomial.

For more information on related topcis, see UnivariatePolynomial, MultivariatePolynomial, and DistributedMultivariatePolynomial. You can also issue the system command

to display the full list of operations defined by Polynomial.