From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: cos(pi/2)   or    sin(-pi)   problem
Date: Sun, 18 Jan 2009 20:57:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 9
Message-ID: <gl052t$fhb$>
References: <> <gksq8p$61f$> <gkvt2k$4ab$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1232312221 15915 (18 Jan 2009 20:57:01 GMT)
NNTP-Posting-Date: Sun, 18 Jan 2009 20:57:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:512337

Peter Perkins <> wrote in message <gkvt2k$4ab$>...
> That's right, but just to be clear:  There is absolutely NOTHING wrong here.  The irrational constant that mathematicians denote by the greek letter pi cannot be represented exactly in floating point, and  the sin/cos above are the correct values for the floating point numbers that one gets when one types pi/2 and -pi at the MATLAB command line.
> ......

  Strictly speaking that isn't quite true, Peter.  It is impossible for 'cos' and 'sin' to return the exactly correct values for angles which are only rational approximations to pi/2 and pi, respectively, because the exact answers would themselves be irrational.  For radian measure, except for x = 0, I believe it is true that there is no case where x and cosine(x), or x and sine(x), are simultaneously rational numbers.

Roger Stafford