\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.0000000000000009:\\
\;\;\;\;\left(1 \cdot x + \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\log \left(\sqrt{1 + x}\right) + \log \left(\sqrt{1 + x}\right)\\
\end{array}double f(double x) {
double r62509 = 1.0;
double r62510 = x;
double r62511 = r62509 + r62510;
double r62512 = log(r62511);
return r62512;
}
double f(double x) {
double r62513 = 1.0;
double r62514 = x;
double r62515 = r62513 + r62514;
double r62516 = 1.0000000000000009;
bool r62517 = r62515 <= r62516;
double r62518 = r62513 * r62514;
double r62519 = log(r62513);
double r62520 = r62518 + r62519;
double r62521 = 0.5;
double r62522 = 2.0;
double r62523 = pow(r62514, r62522);
double r62524 = pow(r62513, r62522);
double r62525 = r62523 / r62524;
double r62526 = r62521 * r62525;
double r62527 = r62520 - r62526;
double r62528 = sqrt(r62515);
double r62529 = log(r62528);
double r62530 = r62529 + r62529;
double r62531 = r62517 ? r62527 : r62530;
return r62531;
}




Bits error versus x
Results
| Original | 39.0 |
|---|---|
| Target | 0.3 |
| Herbie | 0.7 |
if (+ 1.0 x) < 1.0000000000000009Initial program 59.3
Taylor expanded around 0 0.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
(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)))