Average Error: 0.0 → 0.3
Time: 10.1s
Precision: 64
\[-\log \left(\frac{1}{x} - 1\right)\]
\[\mathsf{fma}\left(\mathsf{fma}\left(x, \frac{1}{2}, 1\right), x, \log x\right)\]
-\log \left(\frac{1}{x} - 1\right)
\mathsf{fma}\left(\mathsf{fma}\left(x, \frac{1}{2}, 1\right), x, \log x\right)
double f(double x) {
        double r245188 = 1.0;
        double r245189 = x;
        double r245190 = r245188 / r245189;
        double r245191 = r245190 - r245188;
        double r245192 = log(r245191);
        double r245193 = -r245192;
        return r245193;
}

double f(double x) {
        double r245194 = x;
        double r245195 = 0.5;
        double r245196 = 1.0;
        double r245197 = fma(r245194, r245195, r245196);
        double r245198 = log(r245194);
        double r245199 = fma(r245197, r245194, r245198);
        return r245199;
}

Error

Bits error versus x

Derivation

  1. Initial program 0.0

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

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

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

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

Reproduce

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