C language hacking

Ken Turkowski ken at turtlevax.UUCP
Sat Nov 17 03:31:00 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.
> 
> 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 at DECWRL.ARPA



More information about the Comp.lang.c mailing list