Average Error: 60.9 → 0.0
Time: 23.1s
Precision: 64
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[\frac{\log_* (1 + \left(-x\right))}{\log_* (1 + x)}\]
double f(double x) {
        double r4992631 = 1.0;
        double r4992632 = x;
        double r4992633 = r4992631 - r4992632;
        double r4992634 = log(r4992633);
        double r4992635 = r4992631 + r4992632;
        double r4992636 = log(r4992635);
        double r4992637 = r4992634 / r4992636;
        return r4992637;
}

double f(double x) {
        double r4992638 = x;
        double r4992639 = -r4992638;
        double r4992640 = log1p(r4992639);
        double r4992641 = log1p(r4992638);
        double r4992642 = r4992640 / r4992641;
        return r4992642;
}

\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\frac{\log_* (1 + \left(-x\right))}{\log_* (1 + x)}

Error

Bits error versus x

Target

Original60.9
Target0.3
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.9

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

    \[\leadsto \color{blue}{\frac{\log \left(1 - x\right)}{\log_* (1 + x)}}\]
  3. Using strategy rm
  4. Applied sub-neg60.0

    \[\leadsto \frac{\log \color{blue}{\left(1 + \left(-x\right)\right)}}{\log_* (1 + x)}\]
  5. Applied log1p-def0.0

    \[\leadsto \frac{\color{blue}{\log_* (1 + \left(-x\right))}}{\log_* (1 + x)}\]
  6. Final simplification0.0

    \[\leadsto \frac{\log_* (1 + \left(-x\right))}{\log_* (1 + x)}\]

Reproduce

herbie shell --seed 2019101 +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))))