As the title of this blog suggests math, it's time to put this in practice. For one of my bachelor projects I had to do exercises from Fulton's Algebraic Curves. People who know me in real life are familiar with my total lack of perseverance for actual calculations. And for one of the exercise I had to do calculations for 15 intersection numbers (fair enough, I didn't have to do them all, but I like to do things properly). So instead of doing the calculations by hand, I decided to implement this in Sage. No other implementation of this is known to me, except for Magma's which is non-free in all meanings of the word.
What is it about? I refer you to the Wikipedia article and Fulton's excellent book. But it concerns how plane curves intersect and how their intersections behave in the local rings to these points. They lead to Max Noether's theorem, also known as the AF+BG theorem and Bézout's theorem which is a global statement relating the local information to the entire curve. Interesting stuff, by all means :).
So, having written an implementation for myself, I decided to share this.
The algorithm is pretty straightforward: based on Fulton's proof of the unicity of the intersection number all the operations I perform are related to reductions in the local rings. The only non-obvious parts might be
determine_variables. The first determines the lowest degree of the first, assuming the polynomial is expressed in 2 variables while the latter determines which variables the algorithm can use. It has no a priori means of determining which variables are used (unless by supplying them as arguments, which would be ugly). I'm sure this can look better, but for the moment it works. I've got a big red niceify and contact Sage developers note on my list by the way. For the moment it's implemented for algebraic schemes, but I'm not yet sure whether it's as it should be.
In case you wish to use it, the following code solves all exercises from Fulton's Algebraic Curves:
To use this: perform
sage intersection_number.sage first and then you can use it by calling