On Saturday 1 September 2007 9:36:02 am Mogens Kjaer wrote: > Chris Jones wrote: > ... > > > for the profiler output. atan2 is taking 50% of the time of this method. > > Not here I don't need that much precision on the result - say +- > > O(2*pi/100). > > Can't you use a Taylor expansion of arctan? Talyor expansions are valid when your argument is 'small' i.e. sin(x) ~ x tan(x) ~ x cos(x) ~ (1-(x)*(x)/2) etc. only work when x is small, and the error increases as x does (since the size of the truncated terms become more important). Yes you can include more terms but that only allows you to go to large x before the errors explode. I'm well aware of these series, and already use them when appropriate. In this case, I need tan(x) with fixed errors, between 0 and 2pi, the whole range. for instance, a really course estimate for atan2(x,y) can be made, by just comparing the signs of x and y, i.e. if x>0 and y>0, atan2(x,y) is between 0 and pi/2 ... Chris