From: jsavard@nospam.ath (John Savard) Newsgroups: sci.math Subject: Re: CORDIC algo? Date: Tue, 17 Feb 1998 20:47:45 GMT marc@aargh.mayn.de (Marc Heuler) wrote: >Can you explain how the CORDIC algorithm works? The documents I found on >the web so far are inconsistent or lack important key information. When I >simulate the algo on the computer, I do not get the correct results. >I'm looking for sin/cos calculation only. Thanks in advance! I once looked up the original paper in print. And I figured out a simpler algorithm (than the one given, using hyperbolic trig functions) for logs using similar principles. Anyhow, for sin and cos, the procedure works like this: Initialize: X = K Y = K theta = 45 degrees You need a fixed table, containing - arctan (1.5) arctan (1.25) arctan (1.125) ... continuing for a length corresponding to the precision you want to achieve. What you then do is: Is the target angle less than 45 degrees? Then: Ynew = Y - X/2 Xnew = X + Y/2 theta = theta - arctan(1.5) Else: Ynew = Y + X/2 Xnew = X - Y/2 theta = theta + arctan(1.5) X = Xnew Y = Ynew then repeat, substituting 'theta' for 45 degrees in the test, and arctan(1.25), arctan(1.125), and so on successively for arctan(1.5). X/2 and Y/2 become X/4, Y/4 then X/8, Y/8, and so on as well. K is chosen so that the square root of X squared plus Y squared comes out to 1 at the end, so that X is the cosine of the target angle and Y is the sine of the target angle. (Actually, you may really have to start by using arctan(2) and Y - X, X + Y to handle all angles between 0 and 90.) The idea is that X/2, X/4, etc., can all be obtained via shifting, so this lets you calculate the trig functions without doing any multiplies, which were slow on old hardware. John Savard ============================================================================== From: Keith Burnett Newsgroups: sci.math,uk.education.maths,aus.mathematics Subject: Re: Algorithm for inverse trigonom. functions Date: Sat, 10 Oct 1998 18:25:36 +0100 In article <361CBE2A.F9224710@woerle.net>, Klaus =?iso- 8859-1?Q?W=F6rle?= writes >I am looking for an algorithm to calculate the inverse >trigonometric functions using only sine, cosine and >+ - * / . A processor system has only the latter and I >need to have the inverse functions of sine and cosine. > >Any idea? >Thanks a lot for your help! > >Klaus > > The CORDIC routine might help, see ftp://ftp.exeter.edu/pub/peanut/cordic.tex might help if you can compile a tex/pictex document. The paper is by Richard Parris, and I can e-mail you a PDF version if needed. Below are the references from the paper References 1. James Kropa, "Calculator Algorithms", Mathematics Magazine, volume 51 (March 1978), pages 106-109. 2. Charles Schelin, "Calculator Function Approximation", The American Mathematical Monthly, volume 90 (May 1983), pages 317-325. 3. Xiaobo Hu, Ronald Harber, and Steven Bass, "Expanding the Range of Con- vergence of the CORDIC Algorithm", IEEE Transactions on Computers, volume 40 (January 1991), pages 13-21. Cheers -- Keith Burnett