It occurred to me that this is a classical problem of factoring with Gaussian integers. The best 'denominators' are the most composite of Gaussian integers, so that you have the widest variety of angles represented. In particular, pick denominators which are the product of 2 with all of the (rational integer) primes of the form 4n+1. Turn on a light at the origin of the complex plane, put up thin barriers at every Gaussian integral point, and distribute some photograhic film around the circumference of a circle of radius r. Wherever the light shines through the most, those are angles that aren't well represented. In particular, I'm interested in the largest _gap_ in this circle for a given radius r; the size of that gap indicates the worst case for that radius r. At 04:21 PM 8/12/2013, Henry Baker wrote:
I guess this is a continuation of my rant of one year ago re rationalizing a complex number instead of rationalizing its real & imaginary parts separately.
I'm interested in approximations to exp(%i*x), for real floating point x, but it is essential that cabs() of the result is identically 1.
One way this can be done is
s = rationalize(sin(x/2)), c = rationalize(cos(x/2))
z = ((c^2-s^2) + %i*2*c*s)/(c^2+s^2) (clear factions with 'factor').
We can compute the accuracy of this approximation by
xp = atan2(2*c*s,c^2-s^2)
and compare xp with x.
Unfortunately, unless the denominators get pretty large, x isn't all that close to xp (considering the worse case error around the unit circle).
Can anyone think of a better method?