page_title: CORDIC
section_title: Rotation mode
hierarchical_section_title: CORDIC / Modes of operation / Rotation mode
caption_attribution_description: Illustration of CORDIC operation. English: An illustration of the CORDIC algorithm in progress. Français&#160;: Illustration de plusieurs itérations de CORDIC Deutsch: Illustration von CORDIC
context_page_description: CORDIC, also known as Volder's algorithm, including Circular CORDIC, Linear CORDIC, Hyperbolic CORDIC, and Generalized Hyperbolic CORDIC, is a simple and efficient algorithm to calculate trigonometric functions, hyperbolic functions, square roots, multiplications, divisions, and exponentials and logarithms with arbitrary base, typically converging with one digit per iteration. CORDIC is therefore also an example of digit-by-digit algorithms. CORDIC and closely related methods known as pseudo-multiplication and pseudo-division or factor combining are commonly used when no hardware multiplier is available, as the only operations it requires are additions, subtractions, bitshift and lookup tables. As such, they all belong to the class of shift-and-add algorithms.
context_section_description: CORDIC can be used to calculate a number of different functions. This explanation shows how to use CORDIC in rotation mode to calculate the sine and cosine of an angle, assuming that the desired angle is given in radians and represented in a fixed-point format. To determine the sine or cosine for an angle , the y or x coordinate of a point on the unit circle corresponding to the desired angle must be found. Using CORDIC, one would start with the vector :
  In the first iteration, this vector is rotated 45° counterclockwise to get the vector . Successive iterations rotate the vector in one or the other direction by size-decreasing steps, until the desired angle has been achieved.  Step  size is  for .
  More formally, every iteration calculates a rotation, which is performed by multiplying the vector  with the rotation matrix :
  The rotation matrix is given by
  Using the following two trigonometric identities:
  the rotation matrix becomes
  The expression for the rotated vector  then becomes
  where  and  are the components of . Restricting the angles  such that , the multiplication with the tangent can be replaced by a division by a power of two, which is efficiently done in digital computer hardware using a bit shift. The expression then becomes
  where
  and  is used to determine the direction of the rotation: if the angle  is positive, then  is +1, otherwise it is −1.
   can be ignored in the iterative process and then applied afterward with a scaling factor
  which is calculated in advance and stored in a table or as a single constant, if the number of iterations is fixed. This correction could also be made in advance, by scaling  and hence saving a multiplication. Additionally, it can be noted that
  to allow further reduction of the algorithm's complexity. Some applications may avoid correcting for  altogether, resulting in a processing gain :
  After a sufficient number of iterations, the vector's angle will be close to the wanted angle . For most ordinary purposes, 40 iterations (n = 40) is sufficient to obtain the correct result to the 10th decimal place.
  The only task left is to determine whether the rotation should be clockwise or counterclockwise at each iteration (choosing the value of ). This is done by keeping track of how much the angle was rotated at each iteration and subtracting that from the wanted angle; then in order to get closer to the wanted angle , if  is positive, the rotation is clockwise, otherwise it is negative and the rotation is counterclockwise:
  The values of  must also be precomputed and stored. But for small angles,  in fixed-point representation, reducing table size.
  As can be seen in the illustration above, the sine of the angle  is the y coordinate of the final vector  while the x coordinate is the cosine value.
caption: An illustration of the CORDIC algorithm in progress
exif: {}