Apparatus and method for minimizing accumulated rounding errors in coefficient values in a lookup table for interpolating polynomials

An apparatus and method are disclosed for minimizing accumulated rounding errors in coefficient values in a lookup table for interpolating polynomials. Unlike prior art methods that individually round each polynomial coefficient of a function, the method of the present invention use a “ripple carry” rounding method to round each coefficient using information from the previously rounded coefficient. The “ripple carry” method generates rounded coefficients that significantly improve the total rounding error for the function.

CROSS REFERENCE TO RELATED APPLICATION

The present invention is related to that disclosed in the following United States Non-Provisional Patent Application:

U.S. patent application Ser. No. 10/107,598, filed concurrently herewith on Mar. 26, 2002, entitled “APPARATUS AND METHOD FOR PROVIDING HIGHER RADIX REDUNDANT DIGIT LOOKUP TABLES FOR RECODING AND COMPRESSING FUNCTION VALUES.”

The above patent application is commonly assigned to the assignee of the present invention. The disclosures in this related patent application are hereby incorporated by reference for all purposes as if fully set forth herein.

FIELD OF THE INVENTION

The present invention relates generally to the field of computer technology. The present invention provides an improved apparatus and method for minimizing accumulated rounding errors in coefficient values in a lookup table for interpolating polynomials.

BACKGROUND OF THE INVENTION

In binary computing devices hardware direct lookup tables are typically employed for function evaluation and for reciprocal and root reciprocal seed values for division and square root procedures. For direct table lookup of a function of a normalized “p” bit argument 1≦x=1.b1b2. . . bibi+1. . . bp-1<2, the “i” leading bits b1b2. . . biprovide an index to a table yielding “j” output bits that determine the approximate function value.

The calculation of values of elementary functions usually uses a polynomial approximation method. The accuracy of the coefficients of the polynomial determines the accuracy of the calculated value of the function. The polynomial coefficients are usually stored in a “constant store” portion (or lookup table) of a “read only memory” of an arithmetic logic unit of a data processor.

The accuracy of the each polynomial coefficient depends upon the number of bits used to express the polynomial coefficient. In practice the last digit of each polynomial coefficient is rounded to give an approximate value of the coefficient.

Prior art methods separately round each individual polynomial coefficient of a function. Because each individual polynomial coefficients is rounded separately, rounding errors accumulate and contribute to value of the total rounded error of the function.

Accordingly, there is a need in the art for a method of rounding the polynomial coefficients of a function so that rounding errors are minimized for each polynomial coefficient of the function. There is also a need in the art for a method of rounding the polynomial coefficients of a function so that total accumulated rounding errors are minimized for the function.

SUMMARY OF THE INVENTION

The present invention is directed to an apparatus and method for minimizing accumulated rounding errors in coefficient values in a lookup table for interpolating polynomials.

An advantageous embodiment of the present invention comprises an apparatus and method for minimizing accumulated rounding errors in coefficient values in a lookup table for interpolating polynomials. Unlike prior art methods that individually round each polynomial coefficient of a function, the method of the present invention use a “ripple carry” rounding method to round each coefficient using information from the previously rounded coefficient. The “ripple carry” method generates rounded coefficients that significantly improve the total rounding error for the function.

It is an object of the present invention to provide an apparatus and method for rounding the polynomial coefficients of a function so that rounding errors are minimized for each polynomial coefficient of the function.

It is another object of the present invention to provide an apparatus and method for rounding the polynomial coefficients of a function so that total accumulated rounding errors are minimized for the function.

It is also an object of the present invention to provide a data processor that contains rounded polynomial coefficients with minimum rounding errors.

Before undertaking the Detailed Description of the Invention, it may be advantageous to set forth definitions of certain words and phrases used throughout this patent document: The terms “include” and “comprise” and derivatives thereof, mean inclusion without limitation, the term “or” is inclusive, meaning “and/or”; the phrases “associated with” and “associated therewith,” as well as derivatives thereof, may mean to include, be included within, interconnect with, contain, be contained within, connect to or with, couple to or with, be communicable with, cooperate with, interleave, juxtapose, be proximate to, to bound to or with, have, have a property of, or the like; and the term “controller,” “processor,” or “apparatus” means any device, system or part thereof that controls at least one operation. Such a device may be implemented in hardware, firmware or software, or some combination of at least two of the same. It should be noted that the functionality associated with any particular controller may be centralized or distributed, whether locally or remotely. Definitions for certain words and phrases are provided throughout this patent document. Those of ordinary skill should understand that in many instances (if not in most instances), such definitions apply to prior uses, as well as to future uses, of such defined words and phrases.

DETAILED DESCRIPTION OF THE INVENTION

FIGS. 1 through 13, discussed below, and the various embodiments used to describe the principles of the present invention in this patent document are by way of illustration only and should not be construed in any way to limit the scope of the invention. Those skilled in the art will understand that the principles of the present invention may be implemented in any suitably arranged lookup table unit in a central processing unit of a computer system.

FIG. 1illustrates a block diagram of a portion of a central processing unit100showing a prior art arithmetic logic unit (ALU)110. Arithmetic logic unit110comprises a lookup table (LUT)120and an arithmetic unit130. Lookup table120receives data in the form of “i” input bits. Lookup table120outputs data to arithmetic unit130in the form of “j” output bits in accordance with principles that are well known in the prior art. Arithmetic unit130may comprise a multiplier unit, an adder unit, a microprogram storage unit, or other type of computational unit.

FIG. 2illustrates a block diagram of a prior art arithmetic logic unit (ALU)200comprising lookup table210, multiplier recoder220, and multiplier unit230. Lookup table210receives data in the form of “i” input bits. Lookup table210outputs data to multiplier recoder220in the form of “j” output bits in accordance with principles that are well known in the prior art. Multiplier recoder220comprises a Booth “radix4” multiplier recoder. Also in accordance with principles that are well known in the prior art multiplier recoder220outputs to multiplier unit230a number of bits equal to3⁢⁢⌈(j+1)2⌉
bits where the bottomless brackets denote taking the smallest integer greater than or equal to the expression within the bottomless brackets.

The calculation of values of elementary functions is usually made using a polynomial approximation method. The accuracy of the coefficients of the polynomial determines the accuracy of the calculated value of the function. Consider the following polynomial approximation for the decimal logarithm of x.
log10x=a1t+a3t3+a5t5+a7t7+a9t9+E(x)  (1)
where t=(x−1)/(x+1). The polynomial approximation is valid for x values in the range110≤x≤10(2)

The accuracy of the values of the polynomial coefficients shown in Equation 3 through Equation 7 is sufficient to ensure that the absolute value of the error E(x) is less than 10−7.

The values of the polynomial coefficients are stored in a hardware direct lookup table. The values of the polynomial coefficients must be rounded (or truncated) at some point for storage in a lookup table. The prior art method for rounding polynomial coefficients individually rounds each polynomial coefficient.

FIG. 3shows five (5) equations that illustrate an exemplary prior art method for rounding coefficients in a polynomial that expresses the value of an exemplary function f(x). The function f(x) shown in Equation 8 ofFIG. 1is an even function. That is, the terms of the function f(x) are in even powers of x. Functions that are of odd powers of x and mixed powers of x will be discussed later.

The first coefficient of the function f(x) shown inFIG. 1has a value of 0.14. This first coefficient will be designated with the expression C0. The second coefficient (for x2) has a value of 0.34 and is designated with the expression C2. The third coefficient (for x4) has a value of 0.74 and is designated with the expression C4. Lastly, the fourth coefficient (for x6) has a value of 0.44 and is designated with the expression C6.

For purposes of illustration the coefficients of f(x) will be assumed to be exact to two decimal places. Therefore, when the value of x is set equal to one (“1”) the exact value of the function f(1) shown in Equation 9 is 1.66.

The prior art method of rounding the coefficients in a polynomial comprises rounding each coefficient individually. The expression fa(x) shown in Equation 10 ofFIG. 3shows the result of rounding the coefficients C0through C6in Equation 8. The value 0.14 of coefficient C0rounds down to the value 0.1. The value 0.34 of coefficient C2rounds down to the value 0.3. The value 0.74 of coefficient C4rounds down to the value 0.7. The value 0.44 of coefficient C6rounds down to the value 0.4.

In order to measure the accuracy provided by the expression fa(x) with rounded coefficients the value of x is set equal to one (“1”) in Equation 10. The result is fa(1) as shown in Equation 11. The value of fa(1) is 1.5. Therefore, the error between the exact value of 1.66 for f(1) and the rounded value of 1.5 for fa(1) is 0.16. This result is shown in Equation 12. This error value of 0.16 will later be compared with an error value obtained using the method of the present invention.

In Equation 13 ofFIG. 4the function f(x) is shown with the coefficients expressed as C0, C2, C4and C6. In Equation 14 the function fa(x) is shown with the rounded coefficients expressed as A0, A2, A4and A6. In the prior art method of rounding coefficients each rounded coefficient Aiis obtained by rounding its corresponding coefficient Ci. An example of this is shown in Equation 15 where the rounded coefficient A0is equal to the rounded value of coefficient C0.

The rounding error Eifor each coefficient is obtained by subtracting the value of the rounded coefficient Aifrom the value of its corresponding coefficient Ci. An example of this is shown in Equation 16 where the rounding error E0is equal to the value of the coefficient C0minus the value of the rounded coefficient A0.

FIG. 5generally illustrates the equations that are used in the prior art method of rounding coefficients. As shown in Equations 17 through 20, each rounded coefficient A1is obtained by rounding its corresponding coefficient Ci. The rounding error Eifor each coefficient is obtained by subtracting the value of the rounded coefficient Aifrom the value of its corresponding coefficient CiFor example, rounded coefficient A4is obtained by rounding the corresponding coefficient C4. The rounding error E4for rounded coefficient A4is obtained by subtracting the value of the rounded coefficient A4from the value of corresponding coefficient C4.

FIG. 6illustrates the method of rounding coefficients of the present invention. Only the first rounded coefficient A0is obtained using the coefficient rounding method of the prior art. This step is shown in Equation 21. In the next portion of the method of present invention (shown in Equation 22), the rounded coefficient A2is obtained by adding the rounding error E0(from Equation 21) to coefficient C2and rounding the sum of C2and E0. The rounding error E2for rounded coefficient A2is then computed by subtracting the value of rounded coefficient A2from the sum of coefficient C2and rounding error E0(as shown in Equation 22).

In the next portion of the method of present invention (shown in Equation 23), the rounded coefficient A4is obtained by adding the rounding error E2(from Equation 22) to coefficient C4and rounding the sum of C4and E2. The rounding error E4for rounded coefficient A4is then computed by subtracting the value of rounded coefficient A4from the sum of coefficient C4and rounding error E2(as shown in Equation 23).

In the next portion of the method of present invention (shown in Equation 24), the rounded coefficient A6is obtained by adding the rounding error E4(from Equation 23) to coefficient C6and rounding the sum of C6and E4. The rounding error E6for rounded coefficient A6is then computed by subtracting the value of rounded coefficient A6from the sum of coefficient C6and rounding error E4(as shown in Equation 24).

The method of the present invention can be continued for as many terms as there are in the polynomial. In the present example there are only four terms in the function f(x) and so only four rounded coefficients (A0, A2, A4, A6) are calculated. Except for the first rounded coefficient A0, the method of the present invention calculates each rounded coefficient Aiusing the value of the rounding error for the previous rounded coefficient. For this reason the method of the present invention is referred to as the “ripple carry” rounding method.

FIG. 7illustrates how the “ripple carry” rounding method of the present invention may be applied to calculate rounded coefficients for the function f(x) shown in Equation 8 ofFIG. 3. The first rounded coefficient A0is obtained from rounding the value 0.14 of C0. As shown in Equation 25 the result for rounded coefficient A0is 0.1. The rounding error E0is equal to C0minus A0. This value is 0.14 minus 0.1. As shown in Equation 26 the result for rounding error E0is 0.04.

The next rounded coefficient A2is obtained from rounding the sum of C2(C2equals 0.34) and the rounding error E0(E0equals 0.04). The sum of C2and E0is 0.38. As shown in Equation 27 the result for rounded coefficient A2is 0.4. The rounding error E2is equal to C2plus E0minus A2. This value is 0.34 plus 0.04 minus 0.4. As shown in Equation 28 the result for rounding error E2is negative 0.02.

The next rounded coefficient A4is obtained from rounding the sum of C4(C4equals 0.74) and the rounding error E2(E2equals negative 0.02). The sum of C4and E2is 0.72. As shown in Equation 29 the result for rounded coefficient A4is 0.7. The rounding error E4is equal to C4plus E2minus A4. This value is 0.74 plus (negative 0.02) minus 0.7. As shown in Equation 30 the result for rounding error E2is a positive 0.02.

The next rounded coefficient A6is obtained from rounding the sum of C6(C6equals 0.44) and the rounding error E4(E4equals 0.02). The sum of C6and E4is 0.46. As shown in Equation 31 the result for rounded coefficient A6is 0.5. The rounding error E6is equal to C6plus E4minus A6. This value is 0.44 plus 0.02 minus 0.5. As shown in Equation 32 the result for rounding error E6is a negative 0.04.

FIG. 8illustrates how the rounded coefficient values A0, A2, A4, and A6generated by the “ripple carry” rounding method described inFIG. 7may be applied to calculate an approximate value of the function f(x) shown in Equation 8 ofFIG. 3. Inserting the rounded coefficient values A0, A2, A4, and A6into Equation 14 ofFIG. 4gives Equation 33 ofFIG. 8. Equation 33 is a more accurate approximation of Equation 8 than the approximation of Equation 10 that was obtained by the prior art rounding method.

The increase in accuracy provided by the method of the present invention may be seen by calculating the value of fa(x) in Equation 33 for the value of x equal to one (“1”). As shown in Equation 34, fa(1) equals 1.7. Therefore, the error between the exact value of 1.66 for f(1) and the rounded value of 1.7 for fa(1) in Equation 34 is a negative 0.04. This result is shown in Equation 35. The absolute value of the error obtained using the “ripple carry” rounding method of the present invention is four (4) times more accurate than the value of the error obtained using the prior art method of rounding.

This relatively simple example set forth above provides an understanding how the “ripple carry” rounding method of the present invention operates. In practice many digits are used to express each coefficient in a high level of accuracy. For example, it is not unusual for a coefficient term to be represented as many as sixty four (64) binary digits.

Consider a transcendental function f(x) over a normalized interval 1≦x≦2. Suppose that a value of x is represented by “p” digits in the form:
x=1.b1b2b3. . . bibi+1. . . bp-1(36)
where the integer one (“1”) is represented by one bit and the fraction is represented by “p-1” binary bits (i.e., bits b1through bp-1). A value of x that is truncated at bit biis designated with the symbol xi.
xi=1.b1b2b3. . . bi(37)
Then let the letter “d” designate a fraction that is represented by bits b1+1through bit bp-1.
d=0.b1+1bi+2b1+3. . . bp-1(38)
The expression for x in Equation 36 may then be represented by
x=xi+d2−i(39)
where the fraction “d” has been multiplied by the factor 2−ito reduce the value of “d” to an appropriate value so that the value “d 2−i” added to xiyields the value x.

Now suppose that the function f(x) is approximated by an even polynomial shown in Equation 40 ofFIG. 9. The term “FE” represents a “function error” that is of order “d82−8i.” FE is suitably small and may be neglected. As shown in Equation 41, each of the coefficients of f(x) (C0, C2, C4, and C6) is represented by a value that is truncated at the ithbit. That is, bit biis the last bit in the fraction of each coefficient.

Each coefficient of f(x) (C0, C2, C4, and C6) is determined by looking up a value in a lookup table. The lookup table is indexed by the same leading “i” bits of the normalized argument's fraction.

In a prior art lookup table each coefficient is truncated independently to provide an output for the lookup table. Each coefficient is truncated independently to the same last fixed point position designated with the letter “n.” This means that an independent rounding error of order 2−(n+1)is introduced for each coefficient. When, as in our example, there are four coefficients, then four independent rounding errors of order 2−(n+1)are introduced. In a worst case scenario when the fraction “d” approaches a value of one (“1”), the total rounding error could approach a value of four (4) times the value 2−(n+1). That is, the total rounding error could approach a value of 4[2−(n+1)].

The “ripple carry” rounding method of the present invention solves this problem by iteratively creating lookup table values so that the total rounding error is a convex combination of the individual rounding errors. A “convex” combination is a linear combination that sums to a value of one (“1”). The total rounding error using the method of the present invention is bounded by the value 2−(n+1). The “ripple carry” rounding method provides a significant improvement over the accuracy obtainable by prior art methods.

The 2−(n+1)bound on the total rounding error of the “ripple carry” rounding method by seen by considering the “ripple carry” rounding equations.FIG. 10illustrates several expressions for the total rounding error “f(x)−fa(x).” Subtracting Equation 14 from Equation 13 yields Equation 42 ofFIG. 10. Equation 43 ofFIG. 10is obtained by substituting the expressions for the rounding error values E0through E6from Equations 21 through 24. Equation 44 ofFIG. 10is obtained by factoring out the individual rounding error values E0through E6.

As can be seen with reference to Equation 44 each rounding error value E0through E6may be considered to be multiplied by a “weight value” (wiwhere i=0, 2, 4, 6) As shown in Equations 45 through 48, the weight value for E0is (1−x2), the weight value for E2is x2(1−x2), the weight value for E4is x4(1−x2), and the weight value for E6is x6. Therefore, the total rounding error may be expressed in Equation 49 as:
f(x)−fa(x)=E0w0+E2w2+E4W4+E6w6(49)
The weight values, wi, satisfy the condition:
0≦wi≦1 for 0≦x≦1  (50)
The weight values, wi, also satisfy the condition:
w0+w2+w4+w6=1  (51)
Equation 49 shows that the total rounding error for the “ripple carry” rounding method of the present invention is a convex combination of E0and E2and E4and E6, the individual “ripple carry” rounding errors. Therefore, the maximum value of the total “ripple carry” rounding error is bounded (as shown in Equation 52 ofFIG. 10) by the value 2−(n+1).

FIG. 11illustrates a data processor1110constructed in accordance with the principles of the present invention. Data processor1110comprises memory1120capable of containing at least one program1130. Memory1120comprises a constant store portion1140that contains polynomial coefficients that have been rounded by the “ripple carry” rounding method of the present invention.

Memory1120may comprise random access memory (RAM) or a combination of random access memory (RAM) and read only memory (ROM). Memory1120may comprise a non-volatile random access memory (RAM), such as flash memory. In an alternate advantageous embodiment of data processor1110, memory1120may comprise a mass storage data device, such as a hard disk drive (not shown). Memory1120may also include an attached peripheral drive or removable disk drives (whether embedded or attached) that reads read/write DVDs or re-writable CD-ROMs. As illustrated schematically inFIG. 11, removable disk drives of this type are capable of receiving and reading re-writable CD-ROM disk1150.

FIG. 12illustrates a data processor1210constructed in accordance with the principles of the present invention. Data processor1210comprises arithmetic logic unit1220capable of containing at least one microprogram1230. Arithmetic logic unit1220comprises constant store unit1240that contains polynomial coefficients that have been rounded by the “ripple carry” rounding method of the present invention.

FIG. 13illustrates a flow chart showing the steps of one advantageous embodiment of a method of the present invention. The steps are collectively referred to with reference numeral1300. The first coefficient C0is rounded to obtain the first rounded coefficient A0(step1310). Then the first rounding error E0is calculated using the equation E0=C0−A0(step1220).

The index “j” is then set equal to one (“1”) (step1330). Then the next rounded coefficient A2jis calculated by rounding the sum (C2j+E2j-2) (step1340). Then the next value of the rounding error E2jis calculated by subtracting A2jfrom the sum (C2j+E2j-2) (step1350). The values A2jand E2jare stored in memory.

Then a determination is made whether the index “j” is equal to the maximum value of “j.” (step1360). If the value of the index “j” is not equal to the maximum value of “j,” then the index “j” is incremented (step1370). Control is then passed to step1340to calculate the next values of A2jand E2jfor the new value of “j.”

When the value of the index “j” equals the maximum value of “j,” then all of the required values of A2jand E2jhave been calculated. Control is then passed to the next portion of the computer software (not shown) that uses the calculated values of A2jand E2j.

An advantageous method of the present invention has been described for an “even” function (i.e., a function of even powers of x such as x2, x4, x6, etc.). The method of the present invention is equally applicable for an “odd” function (i.e., a function of odd powers of x such as x, x3, x5, x7, etc.). The index “2j” is replaced by the index “2j-1.”

The method of the present invention may also be applied to a function of “mixed” powers of x (i.e., a function of both even and odd powers of x). For a “mixed” powers function, the function is first separated into to its odd and even parts. The method is applied to the odd and even parts separately. The rounded odd coefficients are used for the odd powers of x in the function and the rounded even coefficients are used for the even powers of x in the function.

The total amount of rounding error of a “mixed” powers function is the sum of the rounding error of the “even” powers portion and the rounding error of the “odd” powers portion. Therefore, the total amount of rounding error for a “mixed” powers function is approximately twice the rounding error of either the “even” or the “odd” powers portion.

FIG. 14illustrates a flow diagram in accordance with the present disclosure. At step1410, a first set of rounded polynomial coefficients A2j of a function are obtained where j=1, 2, . . . , n for even powers of said function. At step1420, a second set of rounded polynomial coefficients A2j-1 of said function are obtained where j=1, 2, . . . , n for even powers of said function.

The above examples and description have been provided only for the purpose of illustration, and are not intended to limit the invention in any way. As will be appreciated by the skilled person, the invention can be carried out in a great variety of ways, employing more than one technique from those described above, all without exceeding the scope of the invention.