\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.0000000288683601:\\
\;\;\;\;\mathsf{fma}\left(\frac{{x}^{2}}{{1}^{2}}, \frac{-1}{2}, \mathsf{fma}\left(1, x, \log 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\
\end{array}double f(double x) {
double r90559 = 1.0;
double r90560 = x;
double r90561 = r90559 + r90560;
double r90562 = log(r90561);
return r90562;
}
double f(double x) {
double r90563 = 1.0;
double r90564 = x;
double r90565 = r90563 + r90564;
double r90566 = 1.0000000288683601;
bool r90567 = r90565 <= r90566;
double r90568 = 2.0;
double r90569 = pow(r90564, r90568);
double r90570 = pow(r90563, r90568);
double r90571 = r90569 / r90570;
double r90572 = -0.5;
double r90573 = log(r90563);
double r90574 = fma(r90563, r90564, r90573);
double r90575 = fma(r90571, r90572, r90574);
double r90576 = log(r90565);
double r90577 = r90567 ? r90575 : r90576;
return r90577;
}




Bits error versus x
| Original | 38.8 |
|---|---|
| Target | 0.3 |
| Herbie | 0.2 |
if (+ 1.0 x) < 1.0000000288683601Initial program 59.4
Taylor expanded around 0 0.3
Simplified0.3
if 1.0000000288683601 < (+ 1.0 x) Initial program 0.2
Final simplification0.2
herbie shell --seed 2019199 +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)))