Page 279 - ARM 64 Bit Assembly Language
P. 279
268 Chapter 8
Table 8.1: Natural and truncated
formats for the powers of x needed by
the Taylor series.
Term Format 32-bit
x S(1,30) S(1,30)
x 3 S(3,90) S(3,28)
x 5 S(5,150) S(5,26)
x 7 S(7,210) S(7,24)
x 9 S(9,270) S(9,22)
x 11 S(11,330) S(11,20)
13
x S(13,390) S(13,18)
x 15 S(15,450) S(15,16)
x 17 S(17,510) S(17,14)
The sine function will map x into the domain accepted by sinq and then call sinq to do the
actual work. If the result should be negative, then the sine function will negate it before re-
turning. The cosine function will use the relationship previously mentioned, and call the sine
function.
π
We have now reduced the problem to one of approximating sinx within the range [0, ].An
2
approximation to the function sinx can be calculated using the Taylor Series:
∞ 2n+1
n x
sinx = (−1) (8.2)
(2n + 1)!
n=0
The first few terms of the series should be sufficient to achieve a good approximation. The
(0.5×π) 13
maximum value possible for the seventh term is ≈ 0.00000005 10 , which indicates
13!
that our function should be accurate to at least 25 bits using seven terms. If more accuracy
is desired, then additional terms can be added. We will use the first nine terms of the Taylor
series in our function.
8.6.1 Formats for the powers of x
3
7
5
The numerators in the first nine terms of the Taylor series approximation are: x, x , x , x ,
9
13
15
17
11
x , x , x , x ,and x . Given an S(1,30) format for x, we can predict the format for the
numerator of each successive term in the Taylor series. If we simply perform successive mul-
tiplies, then we would get the formats shown in Table 8.1. The middle column in the table
shows that the format for x 17 would require 528 bits if all of the fractional bits are retained.
Dealing with a number at that level of precision would be slow and impractical. We will, of