[6248] in s-news-athena

home help back first fref pref prev next nref lref last post

Bug / Inconsistency of cosh / cos, ... with complex numbers

daemon@ATHENA.MIT.EDU (Martin Maechler)
Tue Jan 24 13:57:49 1995

From: Martin Maechler <maechler@stat.math.ethz.ch>
Date: Tue, 24 Jan 1995 18:47:02 +0100
To: S-News <s-news@utstat.toronto.edu>
Cc: maechler@stat.math.ethz.ch
Reply-To: Martin Maechler <maechler@stat.math.ethz.ch>


	[ This is  Splus 3.2, on Sun SPARC, SunOS 4.1.3 ]

The real bug may well lie in
 the  IEEE arithmetic / dealing with 'Complex INFINITY'


Consider the following example:

z <- 100*5:10 + 0*1i ### These are  real numbers 'disguised' as complex...

z ## is mathematically the same as  Re(z) !
##>> [1]  500+0i  600+0i  700+0i  800+0i  900+0i 1000+0i

cosh(z) ## oops: see the jump ?
##>> [1] 7.018e+216+0i 1.8865e+260+0i 5.0712e+303+0i 8.000e+02+0i 9.000e+02+0i
##>> [6] 1.000e+03+0i

cosh(Re(z)) ## should be the same as above, but this time is correct
##>> [1] 7.0180e+216 1.8865e+260 5.0712e+303         Inf         Inf         Inf

Re(cosh(Re(z)))
##>> [1] 7.0180e+216 1.8865e+260 5.0712e+303         Inf         Inf         Inf

Re(cosh(z)) ## here you see the jump even better ...
##>> [1] 7.0180e+216 1.8865e+260 5.0712e+303  8.0000e+02  9.0000e+02  1.0000e+03

#### NOTE:  sinh(z)  gives identical answers  (which at least is consistent..)

In conclusion,  the hyperbolic (co)sine 
	 (but this is also true for  cos(), sin() with approp.arguments !!!)
becomes non-monotone for the positive reals,
even though it's well known to be a monotone function there....

--- an average user would consider this to be a bug ...

Martin Maechler <maechler@stat.math.ethz.ch>		 <><	 _
Seminar fuer Statistik, SOL F5				       _| |_
ETH (Federal Inst. Technology)	8092 Zurich	 SWITZERLAND  |_   _|
phone: x-41-1-632-3408		fax: ...-1086			|_|

home help back first fref pref prev next nref lref last post