Average Error: 61.4 → 0.4
Time: 16.9s
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{\frac{{x}^{2}}{1}}{1}, \frac{1}{2}, 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)}\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\frac{\log 1 - \mathsf{fma}\left(\frac{\frac{{x}^{2}}{1}}{1}, \frac{1}{2}, 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)}
double f(double x) {
        double r36200 = 1.0;
        double r36201 = x;
        double r36202 = r36200 - r36201;
        double r36203 = log(r36202);
        double r36204 = r36200 + r36201;
        double r36205 = log(r36204);
        double r36206 = r36203 / r36205;
        return r36206;
}

double f(double x) {
        double r36207 = 1.0;
        double r36208 = log(r36207);
        double r36209 = x;
        double r36210 = 2.0;
        double r36211 = pow(r36209, r36210);
        double r36212 = r36211 / r36207;
        double r36213 = r36212 / r36207;
        double r36214 = 0.5;
        double r36215 = r36207 * r36209;
        double r36216 = fma(r36213, r36214, r36215);
        double r36217 = r36208 - r36216;
        double r36218 = -0.5;
        double r36219 = r36209 / r36207;
        double r36220 = r36219 * r36219;
        double r36221 = fma(r36207, r36209, r36208);
        double r36222 = fma(r36218, r36220, r36221);
        double r36223 = r36217 / r36222;
        return r36223;
}

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.4166666666666666851703837437526090070605 \cdot {x}^{3}\right)\]

Derivation

  1. Initial program 61.4

    \[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
  2. Simplified61.4

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

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

    \[\leadsto \frac{\log 1 - \mathsf{fma}\left(\frac{\frac{{x}^{2}}{1}}{1}, \frac{1}{2}, 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)}\]

Reproduce

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