Average Error: 0.0 → 0.4
Time: 2.4s
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 f(double x) {
        double r4278 = 1.0;
        double r4279 = x;
        double r4280 = r4278 / r4279;
        double r4281 = r4280 - r4278;
        double r4282 = log(r4281);
        double r4283 = -r4282;
        return r4283;
}

double f(double x) {
        double r4284 = 1.0;
        double r4285 = log(r4284);
        double r4286 = x;
        double r4287 = log(r4286);
        double r4288 = r4285 - r4287;
        double r4289 = 0.5;
        double r4290 = 2.0;
        double r4291 = pow(r4286, r4290);
        double r4292 = pow(r4284, r4290);
        double r4293 = r4291 / r4292;
        double r4294 = r4289 * r4293;
        double r4295 = fma(r4284, r4286, r4294);
        double r4296 = r4288 - r4295;
        double r4297 = -r4296;
        return r4297;
}

Error

Bits error versus x

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))))