Average Error: 61.3 → 0.5
Time: 21.2s
Precision: 64
\[-1 \lt x \land x \lt 1\]
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[\frac{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\right)}}{\frac{1}{\log 1 - \mathsf{fma}\left(1, x, \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}}\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\frac{\frac{1}{\mathsf{fma}\left(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\right)}}{\frac{1}{\log 1 - \mathsf{fma}\left(1, x, \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}}
double f(double x) {
        double r65369 = 1.0;
        double r65370 = x;
        double r65371 = r65369 - r65370;
        double r65372 = log(r65371);
        double r65373 = r65369 + r65370;
        double r65374 = log(r65373);
        double r65375 = r65372 / r65374;
        return r65375;
}

double f(double x) {
        double r65376 = 1.0;
        double r65377 = -0.5;
        double r65378 = x;
        double r65379 = 2.0;
        double r65380 = pow(r65378, r65379);
        double r65381 = 1.0;
        double r65382 = pow(r65381, r65379);
        double r65383 = r65380 / r65382;
        double r65384 = log(r65381);
        double r65385 = fma(r65381, r65378, r65384);
        double r65386 = fma(r65377, r65383, r65385);
        double r65387 = r65376 / r65386;
        double r65388 = 0.5;
        double r65389 = r65388 * r65383;
        double r65390 = fma(r65381, r65378, r65389);
        double r65391 = r65384 - r65390;
        double r65392 = r65376 / r65391;
        double r65393 = r65387 / r65392;
        return r65393;
}

Error

Bits error versus x

Target

Original61.3
Target0.3
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.3

    \[\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(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\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(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\]
  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(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\]
  6. Using strategy rm
  7. Applied clear-num0.4

    \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\right)}{\log 1 - \mathsf{fma}\left(1, x, \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}}}\]
  8. Using strategy rm
  9. Applied div-inv0.6

    \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\right) \cdot \frac{1}{\log 1 - \mathsf{fma}\left(1, x, \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}}}\]
  10. Applied associate-/r*0.5

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

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

Reproduce

herbie shell --seed 2019303 +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.416666666666666685 (pow x 3))))

  (/ (log (- 1 x)) (log (+ 1 x))))