\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.000000014348698229582623753231018781662:\\
\;\;\;\;\mathsf{fma}\left(\frac{-1}{2}, \frac{x}{1} \cdot \frac{x}{1}, \mathsf{fma}\left(1, x, \log 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\
\end{array}double f(double x) {
double r4470600 = 1.0;
double r4470601 = x;
double r4470602 = r4470600 + r4470601;
double r4470603 = log(r4470602);
return r4470603;
}
double f(double x) {
double r4470604 = 1.0;
double r4470605 = x;
double r4470606 = r4470604 + r4470605;
double r4470607 = 1.0000000143486982;
bool r4470608 = r4470606 <= r4470607;
double r4470609 = -0.5;
double r4470610 = r4470605 / r4470604;
double r4470611 = r4470610 * r4470610;
double r4470612 = log(r4470604);
double r4470613 = fma(r4470604, r4470605, r4470612);
double r4470614 = fma(r4470609, r4470611, r4470613);
double r4470615 = log(r4470606);
double r4470616 = r4470608 ? r4470614 : r4470615;
return r4470616;
}




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