Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Convergence methods for approximated reciprocal and reciprocal-square-root
1. Convergence methods for approximated
reciprocal and reciprocal-square-root
Keigo Nitadori
February 4, 2014
Since most hardware of today supports instructions for approximating reciprocal (hereafter rcp) y ∼ 1/x, and reciprocal-square-root (rsqrt)
√
y ∼ 1/ x, convergence methods for these have some interests.
1
General form
Provided an approximation
yapp = (1 + ε)
1
x1/n
,
n = 1 gives rcp and n = 2 rsqrt. Then, calculate a small number
n
h = 1 − xyapp = 1 − (1 + ε)n .
Hence,
1 + ε = (1 − h)1/n .
The true value of y is obtained in
y = yapp /(1 + ε) = (1 − h)−1/n · yapp .
The factor (1 − h)−1/n is expanded in Taylor series to a certain order, as in
p(h) = 1 + a1 h + a2 h2 · · ·
1
(1 − h)−1/n .
2. n = 1, reciprocal
2
For n = 1, we have a very simple series ak = 1. A second order method
y =(1 + h) · yapp
=(2 − xyapp ) · yapp ,
is well-known as the Newton–Raphson method. A polynomial for a fourth
order convergence is factorized in
p(h) = (1 + h)(1 + h2 ),
and an eighth order one
p(h) = (1 + h)(1 + h2 )(1 + h4 ).
Here, an m-th order convergence means that the effective digits grow m
times per iteration. We remark that h = 1 − xyapp is very accurately calculated in FMA (fused multiply-add) hardware.
n = 2, reciprocal-square-root
3
For n = 2, the polynomial takes a form
1
3
5
35
+h +h
+h
+ h ...
2
8
16
128
p(h) = 1 + h
,
with general coefficients
ak =
(2k − 1)!! k(2k − 1)!
= 2k−1
.
2k k!
2
(k!)2
Here, (·)!! is a double factorial 1 .
The second order one
3
2
y yapp − (x/2) yapp
2
1
2
=yapp + yapp − (x/2) yapp ,
2
is known as the Newton–Raphson method. The (x/2) can be reused over
iterations. The form in the second line is slightly suitable for FMA hardware.
1
0!! = 1!! = 1, n!! = n(n − 2)!!
2
3. 4
Other cases
We put a sequence for n = 3, a reciprocal of cbrt() function.
1 2 14 35 91
,
,...
{ak } = 1, , , ,
3 9 81 243 729
(k ≥ 0),
which we obtained from Maxima with
taylor((1-h)ˆ(-1/3), h, 0, 5);
Also, it is fun to see
powerseries((1-h)ˆ(-1/3), h, 0);
which outputs
∞
(%)
i=0
hi (−1)i
β
2
3
− i, i i
where β(·, ·) is the beta function 2 .
Finally, we remark that higher order methods can cause pressure for
registers to store the coefficients. The application need to find a suitable
points for the order of convergence and the number of iterations.
Reference
Japanese readers should also refer to:
http://www.finetune.co.jp/˜lyuka/technote/fract/sqrt.html
2
http://en.wikipedia.org/wiki/Beta_function
3