Average Error: 61.3 → 0.7
Time: 7.6s
Precision: 64
\[-1 \lt x \land x \lt 1\]
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[\mathsf{fma}\left(\log 1, 1, \mathsf{fma}\left(1, \frac{\log 1}{x}, 0.25 \cdot \frac{x \cdot \log 1}{{1}^{4}}\right) - \mathsf{fma}\left(0.3333333333333333148296162562473909929395, \frac{x \cdot \log 1}{{1}^{3}}, \mathsf{fma}\left(1, x, \mathsf{fma}\left(0.5, \frac{\log 1}{{1}^{2}}, 1\right)\right)\right)\right)\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\mathsf{fma}\left(\log 1, 1, \mathsf{fma}\left(1, \frac{\log 1}{x}, 0.25 \cdot \frac{x \cdot \log 1}{{1}^{4}}\right) - \mathsf{fma}\left(0.3333333333333333148296162562473909929395, \frac{x \cdot \log 1}{{1}^{3}}, \mathsf{fma}\left(1, x, \mathsf{fma}\left(0.5, \frac{\log 1}{{1}^{2}}, 1\right)\right)\right)\right)
double f(double x) {
        double r90963 = 1.0;
        double r90964 = x;
        double r90965 = r90963 - r90964;
        double r90966 = log(r90965);
        double r90967 = r90963 + r90964;
        double r90968 = log(r90967);
        double r90969 = r90966 / r90968;
        return r90969;
}

double f(double x) {
        double r90970 = 1.0;
        double r90971 = log(r90970);
        double r90972 = x;
        double r90973 = r90971 / r90972;
        double r90974 = 0.25;
        double r90975 = r90972 * r90971;
        double r90976 = 4.0;
        double r90977 = pow(r90970, r90976);
        double r90978 = r90975 / r90977;
        double r90979 = r90974 * r90978;
        double r90980 = fma(r90970, r90973, r90979);
        double r90981 = 0.3333333333333333;
        double r90982 = 3.0;
        double r90983 = pow(r90970, r90982);
        double r90984 = r90975 / r90983;
        double r90985 = 0.5;
        double r90986 = 2.0;
        double r90987 = pow(r90970, r90986);
        double r90988 = r90971 / r90987;
        double r90989 = fma(r90985, r90988, r90970);
        double r90990 = fma(r90970, r90972, r90989);
        double r90991 = fma(r90981, r90984, r90990);
        double r90992 = r90980 - r90991;
        double r90993 = fma(r90971, r90970, r90992);
        return r90993;
}

Error

Bits error versus x

Target

Original61.3
Target0.3
Herbie0.7
\[-\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. Using strategy rm
  3. Applied flip3-+61.1

    \[\leadsto \frac{\log \left(1 - x\right)}{\log \color{blue}{\left(\frac{{1}^{3} + {x}^{3}}{1 \cdot 1 + \left(x \cdot x - 1 \cdot x\right)}\right)}}\]
  4. Applied log-div61.2

    \[\leadsto \frac{\log \left(1 - x\right)}{\color{blue}{\log \left({1}^{3} + {x}^{3}\right) - \log \left(1 \cdot 1 + \left(x \cdot x - 1 \cdot x\right)\right)}}\]
  5. Taylor expanded around 0 0.7

    \[\leadsto \color{blue}{\left(1 \cdot \log 1 + \left(1 \cdot \frac{\log 1}{x} + 0.25 \cdot \frac{x \cdot \log 1}{{1}^{4}}\right)\right) - \left(0.3333333333333333148296162562473909929395 \cdot \frac{x \cdot \log 1}{{1}^{3}} + \left(1 \cdot x + \left(0.5 \cdot \frac{\log 1}{{1}^{2}} + 1\right)\right)\right)}\]
  6. Simplified0.7

    \[\leadsto \color{blue}{\mathsf{fma}\left(\log 1, 1, \mathsf{fma}\left(1, \frac{\log 1}{x}, 0.25 \cdot \frac{x \cdot \log 1}{{1}^{4}}\right) - \mathsf{fma}\left(0.3333333333333333148296162562473909929395, \frac{x \cdot \log 1}{{1}^{3}}, \mathsf{fma}\left(1, x, \mathsf{fma}\left(0.5, \frac{\log 1}{{1}^{2}}, 1\right)\right)\right)\right)}\]
  7. Final simplification0.7

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

Reproduce

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