Average Error: 0.0 → 0.1
Time: 20.7s
Precision: 64
\[-\log \left(\frac{1}{x} - 1\right)\]
\[-\log \left(\mathsf{expm1}\left(-\log x\right)\right)\]
-\log \left(\frac{1}{x} - 1\right)
-\log \left(\mathsf{expm1}\left(-\log x\right)\right)
double f(double x) {
        double r419927 = 1.0;
        double r419928 = x;
        double r419929 = r419927 / r419928;
        double r419930 = r419929 - r419927;
        double r419931 = log(r419930);
        double r419932 = -r419931;
        return r419932;
}

double f(double x) {
        double r419933 = x;
        double r419934 = log(r419933);
        double r419935 = -r419934;
        double r419936 = expm1(r419935);
        double r419937 = log(r419936);
        double r419938 = -r419937;
        return r419938;
}

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. Using strategy rm
  3. Applied add-exp-log0.1

    \[\leadsto -\log \left(\frac{1}{\color{blue}{e^{\log x}}} - 1\right)\]
  4. Applied rec-exp0.1

    \[\leadsto -\log \left(\color{blue}{e^{-\log x}} - 1\right)\]
  5. Applied expm1-def0.1

    \[\leadsto -\log \color{blue}{\left(\mathsf{expm1}\left(-\log x\right)\right)}\]
  6. Final simplification0.1

    \[\leadsto -\log \left(\mathsf{expm1}\left(-\log x\right)\right)\]

Reproduce

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