# Basic Element Operations

## Parent and Category

### `Parent(r): RngSerElt -> RngSer`

### `Category(r): RngSerElt -> Cat`

## Arithmetic Operators

### `+ b: RngSerElt -> RngSerElt`

### `- b: RngSerElt -> RngSerElt`

### `a + b: RngSerElt, RngSerElt -> RngSerElt`

### `a - b: RngSerElt, RngSerElt -> RngSerElt`

### `a * b: RngSerElt, RngSerElt -> RngSerElt`

### `a ^ k: RngSerElt, RngIntElt -> RngSerElt`

### `a div b: RngSerPowElt, RngSerPowElt -> RngSerPowElt`

### `a / b: RngSerElt, RngSerElt -> RngSerElt`

## Equality and Membership

### `a eq b: RngSerElt, RngSerElt -> BoolElt`

### `a ne b: RngSerElt, RngSerElt -> BoolElt`

### `a in R: RngSerElt, RngSer -> BoolElt`

### `a notin R: RngSerElt, RngSer -> BoolElt`

## Predicates on Ring Elements

Note the definition of equality in the introduction to this Chapter. This not only affects the result of the application of `eq` and `ne`, but also that of `IsOne, IsZero` and `IsMinusOne`.

### `IsZero(a): RngSerElt -> BoolElt`

### `IsOne(a): RngSerElt -> BoolElt`

### `IsMinusOne(a): RngSerElt -> BoolElt`

### `IsNilpotent(x): RngSerElt -> BoolElt`

### `IsIdempotent(x): RngSerElt -> BoolElt`

### `IsUnit(a): RngSerElt -> BoolElt`

### `IsZeroDivisor(x): RngSerElt -> BoolElt`

### `IsRegular(x): RngSerElt -> BoolElt`

### `IsIrreducible(x): RngSerElt -> BoolElt`

### `IsPrime(x): RngSerElt -> BoolElt`

### `IsWeaklyZero(f): RngSerElt -> BoolElt`

Given a series $f$, return whether $f$ is weakly zero, which is whether $f$ is exactly zero or of the form $O(x^p)$ for some $p$.

### `IsWeaklyEqual(f, g): RngSerElt, RngSerElt -> BoolElt`

Given series $f$ and $g$, return whether $f$ is weakly equal to $g$, which is whether ($f-g$) is weakly zero (see `IsWeaklyZero`).

### `IsIdentical(f, g): RngSerElt, RngSerElt -> BoolElt`

Given series $f$ and $g$, return whether $f$ is identical to $g$, which is whether $f$ and $g$ have exactly the same valuation, precision, and coefficients.

## Precision

### `AbsolutePrecision(f): RngSerElt -> RngIntElt`

Given a series $f$, this returns the absolute precision that is stored with $f$. If $f$ is a series in $x$, the absolute precision of $f$ is the exponent $p$ such that $x^p$ is the first term of $f$ of which the coefficient is not known, that is, it is the least $p$ such that $f\in O(x^p)$. If $f$ is known exactly (in a free ring), the absolute precision is infinite and an error occurs. Note that the absolute precision may be a non-integral rational number if $f$ is a Puiseux series.

### `RelativePrecision(f): RngSerElt -> RngIntElt`

Given a series $f$, this returns the relative precision that is stored with $f$. The relative precision counts the number of coefficients of $f$ that is known, starting at the first non-zero term. Hence the relative precision is the difference between the absolute precision and the valuation of $f$, and is therefore always non-negative; however, if $f$ is exact, the relative precision is infinite and the value $\infty$ is returned. Note that the relative precision may be a non-integral rational number if $f$ is a Puiseux series.

### `ChangePrecision(f, r): RngSerElt, RngIntElt -> RngSerElt`

### `ChangePrecision(f, r): RngSerElt, Infty -> RngSerElt`

### `ChangePrecision(~f, r): RngSerElt, RngIntElt`

### `ChangePrecision(~f, r): RngSerElt, Infty`

The (non puiseux) series $f$ with absolute precision $r$ (which can be positive infinity).

## Coefficients and Degree

### `Coefficients(f): RngSerElt -> [ RngElt ], RngIntElt, RngIntElt`

### `ElementToSequence(f): RngSerElt -> [ RngElt ], RngIntElt, RngIntElt`

### `Eltseq(f): RngSerElt -> [ RngElt ], RngIntElt, RngIntElt`

Let $f$ be a series with coefficients in a ring $R$ and with indeterminate $x$. This function returns the sequence $Q$ of coefficients of $f$, the unscaled valuation $v$ and the exponent denominator $d$ of $f$ ($v$ is the true valuation of $f$ multiplied by $d$). The $i$-th entry $Q[i]$ of $Q$ equals the coefficient of $x^{{v+i-1}\over{d}}$ in $f$. Thus the first entry of $Q$ is the ‘first’ (lowest order) non-zero coefficient of $f$, i.e., the coefficient of $x^w$ where $w$ is the true valuation of $f$.

### `Coefficient(f, i): RngSerElt, RngElt -> RngElt`

Given a series $f$ with coefficients in a ring $R$, and a rational or integer $i$, return the coefficient of the $i$-th power of the indeterminate $x$ of $f$ as an element of $R$. If $f$ is a Puiseux series $i$ may be a (non-integral) rational; otherwise $i$ must be an integer (and also must be non-negative if $f$ is a power series). Also, $i$ must be less than $p$, the precision of $f$.

### `LeadingCoefficient(f): RngSerElt -> RngElt`

Given a series $f$ with coefficients in a ring $R$, return the leading coefficient of $f$ as an element of $R$, which is the first non-zero coefficient of $f$ (i.e., the coefficient $x^v$ in $f$, where $x$ is the indeterminate of $f$ and $v$ is the valuation of $f$).

### `LeadingTerm(f): RngSerElt -> RngElt`

Given a series $f$ with coefficients in a ring $R$, return the leading term of $f$, which is the first non-zero term of $f$ (i.e., the term of $f$ whose monomial is $x^v$, where $x$ is the indeterminate of $f$ and $v$ is the valuation of $f$).

### `Truncate(f): RngSerElt -> RngSerElt`

Given a series $f$, return the exact series obtained by truncating $f$ after the last known non-zero coefficient.

### `ExponentDenominator(f): RngMSerElt -> RngElt`

Given a series $f$, return the exponent denominator of $f$, i.e., the lowest common denominator of all the exponents of the non-zero terms of $f$ (always an integer). For power series and Laurent series, this will always be $1$ of course.

### `Degree(f): RngSerElt -> RngIntElt`

Given a series $f$, return the degree of the truncation of $f$, that is, the exponent of the last known non-zero term. Note that this may be a non-integral rational number if $f$ is a Puiseux series.

### `Valuation(f): RngSerElt -> RngIntElt`

Given a series $f$, return the smallest integer $v$ (possibly negative for Laurent series) such that the coefficient of $x^v$ in $f$ is not known to be zero. For the exact $0$ element (in a free ring), the valuation is $\infty$. Note that the valuation may be a non-integral rational number if $f$ is a Puiseux series.

### `ExponentDenominator(f): RngSerElt -> RngIntElt`

The exponent denominator of the series $f$. This is the lowest common denominator of the exponents of the non-zero terms of $f$.

## Evaluation and Derivative

### `Derivative(f): RngSerElt -> RngSerElt`

Given a series $f\in R$, return the derivative of $f$ with respect to its indeterminate, as an element of $R$. Note that the precision decreases by 1 (unless $f$ has infinite precision).

### `Derivative(f, n): RngSerElt, RngIntElt -> RngSerElt`

Given a series $f\in R$ and an integer $n > 0$, return the $n$-th derivative of $f$ with respect to its indeterminate, as an element of $R$. Note that the precision decreases by $n$ (unless $f$ has infinite precision).

### `Integral(f): RngSerElt -> RngSerElt`

Given a series $f\in R$, return an anti-derivative $F$ of $f$ with respect to its indeterminate, which is an element of $R$ which has derivative $f$. The coefficient of $x^{-1}$ in $f$ must be zero. Note that the precision of $F$ will be exceeding that of $f$ by 1 (unless $f$ has infinite precision).

### `Evaluate(f, s): RngSerElt, RngElt -> RngElt`

Given an element $f$ of a series ring over the coefficient ring $R$, and an element $s$ of the ring $S$, return the value of $f(s)$ when the indeterminate $x$ is evaluated at $s$. The result will be an element of the common overstructure over $R$ and $S$.

### `Laplace(f): RngSerElt -> RngSerElt`

The Laplace transform of the series $f$; if $f$ has expansion $\sum_{i\geq 0} a_ix^i$, its Laplace transform has expansion $\sum_{i\geq 0} (i!a_i)x^i$. The valuation of $f$ must be integral and non-negative.

## Square Root

### `SquareRoot(f): RngSerElt -> RngSerElt`

### `Sqrt(f): RngSerElt -> RngSerElt`

Return the square root of the series $f$, $f$ must have even valuation if it is a power or Laurent series.

## Composition and Reversion

### `Composition(f, g): RngSerElt, RngSerElt -> RngSerElt`

Given elements $f$ and $g$ from the same series ring $P$, return their composition, defined by

$$
f\circ g = \sum_{i < p}f_i(g^i),
$$

where $f=\sum_{i < p} f_ix^i$.

### `Reversion(f): RngSerElt -> RngSerElt`

### `Reverse(f): RngSerElt -> RngSerElt`

Given a series $f$ (in $x$, say), this returns the inverse of $f$ under composition, that is, an element $g$ of the same power series ring such that its composition with $f$ equals $x$ to the best possible precision. If $f$ is a power or Laurent series, the valuation of $f$ must be 1. If $f$ is a Puiseux series, the valuation of $f$ must be positive (but need not equal 1), and if the valuation of $f$ is not 1, the leading coefficient of $f$ must be 1.

### `Convolution(f, g): RngSerElt, RngSerElt -> RngSerElt`

Given elements $f$ and $g$ from the same series ring $P$, return their convolution $f\ast g$, defined by

$$
f\ast g = \sum_{i < \min(p,q)}f_ig_ix^i,
$$

where $f=\sum_{i < p} f_ix^i+O(x^p)$ and $g=\sum_{i < q}g_ix^i+O(x^q)$.

### `Example: Composition Reversion (ex-cad173)`

We demonstrate the functions `Composition` and `Reversion`. First we check that `Arcsin` is the reversion of `Sin`.

```magma
> S<x> := PowerSeriesRing(RationalField());
> f := Sin(x);
> g := Arcsin(x);
> f;
x - 1/6*x^3 + 1/120*x^5 - 1/5040*x^7 + 1/362880*x^9 -
    1/39916800*x^11 + 1/6227020800*x^13 - 1/1307674368000*x^15 +
    1/355687428096000*x^17 - 1/121645100408832000*x^19 + O(x^21)
> g;
x + 1/6*x^3 + 3/40*x^5 + 5/112*x^7 + 35/1152*x^9 + 63/2816*x^11 +
    231/13312*x^13 + 143/10240*x^15 + 6435/557056*x^17 +
    12155/1245184*x^19 + O(x^21)
> Composition(f, g);
x + O(x^21)
> Composition(g, f);
x + O(x^21)
> Reversion(f) - g;
O(x^21)
> Reversion(g) - f;
O(x^21)

```

Next we compute the reversion of a series whose valuation is not 1.

```magma
> S<x> := PuiseuxSeriesRing(RationalField());
> f := x^3 - x^5 + 2*x^8;
> r := Reversion(f);
> f;
x^3 - x^5 + 2*x^8
> r;
x^(1/3) + 1/3*x + 4/9*x^(5/3) - 2/3*x^2 + 65/81*x^(7/3) -
    22/9*x^(8/3) + 5/3*x^3 - 208/27*x^(10/3) + 5005/729*x^(11/3)
    - 70/3*x^4 + 206264/6561*x^(13/3) - 50830/729*x^(14/3) +
    134*x^5 - 498674/2187*x^(16/3) + 31389020/59049*x^(17/3) +
    O(x^6)
> Composition(r, f);
x + O(x^18)
> Composition(f, r);
x + O(x^(20/3))

```

Finally we compute the reversion of a proper Puiseux series.

```magma
> f := x^(2/5) - x^(2/3) + x^(3/2) + O(x^2);
> r := Reversion(f);
> r;
x^(5/2) + 5/2*x^(19/6) + 145/24*x^(23/6) + 715/48*x^(9/2) +
    389795/10368*x^(31/6) - 5/2*x^(21/4) + O(x^(11/2))
> Composition(f, r);
x + O(x^4)
> Composition(r, f);
x + O(x^(11/5))

```
