octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #45339] sind, cosd don't do range reduction ac


From: Charles Karney
Subject: [Octave-bug-tracker] [bug #45339] sind, cosd don't do range reduction accurately
Date: Fri, 17 Jul 2015 17:29:32 +0000
User-agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0

Follow-up Comment #2, bug #45339 (project octave):

Your observations about the challenges of argument reduction for the
sine and cosine routines are entirely correct.

However when the arguments are in degrees, as they are for sind and
cosd, argument reduction is exact.  Indeed, this is one reason to keep
angles as degrees instead of converting them to radians.  It's also
possible to reduce arguments to the range [-45deg, 45deg] exactly, and
this allows the sind and cosd routines to obey identities like sind(1) =
cosd(89).

Having these properties built into the default implementations of sind
and cosd is an obvious win.  (And, as I noted, the MATLAB
implementations work like this.)

I should note one defect of my implementation and that is that sind(180)
= cosd(90) = -0 (instead of +0).  This is easily fixed (just add 0 to
the result).  Unfortunately sind(-0) returns +0 instead of -0; but that
is a consequence of rem(-0,360) returning +0 instead of -0 (a bug
surely?).

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?45339>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]