Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!hp4nl!charon!dik From: dik@cwi.nl (Dik T. Winter) Newsgroups: comp.sys.sgi Subject: Re: trig functions Message-ID: <2535@charon.cwi.nl> Date: 14 Nov 90 02:07:31 GMT References: <9011131959.AA11389@> Sender: news@cwi.nl Organization: CWI, Amsterdam Lines: 39 (I did already respond to the original article, but follow-up now.) In article <9011131959.AA11389@> lmo@lsr-vax.UUCP ("Lance M. Optican - LMO") writes: > ----- Begin Included Message ----- ...[lots of included message omitted]... > Is it reasonable to expect the cosine of (exactly) 0 to be (exactly) 1? > ----- End Included Message ----- > It is reasonable to expect the maht library to perform well! Yes, but that does not imply that cos(0)=1. > What standards > of compatibility are enforced with other machine architectures? What do you mean? Which machine architecture? Honeywell? (where cos(0)>1). The problem is more complex than you think. When implementing cos and sin you have two algorithmic choices (if you use additional precision you've got a few more choices): 1. Promise that the functions are monotonic at pi/4, but do not promise that cos(0)=1. This is what you get if you implement Cody-Waite's functions. You might even end up with cos(0)>1. When you reduce the range of the argument to (-pi/2,pi/2) and do an approximation there you end up with this behaviour (not exactly true, but nearly). 2. Promise that cos(0)=1, but do not promise that the functions are monotonic at pi/4 (i.e. in the neighbourhood of pi/4 it can happen that x>y but sin(x)