12 Aug
2013
12 Aug
'13
5:22 p.m.
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?