\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;x + 1 \le 1.000000000000000222044604925031308084726:\\
\;\;\;\;\mathsf{fma}\left(\frac{-1}{2} \cdot \frac{x}{1}, \frac{x}{1}, \mathsf{fma}\left(1, x, \log 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + 1\right)\\
\end{array}double f(double x) {
double r3392549 = 1.0;
double r3392550 = x;
double r3392551 = r3392549 + r3392550;
double r3392552 = log(r3392551);
return r3392552;
}
double f(double x) {
double r3392553 = x;
double r3392554 = 1.0;
double r3392555 = r3392553 + r3392554;
double r3392556 = 1.0000000000000002;
bool r3392557 = r3392555 <= r3392556;
double r3392558 = -0.5;
double r3392559 = r3392553 / r3392554;
double r3392560 = r3392558 * r3392559;
double r3392561 = log(r3392554);
double r3392562 = fma(r3392554, r3392553, r3392561);
double r3392563 = fma(r3392560, r3392559, r3392562);
double r3392564 = log(r3392555);
double r3392565 = r3392557 ? r3392563 : r3392564;
return r3392565;
}




Bits error versus x
| Original | 39.3 |
|---|---|
| Target | 0.3 |
| Herbie | 0.6 |
if (+ 1.0 x) < 1.0000000000000002Initial program 59.5
Taylor expanded around 0 0.3
Simplified0.3
if 1.0000000000000002 < (+ 1.0 x) Initial program 1.2
Final simplification0.6
herbie shell --seed 2019192 +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)))