Average Error: 61.0 → 0.0
Time: 24.4s
Precision: 64
\[-1 \lt x \land x \lt 1\]
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[\frac{\mathsf{log1p}\left(-x\right)}{\mathsf{log1p}\left(x\right)}\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\frac{\mathsf{log1p}\left(-x\right)}{\mathsf{log1p}\left(x\right)}
double f(double x) {
        double r3684957 = 1.0;
        double r3684958 = x;
        double r3684959 = r3684957 - r3684958;
        double r3684960 = log(r3684959);
        double r3684961 = r3684957 + r3684958;
        double r3684962 = log(r3684961);
        double r3684963 = r3684960 / r3684962;
        return r3684963;
}

double f(double x) {
        double r3684964 = x;
        double r3684965 = -r3684964;
        double r3684966 = log1p(r3684965);
        double r3684967 = log1p(r3684964);
        double r3684968 = r3684966 / r3684967;
        return r3684968;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original61.0
Target0.4
Herbie0.0
\[-\left(\left(\left(1 + x\right) + \frac{x \cdot x}{2}\right) + \frac{5}{12} \cdot {x}^{3}\right)\]

Derivation

  1. Initial program 61.0

    \[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
  2. Simplified60.0

    \[\leadsto \color{blue}{\frac{\log \left(1 - x\right)}{\mathsf{log1p}\left(x\right)}}\]
  3. Using strategy rm
  4. Applied log1p-expm1-u60.0

    \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(1 - x\right)\right)\right)}}{\mathsf{log1p}\left(x\right)}\]
  5. Simplified0.0

    \[\leadsto \frac{\mathsf{log1p}\left(\color{blue}{-x}\right)}{\mathsf{log1p}\left(x\right)}\]
  6. Final simplification0.0

    \[\leadsto \frac{\mathsf{log1p}\left(-x\right)}{\mathsf{log1p}\left(x\right)}\]

Reproduce

herbie shell --seed 2019168 +o rules:numerics
(FPCore (x)
  :name "qlog (example 3.10)"
  :pre (and (< -1 x) (< x 1))

  :herbie-target
  (- (+ (+ (+ 1 x) (/ (* x x) 2)) (* 5/12 (pow x 3))))

  (/ (log (- 1 x)) (log (+ 1 x))))