Average Error: 61.4 → 0.4
Time: 9.0s
Precision: 64
\[-1 \lt x \land x \lt 1\]
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[\log \left(\frac{e^{\frac{\log 1}{\mathsf{fma}\left(x, 1, \log 1 - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}}}{e^{\frac{1 \cdot x + \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}{\mathsf{fma}\left(x, 1, \log 1 - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}}}\right)\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\log \left(\frac{e^{\frac{\log 1}{\mathsf{fma}\left(x, 1, \log 1 - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}}}{e^{\frac{1 \cdot x + \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}{\mathsf{fma}\left(x, 1, \log 1 - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}}}\right)
double f(double x) {
        double r86611 = 1.0;
        double r86612 = x;
        double r86613 = r86611 - r86612;
        double r86614 = log(r86613);
        double r86615 = r86611 + r86612;
        double r86616 = log(r86615);
        double r86617 = r86614 / r86616;
        return r86617;
}

double f(double x) {
        double r86618 = 1.0;
        double r86619 = log(r86618);
        double r86620 = x;
        double r86621 = 0.5;
        double r86622 = 2.0;
        double r86623 = pow(r86620, r86622);
        double r86624 = pow(r86618, r86622);
        double r86625 = r86623 / r86624;
        double r86626 = r86621 * r86625;
        double r86627 = r86619 - r86626;
        double r86628 = fma(r86620, r86618, r86627);
        double r86629 = r86619 / r86628;
        double r86630 = exp(r86629);
        double r86631 = r86618 * r86620;
        double r86632 = r86631 + r86626;
        double r86633 = r86632 / r86628;
        double r86634 = exp(r86633);
        double r86635 = r86630 / r86634;
        double r86636 = log(r86635);
        return r86636;
}

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

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

    \[\leadsto \log \left(e^{\color{blue}{\frac{\log 1}{\mathsf{fma}\left(x, 1, \log 1 - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)} - \frac{1 \cdot x + \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}{\mathsf{fma}\left(x, 1, \log 1 - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}}}\right)\]
  9. Applied exp-diff0.4

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

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

Reproduce

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