Average Error: 61.4 → 0.4
Time: 12.6s
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(1, x, \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}{\mathsf{fma}\left(1, x, \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\frac{\log 1 - \mathsf{fma}\left(1, x, \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}{\mathsf{fma}\left(1, x, \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}
double f(double x) {
        double r86122 = 1.0;
        double r86123 = x;
        double r86124 = r86122 - r86123;
        double r86125 = log(r86124);
        double r86126 = r86122 + r86123;
        double r86127 = log(r86126);
        double r86128 = r86125 / r86127;
        return r86128;
}

double f(double x) {
        double r86129 = 1.0;
        double r86130 = log(r86129);
        double r86131 = x;
        double r86132 = 0.5;
        double r86133 = 2.0;
        double r86134 = pow(r86131, r86133);
        double r86135 = pow(r86129, r86133);
        double r86136 = r86134 / r86135;
        double r86137 = r86132 * r86136;
        double r86138 = fma(r86129, r86131, r86137);
        double r86139 = r86130 - r86138;
        double r86140 = fma(r86129, r86131, r86130);
        double r86141 = r86140 - r86137;
        double r86142 = r86139 / r86141;
        return r86142;
}

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.416666666666666685 \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(1 \cdot x + \log 1\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(1, x, \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}}\]
  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(1, x, \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}\]
  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(1, x, \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}\]
  6. Final simplification0.4

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

Reproduce

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