\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.0000025653698017:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{3}, \frac{{x}^{3}}{{1}^{3}}, \mathsf{fma}\left(1, x, \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right) - 1 \cdot {x}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\
\end{array}double code(double x) {
return log((1.0 + x));
}
double code(double x) {
double VAR;
if (((1.0 + x) <= 1.0000025653698017)) {
VAR = fma(0.3333333333333333, (pow(x, 3.0) / pow(1.0, 3.0)), (fma(1.0, x, (0.5 * (pow(x, 2.0) / pow(1.0, 2.0)))) - (1.0 * pow(x, 2.0))));
} else {
VAR = log((1.0 + x));
}
return VAR;
}




Bits error versus x
Results
| Original | 39.1 |
|---|---|
| Target | 0.3 |
| Herbie | 0.2 |
if (+ 1.0 x) < 1.0000025653698017Initial program 59.0
rmApplied flip-+59.0
Applied log-div59.0
Taylor expanded around 0 0.3
Simplified0.3
if 1.0000025653698017 < (+ 1.0 x) Initial program 0.1
Final simplification0.2
herbie shell --seed 2020071 +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)))