Factor Combining
   HOME

TheInfoList



OR:

CORDIC, short for coordinate rotation digital computer, is a simple and efficient
algorithm In mathematics and computer science, an algorithm () is a finite sequence of Rigour#Mathematics, mathematically rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algo ...
to calculate
trigonometric function In mathematics, the trigonometric functions (also called circular functions, angle functions or goniometric functions) are real functions which relate an angle of a right-angled triangle to ratios of two side lengths. They are widely used in all ...
s,
hyperbolic function In mathematics, hyperbolic functions are analogues of the ordinary trigonometric functions, but defined using the hyperbola rather than the circle. Just as the points form a circle with a unit radius, the points form the right half of the ...
s,
square roots In mathematics, a square root of a number is a number such that y^2 = x; in other words, a number whose ''square'' (the result of multiplying the number by itself, or y \cdot y) is . For example, 4 and −4 are square roots of 16 because 4 ...
,
multiplications Multiplication is one of the four elementary mathematical operations of arithmetic, with the other ones being addition, subtraction, and division. The result of a multiplication operation is called a '' product''. Multiplication is often de ...
,
divisions Division may refer to: Mathematics *Division (mathematics), the inverse of multiplication * Division algorithm, a method for computing the result of mathematical division Military *Division (military), a formation typically consisting of 10,000 t ...
, and
exponentials Exponential may refer to any of several mathematical topics related to exponentiation, including: *Exponential function, also: **Matrix exponential, the matrix analogue to the above *Exponential decay, decrease at a rate proportional to value *Expo ...
and
logarithms In mathematics, the logarithm of a number is the exponent by which another fixed value, the base, must be raised to produce that number. For example, the logarithm of to base is , because is to the rd power: . More generally, if , the ...
with arbitrary base, typically converging with one digit (or bit) per iteration. CORDIC is therefore also an example of digit-by-digit algorithms. The original system is sometimes referred to as Volder's algorithm. CORDIC and closely related methods known as pseudo-multiplication and pseudo-division or factor combining are commonly used when no
hardware multiplier A binary multiplier is an electronic circuit used in digital electronics, such as a computer, to multiply two binary numbers. A variety of computer arithmetic techniques can be used to implement a digital multiplier. Most techniques involve com ...
is available (e.g. in simple
microcontroller A microcontroller (MC, uC, or μC) or microcontroller unit (MCU) is a small computer on a single integrated circuit. A microcontroller contains one or more CPUs (processor cores) along with memory and programmable input/output peripherals. Pro ...
s and field-programmable gate arrays or FPGAs), as the only operations they require are
addition Addition (usually signified by the Plus and minus signs#Plus sign, plus symbol, +) is one of the four basic Operation (mathematics), operations of arithmetic, the other three being subtraction, multiplication, and Division (mathematics), divis ...
,
subtraction Subtraction (which is signified by the minus sign, –) is one of the four Arithmetic#Arithmetic operations, arithmetic operations along with addition, multiplication and Division (mathematics), division. Subtraction is an operation that repre ...
,
bitshift In computer programming, a bitwise operation operates on a bit string, a bit array or a binary numeral (considered as a bit string) at the level of its individual bits. It is a fast and simple action, basic to the higher-level arithmetic operatio ...
and
lookup table In computer science, a lookup table (LUT) is an array data structure, array that replaces runtime (program lifecycle phase), runtime computation of a mathematical function (mathematics), function with a simpler array indexing operation, in a proc ...
s. As such, they all belong to the class of
shift-and-add algorithm Speckle imaging comprises a range of high-resolution astronomical imaging techniques based on the analysis of large numbers of short exposures that freeze the variation of atmospheric turbulence. They can be divided into the shift-and-add ("' ...
s. In computer science, CORDIC is often used to implement
floating-point arithmetic In computing, floating-point arithmetic (FP) is arithmetic on subsets of real numbers formed by a ''significand'' (a Sign (mathematics), signed sequence of a fixed number of digits in some Radix, base) multiplied by an integer power of that ba ...
when the target platform lacks hardware multiply for cost or space reasons. This was the case for most early
microcomputer A microcomputer is a small, relatively inexpensive computer having a central processing unit (CPU) made out of a microprocessor. The computer also includes memory and input/output (I/O) circuitry together mounted on a printed circuit board (P ...
s based on processors like the
MOS 6502 The MOS Technology 6502 (typically pronounced "sixty-five-oh-two" or "six-five-oh-two") William Mensch and the moderator both pronounce the 6502 microprocessor as ''"sixty-five-oh-two"''. is an 8-bit microprocessor that was designed by a small ...
and
Zilog Z80 The Zilog Z80 is an 8-bit computing, 8-bit microprocessor designed by Zilog that played an important role in the evolution of early personal computing. Launched in 1976, it was designed to be Backward compatibility, software-compatible with the ...
. Over the years, a number of variations on the concept emerged, including Circular CORDIC ( Jack E. Volder), Linear CORDIC, Hyperbolic CORDIC (John Stephen Walther), and Generalized Hyperbolic CORDIC (GH CORDIC) (Yuanyong Luo et al.),


History

Similar mathematical techniques were published by Henry Briggs as early as 1624 and Robert Flower in 1771, but CORDIC is better optimized for low-complexity finite-state CPUs. CORDIC was conceived in 1956 by Jack E. Volder at the
aeroelectronics Avionics (a portmanteau of ''aviation'' and ''electronics'') are the electronic systems used on aircraft. Avionic systems include communications, navigation, the display and management of multiple systems, and the hundreds of systems that are ...
department of
Convair Convair, previously Consolidated Vultee Aircraft Corporation, was an American aircraft-manufacturing company that later expanded into rockets and spacecraft. The company was formed in 1943 by the merger of Consolidated Aircraft and Vultee ...
out of necessity to replace the
analog resolver A resolver is a type of rotary electrical transformer used for measuring degrees of rotation. It is considered an analog device, and has digital counterparts such as the digital resolver, rotary (or pulse) encoder. A rotating coil induces voltag ...
in the B-58 bomber's navigation computer with a more accurate and faster real-time digital solution. Therefore, CORDIC is sometimes referred to as a
digital resolver Digital usually refers to something using discrete digits, often binary digits. Businesses *Digital bank, a form of financial institution *Digital Equipment Corporation (DEC) or Digital, a computer company *Digital Research (DR or DRI), a software ...
. In his research Volder was inspired by a formula in the 1946 edition of the ''
CRC Handbook of Chemistry and Physics The ''CRC Handbook of Chemistry and Physics'' is a comprehensive one-volume reference resource for science research. First published in 1914, it is currently () in its 105th edition, published in 2024. It is known colloquially among chemists as ...
'': : \begin K_n R \sin(\theta \pm \varphi) &= R \sin(\theta) \pm 2^ R \cos(\theta), \\ K_n R \cos(\theta \pm \varphi) &= R \cos(\theta) \mp 2^ R \sin(\theta), \\ \end where \varphi is such that \tan(\varphi) = 2^, and K_n := \sqrt. His research led to an internal technical report proposing the CORDIC algorithm to solve
sine In mathematics, sine and cosine are trigonometric functions of an angle. The sine and cosine of an acute angle are defined in the context of a right triangle: for the specified angle, its sine is the ratio of the length of the side opposite th ...
and
cosine In mathematics, sine and cosine are trigonometric functions of an angle. The sine and cosine of an acute angle are defined in the context of a right triangle: for the specified angle, its sine is the ratio of the length of the side opposite that ...
functions and a prototypical computer implementing it. The report also discussed the possibility to compute hyperbolic
coordinate rotation Rotation in mathematics is a concept originating in geometry. Any rotation is a motion of a certain space that preserves at least one point. It can describe, for example, the motion of a rigid body around a fixed point. Rotation can have a sig ...
,
logarithm In mathematics, the logarithm of a number is the exponent by which another fixed value, the base, must be raised to produce that number. For example, the logarithm of to base is , because is to the rd power: . More generally, if , the ...
s and exponential functions with modified CORDIC algorithms. Utilizing CORDIC for
multiplication Multiplication is one of the four elementary mathematical operations of arithmetic, with the other ones being addition, subtraction, and division (mathematics), division. The result of a multiplication operation is called a ''Product (mathem ...
and division was also conceived at this time. Based on the CORDIC principle, Dan H. Daggett, a colleague of Volder at Convair, developed conversion algorithms between binary and
binary-coded decimal In computing and electronic systems, binary-coded decimal (BCD) is a class of binary encodings of decimal numbers where each digit is represented by a fixed number of bits, usually four or eight. Sometimes, special bit patterns are used f ...
(BCD). In 1958, Convair finally started to build a demonstration system to solve
radar fix Radar navigation is the utilization of marine and aviation radar systems for vessel and aircraft navigation. When a craft is within radar range of land or special radar aids to navigation, the navigator can take distances and angular bearings ...
–taking problems named ''CORDIC I'', completed in 1960 without Volder, who had left the company already. More universal ''CORDIC II'' models ''A'' (stationary) and ''B'' (airborne) were built and tested by Daggett and Harry Schuss in 1962. Volder's CORDIC algorithm was first described in public in 1959, which caused it to be incorporated into navigation computers by companies including Martin-Orlando, Computer Control, Litton,
Kearfott Kearfott is a defense equipment manufacturer founded in 1918 in New Jersey, United States. It is based in Woodland Park. Today the electronics division is part of BAE Systems, while the remaining Kearfott Guidance & Navigation division is a subsi ...
,
Lear-Siegler Lear Siegler Incorporated (LSI) is a diverse American corporation established in 1962. Its products range from car seats and brakes to weapons control systems for military fighter planes. The company's more than $2 billion-a-year annual sales come ...
,
Sperry Sperry may refer to: Places In the United States: * Sperry, Iowa, community in Des Moines County * Sperry, Missouri *Sperry, Oklahoma, town in Tulsa County * Sperry Chalet, historic backcountry chalet, Glacier National Park, Montana * Sperry Glaci ...
,
Raytheon Raytheon is a business unit of RTX Corporation and is a major U.S. defense contractor and industrial corporation with manufacturing concentrations in weapons and military and commercial electronics. Founded in 1922, it merged in 2020 with Unite ...
, and
Collins Radio Rockwell Collins, Inc. was a multinational corporation headquartered in Cedar Rapids, Iowa, providing avionics and information technology systems and services to government agencies and aircraft manufacturers. It was formed when the Collins Radio ...
. Volder teamed up with Malcolm McMillan to build ''Athena'', a fixed-point
desktop calculator An electronic calculator is typically a portable electronic device used to perform calculations, ranging from basic arithmetic to complex mathematics. The first solid-state electronic calculator was created in the early 1960s. Pocket-size ...
utilizing his binary CORDIC algorithm. The design was introduced to
Hewlett-Packard The Hewlett-Packard Company, commonly shortened to Hewlett-Packard ( ) or HP, was an American multinational information technology company. It was founded by Bill Hewlett and David Packard in 1939 in a one-car garage in Palo Alto, California ...
in June 1965, but not accepted. Still, McMillan introduced David S. Cochran (HP) to Volder's algorithm and when Cochran later met Volder he referred him to a similar approach John E. Meggitt (IBM) had proposed as ''pseudo-multiplication'' and ''pseudo-division'' in 1961. Meggitt's method also suggested the use of base 10 rather than base 2, as used by Volder's CORDIC so far. These efforts led to the ROMable logic implementation of a decimal CORDIC prototype machine inside of Hewlett-Packard in 1966, built by and conceptually derived from Thomas E. Osborne's prototypical ''Green Machine'', a four-function,
floating-point In computing, floating-point arithmetic (FP) is arithmetic on subsets of real numbers formed by a ''significand'' (a Sign (mathematics), signed sequence of a fixed number of digits in some Radix, base) multiplied by an integer power of that ba ...
desktop calculator he had completed in DTL logic in December 1964. This project resulted in the public demonstration of Hewlett-Packard's first desktop calculator with scientific functions, the HP 9100A in March 1968, with series production starting later that year. When
Wang Laboratories Wang Laboratories, Inc., was an American computer company founded in 1951 by An Wang and G. Y. Chu. The company was successively headquartered in Cambridge, Massachusetts (1954–1963), Tewksbury, Massachusetts (1963–1976), Lowell, Massachuse ...
found that the HP 9100A used an approach similar to the ''factor combining'' method in their earlier LOCI-1 (September 1964) and LOCI-2 (January 1965) ''Logarithmic Computing Instrument'' desktop calculators, they unsuccessfully accused Hewlett-Packard of infringement of one of
An Wang An Wang (; February 7, 1920 – March 24, 1990) was a Chinese-American computer engineer and inventor, and cofounder of computer company Wang Laboratories, which was known primarily for its dedicated word processing machines. An Wang was an im ...
's patents in 1968. John Stephen Walther at Hewlett-Packard generalized the algorithm into the ''Unified CORDIC'' algorithm in 1971, allowing it to calculate
hyperbolic functions In mathematics, hyperbolic functions are analogues of the ordinary trigonometric functions, but defined using the hyperbola rather than the circle. Just as the points form a circle with a unit radius, the points form the right half of the u ...
, natural exponentials,
natural logarithm The natural logarithm of a number is its logarithm to the base of a logarithm, base of the e (mathematical constant), mathematical constant , which is an Irrational number, irrational and Transcendental number, transcendental number approxima ...
s,
multiplication Multiplication is one of the four elementary mathematical operations of arithmetic, with the other ones being addition, subtraction, and division (mathematics), division. The result of a multiplication operation is called a ''Product (mathem ...
s, divisions, and
square root In mathematics, a square root of a number is a number such that y^2 = x; in other words, a number whose ''square'' (the result of multiplying the number by itself, or y \cdot y) is . For example, 4 and −4 are square roots of 16 because 4 ...
s. The CORDIC
subroutines In computer programming, a function (also procedure, method, subroutine, routine, or subprogram) is a callable unit of software logic that has a well-defined interface and behavior and can be invoked multiple times. Callable units provide a p ...
for trigonometric and hyperbolic functions could share most of their code. This development resulted in the first
scientific Science is a systematic discipline that builds and organises knowledge in the form of testable hypotheses and predictions about the universe. Modern science is typically divided into twoor threemajor branches: the natural sciences, which stu ...
handheld calculator, the
HP-35 The HP-35 was Hewlett-Packard's first pocket calculator and the world's first ''scientific'' pocket calculator: a calculator with trigonometric and exponential functions. It was introduced in 1972. History In about 1970 HP co-founder Bill He ...
in 1972. Based on hyperbolic CORDIC, Yuanyong Luo et al. further proposed a Generalized Hyperbolic CORDIC (GH CORDIC) to directly compute logarithms and exponentials with an arbitrary fixed base in 2019. Theoretically, Hyperbolic CORDIC is a special case of GH CORDIC. Originally, CORDIC was implemented only using the
binary numeral system A binary number is a number expressed in the base-2 numeral system or binary numeral system, a method for representing numbers that uses only two symbols for the natural numbers: typically "0" ( zero) and "1" ( one). A ''binary number'' may als ...
and despite Meggitt suggesting the use of the decimal system for his pseudo-multiplication approach, decimal CORDIC continued to remain mostly unheard of for several more years, so that Hermann Schmid and Anthony Bogacki still suggested it as a novelty as late as 1973 and it was found only later that Hewlett-Packard had implemented it in 1966 already. Decimal CORDIC became widely used in
pocket calculator An electronic calculator is typically a portable electronic device used to perform calculations, ranging from basic arithmetic to complex mathematics. The first solid-state electronic calculator was created in the early 1960s. Pocket-siz ...
s, most of which operate in binary-coded decimal (BCD) rather than binary. This change in the input and output format did not alter CORDIC's core calculation algorithms. CORDIC is particularly well-suited for handheld calculators, in which low cost – and thus low chip gate count – is much more important than speed. CORDIC has been implemented in the ARM-based STM32G4,
Intel 8087 The Intel 8087, announced in 1980, was the first floating-point coprocessor for the 8086 line of microprocessors. The purpose of the chip was to speed up floating-point arithmetic operations, such as addition, subtraction, multiplication, div ...
,
80287 x87 is a floating-point-related subset of the x86 architecture instruction set. It originated as an extension of the 8086 instruction set in the form of optional floating-point coprocessors that work in tandem with corresponding x86 CPUs. These m ...
,
80387 x87 is a floating-point-related subset of the x86 architecture instruction set. It originated as an extension of the 8086 instruction set in the form of optional floating-point coprocessors that work in tandem with corresponding x86 CPUs. These m ...
up to the
80486 The Intel 486, officially named i486 and also known as 80486, is a microprocessor introduced in 1989. It is a higher-performance follow-up to the Intel 386. It represents the fourth generation of binary compatible CPUs following the 8086 of 19 ...
coprocessor series as well as in the
Motorola 68881 The Motorola 68881 and Motorola 68882 are floating-point units (FPUs) used in some computer systems in conjunction with Motorola's 32-bit 68020 or 68030 microprocessors. These coprocessors are external chips, designed before floating point math ...
and
68882 The Motorola 68881 and Motorola 68882 are floating-point units (FPUs) used in some computer systems in conjunction with Motorola's 32-bit 68020 or 68030 microprocessors. These coprocessors are external chips, designed before floating point math ...
for some kinds of floating-point instructions, mainly as a way to reduce the gate counts (and complexity) of the FPU sub-system.


Applications

CORDIC uses simple shift-add operations for several computing tasks such as the calculation of trigonometric, hyperbolic and logarithmic functions, real and complex multiplications, division, square-root calculation, solution of linear systems,
eigenvalue In linear algebra, an eigenvector ( ) or characteristic vector is a vector that has its direction unchanged (or reversed) by a given linear transformation. More precisely, an eigenvector \mathbf v of a linear transformation T is scaled by a ...
estimation,
singular value decomposition In linear algebra, the singular value decomposition (SVD) is a Matrix decomposition, factorization of a real number, real or complex number, complex matrix (mathematics), matrix into a rotation, followed by a rescaling followed by another rota ...
,
QR factorization In linear algebra, a QR decomposition, also known as a QR factorization or QU factorization, is a decomposition of a matrix ''A'' into a product ''A'' = ''QR'' of an orthonormal matrix ''Q'' and an upper triangular matrix ''R''. QR decomp ...
and many others. As a consequence, CORDIC has been used for applications in diverse areas such as
signal A signal is both the process and the result of transmission of data over some media accomplished by embedding some variation. Signals are important in multiple subject fields including signal processing, information theory and biology. In ...
and
image processing An image or picture is a visual representation. An image can be two-dimensional, such as a drawing, painting, or photograph, or three-dimensional, such as a carving or sculpture. Images may be displayed through other media, including a pr ...
,
communication systems A communications system is a collection of individual telecommunications networks systems, relay stations, tributary stations, and terminal equipment usually capable of interconnection and interoperation to form an integrated whole. Commun ...
,
robotics Robotics is the interdisciplinary study and practice of the design, construction, operation, and use of robots. Within mechanical engineering, robotics is the design and construction of the physical structures of robots, while in computer s ...
and
3D graphics 3D computer graphics, sometimes called CGI, 3D-CGI or three-dimensional computer graphics, are graphics that use a three-dimensional representation of geometric data (often Cartesian) that is stored in the computer for the purposes of perfor ...
apart from general scientific and technical computation.


Hardware

The algorithm was used in the navigational system of the
Apollo program The Apollo program, also known as Project Apollo, was the United States human spaceflight program led by NASA, which Moon landing, landed the first humans on the Moon in 1969. Apollo followed Project Mercury that put the first Americans in sp ...
's
Lunar Roving Vehicle The Lunar Roving Vehicle (LRV) is a Battery electric vehicle, battery-powered four-wheeled Rover (space exploration), rover used on the Moon in the last three missions of the American Apollo program (Apollo 15, 15, Apollo 16, 16, and Apollo 17 ...
to compute bearing and range, or distance from the
Lunar module The Apollo Lunar Module (LM ), originally designated the Lunar Excursion Module (LEM), was the lunar lander spacecraft that was flown between lunar orbit and the Moon's surface during the United States' Apollo program. It was the first crewed s ...
. CORDIC was used to implement the
Intel 8087 The Intel 8087, announced in 1980, was the first floating-point coprocessor for the 8086 line of microprocessors. The purpose of the chip was to speed up floating-point arithmetic operations, such as addition, subtraction, multiplication, div ...
math coprocessor in 1980, avoiding the need to implement hardware multiplication. CORDIC is generally faster than other approaches when a hardware multiplier is not available (e.g., a microcontroller), or when the number of gates required to implement the functions it supports should be minimized (e.g., in an FPGA or
ASIC An application-specific integrated circuit (ASIC ) is an integrated circuit (IC) chip customized for a particular use, rather than intended for general-purpose use, such as a chip designed to run in a digital voice recorder or a high-efficien ...
). In fact, CORDIC is a standard drop-in IP in FPGA development applications such as Vivado for Xilinx, while a power series implementation is not due to the specificity of such an IP, i.e. CORDIC can compute many different functions (general purpose) while a hardware multiplier configured to execute power series implementations can only compute the function it was designed for. On the other hand, when a hardware multiplier is available (''e.g.'', in a
DSP DSP may refer to: Computing * Digital signal processing, the mathematical manipulation of an information signal * Digital signal processor, a microprocessor designed for digital signal processing * Dynamic Reconfiguration port * Yamaha DSP-1 ...
microprocessor), table-lookup methods and
power series In mathematics, a power series (in one variable) is an infinite series of the form \sum_^\infty a_n \left(x - c\right)^n = a_0 + a_1 (x - c) + a_2 (x - c)^2 + \dots where ''a_n'' represents the coefficient of the ''n''th term and ''c'' is a co ...
are generally faster than CORDIC. In recent years, the CORDIC algorithm has been used extensively for various biomedical applications, especially in FPGA implementations. The STM32G4,
STM32U5 STM32 is a family of 32-bit microcontroller and microprocessor integrated circuits by STMicroelectronics. STM32 microcontrollers are grouped into related series that are based around the same 32-bit ARM processor core: Cortex-M0, Cortex-M0+, Cor ...
and STM32H5 series and certain STM32H7 series of MCUs implement a CORDIC module to accelerate computations in various mixed signal applications such as graphics for
human-machine interface In the industrial design field of human–computer interaction, a user interface (UI) is the space where interactions between humans and machines occur. The goal of this interaction is to allow effective operation and control of the machine fro ...
and field oriented control of motors. While not as fast as a power series approximation, CORDIC is indeed faster than interpolating table based implementations such as the ones provided by the ARM CMSIS and C standard libraries. Though the results may be slightly less accurate as the CORDIC modules provided only achieve 20 bits of precision in the result. For example, most of the performance difference compared to the ARM implementation is due to the overhead of the interpolation algorithm, which achieves full floating point precision (24 bits) and can likely achieve relative error to that precision. Another benefit is that the CORDIC module is a coprocessor and can be run in parallel with other CPU tasks. The issue with using
Taylor series In mathematics, the Taylor series or Taylor expansion of a function is an infinite sum of terms that are expressed in terms of the function's derivatives at a single point. For most common functions, the function and the sum of its Taylor ser ...
is that while they do provide small absolute error, they do not exhibit well behaved relative error. Other means of polynomial approximation, such as
minimax Minimax (sometimes Minmax, MM or saddle point) is a decision rule used in artificial intelligence, decision theory, combinatorial game theory, statistics, and philosophy for ''minimizing'' the possible loss function, loss for a Worst-case scenari ...
optimization, may be used to control both kinds of error.


Software

Many older systems with integer-only CPUs have implemented CORDIC to varying extents as part of their
IEEE floating-point The IEEE Standard for Floating-Point Arithmetic (IEEE 754) is a technical standard for floating-point arithmetic originally established in 1985 by the Institute of Electrical and Electronics Engineers (IEEE). The standard addressed many proble ...
libraries. As most modern general-purpose CPUs have floating-point registers with common operations such as add, subtract, multiply, divide, sine, cosine, square root, log10, natural log, the need to implement CORDIC in them with software is nearly non-existent. Only microcontroller or special safety and time-constrained software applications would need to consider using CORDIC.


Modes of operation


Rotation mode

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
radian The radian, denoted by the symbol rad, is the unit of angle in the International System of Units (SI) and is the standard unit of angular measure used in many areas of mathematics. It is defined such that one radian is the angle subtended at ...
s 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 In mathematics, a unit circle is a circle of unit radius—that is, a radius of 1. Frequently, especially in trigonometry, the unit circle is the circle of radius 1 centered at the origin (0, 0) in the Cartesian coordinate system in the Eucli ...
corresponding to the desired angle must be found. Using CORDIC, one would start with the vector v_0: : v_0 = \begin 1 \\ 0 \end. In the first iteration, this vector is rotated 45° counterclockwise to get the vector v_1. Successive iterations rotate the vector in one or the other direction by size-decreasing steps, until the desired angle has been achieved. Each step angle is \gamma_i = \arctan for i = 0, 1, 2, \dots. More formally, every iteration calculates a rotation, which is performed by multiplying the vector v_i with the
rotation matrix In linear algebra, a rotation matrix is a transformation matrix that is used to perform a rotation (mathematics), rotation in Euclidean space. For example, using the convention below, the matrix :R = \begin \cos \theta & -\sin \theta \\ \sin \t ...
R_: : v_ = R_i v_i. The rotation matrix is given by : R_i = \begin \cos(\gamma_i) & -\sin(\gamma_i) \\ \sin(\gamma_i) & \cos(\gamma_i) \end. Using the
trigonometric identity In trigonometry, trigonometric identities are equalities that involve trigonometric functions and are true for every value of the occurring variables for which both sides of the equality are defined. Geometrically, these are identities involvin ...
: : \begin \tan(\gamma_i) &\equiv \frac, \end the cosine factor can be taken out to give: : R_i = \cos(\gamma_i) \begin 1 & -\tan(\gamma_i) \\ \tan(\gamma_i) & 1 \end. The expression for the rotated vector v_ = R_i v_i then becomes: : \begin x_ \\ y_ \end = \cos(\gamma_i) \begin 1 & -\tan(\gamma_i) \\ \tan(\gamma_i) & 1 \end \begin x_i \\ y_i \end, where x_i and y_i are the components of v_i. Setting the angle \gamma_i for each iteration such that \tan(\gamma_i) = \pm 2^ still yields a series that converges to every possible output value. The multiplication with the tangent can therefore be replaced by a division by a power of two, which is efficiently done in digital computer hardware using a
bit shift In computer programming, a bitwise operation operates on a bit string, a bit array or a binary numeral (considered as a bit string) at the level of its individual bits. It is a fast and simple action, basic to the higher-level arithmetic opera ...
. The expression then becomes: : \begin x_ \\ y_ \end = \cos(\arctan(2^)) \begin 1 & -\sigma_i 2^ \\ \sigma_i 2^ & 1 \end \begin x_i \\ y_i \end, in which \sigma_i determines the direction of the rotation. If the rotation angle \gamma_i is to be positive, \sigma_i is +1, otherwise it is −1. The following trigonometric identity can be used to replace the cosine: : \cos(\gamma_i) \equiv \frac, giving this multiplier for each iteration: : K_i = \cos(\arctan(2^)) = \frac. The K_i factors can then be taken out of the iterative process and applied all at once afterwards with a scaling factor K(n): : K(n) = \prod_^ K_i = \prod_^ \frac, 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 v_0 and hence saving a multiplication. Additionally, it can be noted that : K = \lim_ K(n) \approx 0.6072529350088812561694 to allow further reduction of the algorithm's complexity. Some applications may avoid correcting for K altogether, resulting in a processing gain A: : A = \frac = \lim_ \prod_^ \sqrt \approx 1.64676025812107. After a sufficient number of iterations, the vector's angle will be close to the wanted angle \beta. For most ordinary purposes, 40 iterations (''n'' = 40) are 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 \sigma). 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 \beta, if \beta_ is positive, the rotation is clockwise, otherwise it is negative and the rotation is counterclockwise: : \beta_0 = \beta : \beta_ = \beta_i - \sigma_i \gamma_i, \quad \gamma_i = \arctan(2^). The values of \gamma_n must also be precomputed and stored. For small angles it can be approximated with \arctan(\gamma_n) \approx \gamma_n to reduce the table size. As can be seen in the illustration above, the sine of the angle \beta is the ''y'' coordinate of the final vector v_n, while the ''x'' coordinate is the cosine value.


Vectoring mode

The rotation-mode algorithm described above can rotate any vector (not only a unit vector aligned along the ''x'' axis) by an angle between −90° and +90°. Decisions on the direction of the rotation depend on \beta_i being positive or negative. The vectoring-mode of operation requires a slight modification of the algorithm. It starts with a vector whose ''x'' coordinate is positive whereas the ''y'' coordinate is arbitrary. Successive rotations have the goal of rotating the vector to the ''x'' axis (and therefore reducing the ''y'' coordinate to zero). At each step, the value of ''y'' determines the direction of the rotation. The final value of \beta_i contains the total angle of rotation. The final value of ''x'' will be the magnitude of the original vector scaled by ''K''. So, an obvious use of the vectoring mode is the transformation from rectangular to polar coordinates.


Implementation

In Java the Math class has a scalb(double x,int scale) method to perform such a shift, C has the ldexp function, and the x86 class of processors have the fscale floating point operation.


Software example (Python)

from math import atan2, sqrt, sin, cos, radians ITERS = 16 theta_table = tan2(1, 2**i) for i in range(ITERS) def compute_K(n): """ Compute K(n) for n = ITERS. This could also be stored as an explicit constant if ITERS above is fixed. """ k = 1.0 for i in range(n): k *= 1 / sqrt(1 + 2 ** (-2 * i)) return k def CORDIC(alpha, n): assert n <= ITERS K_n = compute_K(n) theta = 0.0 x = 1.0 y = 0.0 P2i = 1 # This will be 2**(-i) in the loop below for arc_tangent in theta_table n sigma = +1 if theta < alpha else -1 theta += sigma * arc_tangent x, y = x - sigma * y * P2i, sigma * P2i * x + y P2i /= 2 return x * K_n, y * K_n if __name__

"__main__": # Print a table of computed sines and cosines, from -90° to +90°, in steps of 15°, # comparing against the available math routines. print(" x sin(x) diff. sine cos(x) diff. cosine ") for x in range(-90, 91, 15): cos_x, sin_x = CORDIC(radians(x), ITERS) print( f"° () ()" )


Output

$ python cordic.py x sin(x) diff. sine cos(x) diff. cosine -90.0° -1.00000000 (+0.00000000) -0.00001759 (-0.00001759) -75.0° -0.96592181 (+0.00000402) +0.25883404 (+0.00001499) -60.0° -0.86601812 (+0.00000729) +0.50001262 (+0.00001262) -45.0° -0.70711776 (-0.00001098) +0.70709580 (-0.00001098) -30.0° -0.50001262 (-0.00001262) +0.86601812 (-0.00000729) -15.0° -0.25883404 (-0.00001499) +0.96592181 (-0.00000402) +00.0° +0.00001759 (+0.00001759) +1.00000000 (-0.00000000) +15.0° +0.25883404 (+0.00001499) +0.96592181 (-0.00000402) +30.0° +0.50001262 (+0.00001262) +0.86601812 (-0.00000729) +45.0° +0.70709580 (-0.00001098) +0.70711776 (+0.00001098) +60.0° +0.86601812 (-0.00000729) +0.50001262 (+0.00001262) +75.0° +0.96592181 (-0.00000402) +0.25883404 (+0.00001499) +90.0° +1.00000000 (-0.00000000) -0.00001759 (-0.00001759)


Hardware example

The number of
logic gate A logic gate is a device that performs a Boolean function, a logical operation performed on one or more binary inputs that produces a single binary output. Depending on the context, the term may refer to an ideal logic gate, one that has, for ...
s for the implementation of a CORDIC is roughly comparable to the number required for a multiplier as both require combinations of shifts and additions. The choice for a multiplier-based or CORDIC-based implementation will depend on the context. The multiplication of two
complex number In mathematics, a complex number is an element of a number system that extends the real numbers with a specific element denoted , called the imaginary unit and satisfying the equation i^= -1; every complex number can be expressed in the for ...
s represented by their real and imaginary components (rectangular coordinates), for example, requires 4 multiplications, but could be realized by a single CORDIC operating on complex numbers represented by their polar coordinates, especially if the magnitude of the numbers is not relevant (multiplying a complex vector with a vector on the unit circle actually amounts to a rotation). CORDICs are often used in circuits for telecommunications such as
digital down converter In digital signal processing, a digital down-converter (DDC) converts a digitized, band-limited signal to a lower frequency signal at a lower sampling rate in order to simplify the subsequent radio stages. The process can preserve all the informa ...
s.


Double iterations CORDIC

In two of the publications by Vladimir Baykov, it was proposed to use the double iterations method for the implementation of the functions: arcsine, arccosine, natural logarithm, exponential function, as well as for the calculation of the hyperbolic functions. Double iterations method consists in the fact that unlike the classical CORDIC method, where the iteration step value changes ''every'' time, i.e. on each iteration, in the double iteration method, the iteration step value is repeated twice and changes only through one iteration. Hence the designation for the degree indicator for double iterations appeared: i = 0, 0, 1, 1, 2, 2\dots. Whereas with ordinary iterations: i = 0, 1, 2\dots. The double iteration method guarantees the convergence of the method throughout the valid range of argument changes. The generalization of the CORDIC convergence problems for the arbitrary positional number system with radix R showed that for the functions sine, cosine, arctangent, it is enough to perform R - 1 iterations for each value of i (i = 0 or 1 to n, where n is the number of digits), i.e. for each digit of the result. For the natural logarithm, exponential, hyperbolic sine, cosine and arctangent, R iterations should be performed for each value i. For the functions arcsine and arccosine, two R - 1 iterations should be performed for each number digit, i.e. for each value of i. For inverse hyperbolic sine and arcosine functions, the number of iterations will be 2R for each i, that is, for each result digit.


Related algorithms

CORDIC is part of the class of "shift-and-add" algorithms, as are the logarithm and exponential algorithms derived from Henry Briggs' work. Another shift-and-add algorithm which can be used for computing many elementary functions is the
BKM algorithm The BKM algorithm is a shift-and-add algorithm for computing elementary functions, first published in 1994 by Jean-Claude Bajard, Sylvanus Kla, and Jean-Michel Muller. BKM is based on computing complex logarithms (''L-mode'') and exponentials ('' ...
, which is a generalization of the logarithm and exponential algorithms to the complex plane. For instance, BKM can be used to compute the sine and cosine of a real angle x (in radians) by computing the exponential of 0+ix, which is \operatorname(x) = \cos(x) + i \sin(x). The BKM algorithm is slightly more complex than CORDIC, but has the advantage that it does not need a scaling factor (''K'').


See also

*
Methods of computing square roots Square root algorithms compute the non-negative square root \sqrt of a positive real number S. Since all square roots of natural numbers, other than of perfect squares, are irrational, square roots can usually only be computed to some finite pre ...
*
IEEE 754 The IEEE Standard for Floating-Point Arithmetic (IEEE 754) is a technical standard for floating-point arithmetic originally established in 1985 by the Institute of Electrical and Electronics Engineers (IEEE). The standard #Design rationale, add ...
*
Floating-point unit A floating-point unit (FPU), numeric processing unit (NPU), colloquially math coprocessor, is a part of a computer system specially designed to carry out operations on floating-point numbers. Typical operations are addition, subtraction, multip ...
s * Digital Circuits/CORDIC in Wikibooks


References


Further reading

* (NB. ''DIVIC'' stands for ''DIgital Variable Increments Computer''. Some sources erroneously refer to this as by ''J. M. Parini''.) * * *

* *

*

*

*

* * * * * * * (about CORDIC in TI-58/
TI-59 The TI-59 is an early programmable calculator, that was manufactured by Texas Instruments from 1977. It is the successor to the TI SR-52, quadrupling the number of "program steps" of storage, and adding "ROM Program Modules" (an insertable ROM ...
) * * * * * * (x+268 pages) * * * * *


External links

*
Soft CORDIC IP (verilog HDL code)

''CORDIC Bibliography Site''



CORDIC implementation in verilog

CORDIC Vectoring with Arbitrary Target Value

Python CORDIC implementation

Simple C code for fixed-point CORDIC

Tutorial and MATLAB Implementation – Using CORDIC to Estimate Phase of a Complex Number (archive.org)

Descriptions of hardware CORDICs in Arx with testbenches in C++ and VHDL

An Introduction to the CORDIC algorithm

Implementation of the CORDIC Algorithm in a Digital Down-Converter
*Implementation of the CORDIC Algorithm
fixed point C code for trigonometric and hyperbolic functionsC code for test and performance verification
{{DEFAULTSORT:Cordic Digit-by-digit algorithms Shift-and-add algorithms Root-finding algorithms Computer arithmetic Numerical analysis Trigonometry