0

I need to calculate log of (1 - (1+x)^(-1)). The problem being, one value of x in my dataset is extremely small (order of e-29). Python calculates the whole equation as zero and hence log gives a "math domain error". This is an important outlier for a meteorological dataset hence can't be ignored. Any help regarding this issue?

round() doesn't help.

  • It isn't Python that is rounding off. It is the floating-point processor in your computer, and so you will see something similar no matter what the language. @KenY-N 's suggestion may be your easiest way out of the problem. – BoarGules Aug 05 '21 at 06:45

1 Answers1

0

because of floating point number precision, i recommend using integral using exponent

https://docs.python.org/3/library/decimal.html

Seonghun
  • 161
  • 7