# Is there software to compute the cohomology of an affine variety?

I have some affine varieties whose cohomology (topological, with $\mathbb{C}$ coefficients) I would like to know. They are very nice, they are all of the form $\mathbb{A}^n \setminus \{ f=0 \}$ for some hypersurface $f$. (In particular, they are smooth.) If I needed to write them as closed subvarieties, I could just write $y f(x_1, \ldots, x_n)=1$.

I want software where I type in $f$ and get back the betti numbers. Or at least directions for how to reasonably hack existing software into doing this. Thanks!

-
If they are smooth, their de Rham cohomology can be computed as the cohomology of the algebraic de Rham complex (that is, the complex constructed from the module of Kähler differentials comme on imagine), by results of Grothendieck, Hartshorne and probably others, no? Since $\Omega^1$ can be constructed easily in Macaulay2, you need to compute its exterior powers and the exterior differential, which should be "easy". –  Mariano Suárez-Alvarez Nov 16 '11 at 21:28
Maybe this is a dumb question but how do I get Macauley to compute the cohomology of the de Rham complex, since the maps in the de Rham complex are not maps of modules? –  David Speyer Nov 16 '11 at 22:08
I know that Uli Walther wrote several papers around this question (math.purdue.edu/~walther/research/index.html ), which means that it certainly feasible in principle. I am not sure if the papers include direct references to ready-made software solutions, or if you have to build it yourself. –  Thierry Zell Nov 16 '11 at 22:14
Thanks Thierry! Following links from Walther's webpage lead me to arxiv.org/abs/math.AG/9801114 , which has everything I want to know about the theory. I'm still hunting to find out how much of this I can get prepackaged; I'll report back on what I find if someone else doesn't leave an answer first. –  David Speyer Nov 17 '11 at 1:49
Macaulay 2 does have the command "deRham" as part of the package "Dmodules", which calculates de Rham cohomology of hypersurface complements in A^n. That package may provide what you need. Walther also wrote a chapter in the Macaulay 2 book (available on the Macaulay 2 web site) that discusses such computations, but it may be faster to go directly to the package rather than to study the chapter. –  user2490 Nov 17 '11 at 2:18