Page 282 - ARM 64 Bit Assembly Language
P. 282

Non-integral mathematics 271

                                             Table 8.2: Reciprocals for the terms two
                                                 through nine of the Taylor series.

                                            Term      Reciprocal      Reciprocal
                                                       Format         Value (Hex)
                                               1
                                             −        S(−2,32)         AAAAAAAA
                                              3!
                                              1       S(−6,32)         44444445
                                              5!
                                               1
                                             −        S(−12,32)        97F97F97
                                              7!
                                              1       S(−18,32)        5C778E96
                                              9!
                                               1
                                            −         S(−25,32)        9466EA60
                                              11!
                                              1       S(−32,32)        5849184F
                                             13!
                                               1
                                            −         S(−40,32)        94603063
                                              15!
                                              1       S(−48,32)        654B1DC1
                                             17!
                     In Hexadecimal, the number to be multiplied is 44444445 16 . Note that since  1  is a positive
                                                                                         5!
                     number, the reciprocal was incremented by one to avoid round-off errors. We can apply the
                     same procedure to the remaining terms. Table 8.2 shows the reciprocals and their formats for
                     terms two through nine. The first term is just one, so it is not included in the table.


                     8.6.3 Putting it all together


                     We want to keep as much precision as is reasonably possible for our intermediate calculations.
                     However, we also want to provide the best performance possible. Using 64 bits of precision
                     for all intermediate calculations will give a good trade-off between performance and preci-
                     sion. Keeping more than 64 bits would require more time to perform the multiplication and
                     addition steps, and would not result in any appreciable difference in our final 32-bit result.
                     The integer portion should never require more than two bits, so we choose an S(2,61) as our
                     intermediate representation. If we combine Table 8.1 and Table 8.2, we can determine what
                     the format of each complete term will be. This is shown in Table 8.3.

                     Note that the formats were truncated to fit in a 64 bit result. We can now see that the formats
                     for the first nine terms of the Taylor series are reasonably similar. They all require exactly 64
                     bits, and the radix points can be shifted so that they are aligned for addition. In order to make
                     the shifting and adding process easier, we will pre-compute the shift amounts and store them
                     in a look-up table. In fact, we will create a look-up table to hold the reciprocal values and
                     the shift amounts together, so that our Taylor series code is greatly simplified and extremely
                     efficient. The procedure will involve calculating the next power of x, multiplying it by the
   277   278   279   280   281   282   283   284   285   286   287