\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.000003244205803554223166429437696933746:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333148296162562473909929395, {\left(\frac{x}{1}\right)}^{3}, \mathsf{fma}\left(\frac{{x}^{2}}{{1}^{2}}, 0.5, 1 \cdot \left({x}^{3} + x\right)\right)\right) - \mathsf{fma}\left(x, 1 \cdot x, \frac{{x}^{3}}{1}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\
\end{array}double f(double x) {
double r93342 = 1.0;
double r93343 = x;
double r93344 = r93342 + r93343;
double r93345 = log(r93344);
return r93345;
}
double f(double x) {
double r93346 = 1.0;
double r93347 = x;
double r93348 = r93346 + r93347;
double r93349 = 1.0000032442058036;
bool r93350 = r93348 <= r93349;
double r93351 = 0.3333333333333333;
double r93352 = r93347 / r93346;
double r93353 = 3.0;
double r93354 = pow(r93352, r93353);
double r93355 = 2.0;
double r93356 = pow(r93347, r93355);
double r93357 = pow(r93346, r93355);
double r93358 = r93356 / r93357;
double r93359 = 0.5;
double r93360 = pow(r93347, r93353);
double r93361 = r93360 + r93347;
double r93362 = r93346 * r93361;
double r93363 = fma(r93358, r93359, r93362);
double r93364 = fma(r93351, r93354, r93363);
double r93365 = r93346 * r93347;
double r93366 = r93360 / r93346;
double r93367 = fma(r93347, r93365, r93366);
double r93368 = r93364 - r93367;
double r93369 = log(r93348);
double r93370 = r93350 ? r93368 : r93369;
return r93370;
}




Bits error versus x
| Original | 39.2 |
|---|---|
| Target | 0.2 |
| Herbie | 0.2 |
if (+ 1.0 x) < 1.0000032442058036Initial program 59.0
rmApplied flip3-+59.0
Applied log-div59.0
Simplified59.0
Taylor expanded around 0 0.2
Simplified0.2
if 1.0000032442058036 < (+ 1.0 x) Initial program 0.1
Final simplification0.2
herbie shell --seed 2019304 +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)))