Performing efficient arctangent approximation - Embedded.com

Performing efficient arctangent approximation

Fast and accurate methods for computing the arctangent of a complex numberx = I + jQ have been the subject of extensive study because estimatingthe angle θ of a complex value has so many applications in the field ofsignal processing. The angle of x is defined as θ = tan-1 (Q/I).

Practitioners interested in computing high speed (minimum computations)arctangents typically use look-up tables where the value Q/I specifies amemory address in programmable read-only memory (PROM) containing an approximationof angle θ.

Those folks interested in enhanced precision implement compute-intensivehigh-order algebraic polynomials, where Chebyshev polynomials seem to bemore popular than Taylor series, to approximate angle θ.

(Unfortunately, because it is such a non-linear function, the arctangentis resistant to accurate reasonable-length polynomial approximations. Sowe end up choosing the least undesirable method for computing arctangents.)

Here’s another contender in the arctangent approximation race that usesneither look-up tables nor high-order polynomials. We can estimate the angleθ in radians, of x = I + jQ using the following approximation

where –1 ≥Q/I ≤1. That is, θ is in the range –45 to +45 degrees (–π/4≥θ≤+π/4 radians). Equation (13–107) has surprisingly good performance, particularlyfor a 90 degrees (π/2 radians) angle range.

Figure 13–59 below shows the maximum error is 0.26 degrees using Eq.(13–107) when the true angle θ is within the angular range of –45 to +45degrees. A nice feature of this θ computation is that it can be written as:

eliminating Eq. (13–107)’s Q/I division operation, at the expense oftwo additional multiplies.

Figure 13–59. Estimated angle theta error in degrees.

Another attribute of Eq. (13–108) is that a single multiply can be eliminatedwith binary right shifts. The product 0.28125Q2 is equal to (1/4+1/32)Q2 ,so we can implement the product by adding Q2 shifted right bytwo bits to Q2 shifted right by five bits.

This arctangent scheme may be useful in a digital receiver applicationwhere I2 and Q2 have been previously computed inconjunction with an AM (amplitude modulation) demodulation process or envelopedetection associated with automatic gain control (AGC).

We can extend the angle range over which our approximation operates.If we break up a circle into eight 45 degree octants, with the first octantbeing 0 to 45 degrees, we can compute the arctangent of a complex numberresiding in any octant. We do this by using the rotational symmetry propertiesof the arctangent:

These properties allow us to create Table 13-6 below.

Table 13–6 Octant Location versus Arctangent Expressions

So we have to check the signs of Q and I, and see if | Q | > | I |,to determine the octant location, and then use the appropriate approximationin Table 13–6. The maximum angle approximation error is 0.26 degrees forall octants.

When θ is in the 5th octant, the above algorithm will yield a θ’ that’smore positive than +π radians. If we need to keep the θ’ estimate in therange of –π to +π, we can rotate any θ residing in the 5th quadrant +π/4radians (45 degrees), by multiplying (I +jQ) by (1 +j) , placingit in the 6th octant.

That multiplication yields new real and imaginary parts defined as

Then the 5th octant θ’ is estimated using I’ and Q’ with

Used with the permission of the publisher, Prentice Hall, this on-going series of articles on Embedded.com is based on copyrighted material from “Understanding Digital Signal Processing, Second Edition” by Richard G. Lyons. The book can be purchased on line.

(Richard Lyons is a consulting systems engineer and lecturer with Besser Associates. As a lecturer with Besser and an instructor for the University of California Santa Cruz Extension, Lyons has delivered digitasl signal processing seminars and training course at technical conferences as well at companies such as Motorola, Freescale, Lockheed Martin, Texas Instruments, Conexant, Northrop Grumman, Lucent, Nokia, Qualcomm, Honeywell, National Semiconductor, General Dynamics and Infinion. )

2 thoughts on “Performing efficient arctangent approximation”

1. rafc says:

There are rational approximations that are defined in an entire quadrant. Although they are more complex, their advantage is that they not require to discriminate the octant.

This is for x in [0, Infinity). When x is negative just use -atan_approx(-x).

S