\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.0000000000000009:\\
\;\;\;\;\mathsf{fma}\left(x, 1, \log 1 - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\sqrt{1 + x}\right) + \log \left(\sqrt{1 + x}\right)\\
\end{array}double f(double x) {
double r52545 = 1.0;
double r52546 = x;
double r52547 = r52545 + r52546;
double r52548 = log(r52547);
return r52548;
}
double f(double x) {
double r52549 = 1.0;
double r52550 = x;
double r52551 = r52549 + r52550;
double r52552 = 1.0000000000000009;
bool r52553 = r52551 <= r52552;
double r52554 = log(r52549);
double r52555 = 0.5;
double r52556 = 2.0;
double r52557 = pow(r52550, r52556);
double r52558 = pow(r52549, r52556);
double r52559 = r52557 / r52558;
double r52560 = r52555 * r52559;
double r52561 = r52554 - r52560;
double r52562 = fma(r52550, r52549, r52561);
double r52563 = sqrt(r52551);
double r52564 = log(r52563);
double r52565 = r52564 + r52564;
double r52566 = r52553 ? r52562 : r52565;
return r52566;
}




Bits error versus x
| Original | 39.0 |
|---|---|
| Target | 0.3 |
| Herbie | 0.7 |
if (+ 1.0 x) < 1.0000000000000009Initial program 59.3
Taylor expanded around 0 0.4
Simplified0.4
if 1.0000000000000009 < (+ 1.0 x) Initial program 1.1
rmApplied add-sqr-sqrt1.2
Applied log-prod1.1
Final simplification0.7
herbie shell --seed 2020100 +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)))