FAST SINE AND COSINE GENERATING APPARATUS

Abstract: Apparatus for developing fast sine and cosine functions via a division of the angle whose trigonometric function is to be developed into a plurality of component angles. Sine and cosine values of the component angles are obtained from look-up tables (10, 11, 12, 13, 14, 15) and appropriately combined (30). High computational speed is obtained by creating the plurality of component angles based on the radix used in the digital representation of the angle and, furthermore, by creating the component angles so that the look-up tables are approximately equal in size.

Description: FAST SINE AND COSINE GENERATING AFFARATUS Background of the lnyention This invention relates to apparatus for quickly and accurately generating sine and cosine function values. Trigonometric functions sin θ and cos θ are used extensively in diverse fields. The accuracy required for various applications, and the speed with which values need to be computed depend greatly on the application domain. However, xhe general trend in recent years has been to require both greater accuracy and higher computational speeds from the apparatus developing these trigonometric functions. This is particularly true in the field of roboτics. Prior art techniques for computing sines and cosines can broadly be divided into three categories. They are series expansion using polynomials, look-up tables with and without interpolation, and special techniques. The computation of sines and cosines by means of series expansion is based cn the well known Euler formula iθ e J = cosθ + j sinθ (1) where j represents the square root of -1 and θ is expressed in radians. When e J iθ is expanded in a power series and the real and imaginary terms are separated, a series expansion results for both the sine and for the cosine, as shown below. θ 2 A 4 θ 6 cos e - ι - §7 + Sτ - f7 + --- < 3 > The above series expansions converge reasonably fast since they involve factorial terms in the denominator. Still faster convergence can be obtained by employing other function approximating polynomials, but the basic principle is the same: a plurality of terms in a series is computed and combined to form the desired function. When great accuracy is required (such as with 32 bit machines operating at double precision), series expansion algorithms generally do not yield results quickly enough for some applications. For example, when these algorithms are implemented on a typical microprocessor, 100 to 150 microseconds are required to compute a sine value even with the help of a floating point processor. This is too long for some applications. Another method for computing sines and cosines, which avoids computations and improves speed, is the straightforward, look-up table technique. In the extreme case, one can store each possible value of the function sought to be determined, permitting generation of the desired value by merely accessing a memory. When high precision is required, however, this approach results in a prohibitive level of storage. For example, when an angle is specified with 24 bit accuracy, 2 distinct values of the function can be ascertained which, at 24 bits per word, requires a lock-up table, of 24x2' ' (or approximately 4x10 8 ) bits. To cut down on this massive storage, the prior art look-up table implementations restrict the angle to π/2 and employ and interpolation technique that relies on the approximation sinθ = θ when θ is small. Thus, when θ - θ + Δθ, the trigonometric identity reduces to sinθ = sinθ 1 + (ΔΘMcosθ..). (4) This method imposes a computational burden of one multiplication and one addition but significantly reduces the storage requirement of the look-up table. It can be shown that for the approximation technique to work, Δθ must be smaller than 2~ ~ . In systems employing binary representations, this requirement translates to a largest acceptable Δθ of 2 2 -N/2 ransl or to .-N/2 for even values of N (where N is the desired precision of the sine and cosine functions) and a θ . that is specified to (N/2) bits. In other words, the look-up table needs to contain 2 entries of N bits each. For example, in order to obtain a sin θ with a 24 bit precision arrangement, each of the look-up tables must have 2 ( 12 ) ' words. Other ways of computing sines and cosines use neither a polynomial expansion nor table look-ups. One such scheme is known as the Coordinate Potation Digital Computer (CORDIC) technique developed by J. E. Voider and described in "The CORDIC Trigonometric Computing Technique," IRE Transactions on Electronic Computers, EC-8, September 1959. This technique is used in most calculators to compute not only sines and cosines but other functions as well. Basically, the technique sets up the equality θ = Σ N + θ. where θ . = —1 r . (5) (i=1) X 1 2 1 Thus, θ is approximated by a series of angles with unique (apriorily defined) magnitudes and, consequently, it turns out that this method, involves nothing more than a sequence of additions and shifts (because of the power of 2 relationship) followed by one multiplication. This method requires only a small memory but its operation is inherently iterative and sequential. The series expansion method is used predominantly in general purpose computers and is implemented with function generating subroutines. The table look-up technique is often used in image processing and robotics where the function values must be generated very fast. The CORDIC method is used primarily in calculators where speed and accuracy can generally be sacrificed for the sake of simplicity. The problem is that none of these methods, however, is able to develop sines and cosines with both great precision and speed. Brief Description, of... . he,, Drawing FIG. 1 depicts a three-way division of an angle θ, specified by a binary word of 24 bits; FIG. 2 describes an arrangement for developing the sine function with a two-way division of angle θ; FIG. 3 describes an arrangement for developing the sine function with a four-way division of the angle θ; FIG. 4 describes an arrangement for developing the cosine function with a four-way division of the angle θ, and FIG. 5 illustrates a variation of the FIG. 3 apparatus employing an approximation technique. Summary, of,„the..Invention In accordance with the principles of this invention, accurate evaluations of the sine and cosine functions are realized via a division of tne angle whose trigonometric function is to be developed into a plurality of component angles. The trigonometric function is developed by deriving the sine and cosine values of the component angles and linearly combining them in accordance with particular trigonometric equations. High computational speed is realized by deriving the sine and cosine values from look-up tables and combining the sine and cosine values in parallel. The high computational speed is enhannced and small size is realized by dividing the angle whose function is to be evaluated into a plurality of component angles based on the radix used in the digital representation of the angle and, furthermore, by creating the component angles so that the necessary look-up tables are approximately equal in size. Detailed Description It is well known that if an angle θ can be expressed as the sum of two component angles (A and B) then the sine and the cosine of the angle can be expressed in terms of the sines and cosines of the respective component angles as shown below. sin(A + B) = sinAcosB + cosAsinB (6) cos(A + B) = cosAcosB - sinAsinB (7) Indeed, the prior art table look-up technique (with interpolation) described above employs this trigonometric identity with a division of the angle θ into angles A and B such that angle E is smaller than a certain value that is dependent on the desired precision. What is generally not realized, is that trigonometric identities (6) and (7) can be extended to three-way, four-way, and any other division of the angle θ. This apparatus for accurately developing the value of trigonometric functions makes use of the above identities, but with a particular division of the angle θ . The angle θ is divided into component angles strictly in accordance with the digital representation of the angle θ, and not based on the value of θ or the value of its components. More particularly, the angle θ is divided so that each of the component angles can be specified by a disjoint subset of the digits defining the angle θ and so that the number of digits in each of the resulting disjoint subsets is selected to reduce the overall required hardware to develop the desired trigonometric function. It should be noted that a correspondence between the angle θ and its digital representation must be established and it is most efficient when a digital representation of zero corresponds to zero radians and the maximum digital representation corresponds (essentially) to π/2 radians. FIG. 1 depicts a three-way division of an angle θ , specified by a binary word of 24 bits, in accordance with my invention. Angle θ is divided into angles A, E, and C such that A is completely defined by the 8 most significant bits of the binary number defining angle θ, angle C is completely defineed by the 8 least significant bits of the binary word defining angle θ, and angle B is completely defined by the middle 8 bits of the binary word defining angle θ. It should be appreciated that FIG. 1 is merely illustrative of my invention and that different word sizes, a division other than into thirds, and a positional representation of the angle θ other than binary are all within the scope of tnis invention. FIG. 2 describes an arrangement for developing the sine function with a two way division of angle θ. For illustrative purposes, angle θ is taken to have 24 bits. In FIG. 2, angle θ is diviided into an angle A defined by the 12 πost significant bits of θ and into εn angle B defined by the 12 least significant bits of θ. Angle A is applied to sine table 100 and to cosine table 110. Similarly, angle B is applied to sine table 120 and to cosine table 130. Tables 120 and 130 contain the sine and cosine values, respectively, for angles that range from 0 to (2 12 -1)/2 24 in increments of 1/2 24 , and tables 100 and 11C contain the sine and cosine values, respectively, for angles that range from 0 to 2 24-212)/224 in increments of 12 1/2 . The outputs cf tables 100 and 130 are applied to multiplier 140, and tne outputs of tables 110 and 120 are applied to multiplier 150. The products developed by multipliers 140 and 150 are combined in summing network 1S0 to develop the sine function in accordance with the applicable trigonometric equation. Although the FIG. 2 apparatus requires slightly more hardware than the interpolation technique, unlike the interpolation technique, the apparatus of FIG. 2 offers increased precision without that size of the look-up table. A much more advantageous result is achieved when, in accordance with the principles of this invention, the angle 9 is divided into more than two angles. Kith a division of the binary representation of angle θ as depicted in FIG. 1, for example, the sine of θ can be realized with apparatus as shown in FIG. 3 and the cosine of θ can be realized with apparatus as shown in FIG. 4. In FIG. 3 the 8 bits defining angle A are applied to sine look-up table 10 and to a cosine look-up table 11. Similarly, the 8 bits defining angle B are applied to a sine look-up table 12 and to a cosine look-up table 13. Finally, the 8 bits defining angle C are applied to a sine look-up table 14 and a cosine look-up table 15. Since a division of the angle θ into angles A, B, and C results in the trigonometric identity sin(A+B+C) = sinAcosBcosC - sinAsinBsinC + cosAsinBcosC + sinAcosEsinC, (8) different outputs of the various look-up tables are applied to different multipliers. Specifically in FIG. 3, multiplier 21 receives input from sinA table 10 and cosB table 13. The output of multipler 21 is applied to multiplier 22 which receives a second input from cosC table 15. The output signal of multiplier 22 thus forms the first term in the above trigonometric identity. Multiplier 23 receives input from sunA table 10 and from sinB table 12. The output off multiplier 23 is applied to multiplier 24 which receives a second input from εinC table 14. The output signal of multiplier 24 thus forms the second term in the above trigonometric identity. Multiplier 25 receives input from cosA table 11 and from sinB table 12. The output of multiplier 25 is applied to multiplier 26 which receives a second input from sinC table 14. The output of multiplier 26 thus forms the third term in the above trigonometric identity. Finally, multiplier 27 receives input from cosA table 11 and from cosE table 13. The output of multiplier 27 is applied to multiplier 28 which receives a second input from cosC table 15. The output of multiplier 28 forms the fourth and last term in the above trigonometric identity. The four outputs of multipliers 22, 24, 26 and 28 are applied to summing network 30 which appropriately adds and substracts the four terms. The output of summing network 30 forms a 24 bit sine value of the input angle θ. - 8 - FIG. 4 is almost identical to FIG. 3, with the only difference being the specific connections between look-up tables 10-15 and multipliers 21-28. The connections to multipliers 10-15 and the selection of addition or subtraction in summing network 30 are made in accordance with the trigonometric identity for the cosine of angle (A+B+C), which is cos(A+B+C) = cosAcosBcosC - cosAεinBsinC - sinAsinBcosC - sinAcoεBsinC. (9) Each one of the sine and cosine look-up tables in FIGS. 3 and 4 has an 8 bit input and, therefore, each Q of the look-up tables needs to have only 2 entries, or 256 words. Each word, however, can have as many bits as the desired accuracy of the sine and cosine function. The total memory requirement of 6 tables of 256 words each- of FIG. 3 compares quite favorably with tne total requirement of 4 tables of 4056 words each of FIG. 2, and even more favorably with the memory requirement of a single look-up table of approximately 400 million words. The advantage of dividing angle θ into three components increases when the level of desired precision is increased. As indicated earlier, the precision of the output values in the apparatus of FIG. 3 and 4 is not a function of the size of the look-up tables but, rather, a function of the word lengths in the look-up tables. Since the process of the FIGS. 3 and 4 is not an approximation, increasing the stored word size is all that is necessary to increase precision. However, once the precision level at the output is selected, the approximation technique described above can be applied to further reduce the required storage. FIG. 5 illustrates a variation of the FIG. 3 apparatus, employing the approximation technique by realizing that angle C is very small and its sine and cosine can be approximated. SinC table 14 is replaced with the angle itself and cosC table 15 is eliminated. Since cosC is approximated with 1, multipliers 22 and 26 are also eliminated, allowing the output of multipliers 21 and 25 to be applied directly to summing network 30. When the approximation technique is employed in conjunction with the principles of this invention, division of the angle θ may follow a slightly different approach. Specifically, given a desired output precision, F, a number of most significant bits corresponding to the integer part of (P+1)/2 are selected and equally divided between angles A and B, and the remaining bits of the input angle are assigned to angle C. What results in applications where the desired output precision is equal to the precision (and the number of input digits) is that the most significant half of the input word digits is split between angles A and B, resulting in an even lower memory requirement. With such an angle division, the FIG. 5 circuit, for example, would require the four look¬ up tables to have only 64 words each.

Claims: Claims 1. A transcendental function generator responsive to a digital signal represented by a number composed of M positional digits of radix K, for developing function values in response to K y possible input signals, comprising: means for separating said M digits into disjoint subsets of digits that are adjacent to each other in said number representation of said digital signal, with the number of digits in each subsets being not less than the integer portion, I, of the quotient M/N (where N is the number of subsets) and not more than 1 + 1; a first transcendental function value generation means responsive to each of said disjoint subsets; a second transcendental function value generation means responsive to each of said disjoint subsets; and means for combining output signals of said first and second transcendental function value generation means to form an output signal of said function generator. 2. A transcendental function generator responsive to an M bit signal representation of an input signal comprising: means for separating said If bits into disjoint subsets of bits that are adjacent to each other in said K bit signal, with the number of bits in each of said subsets being not less than the integer portion, I, of the quotient K/N (when N is the number of subsets) and not more than 1 + 1; a first transcendental function value generation means responsive to each of said disjoint subsets; a second transcendental function value generation means responsive to each of said disjoint subsets: and means for combining output signals of said first and second transcendental function value generation means to form an output signal of said function generator. 3. The apparatus of claim 1 wherein said transcendental function is the trigonometric sine function. 4. The apparatus of claim 1 wherein said transcendental function is the trigonometric cosine function. 5. The apparatus of claim 1 wherein said first and second transcendental generation means are look-up tables. 6. A transcendental function generator responsive to a digital signal represented by a number composed of M positional digits of radix K, for developing function values that are accurate to within P positional w digits of radix K in response to " possible input signals, comprising: means for separating said K digits into an upper set of digits including the J most significant digits of said Yi positional digit number, where J is the integer portion of the number [(P/2)+( 1/2) ] , and into a lower set of digits including the remaining M-J digits; means for separating said J most significant digits into at least two disjoint subsets of digits that are adjacent to each other in said number representation of said digital signal, with the number of digits in each of said subsets being not less than the integer portion I, of the quotient J/N (when N is the number of subsets) and not more than I + 1 : a first transcendental function value generation means responsive to each of said disjoint subsets; a second transcendental function value generation means responsive to each of said disjoint subsets; and means for combining output signals of said first and second transcendental function value generation means and said lower set of digits to form an output signal of said function generator. 7. The apparatus of claim 6 wherein said first transcendental function generation means comprises sine look-up tables and said second transcendental function generation means comprises cosine look-up tables. 8. A transcendental function generator responsive to an M bit representation of an angle for developing function values that are accurate to within P bits comprising: means for separating said M bits into an upper set of bits including the J most significant bits of said angle (where J is the integer portion of [(F/2) + (1/2)]) and into a lower set of bits including the remaining M-J bits; means for separating said J most significant bits into two disjoint subsets (A and B) of adjacent bits having approximately eσual number of bits each; a first sine look-up table responsive to said subset A of adjacent bits for developing a sinA output signal; a first cosine look-up table responsive to said subset A of adjacent bits for developing a cosA output signal; a second sine look-up table responsive to said subset E of adjacent bits for developing a sinB output signal; a second cosine look-up table responsive to said subset B of adjacent bits for developing a cosB output signal; and means for combining said output signals sinA, sinB, cosA, and cosB to form an output signal of said function generator. 9. The apparatus of claim 8 wherein said means for combining develops the linear combination sinAcosB + cosAsinB. 10. The apparatus of claim 8 wherein said means for combining develops the linear combination sinAsinB- cosAcosB.

Inventors: GANAPATHY SUNDARAM, GANAPATHY, SUNDARAM
Applicants: AMERICAN TELEPHONE & TELEGRAPH, AMERICAN TELEPHONE & TELEGRAPH COMPANY
Application year: 1986
Main classification: G06F1
IPC codes: G06F1, G06F7, G06F17