Average Error: 61.3 → 0.5
Time: 37.8s
Precision: 64
\[-1.0 \lt x \land x \lt 1.0\]
\[\frac{\log \left(1.0 - x\right)}{\log \left(1.0 + x\right)}\]
\[\frac{\log 1.0 - \mathsf{fma}\left(\frac{1}{2}, \frac{x}{1.0} \cdot \frac{x}{1.0}, x \cdot 1.0\right)}{\mathsf{fma}\left(\frac{-1}{2}, \frac{x}{1.0} \cdot \frac{x}{1.0}, \mathsf{fma}\left(1.0, x, \log 1.0\right)\right)}\]
\frac{\log \left(1.0 - x\right)}{\log \left(1.0 + x\right)}
\frac{\log 1.0 - \mathsf{fma}\left(\frac{1}{2}, \frac{x}{1.0} \cdot \frac{x}{1.0}, x \cdot 1.0\right)}{\mathsf{fma}\left(\frac{-1}{2}, \frac{x}{1.0} \cdot \frac{x}{1.0}, \mathsf{fma}\left(1.0, x, \log 1.0\right)\right)}
double f(double x) {
        double r4435102 = 1.0;
        double r4435103 = x;
        double r4435104 = r4435102 - r4435103;
        double r4435105 = log(r4435104);
        double r4435106 = r4435102 + r4435103;
        double r4435107 = log(r4435106);
        double r4435108 = r4435105 / r4435107;
        return r4435108;
}

double f(double x) {
        double r4435109 = 1.0;
        double r4435110 = log(r4435109);
        double r4435111 = 0.5;
        double r4435112 = x;
        double r4435113 = r4435112 / r4435109;
        double r4435114 = r4435113 * r4435113;
        double r4435115 = r4435112 * r4435109;
        double r4435116 = fma(r4435111, r4435114, r4435115);
        double r4435117 = r4435110 - r4435116;
        double r4435118 = -0.5;
        double r4435119 = fma(r4435109, r4435112, r4435110);
        double r4435120 = fma(r4435118, r4435114, r4435119);
        double r4435121 = r4435117 / r4435120;
        return r4435121;
}

Error

Bits error versus x

Target

Original61.3
Target0.4
Herbie0.5
\[-\left(\left(\left(1.0 + x\right) + \frac{x \cdot x}{2.0}\right) + 0.4166666666666667 \cdot {x}^{3.0}\right)\]

Derivation

  1. Initial program 61.3

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

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

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

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

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

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

Reproduce

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