Average Error: 0.0 → 0.4
Time: 2.2s
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 r24012 = 1.0;
        double r24013 = x;
        double r24014 = r24012 / r24013;
        double r24015 = r24014 - r24012;
        double r24016 = log(r24015);
        double r24017 = -r24016;
        return r24017;
}

double f(double x) {
        double r24018 = 1.0;
        double r24019 = log(r24018);
        double r24020 = x;
        double r24021 = log(r24020);
        double r24022 = r24019 - r24021;
        double r24023 = 0.5;
        double r24024 = 2.0;
        double r24025 = pow(r24020, r24024);
        double r24026 = pow(r24018, r24024);
        double r24027 = r24025 / r24026;
        double r24028 = r24023 * r24027;
        double r24029 = fma(r24018, r24020, r24028);
        double r24030 = r24022 - r24029;
        double r24031 = -r24030;
        return r24031;
}

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 2020062 +o rules:numerics
(FPCore (x)
  :name "neg log"
  :precision binary64
  (- (log (- (/ 1 x) 1))))