\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;x + 1 \le 1:\\
\;\;\;\;\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 r3217770 = 1.0;
double r3217771 = x;
double r3217772 = r3217770 + r3217771;
double r3217773 = log(r3217772);
return r3217773;
}
double f(double x) {
double r3217774 = x;
double r3217775 = 1.0;
double r3217776 = r3217774 + r3217775;
bool r3217777 = r3217776 <= r3217775;
double r3217778 = r3217774 / r3217775;
double r3217779 = r3217778 * r3217778;
double r3217780 = -0.5;
double r3217781 = log(r3217775);
double r3217782 = fma(r3217775, r3217774, r3217781);
double r3217783 = fma(r3217779, r3217780, r3217782);
double r3217784 = log(r3217776);
double r3217785 = r3217777 ? r3217783 : r3217784;
return r3217785;
}




Bits error versus x
| Original | 39.3 |
|---|---|
| Target | 0.2 |
| Herbie | 0.6 |
if (+ 1.0 x) < 1.0Initial program 59.6
Taylor expanded around 0 0.3
Simplified0.3
if 1.0 < (+ 1.0 x) Initial program 1.3
rmApplied pow11.3
Applied log-pow1.3
Final simplification0.6
herbie shell --seed 2019172 +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)))