Average Error: 61.5 → 0.4
Time: 17.3s
Precision: 64
\[-1 \lt x \land x \lt 1\]
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[\sqrt[3]{\mathsf{log1p}\left(\mathsf{expm1}\left({\left(\frac{\log 1 - \mathsf{fma}\left(\frac{\frac{1}{2}}{1}, x \cdot \frac{x}{1}, x \cdot 1\right)}{\mathsf{fma}\left(\frac{x}{1} \cdot \frac{-1}{2}, \frac{x}{1}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\right)}^{3}\right)\right)}\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\sqrt[3]{\mathsf{log1p}\left(\mathsf{expm1}\left({\left(\frac{\log 1 - \mathsf{fma}\left(\frac{\frac{1}{2}}{1}, x \cdot \frac{x}{1}, x \cdot 1\right)}{\mathsf{fma}\left(\frac{x}{1} \cdot \frac{-1}{2}, \frac{x}{1}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\right)}^{3}\right)\right)}
double f(double x) {
        double r50904 = 1.0;
        double r50905 = x;
        double r50906 = r50904 - r50905;
        double r50907 = log(r50906);
        double r50908 = r50904 + r50905;
        double r50909 = log(r50908);
        double r50910 = r50907 / r50909;
        return r50910;
}

double f(double x) {
        double r50911 = 1.0;
        double r50912 = log(r50911);
        double r50913 = 0.5;
        double r50914 = r50913 / r50911;
        double r50915 = x;
        double r50916 = r50915 / r50911;
        double r50917 = r50915 * r50916;
        double r50918 = r50915 * r50911;
        double r50919 = fma(r50914, r50917, r50918);
        double r50920 = r50912 - r50919;
        double r50921 = -0.5;
        double r50922 = r50916 * r50921;
        double r50923 = fma(r50911, r50915, r50912);
        double r50924 = fma(r50922, r50916, r50923);
        double r50925 = r50920 / r50924;
        double r50926 = 3.0;
        double r50927 = pow(r50925, r50926);
        double r50928 = expm1(r50927);
        double r50929 = log1p(r50928);
        double r50930 = cbrt(r50929);
        return r50930;
}

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.4166666666666666851703837437526090070605 \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(\log 1 + 1 \cdot x\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(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \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{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \log 1\right)\right)}\]
  5. Simplified0.4

    \[\leadsto \frac{\color{blue}{\log 1 - \mathsf{fma}\left(\frac{\frac{1}{2}}{1}, \frac{x \cdot x}{1}, 1 \cdot x\right)}}{\mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \log 1\right)\right)}\]
  6. Using strategy rm
  7. Applied add-cbrt-cube42.8

    \[\leadsto \frac{\log 1 - \mathsf{fma}\left(\frac{\frac{1}{2}}{1}, \frac{x \cdot x}{1}, 1 \cdot x\right)}{\color{blue}{\sqrt[3]{\left(\mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \log 1\right)\right) \cdot \mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \log 1\right)\right)\right) \cdot \mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \log 1\right)\right)}}}\]
  8. Applied add-cbrt-cube42.2

    \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\log 1 - \mathsf{fma}\left(\frac{\frac{1}{2}}{1}, \frac{x \cdot x}{1}, 1 \cdot x\right)\right) \cdot \left(\log 1 - \mathsf{fma}\left(\frac{\frac{1}{2}}{1}, \frac{x \cdot x}{1}, 1 \cdot x\right)\right)\right) \cdot \left(\log 1 - \mathsf{fma}\left(\frac{\frac{1}{2}}{1}, \frac{x \cdot x}{1}, 1 \cdot x\right)\right)}}}{\sqrt[3]{\left(\mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \log 1\right)\right) \cdot \mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \log 1\right)\right)\right) \cdot \mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \log 1\right)\right)}}\]
  9. Applied cbrt-undiv42.2

    \[\leadsto \color{blue}{\sqrt[3]{\frac{\left(\left(\log 1 - \mathsf{fma}\left(\frac{\frac{1}{2}}{1}, \frac{x \cdot x}{1}, 1 \cdot x\right)\right) \cdot \left(\log 1 - \mathsf{fma}\left(\frac{\frac{1}{2}}{1}, \frac{x \cdot x}{1}, 1 \cdot x\right)\right)\right) \cdot \left(\log 1 - \mathsf{fma}\left(\frac{\frac{1}{2}}{1}, \frac{x \cdot x}{1}, 1 \cdot x\right)\right)}{\left(\mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \log 1\right)\right) \cdot \mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \log 1\right)\right)\right) \cdot \mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(x, 1, \log 1\right)\right)}}}\]
  10. Simplified0.4

    \[\leadsto \sqrt[3]{\color{blue}{{\left(\frac{\log 1 - \mathsf{fma}\left(\frac{x \cdot x}{1}, \frac{\frac{1}{2}}{1}, x \cdot 1\right)}{\mathsf{fma}\left(\frac{x}{1}, \frac{x \cdot \frac{-1}{2}}{1}, \mathsf{fma}\left(x, 1, \log 1\right)\right)}\right)}^{3}}}\]
  11. Using strategy rm
  12. Applied log1p-expm1-u0.4

    \[\leadsto \sqrt[3]{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left({\left(\frac{\log 1 - \mathsf{fma}\left(\frac{x \cdot x}{1}, \frac{\frac{1}{2}}{1}, x \cdot 1\right)}{\mathsf{fma}\left(\frac{x}{1}, \frac{x \cdot \frac{-1}{2}}{1}, \mathsf{fma}\left(x, 1, \log 1\right)\right)}\right)}^{3}\right)\right)}}\]
  13. Simplified0.4

    \[\leadsto \sqrt[3]{\mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left({\left(\frac{\log 1 - \mathsf{fma}\left(\frac{\frac{1}{2}}{1}, \frac{x}{1} \cdot x, 1 \cdot x\right)}{\mathsf{fma}\left(\frac{x}{1} \cdot \frac{-1}{2}, \frac{x}{1}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\right)}^{3}\right)}\right)}\]
  14. Final simplification0.4

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

Reproduce

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