# Variable Extension of Ideals

Often one wishes to introduce new variables temporarily to a polynomial ring. Magma allows one to do this by use of the `VariableExtension` function, and also to restrict again to the original ring with elimination performed automatically.

## `VariableExtension(I, k, b): RngMPol, RngIntElt, BoolElt -> RngMPol, Map`

## `VariableExtension(I, k, b, order): RngMPol, RngIntElt, BoolElt, ... -> RngMPol, Map`

Given an ideal $I$ of the polynomial ring $P = R[x_1, \ldots, x_n]$, create a polynomial ring $Q$ as a $k$-variable extension of $P$, the ideal $J$ of $Q$ corresponding to $I$, and the embedding map $f: P \rightarrow Q$, and return $J$ and $f$.

If the argument $b$ (standing for “before”) is `true`, the $k$ variables are inserted before the current variables of $P$, so $Q$ is defined to be $R[y_1, \ldots, y_k, x_1, \ldots, x_n]$ and $f$ maps $P.i$ to $Q.(k+i)$ (so the $x_i$ variables of $P$ are mapped to the $x_i$ variables of $Q$).

If the argument $b$ is `false`, the $k$ variables are inserted after the current variables of $P$, so $Q$ is defined to be $R[x_1, \ldots, x_n, y_1, \ldots, y_k]$ and $f$ maps $P.i$ to $Q.i$ (so the $x_i$ variables of $P$ are mapped to the $x_i$ variables of $Q$).

If the argument order is given, then $Q$ is constructed with the specified order; otherwise, the `grevlex` order is used for $Q$ by default. See the section on monomial orders (Section [Representation and Monomial Orders](../GrobnerBases/order.md#dpoly-monomial-orders)) for the valid values for the argument order.

The image under $f$ of a polynomial of $P$ is the corresponding polynomial of $Q$, while the image under $f$ of an ideal of $P$ is the corresponding ideal of $Q$. The inverse image under $f$ of a polynomial of $Q$ is only defined if none of the extension variables of $Q$ occur in that polynomial, in which case the inverse image is just the restriction back to $P$, while the inverse image under $f$ of an ideal $H$ of $Q$ is always defined and is the restriction back to $P$ of the elimination ideal $H \cap R[x_1, \ldots, x_n]$.
