# Hilbert Series and Hilbert Polynomial

Let $I$ be a *homogeneous* ideal of the graded polynomial ring $P = K[x_1, \ldots, x_n]$, where $K$ is a field. Then the quotient ring $P/I$ is a *graded* vector space in the following way: $P/I$ is the direct sum of the vector spaces $V_d$ for $d = 0, 1, \ldots$ where $V_d$ is the $K$-vector space consisting of all homogeneous polynomials in $P/I$ (i.e., reduced residues of polynomials of $P$ with respect to $I$) of weighted degree $d$. The *Hilbert Series* of the graded vector space $P/I$ is the generating function

$$
H_{P/I}(t) = \sum_{d=0}^{\infty} \hbox{dim}(V_d) t^d.
$$

The Hilbert series can be written as a rational function in the variable $t$. If the weights on the variables of $P$ are all $1$, then there also exists the Hilbert polynomial $F_{P/I}(d)$ corresponding to the Hilbert series $H_{P/I}(t)$ which is a univariate polynomial in ${\mathbb{Q}}[d]$ such that $F_{P/I}(i)$ is equal to the coefficient of $t^i$ in the Hilbert series for all $i \geq k$ for some fixed $k$.

## `HilbertSeries(I): RngMPol -> FldFunUElt`

Given an homogeneous ideal $I$ of a polynomial ring $P$ over a field, return the Hilbert series $H_{P/I}(t)$ of the quotient ring $P/I$ as an element of the univariate function field ${\mathbb{Z}}(t)$ over the ring of integers. The algorithm implemented is that given in [[Bayer and Stillman, 1992](../../references.md#cite-bayerstillman)]. Note that this is equivalent to [`HilbertSeries`](../ModulesOverMultivariateRings/hilbert.md#function-pmod-hilbertseries)`(QuotientModule(I))`, while if one wishes the Hilbert series of $I$ considered as a $P$-module, one should call [`HilbertSeries`](../ModulesOverMultivariateRings/hilbert.md#function-pmod-hilbertseries)`(Submodule(I))`.

## `HilbertSeries(I, p): RngMPol, RngIntElt -> RngSerLaurElt`

Given an homogeneous ideal $I$ of a polynomial ring $P$ over a field, return the Hilbert series $H_{P/I}(t)$ of the quotient ring $P/I$ as a power series to precision $p$.

## `HilbertDenominator(I): RngMPol -> RngUPol`

Given an homogeneous ideal $I$ of a polynomial ring $P$ over a field, return the unreduced Hilbert denominator $D$ of $P/I$ (as a univariate polynomial over the ring of integers). The denominator $D$ equals $\prod_{i=1}^n (1-t^{w_i}),$ where $n$ is the rank of $P$ and $w_i$ is the weight of the $i$-th variable (1 by default).

## `HilbertNumerator(I): RngMPol -> RngUPol`

Given an homogeneous ideal $I$ of a polynomial ring $P$ over a field, return the unreduced Hilbert numerator $N$ of $P/I$ (as a univariate polynomial over the ring of integers). The numerator $N$ equals $D\times \times H_{P/I}(t)$, where $D$ is the unreduced Hilbert denominator above. Computing with the unreduced numerator is often more convenient.

## `HilbertPolynomial(I): RngMPol -> RngUPolElt, RngIntElt`

Given an homogeneous ideal $I$ of a polynomial ring $P$ over a field with weight 1 for each variable, return the Hilbert polynomial $H(d)$ of the quotient ring $P/I$ as an element of the univariate polynomial ring $Q[d]$, together with the index of regularity of $P/I$ (the minimal integer $k \geq 0$ such that $H(d)$ agrees with the Hilbert function of $P/I$ at $d$ for all $d \geq k$).

## `Example: Hilbert (ex-d1966b)`

We compute the Hilbert series and Hilbert polynomial for an ideal corresponding to the square of a matrix (see [[Bayer and Stillman, 1992](../../references.md#cite-bayerstillman)]).

```magma
> MatSquare := function(n)
>     P := PolynomialRing(RationalField(), n * n, "grevlex");
>     AssignNames(
>         ~P,
>         ["x" cat IntegerToString(i) cat IntegerToString(j): i, j in [1..n]]
>     );
>     M := MatrixRing(P, n);
>     X := M ! [P.((i - 1) * n + j): i, j in [1 .. n]];
>     Y := X^2;
>     return ideal<P | [Y[i][j]: i, j in [1 .. n]]>;
> end function;
> I := MatSquare(4);
> I;
Ideal of Polynomial ring of rank 16 over Rational Field
Order: Graded Reverse Lexicographical
Variables: x11, x12, x13, x14, x21, x22, x23, x24, x31, x32,
    x33, x34, x41, x42, x43, x44
Homogeneous
Basis:
[
    x11^2 + x12*x21 + x13*x31 + x14*x41,
    x11*x12 + x12*x22 + x13*x32 + x14*x42,
    x11*x13 + x12*x23 + x13*x33 + x14*x43,
    x11*x14 + x12*x24 + x13*x34 + x14*x44,
    x11*x21 + x21*x22 + x23*x31 + x24*x41,
    x12*x21 + x22^2 + x23*x32 + x24*x42,
    x13*x21 + x22*x23 + x23*x33 + x24*x43,
    x14*x21 + x22*x24 + x23*x34 + x24*x44,
    x11*x31 + x21*x32 + x31*x33 + x34*x41,
    x12*x31 + x22*x32 + x32*x33 + x34*x42,
    x13*x31 + x23*x32 + x33^2 + x34*x43,
    x14*x31 + x24*x32 + x33*x34 + x34*x44,
    x11*x41 + x21*x42 + x31*x43 + x41*x44,
    x12*x41 + x22*x42 + x32*x43 + x42*x44,
    x13*x41 + x23*x42 + x33*x43 + x43*x44,
    x14*x41 + x24*x42 + x34*x43 + x44^2
]
> S<t> := HilbertSeries(I);
> S;
(t^12 - 7*t^11 + 20*t^10 - 28*t^9 + 14*t^8 + 15*t^7 - 20*t^6 +
    19*t^5 - 22*t^4 + 7*t^3 + 20*t^2 + 8*t + 1)/(t^8 - 8*t^7 +
    28*t^6 - 56*t^5 + 70*t^4 - 56*t^3 + 28*t^2 - 8*t + 1)
> H<d>, k := HilbertPolynomial(I);
> H, k;
1/180*d^7 + 7/90*d^6 + 293/360*d^5 + 61/36*d^4 + 1553/360*d^3 +
    851/180*d^2 + 101/30*d + 1
5
> // Check that evaluations of H for d >= 5 match coefficients of S:
> L<u> := LaurentSeriesRing(IntegerRing());
> L;
Laurent Series Algebra over Integer Ring
> L ! S;
1 + 16*u + 120*u^2 + 575*u^3 + 2044*u^4 + 5927*u^5 + 14832*u^6 +
    33209*u^7 + 68189*u^8 + 130642*u^9 + 236488*u^10 + 408288*u^11 +
    677143*u^12 + 1084929*u^13 + 1686896*u^14 + 2554659*u^15 +
    3779609*u^16 + 5476772*u^17 + 7789144*u^18 + 10892530*u^19 +
    O(u^20)
> Evaluate(H, 5);
5927
> Evaluate(H, 6);
14832
> Evaluate(H, 19);
10892530

```
