---
title: "Structure Operations"
canonical: "https://docs.magma-maths.org/v2.30-1/BasicRings/UnivariatePolynomialRings/operation.html"
source: "https://docs.magma-maths.org/v2.30-1/BasicRings/UnivariatePolynomialRings/operation.md"
part: "Basic Rings"
chapter: "Univariate Polynomial Rings"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Basic Rings", "source": "https://docs.magma-maths.org/v2.30-1/BasicRings/index-basic-rings.md"}
  - {"title": "Univariate Polynomial Rings", "source": "https://docs.magma-maths.org/v2.30-1/BasicRings/UnivariatePolynomialRings/index-univariate-polynomial-rings.md"}
prev: {"title": "Creation Functions", "source": "https://docs.magma-maths.org/v2.30-1/BasicRings/UnivariatePolynomialRings/creation.md"}
next: {"title": "Element Operations", "source": "https://docs.magma-maths.org/v2.30-1/BasicRings/UnivariatePolynomialRings/operation-element.md"}
intrinsics:
  - {"name": "BaseRing", "signature": "BaseRing(P): RngUPol -> Rng"}
  - {"name": "CoefficientRing", "signature": "CoefficientRing(P): RngUPol -> Rng"}
  - {"name": "CoefficientRing", "signature": "CoefficientRing(f): RngUPolElt -> Rng"}
  - {"name": "Category", "signature": "Category(P): RngUPol -> Cat"}
  - {"name": "Parent", "signature": "Parent(P): RngUPol -> Pow"}
  - {"name": "PrimeRing", "signature": "PrimeRing(P): RngUPol -> Rng"}
  - {"name": "ChangeRing", "signature": "ChangeRing(P, S): RngUPol, Rng -> RngUPol, Map"}
  - {"name": "ChangeRing", "signature": "ChangeRing(P, S, f): RngUPol, Rng, Map -> RngUPol, Map"}
  - {"name": "Rank", "signature": "Rank(P): RngUPol -> RngIntElt"}
  - {"name": "#", "signature": "# P: RngUPolRes -> RngIntElt"}
  - {"name": "Characteristic", "signature": "Characteristic(P): RngUPol -> RngIntElt"}
  - {"name": "IsCommutative", "signature": "IsCommutative(P): RngUPol -> BoolElt"}
  - {"name": "IsUnitary", "signature": "IsUnitary(P): RngUPol -> BoolElt"}
  - {"name": "IsFinite", "signature": "IsFinite(P): RngUPol -> BoolElt"}
  - {"name": "IsOrdered", "signature": "IsOrdered(P): RngUPol -> BoolElt"}
  - {"name": "IsField", "signature": "IsField(P): RngUPol -> BoolElt"}
  - {"name": "IsEuclideanDomain", "signature": "IsEuclideanDomain(P): RngUPol -> BoolElt"}
  - {"name": "IsPID", "signature": "IsPID(P): RngUPol -> BoolElt"}
  - {"name": "IsUFD", "signature": "IsUFD(P): RngUPol -> BoolElt"}
  - {"name": "IsDivisionRing", "signature": "IsDivisionRing(P): RngUPol -> BoolElt"}
  - {"name": "IsEuclideanRing", "signature": "IsEuclideanRing(P): RngUPol -> BoolElt"}
  - {"name": "IsDomain", "signature": "IsDomain(P): RngUPol -> BoolElt"}
  - {"name": "IsPrincipalIdealRing", "signature": "IsPrincipalIdealRing(P): RngUPol -> BoolElt"}
  - {"name": "eq", "signature": "P eq Q: RngUPol, RngUPol -> BoolElt"}
  - {"name": "ne", "signature": "P ne Q: RngUPol, RngUPol -> BoolElt"}
  - {"name": "lt", "signature": "P lt Q: RngUPol, RngUPol -> BoolElt"}
  - {"name": "gt", "signature": "P gt Q: RngUPol, RngUPol -> BoolElt"}
  - {"name": "le", "signature": "P le Q: RngUPol, RngUPol -> BoolElt"}
  - {"name": "ge", "signature": "P ge Q: RngUPol, RngUPol -> BoolElt"}
  - {"name": "hom", "signature": "hom< P -> S | f, y >: RngUPol, Rng, Map, RngElt -> Map"}
  - {"name": "hom", "signature": "hom< P -> S | y >: RngPol, Rng, RngElt -> Map"}
examples:
  - "ex-332ea1"
  - "ex-c83216"
---

# Structure Operations

## Related Structures

The main structure related to a polynomial ring is its coefficient ring. Univariate polynomial rings belong to the Magma category `RngUPol`.

<a id="function-basering-rngupol"></a>
### `BaseRing(P): RngUPol -> Rng`

<a id="function-coefficientring-rngupol"></a>
### `CoefficientRing(P): RngUPol -> Rng`

<a id="function-coefficientring-rngupolelt"></a>
### `CoefficientRing(f): RngUPolElt -> Rng`

Return the coefficient ring of polynomial ring $P$ (the parent of $f$).

<a id="function-category-rngupol"></a>
### `Category(P): RngUPol -> Cat`

<a id="function-parent-rngupol"></a>
### `Parent(P): RngUPol -> Pow`

<a id="function-primering-rngupol"></a>
### `PrimeRing(P): RngUPol -> Rng`

## Changing Rings

The `ChangeRing` function enables changing coefficient rings on a polynomial ring.

<a id="function-changering-rngupol-rng"></a>
### `ChangeRing(P, S): RngUPol, Rng -> RngUPol, Map`

Given a polynomial ring $P=R[x]$, together with a ring $S$, construct the polynomial ring $Q=S[y]$, together with the homomorphism $h$ from $P$ to $Q$. It is necessary that all elements of the old coefficient ring $R$ can be automatically coerced into the new coefficient ring $S$. The homomorphism $h$ will apply this coercion to the coefficients of elements in $P$ to return elements of $Q$. The usual angle bracket notation can be used for indeterminate names on the result.

<a id="function-changering-rngupol-rng-map"></a>
### `ChangeRing(P, S, f): RngUPol, Rng, Map -> RngUPol, Map`

Given a polynomial ring $P=R[x]$, together with a ring $S$ and a map $f\colon R\rightarrow S$, construct the polynomial ring $Q=S[y]$ together with the homomorphism $h$ from $P$ to $Q$ obtained by applying $h$ to the coefficients of elements of $P$. The usual angle bracket notation can be used for indeterminate names on the result.

<a id="example-ex-332ea1"></a>
### `Example: Changing the Coefficient Ring (ex-332ea1)`

In the first example of `ChangeRing` below we use automatic coercion of integers to rationals to go from ${\mathbb{Z}}[x]$ to ${\mathbb{Q}}[y]$. In fact `!` can be used for this as well. In the second example we use a map to obtain a non-standard embedding (not mapping $1$ to $1$) of ${\mathbb{Z}}$ in ${\mathbb{Q}}$.

```magma
> Z := Integers();
> Q := RationalField();
> P<x> := PolynomialRing(Z);
> S<y>, h := ChangeRing(P, Q);
> h(x^3-2*x+5);
y^3 - 2*y + 5
> S ! (x^3-2*x+5);
y^3 - 2*y + 5
> m := hom< Z -> Q | x :-> 3*x >;
> S<y>, h := ChangeRing(P, Q, m);
> h(x^3-2*x+5);
3*y^3 - 6*y + 15
```

## Numerical Invariants

The characteristic can be obtained for any polynomial ring, the rank for free polynomial rings, and the cardinality only for finite quotients.

<a id="function-rank-rngupol"></a>
### `Rank(P): RngUPol -> RngIntElt`

Return the rank of the polynomial ring $P$, defined as the maximal number of independent indeterminates in $P$ over its coefficient ring; for univariate polynomial rings this will therefore always return $1$.

<a id="operation-operation-rngupolres-rngintelt"></a>
### `# P: RngUPolRes -> RngIntElt`

Return the number of elements of $P$; this will only return an integer value if $P$ is finite, which for polynomial rings can only happen for quotients of polynomial rings over finite coefficient rings.

<a id="function-characteristic-rngupol"></a>
### `Characteristic(P): RngUPol -> RngIntElt`

## Ring Predicates and Booleans

The usual ring functions returning Boolean values are available on polynomial rings.

<a id="function-iscommutative-rngupol"></a>
### `IsCommutative(P): RngUPol -> BoolElt`

<a id="function-isunitary-rngupol"></a>
### `IsUnitary(P): RngUPol -> BoolElt`

<a id="function-isfinite-rngupol"></a>
### `IsFinite(P): RngUPol -> BoolElt`

<a id="function-isordered-rngupol"></a>
### `IsOrdered(P): RngUPol -> BoolElt`

<a id="function-isfield-rngupol"></a>
### `IsField(P): RngUPol -> BoolElt`

<a id="function-iseuclideandomain-rngupol"></a>
### `IsEuclideanDomain(P): RngUPol -> BoolElt`

<a id="function-ispid-rngupol"></a>
### `IsPID(P): RngUPol -> BoolElt`

<a id="function-isufd-rngupol"></a>
### `IsUFD(P): RngUPol -> BoolElt`

<a id="function-isdivisionring-rngupol"></a>
### `IsDivisionRing(P): RngUPol -> BoolElt`

<a id="function-iseuclideanring-rngupol"></a>
### `IsEuclideanRing(P): RngUPol -> BoolElt`

<a id="function-isdomain-rngupol"></a>
### `IsDomain(P): RngUPol -> BoolElt`

<a id="function-isprincipalidealring-rngupol"></a>
### `IsPrincipalIdealRing(P): RngUPol -> BoolElt`

<a id="operation-op-eq-rngupol-rngupol"></a>
### `P eq Q: RngUPol, RngUPol -> BoolElt`

<a id="operation-op-ne-rngupol-rngupol"></a>
### `P ne Q: RngUPol, RngUPol -> BoolElt`

<a id="operation-op-lt-rngupol-rngupol"></a>
### `P lt Q: RngUPol, RngUPol -> BoolElt`

<a id="operation-op-gt-rngupol-rngupol"></a>
### `P gt Q: RngUPol, RngUPol -> BoolElt`

<a id="operation-op-le-rngupol-rngupol"></a>
### `P le Q: RngUPol, RngUPol -> BoolElt`

<a id="operation-op-ge-rngupol-rngupol"></a>
### `P ge Q: RngUPol, RngUPol -> BoolElt`

## Homomorphisms

A ring homomorphism taking a polynomial ring $R[x]$ as its domain requires $2$ pieces of information, namely, a map (homomorphism) telling how to map the coefficient ring $R$, together with the image of the indeterminate $x$. The map may be omitted.

<a id="constructor-constructor-hom-rngupol-rng-map-rngelt-map"></a>
### `hom< P -> S | f, y >: RngUPol, Rng, Map, RngElt -> Map`

<a id="constructor-constructor-hom-rngpol-rng-rngelt-map"></a>
### `hom< P -> S | y >: RngPol, Rng, RngElt -> Map`

Given a polynomial ring $P=R[x]$, a ring $S$, a map $f : R\ar S$, and an element $y\in S$, create the homomorphism $g : P\ar S$ given by that $g(\sum s_ix^i)=\sum f(s_i)y^{i}$. The coefficient ring map may be omitted, in which case the coefficients are mapped into $S$ by the unitary homomorphism sending $1_R$ to $1_S$. Also, the image $y$ is allowed to be from a structure that allows automatic coercion into $S$.

<a id="example-ex-c83216"></a>
### `Example: Homomorphism into the Real Field (ex-c83216)`

In this example we map ${\mathbb{Z}}[x]$ into the reals by sending $x$ to $1/2$. Note that we do not have a choice for the coefficient map (since we require it to be unitary), and also that we give the image of $x$ as a rational number that is automatically coerced into the reals.

```magma
> Z := Integers();
> P<x> := PolynomialRing(Z);
> Re := RealField(20);
> half := hom< P -> Re | 1/2 >;
> half(x^3-3*x+5);
3.625
```
