Average Error: 61.3 → 0.4
Time: 19.5s
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{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \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{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \log 1\right)\right)}
double f(double x) {
        double r3302203 = 1.0;
        double r3302204 = x;
        double r3302205 = r3302203 - r3302204;
        double r3302206 = log(r3302205);
        double r3302207 = r3302203 + r3302204;
        double r3302208 = log(r3302207);
        double r3302209 = r3302206 / r3302208;
        return r3302209;
}

double f(double x) {
        double r3302210 = 1.0;
        double r3302211 = log(r3302210);
        double r3302212 = x;
        double r3302213 = r3302212 / r3302210;
        double r3302214 = r3302213 * r3302213;
        double r3302215 = 0.5;
        double r3302216 = r3302210 * r3302212;
        double r3302217 = fma(r3302214, r3302215, r3302216);
        double r3302218 = r3302211 - r3302217;
        double r3302219 = -0.5;
        double r3302220 = fma(r3302212, r3302210, r3302211);
        double r3302221 = fma(r3302214, r3302219, r3302220);
        double r3302222 = r3302218 / r3302221;
        return r3302222;
}

Error

Bits error versus x

Target

Original61.3
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.3

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

    \[\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.5

    \[\leadsto \frac{\log \left(1 - x\right)}{\color{blue}{\mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \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{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \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{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \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{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \log 1\right)\right)}\]

Reproduce

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