Average Error: 61.6 → 0.4
Time: 19.6s
Precision: 64
\[-1 \lt x \land x \lt 1\]
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[\sqrt[3]{{\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\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)}\right)\right)\right)}^{3}}\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\sqrt[3]{{\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\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)}\right)\right)\right)}^{3}}
double f(double x) {
        double r80604 = 1.0;
        double r80605 = x;
        double r80606 = r80604 - r80605;
        double r80607 = log(r80606);
        double r80608 = r80604 + r80605;
        double r80609 = log(r80608);
        double r80610 = r80607 / r80609;
        return r80610;
}

double f(double x) {
        double r80611 = 1.0;
        double r80612 = log(r80611);
        double r80613 = x;
        double r80614 = 0.5;
        double r80615 = 2.0;
        double r80616 = pow(r80613, r80615);
        double r80617 = pow(r80611, r80615);
        double r80618 = r80616 / r80617;
        double r80619 = r80614 * r80618;
        double r80620 = fma(r80611, r80613, r80619);
        double r80621 = r80612 - r80620;
        double r80622 = -0.5;
        double r80623 = fma(r80611, r80613, r80612);
        double r80624 = fma(r80622, r80618, r80623);
        double r80625 = r80621 / r80624;
        double r80626 = expm1(r80625);
        double r80627 = log1p(r80626);
        double r80628 = 3.0;
        double r80629 = pow(r80627, r80628);
        double r80630 = cbrt(r80629);
        return r80630;
}

Error

Bits error versus x

Target

Original61.6
Target0.3
Herbie0.4
\[-\left(\left(\left(1 + x\right) + \frac{x \cdot x}{2}\right) + 0.416666666666666685 \cdot {x}^{3}\right)\]

Derivation

  1. Initial program 61.6

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

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

    \[\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 add-cbrt-cube42.9

    \[\leadsto \frac{\log 1 - \mathsf{fma}\left(1, x, \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}{\color{blue}{\sqrt[3]{\left(\mathsf{fma}\left(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\right) \cdot \mathsf{fma}\left(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\right)\right) \cdot \mathsf{fma}\left(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\right)}}}\]
  8. Applied add-cbrt-cube42.3

    \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\log 1 - \mathsf{fma}\left(1, x, \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)\right) \cdot \left(\log 1 - \mathsf{fma}\left(1, x, \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)\right)\right) \cdot \left(\log 1 - \mathsf{fma}\left(1, x, \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)\right)}}}{\sqrt[3]{\left(\mathsf{fma}\left(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\right) \cdot \mathsf{fma}\left(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\right)\right) \cdot \mathsf{fma}\left(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\right)}}\]
  9. Applied cbrt-undiv42.2

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

    \[\leadsto \sqrt[3]{\color{blue}{{\left(\frac{\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)}\right)}^{3}}}\]
  11. Using strategy rm
  12. Applied log1p-expm1-u0.4

    \[\leadsto \sqrt[3]{{\color{blue}{\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\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)}\right)\right)\right)}}^{3}}\]
  13. Final simplification0.4

    \[\leadsto \sqrt[3]{{\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\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)}\right)\right)\right)}^{3}}\]

Reproduce

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