\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.00000051390067646:\\
\;\;\;\;\mathsf{fma}\left(x, 1 - 0.5 \cdot x, \log 1\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\
\end{array}double f(double x) {
double r114506 = 1.0;
double r114507 = x;
double r114508 = r114506 + r114507;
double r114509 = log(r114508);
return r114509;
}
double f(double x) {
double r114510 = 1.0;
double r114511 = x;
double r114512 = r114510 + r114511;
double r114513 = 1.0000005139006765;
bool r114514 = r114512 <= r114513;
double r114515 = 0.5;
double r114516 = r114515 * r114511;
double r114517 = r114510 - r114516;
double r114518 = log(r114510);
double r114519 = fma(r114511, r114517, r114518);
double r114520 = log(r114512);
double r114521 = r114514 ? r114519 : r114520;
return r114521;
}




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