I write a lot of code like that. Usually I start off with a huge comment block, detailing what the function does, outlining the algorithm used and explaining the notation. Only then I include both the link to the paper and and the full citation.
It's about as much work as writing the code in the first place, but it has saved me a lot of times when I or someone else had to go and work on it.