\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.0000000000568305:\\
\;\;\;\;\mathsf{fma}\left(x, 1, \log 1 - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\log \left(1 + x\right)\right)}^{1}\\
\end{array}double f(double x) {
double r85446 = 1.0;
double r85447 = x;
double r85448 = r85446 + r85447;
double r85449 = log(r85448);
return r85449;
}
double f(double x) {
double r85450 = 1.0;
double r85451 = x;
double r85452 = r85450 + r85451;
double r85453 = 1.0000000000568305;
bool r85454 = r85452 <= r85453;
double r85455 = log(r85450);
double r85456 = 0.5;
double r85457 = 2.0;
double r85458 = pow(r85451, r85457);
double r85459 = pow(r85450, r85457);
double r85460 = r85458 / r85459;
double r85461 = r85456 * r85460;
double r85462 = r85455 - r85461;
double r85463 = fma(r85451, r85450, r85462);
double r85464 = log(r85452);
double r85465 = 1.0;
double r85466 = pow(r85464, r85465);
double r85467 = r85454 ? r85463 : r85466;
return r85467;
}




Bits error versus x
| Original | 39.3 |
|---|---|
| Target | 0.2 |
| Herbie | 0.4 |
if (+ 1.0 x) < 1.0000000000568305Initial program 59.3
Taylor expanded around 0 0.3
Simplified0.3
if 1.0000000000568305 < (+ 1.0 x) Initial program 0.5
rmApplied pow10.5
Final simplification0.4
herbie shell --seed 2020057 +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)))