C language hacking

Guido van Rossum guido at mcvax.UUCP
Mon Nov 12 23:17:51 AEST 1984


>It would also be nice if sin( x ) and cos( x ) could be computed
>simultaneously with reduced cost.  I doubt if this is possible
>but would like to know if it is.

Can't you use (sin x)**2 + (cos x)**2 = 1 ?  This suggests that
abs cos x = root(1 - (sin x)**2); surely something can be said about
the sign given the range x is in.  This assumes computing a square root
is faster than computing a sine.  This is as close as you can g;
the type polynomial approximations used for computing sine/cosine
are not symmetrical around pi/4.  (I doubt that they are symmetrical
around any point, since their precision is only relevant between
0 and pi/2.)

Anyway, I wouldn't want to add such a function to the standard library.
A specialized numerical library could provide one, however.

BTW, does anybody know whether the NAG library of numerical algorithms
has been translated into C?  This surely would make a great standard!
Thesis: a language standard should not incorporate standards
	for numerical functions.  It should only provide the raw
	material to allow a numerical library to be written.
(I believe the ANSI Committee is well aware of this, and only defines
the most basic numerical functions.  If only compiler writers would
provide decent implementations of these... (and of printf %e/%f/%g).)

--
	Guido van Rossum, "Stamp Out BASIC" Committee, CWI, Amsterdam, Holland
	guido at mcvax.UUCP

"Life is like a sewer.  What you get out of it, depends on what you put
 into it."



More information about the Comp.lang.c mailing list