[Next] [Prev] [Right] [Left] [Up] [Index] [Root]
Creation Functions

Creation Functions

Subsections

Creation of Structures

There are two different ways to create polynomial rings, corresponding to the different internal representations (vector versus distributive --- see the introductory section): PolynomialRing(S) and PolynomialRing(S, n). The latter should be used to create multivariate polynomials; the former is recommended for univariate polynomials.

PolynomialAlgebra(P) : Rng -> RngUPol
PolynomialRing(P) : Rng -> RngUPol
Create a univariate polynomial ring over the ring S. The ring is regarded as an S-algebra via the usual identification of elements of S and the constant polynomials. The polynomials are stored in vector form, which allows fast arithmetic. It is not recommended to use this function recursively to build multivariate polynomial rings. The angle bracket notation can be used to assign names to the indeterminates: P<x> := PolynomialRing(R).

Creation of Elements

The easiest way to create polynomials in a given ring is to use the angle bracket construction to attach names to the indeterminates, and to use these names to express polynomials (see the examples). Below we list other options.

One(P) : RngUPol -> RngUPolElt
Identity(P) : RngUPol -> RngUPolElt
Zero(P) : RngUPol -> RngUPolElt
Representative(P) : RngUPol -> RngUPolElt
P . 1 : RngUPol, RngInt -> RngPolElt
Return the indeterminate for the polynomial ring P, as an element of P.
elt< P | a_0, ..., a_d > : RngUPol, RngElt, ..., RngElt -> RngUPolElt
Given a polynomial ring P=R[x] and elements a_0, ..., a_d coercible into the coefficient ring R, return the polynomial a_0 + a_1x_n + ... + a_dx_n^d as an element of P.
P ! s : RngUPol, RngElt -> RngPolElt
P ! s : RngUPol, [ RngElt ] -> RngPolElt
elt< P | s > : RngUPol, [ RngElt ] -> RngUPolElt
Coerce the element s into the polynomial ring P = R[x]. The following possibilities for s exist. Note that constant polynomials cannot be coerced into their coefficient rings, but the function Coefficient can be used for that.

Example RngPol_Polynomials (H28E2)

The easiest way to create the polynomial x^3 + 3x + 1 (over the integers) is as follows.

> P<x> := PolynomialRing(Integers());
> f := x^3+3*x+1;
> f;
x^3 + 3*x + 1
Alternative ways to create polynomials are given by the element constructor and the ! operator:

> P<x> := PolynomialAlgebra(Integers());
> f := elt< P | 2, 3, 0, 1 >;
> f;
x^3 + 3*x + 2
> P ! [ 2, 3, 0, 1 ];
x^3 + 3*x + 2
Note that it is important to realize that a sequence is coerced into a polynomial ring by coercing its entries into the coefficient ring, and it is not attempted first to coerce the sequence as a whole into the coefficient ring:

> Q := RationalField();
> Q ! [1, 2];
1/2
> P<x> := PolynomialRing(Q);
> P ! [1,2];
2*x + 1
> P ! Q ! [1,2];
1/2
> P ! [ [1,2], [2,3] ];
2/3*x + 1/2

[Next] [Prev] [Right] [Left] [Up] [Index] [Root]