Average Error: 61.4 → 0.4
Time: 13.2s
Precision: 64
\[-1 \lt x \land x \lt 1\]
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[\sqrt[3]{{\left(\frac{\log 1 - \mathsf{fma}\left(1, x, \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}{\mathsf{fma}\left(1, x, \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}\right)}^{3}}\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\sqrt[3]{{\left(\frac{\log 1 - \mathsf{fma}\left(1, x, \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}{\mathsf{fma}\left(1, x, \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}\right)}^{3}}
double f(double x) {
        double r77577 = 1.0;
        double r77578 = x;
        double r77579 = r77577 - r77578;
        double r77580 = log(r77579);
        double r77581 = r77577 + r77578;
        double r77582 = log(r77581);
        double r77583 = r77580 / r77582;
        return r77583;
}

double f(double x) {
        double r77584 = 1.0;
        double r77585 = log(r77584);
        double r77586 = x;
        double r77587 = 0.5;
        double r77588 = 2.0;
        double r77589 = pow(r77586, r77588);
        double r77590 = pow(r77584, r77588);
        double r77591 = r77589 / r77590;
        double r77592 = r77587 * r77591;
        double r77593 = fma(r77584, r77586, r77592);
        double r77594 = r77585 - r77593;
        double r77595 = fma(r77584, r77586, r77585);
        double r77596 = r77595 - r77592;
        double r77597 = r77594 / r77596;
        double r77598 = 3.0;
        double r77599 = pow(r77597, r77598);
        double r77600 = cbrt(r77599);
        return r77600;
}

Error

Bits error versus x

Target

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

    \[\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(1 \cdot x + \log 1\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(1, x, \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}}\]
  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(1, x, \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}\]
  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(1, x, \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}\]
  6. Using strategy rm
  7. Applied add-cbrt-cube42.4

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

    \[\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(\left(\mathsf{fma}\left(1, x, \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right) \cdot \left(\mathsf{fma}\left(1, x, \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)\right) \cdot \left(\mathsf{fma}\left(1, x, \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}}\]
  9. Applied cbrt-undiv41.8

    \[\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(\left(\mathsf{fma}\left(1, x, \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right) \cdot \left(\mathsf{fma}\left(1, x, \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)\right) \cdot \left(\mathsf{fma}\left(1, x, \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\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(1, x, \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}\right)}^{3}}}\]
  11. Final simplification0.4

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

Reproduce

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