Search code examples
mathdecimalsquare-rootsqrt

Sqrt and decimals


Is there any standard number of decimals needed to be able to reconstitute a number from it's sqrt decomposition with an error < 1 ?

I mean this : sqrt(200000) = 447.21359 ... If I try to do rebuild my number with only two decimals I have (447.21)^2 = 199996.7841 but if I use the first three decimals I get
(447.213)^2 = 199999.467369 which is an error less then 1 from the original number.

Is there any formula for the number of decimals I need to save ?


Solution

  • The error will be 1 when the re-squared square root is equal to or greater than the original value +/- 1, so just find the difference between the square root of x+1 (the error is higher on the + side) and the square root of x:

    maximum error = sqrt(x+1) - sqrt(x)
    

    e.g:

    sqrt(200001) - sqrt(200000) = 0.001118033
    

    So you need 3 digits

    The full formula is:

    decimal digits required = ceil(-log10(sqrt(x+1)-sqrt(x)))