From bug-request at octave dot org Thu Nov 17 12:08:45 2005 Subject: Re: acot, acsc, asec From: Quentin Spencer To: bug at octave dot org CC: William Poetra Yoga H , bug@octave.org Date: Thu, 17 Nov 2005 12:04:50 -0600 Quentin Spencer wrote: > William Poetra Yoga H wrote: > >>> | Also, I made a few references to sind, cosd, and other functions >>> with arguments >>> | in degrees. Do you think it would be better to implement them just by >>> | multiplying the arguments with 180/pi and pi/180, or should we use >>> a different >>> | approach: use trig tables for exact degrees (0,3,6,...,45) then >>> use some kind >>> | of interpolation to fill up the gaps? This is what I've found on >>> the Internet >>> | for computing trigonometric functions. What do you think? >>> >>> I think the best solution would be to adjust the argument. What do >>> you hope to gain by using a table plus interpolation? >>> >>> >> >> >> I was hoping that by using a table, we can get more accurate results, >> and it >> also makes cosd(90) return 0 instead of 6.1230e-17 (like what the Matlab >> documentation says). What do you think? >> >> > > Matlab's cosd is "more accurate" for one value (90 degrees). In > Matlab, I also get the following: > > cosd(45)-sqrt(2)/2 = -1.1102e-16 > cos(pi/4)-sqrt(2)/2 = 0 > > So which function is more accurate? I read the Matlab help for the > cosd function, which claims that it is provided to enable exact zero > values for integer inputs. What computations benefit from this > "feature"? I think this serves to mislead users into thinking computer > representations of real numbers are exact. See the lengthy discussion > on this list a few months ago about "negative zero" values for more on > this. I'm all for providing these functions for compatibility, but I > don't see obtaining cosd(90)==0 as a high-priority goal. One more thing: Matlab's cos function is approximately 3x faster than the cosd function on my machine. I think speed is definitely preferred if the error is less than epsilon (which it is: eps=2.2204e-16). -Quentin ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------