Average Error: 60.9 → 0.4
Time: 27.4s
Precision: 64
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[-1 - \left(x - \left(x \cdot x\right) \cdot \frac{-1}{2}\right)\]
double f(double x) {
        double r2933898 = 1.0;
        double r2933899 = x;
        double r2933900 = r2933898 - r2933899;
        double r2933901 = log(r2933900);
        double r2933902 = r2933898 + r2933899;
        double r2933903 = log(r2933902);
        double r2933904 = r2933901 / r2933903;
        return r2933904;
}

double f(double x) {
        double r2933905 = -1.0;
        double r2933906 = x;
        double r2933907 = r2933906 * r2933906;
        double r2933908 = -0.5;
        double r2933909 = r2933907 * r2933908;
        double r2933910 = r2933906 - r2933909;
        double r2933911 = r2933905 - r2933910;
        return r2933911;
}

\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
-1 - \left(x - \left(x \cdot x\right) \cdot \frac{-1}{2}\right)

Error

Bits error versus x

Target

Original60.9
Target0.3
Herbie0.4
\[-\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. Taylor expanded around 0 0.4

    \[\leadsto \color{blue}{-\left(x + \left(\frac{1}{2} \cdot {x}^{2} + 1\right)\right)}\]
  3. Simplified0.4

    \[\leadsto \color{blue}{\left(-1 - x\right) + \left(x \cdot x\right) \cdot \frac{-1}{2}}\]
  4. Using strategy rm
  5. Applied associate-+l-0.4

    \[\leadsto \color{blue}{-1 - \left(x - \left(x \cdot x\right) \cdot \frac{-1}{2}\right)}\]
  6. Final simplification0.4

    \[\leadsto -1 - \left(x - \left(x \cdot x\right) \cdot \frac{-1}{2}\right)\]

Reproduce

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