[gambit-list] Kahan's codes for complex functions

Bradley Lucier lucier at math.purdue.edu
Mon Nov 18 18:21:04 EST 2013


Marc:

I've started implementing the codes in Kahan's paper "Branch Cuts for 
Complex Elementary Functions, or Much Ado About Nothing's Sign Bit".  
The first nontrivial code is for complex magnitude, which he calls cabs.

I've met Kahan a number of times, mainly when I was a graduate student, 
and he's a very bright guy.  A bit scary, actually.

Anyway, I've now compared his code to our current magnitude code for 
1,000,000 pairs of floating-point numbers exponentially distributed (the 
logarithms are distributed uniformly) between the smallest positive 
flonum and the largest finite flonum.

A correctly-rounded result has an error of less than 1/2 unit in the 
last place (ulp). I recorded the number of times the answers were 
incorrect (but still within one ulp of the true answer) and the number 
of times the error was greater than 1 ulp.  The correct answers were 
computed using my computable reals code.

The results were as follows:

Current Gambit magnitude:

Incorrect, but within 1 ulp: 7909
Incorrect, error > 1 ulp: 2132

Kahan's cabs:

Incorrect, but within 1 ulp: 150
Incorrect, error > 1 ulp: 0

Like I said, a bit scary.

Brad



More information about the Gambit-list mailing list