Average Error: 61.5 → 0.4
Time: 9.5s
Precision: 64
\[-1 \lt x \land x \lt 1\]
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[\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)}\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\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)}
double f(double x) {
        double r74447 = 1.0;
        double r74448 = x;
        double r74449 = r74447 - r74448;
        double r74450 = log(r74449);
        double r74451 = r74447 + r74448;
        double r74452 = log(r74451);
        double r74453 = r74450 / r74452;
        return r74453;
}

double f(double x) {
        double r74454 = 1.0;
        double r74455 = log(r74454);
        double r74456 = x;
        double r74457 = r74454 * r74456;
        double r74458 = 0.5;
        double r74459 = 2.0;
        double r74460 = pow(r74456, r74459);
        double r74461 = pow(r74454, r74459);
        double r74462 = r74460 / r74461;
        double r74463 = r74458 * r74462;
        double r74464 = r74457 + r74463;
        double r74465 = r74455 - r74464;
        double r74466 = r74455 - r74463;
        double r74467 = fma(r74456, r74454, r74466);
        double r74468 = r74465 / r74467;
        return r74468;
}

Error

Bits error versus x

Target

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

    \[\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. Final simplification0.4

    \[\leadsto \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)}\]

Reproduce

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