# Extension and Contraction of Ideals

Magma allows the extension to and contraction from the ring of quotients of an ideal, defined over a field, with respect to certain variables. See [[Becker and Weispfenning, 1993](../../references.md#cite-beckerweispfenning), pp. 54--58 and 388--397] for the relevant definitions and theory.

## `Extension(I, U): RngMPol, [ RngIntElt ] -> RngMPol, Map`

Given an ideal $I$ of the polynomial ring $P = K[x_1, \ldots, x_n]$, where $K$ is a field, together with a sequence $U$ of integers each between 1 and $n$, create the (ring of quotients) extension $Q$ of $P$, and return the ideal $J$ of $Q$, together with the map $f: P \rightarrow Q$.

If $U$ has length $k$ and the values (in order) of $U$ are $u_1, \ldots, u_k$, then first the rational function field $F = K(x_{u_1}, \ldots, x_{u_k})$ is constructed, then the list $v_1, \ldots, v_{n-k}$ is constructed as the list $1, \ldots, n$ with the $u_i$ removed, and finally the extension $Q$ of $P$ is defined to be the polynomial ring $F[x_{v_1}, \ldots, x_{v_{n-k}}] = K(x_{u_1}, \ldots, x_{u_k})[x_{v_1}, \ldots, x_{v_{n-k}}]$.

The map $f$ is constructed in the obvious way so that $x_i$ is mapped to the appropriate variable in $F$ if $i$ is in $U$, or the appropriate variable in $Q$ otherwise. The image under $f$ of an ideal of $P$ is just the appropriate ideal of $Q$ whose basis is obtained by taking the image under $f$ of each of the polynomials in the basis of $I$.

The inverse image under $f$ of a polynomial of $Q$ is obtained by first making the polynomial monic, then multiplying by the LCM of the denominators (“clearing the denominators”), then mapping each variable back to the appropriate one in $P$—this is possible since there are no proper denominators. The inverse image under $f$ of an ideal $H$ of $Q$ is defined to be the ideal of $P$ generated by the inverse images under $f$ of the polynomials in the basis of $H$ (note that this is not always equal to the contraction of $H$—see [[Becker and Weispfenning, 1993](../../references.md#cite-beckerweispfenning), p. 389], for a simple algorithm to compute the contraction of an ideal of $Q$).
