Path: news.mathworks.com!not-for-mail 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$1@fred.mathworks.com> References: <15244285.1232199505643.JavaMail.jakarta@nitrogen.mathforum.org> <gksq8p$61f$1@fred.mathworks.com> <gkvt2k$4ab$1@fred.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: webapp-02-blr.mathworks.com Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1232312221 15915 172.30.248.37 (18 Jan 2009 20:57:01 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Sun, 18 Jan 2009 20:57:01 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1187260 Xref: news.mathworks.com comp.soft-sys.matlab:512337 Peter Perkins <Peter.PerkinsRemoveThis@mathworks.com> wrote in message <gkvt2k$4ab$1@fred.mathworks.com>... > > 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