I am thinking about calculating $(1-1/x)^y$ for very large x,y numbers in python.
One way todo so, it to use exp(y*log1p(-1/x)), but I am not sure about its accuracy.
Are they any results on using such accuracy? e.g., bound the error of such result?
I guess it better than using the approximation exp(-y/x)).
Definitely there will be accuracy concerns, especially for very large x and y. You can use result = math.expm1(y * math.log1p(-1/x)) this will calculate higher precision for values close to zero. Alternately,egarding error bounds, it's challenging to provide a general bound without knowing specific ranges for x and y. However, you can consider using numerical libraries that provide functions specifically designed for high precision, such as the mpmath library in Python. mpmath allows you to perform arithmetic with arbitrary precision: