Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site turtlevax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!flairvax!turtlevax!ken From: ken@turtlevax.UUCP (Ken Turkowski) Newsgroups: net.lang.c Subject: Re: C language hacking Message-ID: <590@turtlevax.UUCP> Date: Fri, 16-Nov-84 12:31:00 EST Article-I.D.: turtleva.590 Posted: Fri Nov 16 12:31:00 1984 Date-Received: Sun, 18-Nov-84 03:19:03 EST References: <5715@brl-tgr.ARPA> <219@desint.UUCP> Distribution: net Organization: CADLINC, Inc. @ Palo Alto, CA Lines: 52 > >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. > > It is. The obvious way is to make use of the identity > > sin (x) == sqrt (1 - cos (x) * cos (x)) > > which can be computed slightly faster than sin(x) on some architectures. > I think that there are also numerical algorithms that generate both > functions at once, though I am out of my field here. I know I have run into > a routine (in the Evans and Sutherland Picture System library?) named > 'sincos', which returned both values at once for use in rotation > calculations, but it may have been fixed-point. > > Geoff Kuenning There is a class of algorithms, called CORDIC (for COordinate Rotation DIgital Computer), which calculates sine and cosine simultaneously with linear convergence in fixed point with no multiplications. There are one test, two shifts, and three adds per bit of precision. It is very easily written entirely in C (except for frmul(), a simple fractional multiplication). The original paper is: Volder, Jack E. "The CORDIC Trigonometric Computing Technique", IRE Trans. on Electronic Computers, Sept. 1959, pp.330-334 Extension to other functions (multiplication, division, sin, cos, tan, arctan, sinh, cosh, tanh, arctanh, ln, exp, and square root) is covered in: Walther, J.S., "A Unified Algorithm for Elementary Functions", Proc. AFIPS 1971 Spring Joint Computer Conference, pp. 379-385 Theory of CORDIC generalizations is discussed in: Chen, Tien Chi, "Automatic Computation of Exponentials, Logarithms, Ratios, and Sqaure Roots", IBM J. Res. Develop., July 1972, pp. 380-388 -- Ken Turkowski @ CADLINC, Palo Alto, CA UUCP: {amd,decwrl,flairvax,nsc}!turtlevax!ken ARPA: turtlevax!ken@DECWRL.ARPA