Average Error: 61.3 → 0.4
Time: 13.3s
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(1, x, \frac{\frac{1}{2}}{1} \cdot \frac{{x}^{2}}{1}\right)}{\mathsf{fma}\left(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \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(1, x, \frac{\frac{1}{2}}{1} \cdot \frac{{x}^{2}}{1}\right)}{\mathsf{fma}\left(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\right)}
double f(double x) {
        double r102621 = 1.0;
        double r102622 = x;
        double r102623 = r102621 - r102622;
        double r102624 = log(r102623);
        double r102625 = r102621 + r102622;
        double r102626 = log(r102625);
        double r102627 = r102624 / r102626;
        return r102627;
}

double f(double x) {
        double r102628 = 1.0;
        double r102629 = log(r102628);
        double r102630 = x;
        double r102631 = 0.5;
        double r102632 = r102631 / r102628;
        double r102633 = 2.0;
        double r102634 = pow(r102630, r102633);
        double r102635 = r102634 / r102628;
        double r102636 = r102632 * r102635;
        double r102637 = fma(r102628, r102630, r102636);
        double r102638 = r102629 - r102637;
        double r102639 = -0.5;
        double r102640 = pow(r102628, r102633);
        double r102641 = r102634 / r102640;
        double r102642 = fma(r102628, r102630, r102629);
        double r102643 = fma(r102639, r102641, r102642);
        double r102644 = r102638 / r102643;
        return r102644;
}

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.4

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

    \[\leadsto \frac{\color{blue}{\log 1 - \mathsf{fma}\left(1, x, \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}}{\mathsf{fma}\left(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\]
  6. Using strategy rm
  7. Applied unpow20.4

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

    \[\leadsto \frac{\log 1 - \mathsf{fma}\left(1, x, \frac{1}{2} \cdot \frac{{\color{blue}{\left(1 \cdot x\right)}}^{2}}{1 \cdot 1}\right)}{\mathsf{fma}\left(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\]
  9. Applied unpow-prod-down0.4

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

    \[\leadsto \frac{\log 1 - \mathsf{fma}\left(1, x, \frac{1}{2} \cdot \color{blue}{\left(\frac{{1}^{2}}{1} \cdot \frac{{x}^{2}}{1}\right)}\right)}{\mathsf{fma}\left(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\]
  11. Applied associate-*r*0.4

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

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

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

Reproduce

herbie shell --seed 2019351 +o rules:numerics
(FPCore (x)
  :name "qlog (example 3.10)"
  :precision binary64
  :pre (and (< -1 x) (< x 1))

  :herbie-target
  (- (+ (+ (+ 1 x) (/ (* x x) 2)) (* 0.4166666666666667 (pow x 3))))

  (/ (log (- 1 x)) (log (+ 1 x))))