[R] strange result of acos

From: Klaus-Peter Pleissner <pleissner_at_mpiib-berlin.mpg.de>
Date: Tue 29 Mar 2005 - 20:24:26 EST


Hi all,

I have to calculate an expression using acos -function. A strange result of acos appears

*1. case with error*

ss <- sin(10.74*pi/180)**2
+(cos(10.74*pi/180)*cos(10.74*pi/180)*cos(0*pi/180))  ss
 acos(ss)

[1] NaN
Warning message:
NaNs produced in: acos(ss)

*2. case without error*

 ss <- sin(10.7*pi/180)**2
+(cos(10.7*pi/180)*cos(10.7*pi/180)*cos(0*pi/180))  ss
 acos(ss)

In both cases the variable ss equals 1. I think there is a problem with precision. If I multiply ss by 0.999999999 (ss*0.99999999) no error occurs. How the results can be explained ?

Regards

Klaus-P.

-- 

Dr. Klaus-Peter Pleissner
Max Planck Institute for Infection Biology
Core Facility Bioinformatics
Campus Charité Mitte
Schumannstr. 21/22
D-10117 Berlin
Germany


*Phone:* +49-30-28460-119
*Fax:* +49-30-28460-507
*URL:* http://web.mpiib-berlin.mpg.de/bioinformatik <http://web.mpiib-berlin.mpg.de/bioinformatik/>
*Email:* pleissner@mpiib-berlin.mpg.de <mailto:pleissner@mpiib-berlin.mpg.de>
______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Tue Mar 29 20:32:36 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:56 EST