Average Error: 61.3 → 0.7
Time: 22.0s
Precision: 64
\[-1 \lt x \land x \lt 1\]
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[\mathsf{fma}\left(1, \frac{\log 1}{x} + \log 1, \mathsf{fma}\left(0.25, \frac{\log 1 \cdot x}{\left(1 \cdot 1\right) \cdot \left(1 \cdot 1\right)}, 1 \cdot \left(\log 1 \cdot x\right)\right)\right) - \mathsf{fma}\left(\frac{0.3333333333333333148296162562473909929395}{1}, \frac{\log 1 \cdot x}{1 \cdot 1}, \mathsf{fma}\left(0.5, \frac{\log 1}{1 \cdot 1}, \mathsf{fma}\left(1, \frac{\log 1 \cdot x}{1 \cdot 1}, \mathsf{fma}\left(1, x, 1\right)\right)\right)\right)\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\mathsf{fma}\left(1, \frac{\log 1}{x} + \log 1, \mathsf{fma}\left(0.25, \frac{\log 1 \cdot x}{\left(1 \cdot 1\right) \cdot \left(1 \cdot 1\right)}, 1 \cdot \left(\log 1 \cdot x\right)\right)\right) - \mathsf{fma}\left(\frac{0.3333333333333333148296162562473909929395}{1}, \frac{\log 1 \cdot x}{1 \cdot 1}, \mathsf{fma}\left(0.5, \frac{\log 1}{1 \cdot 1}, \mathsf{fma}\left(1, \frac{\log 1 \cdot x}{1 \cdot 1}, \mathsf{fma}\left(1, x, 1\right)\right)\right)\right)
double f(double x) {
        double r5920884 = 1.0;
        double r5920885 = x;
        double r5920886 = r5920884 - r5920885;
        double r5920887 = log(r5920886);
        double r5920888 = r5920884 + r5920885;
        double r5920889 = log(r5920888);
        double r5920890 = r5920887 / r5920889;
        return r5920890;
}

double f(double x) {
        double r5920891 = 1.0;
        double r5920892 = log(r5920891);
        double r5920893 = x;
        double r5920894 = r5920892 / r5920893;
        double r5920895 = r5920894 + r5920892;
        double r5920896 = 0.25;
        double r5920897 = r5920892 * r5920893;
        double r5920898 = r5920891 * r5920891;
        double r5920899 = r5920898 * r5920898;
        double r5920900 = r5920897 / r5920899;
        double r5920901 = r5920891 * r5920897;
        double r5920902 = fma(r5920896, r5920900, r5920901);
        double r5920903 = fma(r5920891, r5920895, r5920902);
        double r5920904 = 0.3333333333333333;
        double r5920905 = r5920904 / r5920891;
        double r5920906 = r5920897 / r5920898;
        double r5920907 = 0.5;
        double r5920908 = r5920892 / r5920898;
        double r5920909 = fma(r5920891, r5920893, r5920891);
        double r5920910 = fma(r5920891, r5920906, r5920909);
        double r5920911 = fma(r5920907, r5920908, r5920910);
        double r5920912 = fma(r5920905, r5920906, r5920911);
        double r5920913 = r5920903 - r5920912;
        return r5920913;
}

Error

Bits error versus x

Target

Original61.3
Target0.4
Herbie0.7
\[-\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. Using strategy rm
  3. Applied flip-+61.0

    \[\leadsto \frac{\log \left(1 - x\right)}{\log \color{blue}{\left(\frac{1 \cdot 1 - x \cdot x}{1 - x}\right)}}\]
  4. Applied log-div61.2

    \[\leadsto \frac{\log \left(1 - x\right)}{\color{blue}{\log \left(1 \cdot 1 - x \cdot x\right) - \log \left(1 - x\right)}}\]
  5. Taylor expanded around 0 59.9

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

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

    \[\leadsto \color{blue}{\left(1 \cdot \frac{\log 1}{x} + \left(1 \cdot \log 1 + \left(0.25 \cdot \frac{\log 1 \cdot x}{{1}^{4}} + 1 \cdot \left(\log 1 \cdot x\right)\right)\right)\right) - \left(0.3333333333333333148296162562473909929395 \cdot \frac{\log 1 \cdot x}{{1}^{3}} + \left(0.5 \cdot \frac{\log 1}{{1}^{2}} + \left(1 \cdot \frac{\log 1 \cdot x}{{1}^{2}} + \left(1 \cdot x + 1\right)\right)\right)\right)}\]
  8. Simplified0.7

    \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{\log 1}{x} + \log 1, \mathsf{fma}\left(0.25, \frac{\log 1 \cdot x}{\left(1 \cdot 1\right) \cdot \left(1 \cdot 1\right)}, 1 \cdot \left(\log 1 \cdot x\right)\right)\right) - \mathsf{fma}\left(\frac{0.3333333333333333148296162562473909929395}{1}, \frac{\log 1 \cdot x}{1 \cdot 1}, \mathsf{fma}\left(0.5, \frac{\log 1}{1 \cdot 1}, \mathsf{fma}\left(1, \frac{\log 1 \cdot x}{1 \cdot 1}, \mathsf{fma}\left(1, x, 1\right)\right)\right)\right)}\]
  9. Final simplification0.7

    \[\leadsto \mathsf{fma}\left(1, \frac{\log 1}{x} + \log 1, \mathsf{fma}\left(0.25, \frac{\log 1 \cdot x}{\left(1 \cdot 1\right) \cdot \left(1 \cdot 1\right)}, 1 \cdot \left(\log 1 \cdot x\right)\right)\right) - \mathsf{fma}\left(\frac{0.3333333333333333148296162562473909929395}{1}, \frac{\log 1 \cdot x}{1 \cdot 1}, \mathsf{fma}\left(0.5, \frac{\log 1}{1 \cdot 1}, \mathsf{fma}\left(1, \frac{\log 1 \cdot x}{1 \cdot 1}, \mathsf{fma}\left(1, x, 1\right)\right)\right)\right)\]

Reproduce

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