88 5. FIXED-POINT VS. FLOATING-POINT
5.4.2 SINE AND COSINE
Trigonometric functions such as sine and cosine can be approximated by using the Taylor series
expansion. For sine, the following expansion can be used:
sin.x/ D x
x
3
C
x
5
x
7
C
x
9
C higher order: (5.8)
Clearly adding higher-order terms leads to more precision. For implementation purposes, this
expansion can be rewritten as follows:
sin.x/ Š x
1
x
2
2 3
1
x
2
4 5
1
x
2
6 7
1
x
2
8 9

: (5.9)
Similarly, for cosine, the following expansion can be used:
cos.x/ Š 1
x
2
2
C
x
4
x
6
C
x
8
D 1
x
2
2
1
x
2
3 4
1
x
2
5 6
1
x
2
7 8

: (5.10)
Furthermore, to generate sine and cosine, the following recursive equations can be used:
sin nx D 2 cos x sin.n 1/x sin.n 2/x
cos nx D 2 cos x cos.n 1/x cos.n 2/x:
(5.11)
5.4.3 SQUARE-ROOT
Square-root sqrt(y) can be approximated by the following Taylor series expansion considering
that y
0:5
D .x C 1/
0:5
:
sqrt.y/ Š 1 C
x
2
x
2
8
C
x
3
16
5x
4
128
C
7x
5
256
D 1 C
x
2
0:5
x
2
2
C 0:5
x
2
3
0:625
x
2
4
C 0:875
x
2
5
:
(5.12)
Here, it is assumed that x is in Q15 format. In this equation, the estimation error would be
small for x values near unity. Hence, to improve accuracy in applications where the range of x
is known,
x
can be scaled by
a
2
to bring it close to 1 (i.e.,
sqrt
a
2
x
where
a
2
x
Š
1
). e result
should then be scaled back by 1=a.
It is also possible to compute square-root by using the Newton–Raphson algorithm. e
NEON coprocessor provides an instruction for the Newton-Raphson iteration of the reciprocal
of square-root:
vŒn C 1 D vŒn .3 x vŒn vŒn/=2: (5.13)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.83.150