\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;x + 1 \le 1.000001508099978009269648282497655600309:\\
\;\;\;\;\mathsf{fma}\left(1 - 0.5 \cdot x, x, \log 1\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\sqrt{x + 1}\right) + \log \left(\sqrt{x + 1}\right)\\
\end{array}double f(double x) {
double r3043565 = 1.0;
double r3043566 = x;
double r3043567 = r3043565 + r3043566;
double r3043568 = log(r3043567);
return r3043568;
}
double f(double x) {
double r3043569 = x;
double r3043570 = 1.0;
double r3043571 = r3043569 + r3043570;
double r3043572 = 1.000001508099978;
bool r3043573 = r3043571 <= r3043572;
double r3043574 = 0.5;
double r3043575 = r3043574 * r3043569;
double r3043576 = r3043570 - r3043575;
double r3043577 = log(r3043570);
double r3043578 = fma(r3043576, r3043569, r3043577);
double r3043579 = sqrt(r3043571);
double r3043580 = log(r3043579);
double r3043581 = r3043580 + r3043580;
double r3043582 = r3043573 ? r3043578 : r3043581;
return r3043582;
}




Bits error versus x
| Original | 38.8 |
|---|---|
| Target | 0.2 |
| Herbie | 0.3 |
if (+ 1.0 x) < 1.000001508099978Initial program 59.1
Taylor expanded around 0 0.4
Simplified0.4
Taylor expanded around 0 0.4
Simplified0.4
if 1.000001508099978 < (+ 1.0 x) Initial program 0.1
rmApplied add-sqr-sqrt0.1
Applied log-prod0.1
Final simplification0.3
herbie shell --seed 2019168 +o rules:numerics
(FPCore (x)
:name "ln(1 + x)"
:herbie-target
(if (== (+ 1.0 x) 1.0) x (/ (* x (log (+ 1.0 x))) (- (+ 1.0 x) 1.0)))
(log (+ 1.0 x)))