Average Error: 61.4 → 0.5
Time: 36.4s
Precision: 64
\[-1 \lt x \land x \lt 1\]
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[\frac{\log 1 - \mathsf{fma}\left(\frac{1}{2}, \frac{x}{1} \cdot \frac{x}{1}, x \cdot 1\right)}{\mathsf{fma}\left(\frac{-1}{2}, \frac{x}{1} \cdot \frac{x}{1}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\frac{\log 1 - \mathsf{fma}\left(\frac{1}{2}, \frac{x}{1} \cdot \frac{x}{1}, x \cdot 1\right)}{\mathsf{fma}\left(\frac{-1}{2}, \frac{x}{1} \cdot \frac{x}{1}, \mathsf{fma}\left(1, x, \log 1\right)\right)}
double f(double x) {
        double r4634782 = 1.0;
        double r4634783 = x;
        double r4634784 = r4634782 - r4634783;
        double r4634785 = log(r4634784);
        double r4634786 = r4634782 + r4634783;
        double r4634787 = log(r4634786);
        double r4634788 = r4634785 / r4634787;
        return r4634788;
}

double f(double x) {
        double r4634789 = 1.0;
        double r4634790 = log(r4634789);
        double r4634791 = 0.5;
        double r4634792 = x;
        double r4634793 = r4634792 / r4634789;
        double r4634794 = r4634793 * r4634793;
        double r4634795 = r4634792 * r4634789;
        double r4634796 = fma(r4634791, r4634794, r4634795);
        double r4634797 = r4634790 - r4634796;
        double r4634798 = -0.5;
        double r4634799 = fma(r4634789, r4634792, r4634790);
        double r4634800 = fma(r4634798, r4634794, r4634799);
        double r4634801 = r4634797 / r4634800;
        return r4634801;
}

Error

Bits error versus x

Target

Original61.4
Target0.4
Herbie0.5
\[-\left(\left(\left(1 + x\right) + \frac{x \cdot x}{2}\right) + 0.4166666666666666851703837437526090070605 \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(\log 1 + 1 \cdot x\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(\frac{-1}{2}, \frac{x}{1} \cdot \frac{x}{1}, \mathsf{fma}\left(1, x, \log 1\right)\right)}}\]
  4. Taylor expanded around 0 0.5

    \[\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}{1} \cdot \frac{x}{1}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\]
  5. Simplified0.5

    \[\leadsto \frac{\color{blue}{\log 1 - \mathsf{fma}\left(\frac{1}{2}, \frac{x}{1} \cdot \frac{x}{1}, 1 \cdot x\right)}}{\mathsf{fma}\left(\frac{-1}{2}, \frac{x}{1} \cdot \frac{x}{1}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\]
  6. Final simplification0.5

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

Reproduce

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