[comp.edu] Cosine of Pi/2.0

jlg@cochiti.lanl.gov (Jim Giles) (04/25/91)

mjo@ttardis.UUCP (Mike O'Connor) writes:

> Well...  on an HP-11 or 15, you can take the cosine of pi/2 and get
> a number that is not zero.  It's rather annoying.

In 'radians' mode:
The calculator is just being honest.  There is no representable
number which is exactly equal to pi/2.  This means that there is
no representable number for which the cosine is exactly zero.
This is one of the first tests I make of a calculator: if it gives
zero for cosine of _anything_ that can be represented, it probably
has a bad cosine function.

On the other hand, if your calculator has a 'degrees' mode for the
trig functions, you _should_ get zero for the cosine of 90.0 degrees.
Similarly for 'grads' mode.

J. Giles

henry@zoo.toronto.edu (Henry Spencer) (04/27/91)

In article <22614@lanl.gov> jlg@cochiti.lanl.gov (Jim Giles) writes:
>This is one of the first tests I make of a calculator: if it gives
>zero for cosine of _anything_ that can be represented, it probably
>has a bad cosine function.

Well, the HP-48 will give you zero for the cosine of pi/2, but that's
because it represents it as "pi/2", not 1.5707...
-- 
And the bean-counter replied,           | Henry Spencer @ U of Toronto Zoology
"beans are more important".             |  henry@zoo.toronto.edu  utzoo!henry

mjo@ttardis.UUCP (Mike O'Connor) (04/27/91)

In article <22614@lanl.gov>, jlg@cochiti.lanl.gov (Jim Giles) writes:

>In 'radians' mode:
>The calculator is just being honest.  There is no representable
>number which is exactly equal to pi/2.  This means that there is
>no representable number for which the cosine is exactly zero.
>This is one of the first tests I make of a calculator: if it gives
>zero for cosine of _anything_ that can be represented, it probably
>has a bad cosine function.

What other calculators have you found this "honesty" on, out of curiosity?

Most of the cheapo scientific calculators I have will output 0 for 
cos of pi/2.

I wouldn't necessarily see this as a big problem...  depends on the kind
of accuracy expected of you.



					...Mike

Phone:			TTARDIS Public Access Unix -- (313) 350-2585
Internet:		mjo%ttardis@uunet.uu.net	
UUCP ("domain"):	mjo@ttardis.UUCP
UUCP (bang):		...!uunet!sharkey!cfctech!ttardis!mjo