\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.000000000077041040213998712715692818165:\\
\;\;\;\;\mathsf{fma}\left(x, 1, \log 1 - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\
\end{array}double f(double x) {
double r73993 = 1.0;
double r73994 = x;
double r73995 = r73993 + r73994;
double r73996 = log(r73995);
return r73996;
}
double f(double x) {
double r73997 = 1.0;
double r73998 = x;
double r73999 = r73997 + r73998;
double r74000 = 1.000000000077041;
bool r74001 = r73999 <= r74000;
double r74002 = log(r73997);
double r74003 = 0.5;
double r74004 = 2.0;
double r74005 = pow(r73998, r74004);
double r74006 = pow(r73997, r74004);
double r74007 = r74005 / r74006;
double r74008 = r74003 * r74007;
double r74009 = r74002 - r74008;
double r74010 = fma(r73998, r73997, r74009);
double r74011 = log(r73999);
double r74012 = r74001 ? r74010 : r74011;
return r74012;
}




Bits error versus x
| Original | 39.0 |
|---|---|
| Target | 0.2 |
| Herbie | 0.4 |
if (+ 1.0 x) < 1.000000000077041Initial program 59.5
Taylor expanded around 0 0.3
Simplified0.3
if 1.000000000077041 < (+ 1.0 x) Initial program 0.5
Final simplification0.4
herbie shell --seed 2019353 +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)))