\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.00000367168599613165724804275669157505:\\
\;\;\;\;\mathsf{fma}\left(\frac{{x}^{2}}{{1}^{2}}, \frac{-1}{2}, \mathsf{fma}\left(1, x, \log 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\
\end{array}double f(double x) {
double r107751 = 1.0;
double r107752 = x;
double r107753 = r107751 + r107752;
double r107754 = log(r107753);
return r107754;
}
double f(double x) {
double r107755 = 1.0;
double r107756 = x;
double r107757 = r107755 + r107756;
double r107758 = 1.0000036716859961;
bool r107759 = r107757 <= r107758;
double r107760 = 2.0;
double r107761 = pow(r107756, r107760);
double r107762 = pow(r107755, r107760);
double r107763 = r107761 / r107762;
double r107764 = -0.5;
double r107765 = log(r107755);
double r107766 = fma(r107755, r107756, r107765);
double r107767 = fma(r107763, r107764, r107766);
double r107768 = log(r107757);
double r107769 = r107759 ? r107767 : r107768;
return r107769;
}




Bits error versus x
| Original | 39.6 |
|---|---|
| Target | 0.3 |
| Herbie | 0.2 |
if (+ 1.0 x) < 1.0000036716859961Initial program 59.1
Taylor expanded around 0 0.3
Simplified0.3
if 1.0000036716859961 < (+ 1.0 x) Initial program 0.1
Final simplification0.2
herbie shell --seed 2019208 +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)))