\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;x + 1 \le 1.000000000966332569518613127002026885748:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(1, x, \log 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + 1\right)\\
\end{array}double f(double x) {
double r3205870 = 1.0;
double r3205871 = x;
double r3205872 = r3205870 + r3205871;
double r3205873 = log(r3205872);
return r3205873;
}
double f(double x) {
double r3205874 = x;
double r3205875 = 1.0;
double r3205876 = r3205874 + r3205875;
double r3205877 = 1.0000000009663326;
bool r3205878 = r3205876 <= r3205877;
double r3205879 = r3205874 / r3205875;
double r3205880 = r3205879 * r3205879;
double r3205881 = -0.5;
double r3205882 = log(r3205875);
double r3205883 = fma(r3205875, r3205874, r3205882);
double r3205884 = fma(r3205880, r3205881, r3205883);
double r3205885 = log(r3205876);
double r3205886 = r3205878 ? r3205884 : r3205885;
return r3205886;
}




Bits error versus x
| Original | 38.6 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
if (+ 1.0 x) < 1.0000000009663326Initial program 59.2
Taylor expanded around 0 0.3
Simplified0.3
if 1.0000000009663326 < (+ 1.0 x) Initial program 0.3
Final simplification0.3
herbie shell --seed 2019170 +o rules:numerics
(FPCore (x)
:name "ln(1 + x)"
:herbie-target
(if (== (+ 1.0 x) 1.0) x (/ (* x (log (+ 1.0 x))) (- (+ 1.0 x) 1.0)))
(log (+ 1.0 x)))