# 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`.

### `BaseRing(P): RngUPol -> Rng`

### `CoefficientRing(P): RngUPol -> Rng`

### `CoefficientRing(f): RngUPolElt -> Rng`

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

### `Category(P): RngUPol -> Cat`

### `Parent(P): RngUPol -> Pow`

### `PrimeRing(P): RngUPol -> Rng`

## Changing Rings

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

### `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.

### `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.

### `Example: Change 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.

### `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$.

### `# 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.

### `Characteristic(P): RngUPol -> RngIntElt`

## Ring Predicates and Booleans

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

### `IsCommutative(P): RngUPol -> BoolElt`

### `IsUnitary(P): RngUPol -> BoolElt`

### `IsFinite(P): RngUPol -> BoolElt`

### `IsOrdered(P): RngUPol -> BoolElt`

### `IsField(P): RngUPol -> BoolElt`

### `IsEuclideanDomain(P): RngUPol -> BoolElt`

### `IsPID(P): RngUPol -> BoolElt`

### `IsUFD(P): RngUPol -> BoolElt`

### `IsDivisionRing(P): RngUPol -> BoolElt`

### `IsEuclideanRing(P): RngUPol -> BoolElt`

### `IsDomain(P): RngUPol -> BoolElt`

### `IsPrincipalIdealRing(P): RngUPol -> BoolElt`

### `P eq Q: RngUPol, RngUPol -> BoolElt`

### `P ne Q: RngUPol, RngUPol -> BoolElt`

### `P lt Q: RngUPol, RngUPol -> BoolElt`

### `P gt Q: RngUPol, RngUPol -> BoolElt`

### `P le Q: RngUPol, RngUPol -> BoolElt`

### `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.

### `hom< P -> S | f, y >: RngUPol, Rng, Map, RngElt -> Map`

### `hom< P -> S | y >: RngPol, Rng, RngElt -> Map`

Given a polynomial ring $P=R[x]$, a ring $S$, a map $f : R\rightarrow S$ and an element $y\in S$, create the homomorphism $g : P\rightarrow 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$.

### `Example: Homomorphism (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

```
