math - Precision of reciprocal in floating point arithmetics -


for fun, i'm trying implement chudnovsky algorithm calculate pi in java using arbitrary precision floating point library. 1 thing strikes me need calculate reciprocal of number 1/n, since formula described 1/pi = sum(...)

how many significant digits/digits of precision 1 need of floating point number n, in order 1/n have desired precision? there easy answer this? tried doing calculations 1/0.100009999999 = 9.99900010009 determine reciprocal of 0.1 5 correct digits after decimal point. see if take first 3 digits after decimal point, , round result correct value 10, there general rule how many digits correct after 1/n operation? interested in same result in binary , hexadecimal bases.

tried googling , fast search on stackoverflow, didnt find previous answer this. apologies if duplicate exists.

you want compute 1/x, computing 1/(x+d) d=delta x truncation error. binomial theorems,

1/(x+d) = (x-d)/(x²-d²) 

and since can assume d² far below floating point error, error of reciprocal -d/x² , more relevant relative error -d/x.

which confirms comment of artur biesiadowski, if 1/x between 1 , 10, error magnification factor 10 in worst case.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -