Average Error: 61.5 → 0.4
Time: 15.1s
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 \cdot x}{1}, \frac{\frac{1}{2}}{1}, x \cdot 1\right)}{\mathsf{fma}\left(\frac{x}{1}, \frac{\frac{-1}{2} \cdot x}{1}, \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 \cdot x}{1}, \frac{\frac{1}{2}}{1}, x \cdot 1\right)}{\mathsf{fma}\left(\frac{x}{1}, \frac{\frac{-1}{2} \cdot x}{1}, \mathsf{fma}\left(x, 1, \log 1\right)\right)}
double f(double x) {
        double r65460 = 1.0;
        double r65461 = x;
        double r65462 = r65460 - r65461;
        double r65463 = log(r65462);
        double r65464 = r65460 + r65461;
        double r65465 = log(r65464);
        double r65466 = r65463 / r65465;
        return r65466;
}

double f(double x) {
        double r65467 = 1.0;
        double r65468 = log(r65467);
        double r65469 = x;
        double r65470 = r65469 * r65469;
        double r65471 = r65470 / r65467;
        double r65472 = 0.5;
        double r65473 = r65472 / r65467;
        double r65474 = r65469 * r65467;
        double r65475 = fma(r65471, r65473, r65474);
        double r65476 = r65468 - r65475;
        double r65477 = r65469 / r65467;
        double r65478 = -0.5;
        double r65479 = r65478 * r65469;
        double r65480 = r65479 / r65467;
        double r65481 = fma(r65469, r65467, r65468);
        double r65482 = fma(r65477, r65480, r65481);
        double r65483 = r65476 / r65482;
        return r65483;
}

Error

Bits error versus x

Target

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

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

    \[\leadsto \color{blue}{\frac{\log \left(1 - x\right)}{\log \left(x + 1\right)}}\]
  3. 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}}}}\]
  4. 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)}}\]
  5. 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)}\]
  6. Simplified0.4

    \[\leadsto \frac{\color{blue}{\log 1 - \mathsf{fma}\left(\frac{\frac{1}{2}}{1}, \frac{x \cdot x}{1}, 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)}\]
  7. Using strategy rm
  8. Applied *-un-lft-identity0.4

    \[\leadsto \frac{\log 1 - \mathsf{fma}\left(\frac{\frac{1}{2}}{1}, \frac{x \cdot x}{1}, 1 \cdot x\right)}{\color{blue}{1 \cdot \mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \log 1\right)\right)}}\]
  9. Applied *-un-lft-identity0.4

    \[\leadsto \frac{\color{blue}{1 \cdot \left(\log 1 - \mathsf{fma}\left(\frac{\frac{1}{2}}{1}, \frac{x \cdot x}{1}, 1 \cdot x\right)\right)}}{1 \cdot \mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \log 1\right)\right)}\]
  10. Applied times-frac0.4

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

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

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

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

Reproduce

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