\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \leq 1.0000003057130176:\\
\;\;\;\;\left(1 \cdot x + \log 1\right) - 0.5 \cdot \frac{x \cdot x}{1 \cdot 1}\\
\mathbf{else}:\\
\;\;\;\;\log \left(\sqrt{1 + x}\right) + \log \left(\sqrt{1 + x}\right)\\
\end{array}(FPCore (x) :precision binary64 (log (+ 1.0 x)))
(FPCore (x) :precision binary64 (if (<= (+ 1.0 x) 1.0000003057130176) (- (+ (* 1.0 x) (log 1.0)) (* 0.5 (/ (* x x) (* 1.0 1.0)))) (+ (log (sqrt (+ 1.0 x))) (log (sqrt (+ 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.0000003057130176)) {
tmp = ((double) (((double) (((double) (1.0 * x)) + ((double) log(1.0)))) - ((double) (0.5 * (((double) (x * x)) / ((double) (1.0 * 1.0)))))));
} else {
tmp = ((double) (((double) log(((double) sqrt(((double) (1.0 + x)))))) + ((double) log(((double) sqrt(((double) (1.0 + x))))))));
}
return tmp;
}




Bits error versus x
Results
| Original | 39.1 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
if (+.f64 1.0 x) < 1.0000003057130176Initial program 58.9
Taylor expanded around 0 0.4
Simplified0.4
if 1.0000003057130176 < (+.f64 1.0 x) Initial program 0.3
rmApplied add-sqr-sqrt_binary640.3
Applied log-prod_binary640.3
Final simplification0.3
herbie shell --seed 2020210
(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)))