\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \leq 1.000000000577583:\\
\;\;\;\;x + x \cdot \left(x \cdot \left(x \cdot 0.3333333333333333 + -0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\
\end{array}(FPCore (x) :precision binary64 (log (+ 1.0 x)))
(FPCore (x) :precision binary64 (if (<= (+ 1.0 x) 1.000000000577583) (+ x (* x (* x (+ (* x 0.3333333333333333) -0.5)))) (log (+ 1.0 x))))
double code(double x) {
return ((double) log(((double) (1.0 + x))));
}
double code(double x) {
double tmp;
if ((((double) (1.0 + x)) <= 1.000000000577583)) {
tmp = ((double) (x + ((double) (x * ((double) (x * ((double) (((double) (x * 0.3333333333333333)) + -0.5))))))));
} else {
tmp = ((double) log(((double) (1.0 + x))));
}
return tmp;
}




Bits error versus x
Results
| Original | 39.5 |
|---|---|
| Target | 0.2 |
| Herbie | 0.3 |
if (+.f64 1 x) < 1.00000000057758309Initial program 59.3
Taylor expanded around 0 0.2
Simplified0.2
rmApplied distribute-lft-in_binary640.2
Simplified0.2
Simplified0.2
if 1.00000000057758309 < (+.f64 1 x) Initial program 0.4
Final simplification0.3
herbie shell --seed 2020219
(FPCore (x)
:name "ln(1 + x)"
:precision binary64
:herbie-target
(if (== (+ 1.0 x) 1.0) x (/ (* x (log (+ 1.0 x))) (- (+ 1.0 x) 1.0)))
(log (+ 1.0 x)))