
[dsp TIPS&TRICKS] Sreeraman Rajan, Sichun Wang, Robert Inkol, and Alain Joyal Efficient Approximations for the Arctangent Function his article provides several Iterative algorithms, such as the required division operations are rela- efficient approximations for coordinated rotation digital computer tively complex to implement; iterative the arctangent function (CORDIC) algorithm (requiring only techniques, such as those based on using Lagrange interpolation shifts and add operations), have been Newton’s method, are often used. and minimax optimization successfully used to compute trigono- The aforementioned approaches are Ttechniques. These approximations are metric functions [1], [2]. However, best suited for applications where pro- particularly useful when processing their sequential nature makes them cessing power and/or memory are read- power, memory, and power consumption less attractive when speed is a major ily available. However, for many are important issues. In addition to com- concern; attempts to increase speed applications, simpler and more effi- paring the errors and the computational have been at the expense of additional cient ways of evaluating arctan(x) are workload of these approximations, we hardware [3]. Lookup-table-based desirable. This article proposes simple also extend them to all four quadrants. approaches to the computation of approximations for evaluating the arct- inverse trigonometric functions are angent function that may be easily ARCTANGENT APPROXIMATIONS very fast but require considerable implemented in hardware with limited The evaluation of the arctangent func- memory [4], [5]. memory and processing power. tion is commonly encountered in real- Polynomial and rational function time signal processing applications. approximations that have been pro- PROPOSED METHODOLOGY Numerous algorithms are available to posed in the literature [3] are more AND APPROXIMATIONS implement the arctangent function suitable for numerical coprocessors. Approximations to the arctangent when computational cost is unimpor- Approximations using polynomials of function can be obtained using second- tant. The most direct solution is based large degrees are computationally and third-order polynomials and on the Taylor series expansion on [−1, expensive. Rational approximations are simple rational functions. Lagrange 1]. However, this series converges in principle more accurate than polyno- interpolation-based and minimax slowly for arguments close to one and mial approximations for the same num- criterion-based approaches are used to hence is inefficient. ber of coefficients. However, the obtain the polynomial coefficients. The following is our initial derivation of an arctangent approximation using Lagrange interpolation. Consider the three points x0 =−1, × 10−2 = = ( ) = 8 x1 0, and x2 1. Let x arctan (1 + x)/(1 − x), −1 ≤ x ≤ 1. According to the Lagrange interpolation formula, we have 4 (x − x1)(x − x2) φ(x) ≈ φ(x0) (x0 − x1)(x0 − x2) 0 (x − x0)(x − x2) + φ(x1) Error (rad) (x1 − x0)(x1 − x2) ( − )( − ) −4 x x0 x x1 + φ(x2) (x2 − x0)(x2 − x1) π = (x + 1), −1 ≤ x ≤ 1.(1) −8 4 −1 0 1 x It can be verified that (x) = π/4 + arctan(x); hence, arctan(x) can be [FIG1] Approximation errors using (2). approximated by the first-order formula IEEE SIGNAL PROCESSING MAGAZINE [108] MAY 2006 1053-5888/06/$20.00©2006IEEE π The above criterion (6) [TABLE 1] MAXIMUM ERROR arctan(x) ≈ x, −1 ≤ x ≤ 1.(2) 4 does the following: for AND COMPUTATIONAL WORKLOAD. every α, the maximum EQUATION ERROR (RAD.) ADDS MULTIPLIES DIVIDES This linear approximation has been used absolute error between (2) 0.07 0 1 0 (5) 0.0053 1 2 0 in [6] for FM demodulation due to its (x) and the second- (7) 0.0038 1 2 0 minimal complexity. It requires only a order polynomial (8) 0.005 1 3 0 2 (9) 0.0015 2 3 0 scaling operation by a fixed constant and (αx − αx) is deter- (10) 0.0047 1 2 1 can be computed in one cycle in most mined. This error, as a (11) 0.0049 2 1 1 processors. Figure 1 shows the deviation function of α, is then of this linear (first-order) approximation minimized. This will from the arctangent function on the yield a unique α that interval [−1, 1]. This error function, gives the least error J; hence the name A better third-order polynomial for given in (3), is antisymmetric with respect minimax criterion, and the approxima- approximating the error is of the form to x = 0 and attains a maximum of about tion is called minimax approximation. x(x − 1)(αx − β) for x in the interval 1/2 0.07 rad (4º) at xmax =±(4/π − 1) Using an extensive computer search, [0,1]. Using the minimax criteria, the fol- the optimum α ≈ 0.273 and the follow- lowing polynomial with a maximum π (x) = arctan(x) − x, ing approximation for the arctan(x) absolute error of 0.0015 rad (0.086º) is 4 with a maximum absolute error of identified as the optimal approximation − 1 ≤ x ≤ 1.(3) 0.0038 rad (0.22º) are obtained: to arctan(x) π Here’s a useful trick to improve the arctan(x) ≈ x + 0.273x(1 −|x|), π accuracy of the first-order approximation 4 arctan(x) ≈ x − x(|x|−1) (2). It can be seen from Figure 1 that the − 1 ≤ x ≤ 1.(7) 4 × ( . + . | |), error curve is approximately quadratic 0 2447 0 0663 x on the interval [0, 1] and hence can be A third-order polynomial is also a − 1 ≤ x ≤ 1.(9) approximated by a second-order polyno- good candidate to fit the error curve mial. Following this strategy and apply- shown in Figure 1. When the third- ing Lagrange’s interpolation formula to order polynomial is constrained to be Another candidate for approximating 3 (x) using x0 = 0, x1 = xmax , and of the form αx + β x, the best mini- the arctangent function is from the x2 = 1, we obtain the following formula: max approximation for the arctangent class of rational functions of the form function is given by τ(x) = x/(1 + β x2) in the interval (x) ≈ 0.285x(1 −|x|), [−1, 1]. For 0 ≤ β ≤ 1, the first deriva- − 1 ≤ x ≤ 1,(4) arctan(x) tive of τ(x) is positive and the second π derivative of τ(x) is negative. This ≈ x + x(0.186982 where the odd symmetry of (x) has 4 implies that τ(x) has a shape very simi- been applied. A second-order, and more − 0.191942x2), −1 ≤ x ≤ 1.(8) lar to that of the arctangent function accurate, approximation for arctan(x) in the same interval. Using minimax with a maximum absolute error of The maximum absolute error for this criteria, the following approximation 0.0053 rad (0.3º) is thus obtained as approximation is 0.005 rad (0.29º) and is with the maximum absolute error of worse than that given by (7). about 0.0047 rad (0.27º) is obtained: π arctan(x) ≈ x + 0.285x(1 −|x|), 4 − 1 ≤ x ≤ 1.(5) It is also of interest to approximate × 10−3 6 the error function, (x), given by (3), by Eq. (5) 4 a second-order polynomial of the form Eq. (11) 2 (αx2 − αx) that passes through the end- 0 points of the interval [0, 1]. The optimum −2 α>0 Error (rad) Eq. (7) parameter, , may be obtained using −4 the following minimax criterion −6 −1 −0.5 0 0.5 1 x J = min max {|(x) − αx(x − 1) |} . α 0≤x≤1 (6) [FIG2] Approximation errors using second-order polynomials (5), (7) and a rational (11). IEEE SIGNAL PROCESSING MAGAZINE [109] MAY 2006 [dsp TIPS&TRICKS] continued information of the argument is already available. However, one needs to check × 10−3 the sign of the argument, which may 5 Eqs. (10),(11) Eq. (8) take an extra cycle. Comparison of the approximations to arctan(x) using the proposed two 0 second-order approximations given by (5) Error (rad) and (7) are shown in Figure 2. These Eq. (9) −5 approximations have maximum errors −1 −0.5 0 0.5 1 that are an order of magnitude better x than that of the linear approximation (2). Furthermore, the second-order approxi- [FIG3] Approximation errors using cubic polynomials (8), (9) and rationals (10), (11). mation given by (5) provides better accu- racy for the subintervals 1 > x > 0.5 and −1 < x < −0.5, where the maximum error is only about 0.001 rad (0.057º). No x arctan(x) ≈ , DISCUSSION such observation can be made for (7). 1 + 0.28086x2 Here we compare the various arctan- Figure 3 shows that (9) provides − 1 ≤ x ≤ 1.(10) gent approximations presented in this the best accuracy amongst the third- article. Table 1 contains the maximum order approximations considered in error and the number of adds, multi- this article, while the rational approxi- Recently, a similar idea was present- plies, and divides for various arctan mations (10) and (11) have essentially ed in [5] with a maximum absolute approximations. The third-order identical errors. The error approaches error of 0.0049 rad (0.28º). The approxi- approximation given by (9) has the zero at x =±1 for (4), (7), and (9) (see mation in [5] is least error among the proposed approx- Figures 2 and 3). imations but has the highest computa- The rational approximations given by tional cost. The second-order (10) and (11) are computationally more x arctan(x) ≈ , approximation given by (7) has the next expensive than the second-order ones 1 + 0.28125x2 lowest error and has fewer operations given by (5) and (7), though this cost − 1 ≤ x ≤ 1.(11) than (9). Hence, (7) provides a favor- increase is partly offset by the elimination able compromise between accuracy and of the need for sign comparisons.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages4 Page
-
File Size-