3 years ago I created a webpage that computes the Hodge diamond and sheaf cohomology of line bundles for complete intersections as a tool to illustrate Serre duality in some lectures on Grothendieck duality.

Now I needed to compute the Hodge numbers $\mathrm{h}^{p,q}(S^{[n]})=\dim_k\mathrm{H}^{q}(S^{[n]},\Omega_{S^{[n]}}^p)$ of the Hilbert scheme of $n$ points on a surface $S$. And for this we can use Göttsche's formula, which expresses these Hodge numbers in terms of the Hodge numbers $\mathrm{h}^{p,q}(S)$, cleverly combining them in a generating series. The statement we need is found as theorem 2.3.14 of Hilbert schemes of zero-dimensional subschemes of smooth varieties. To understand the statement, recall that the Hodge–Poincaré polynomial of a variety $X$ is $$\mathrm{h}(X,x,y):=\sum_{p,q=0}^{\dim X}\mathrm{h}^{p,q}(X)x^py^q$$ and then Göttsche's formula expresses the Hodge–Poincaré polynomials for all values of $n$ simultaneously as $$\sum_{n=1}^{+\infty}\mathrm{h}(S^{[n]}x,y)t^n = \prod_{k=1}^{+\infty}\prod_{p,q=0}^2\left( 1 + (-1)^{p+q+1}x^{p+k-1}y^{q+k-1}t^k \right)^{(-1)^{p+q+1}\mathrm{h}^{p,q}(S)}$$

What is important to note is that to compute the Hodge numbers for of $S^{[n]}$ we don't need to do the infinite product, it suffices to do this up to $k=n$, at which point we can read off the Hodge–Poincaré polynomial of $S^{[n]}$ from the coefficients of the monomials $x^py^qt^n$.

Now it becomes basically a no-brainer in Sage, using its implementation for power series rings. The final observation to be made is that we only need to compute coefficients for monomials of total degree up to $3n$, even though we need $x^{2n}y^{2n}t^n$, but Serre duality comes to the rescue. Increasing the precision seems to be an important factor in the running time of these computations, so it's best to keep it as low as possible.

You can easily plug in other Hodge diamonds, e.g. if you like K3 surfaces.

I am wondering about how to optimise this computation, as already for $\mathbb{P}^2$ and $n=10$ it takes a while. Am I missing something obvious to speed up this computation significantly? Sage probably isn't the fastest kid on the block, but maybe I'm just being stupid here.

I realised that I missed an episode of fortnightly links last week. I'll shift the schedule by 1 week, so tomorrow there will be a new one.