Skip to content
Prev 66664 / 398502 Next

strange result of acos

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.