I've been playing around with domain coloring recently, and discovered a bug in PARI's lngamma function-- it would give results off by **2πi** when the real part of the input was exactly **-1/2**. (I was graphing the Z function at the time.)

It turns out the problem had to do with the use of Euler's reflection formula, which necessitates the calculation of **log sin(πz)** with branch cuts along **(-∞,0]** and **[1,∞)**. In principle we know exactly what integer multiple of **2πi** to add to the principal value of the logarithm, but unfortunately we can't rely on this prediction because of numerical instabilities in the computation of **sin(πz)**. (Actually, PARI is so frakking brilliant that this problem really only shows up when **Re(z)** is exactly a half-integer.) So the solution is of course to compute the logarithm first, see what imaginary part we get, and then add the appropriate multiple of **2πi**.

And of course I had to make some domain coloring plots to check that I'd fixed things up. :^) The pictures are of the region **[-10,10] x [-10,10]**. (scroll right to see a high-contrast diff of the two)

Original: | Fixed: | Diff: |