Average Error: 61.2 → 0.4
Time: 9.1s
Precision: 64
\[-1 \lt x \land x \lt 1\]
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[\log \left(e^{\frac{1}{\frac{\mathsf{fma}\left(x, 1, \log 1 - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}{\log 1 - \left(1 \cdot x + \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}}}\right)\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\log \left(e^{\frac{1}{\frac{\mathsf{fma}\left(x, 1, \log 1 - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}{\log 1 - \left(1 \cdot x + \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}}}\right)
double f(double x) {
        double r84911 = 1.0;
        double r84912 = x;
        double r84913 = r84911 - r84912;
        double r84914 = log(r84913);
        double r84915 = r84911 + r84912;
        double r84916 = log(r84915);
        double r84917 = r84914 / r84916;
        return r84917;
}

double f(double x) {
        double r84918 = 1.0;
        double r84919 = x;
        double r84920 = 1.0;
        double r84921 = log(r84920);
        double r84922 = 0.5;
        double r84923 = 2.0;
        double r84924 = pow(r84919, r84923);
        double r84925 = pow(r84920, r84923);
        double r84926 = r84924 / r84925;
        double r84927 = r84922 * r84926;
        double r84928 = r84921 - r84927;
        double r84929 = fma(r84919, r84920, r84928);
        double r84930 = r84920 * r84919;
        double r84931 = r84930 + r84927;
        double r84932 = r84921 - r84931;
        double r84933 = r84929 / r84932;
        double r84934 = r84918 / r84933;
        double r84935 = exp(r84934);
        double r84936 = log(r84935);
        return r84936;
}

Error

Bits error versus x

Target

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

    \[\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(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 clear-num0.4

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

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

Reproduce

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