Average Error: 61.2 → 0.4
Time: 19.7s
Precision: 64
\[-1 \lt x \land x \lt 1\]
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[\frac{\log 1 - \mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{1}{2}, 1 \cdot x\right)}{\mathsf{fma}\left(\frac{-1}{2}, \frac{x}{1} \cdot \frac{x}{1}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\frac{\log 1 - \mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{1}{2}, 1 \cdot x\right)}{\mathsf{fma}\left(\frac{-1}{2}, \frac{x}{1} \cdot \frac{x}{1}, \mathsf{fma}\left(1, x, \log 1\right)\right)}
double f(double x) {
        double r4007989 = 1.0;
        double r4007990 = x;
        double r4007991 = r4007989 - r4007990;
        double r4007992 = log(r4007991);
        double r4007993 = r4007989 + r4007990;
        double r4007994 = log(r4007993);
        double r4007995 = r4007992 / r4007994;
        return r4007995;
}

double f(double x) {
        double r4007996 = 1.0;
        double r4007997 = log(r4007996);
        double r4007998 = x;
        double r4007999 = r4007998 / r4007996;
        double r4008000 = r4007999 * r4007999;
        double r4008001 = 0.5;
        double r4008002 = r4007996 * r4007998;
        double r4008003 = fma(r4008000, r4008001, r4008002);
        double r4008004 = r4007997 - r4008003;
        double r4008005 = -0.5;
        double r4008006 = fma(r4007996, r4007998, r4007997);
        double r4008007 = fma(r4008005, r4008000, r4008006);
        double r4008008 = r4008004 / r4008007;
        return r4008008;
}

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 61.2

    \[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
  2. Taylor expanded around 0 60.4

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

    \[\leadsto \frac{\log \left(1 - x\right)}{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \frac{x}{1} \cdot \frac{x}{1}, \mathsf{fma}\left(1, x, \log 1\right)\right)}}\]
  4. Taylor expanded around 0 0.4

    \[\leadsto \frac{\color{blue}{\log 1 - \left(1 \cdot x + \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}}{\mathsf{fma}\left(\frac{-1}{2}, \frac{x}{1} \cdot \frac{x}{1}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\]
  5. Simplified0.4

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

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

Reproduce

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

  :herbie-target
  (- (+ (+ (+ 1.0 x) (/ (* x x) 2.0)) (* 0.4166666666666667 (pow x 3.0))))

  (/ (log (- 1.0 x)) (log (+ 1.0 x))))