Average Error: 0.0 → 0.4
Time: 1.8s
Precision: 64
\[-\log \left(\frac{1}{x} - 1\right)\]
\[-\left(\left(\log 1 - \log x\right) - \mathsf{fma}\left(1, x, 0.5 \cdot \frac{{x}^{2}}{{1}^{2}}\right)\right)\]
-\log \left(\frac{1}{x} - 1\right)
-\left(\left(\log 1 - \log x\right) - \mathsf{fma}\left(1, x, 0.5 \cdot \frac{{x}^{2}}{{1}^{2}}\right)\right)
double code(double x) {
	return -log(((1.0 / x) - 1.0));
}
double code(double x) {
	return -((log(1.0) - log(x)) - fma(1.0, x, (0.5 * (pow(x, 2.0) / pow(1.0, 2.0)))));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.0

    \[-\log \left(\frac{1}{x} - 1\right)\]
  2. Taylor expanded around 0 0.4

    \[\leadsto -\color{blue}{\left(\log 1 - \left(\log x + \left(1 \cdot x + 0.5 \cdot \frac{{x}^{2}}{{1}^{2}}\right)\right)\right)}\]
  3. Simplified0.4

    \[\leadsto -\color{blue}{\left(\left(\log 1 - \log x\right) - \mathsf{fma}\left(1, x, 0.5 \cdot \frac{{x}^{2}}{{1}^{2}}\right)\right)}\]
  4. Final simplification0.4

    \[\leadsto -\left(\left(\log 1 - \log x\right) - \mathsf{fma}\left(1, x, 0.5 \cdot \frac{{x}^{2}}{{1}^{2}}\right)\right)\]

Reproduce

herbie shell --seed 2020100 +o rules:numerics
(FPCore (x)
  :name "neg log"
  :precision binary64
  (- (log (- (/ 1 x) 1))))