Average Error: 60.7 → 0.0
Time: 16.0s
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 r1795696 = 1.0;
        double r1795697 = x;
        double r1795698 = r1795696 - r1795697;
        double r1795699 = log(r1795698);
        double r1795700 = r1795696 + r1795697;
        double r1795701 = log(r1795700);
        double r1795702 = r1795699 / r1795701;
        return r1795702;
}

double f(double x) {
        double r1795703 = x;
        double r1795704 = -r1795703;
        double r1795705 = log1p(r1795704);
        double r1795706 = log1p(r1795703);
        double r1795707 = r1795705 / r1795706;
        return r1795707;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original60.7
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 60.7

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

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

    \[\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 2019143 +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))))