\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le \frac{35184377452467}{35184372088832}:\\
\;\;\;\;\log 1 - \left(\frac{\frac{{x}^{2}}{{1}^{2}}}{2} - 1 \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\sqrt{1 + x}\right) + \log \left(\sqrt{1 + x}\right)\\
\end{array}double f(double x) {
double r88701 = 1.0;
double r88702 = x;
double r88703 = r88701 + r88702;
double r88704 = log(r88703);
return r88704;
}
double f(double x) {
double r88705 = 1.0;
double r88706 = x;
double r88707 = r88705 + r88706;
double r88708 = 35184377452467.0;
double r88709 = 35184372088832.0;
double r88710 = r88708 / r88709;
bool r88711 = r88707 <= r88710;
double r88712 = log(r88705);
double r88713 = 2.0;
double r88714 = pow(r88706, r88713);
double r88715 = pow(r88705, r88713);
double r88716 = r88714 / r88715;
double r88717 = r88716 / r88713;
double r88718 = r88705 * r88706;
double r88719 = r88717 - r88718;
double r88720 = r88712 - r88719;
double r88721 = sqrt(r88707);
double r88722 = log(r88721);
double r88723 = r88722 + r88722;
double r88724 = r88711 ? r88720 : r88723;
return r88724;
}




Bits error versus x
Results
| Original | 39.6 |
|---|---|
| Target | 0.2 |
| Herbie | 0.3 |
if (+ 1.0 x) < 1.0000001524436755Initial program 59.1
Taylor expanded around 0 0.4
Simplified0.4
if 1.0000001524436755 < (+ 1.0 x) Initial program 0.2
rmApplied add-sqr-sqrt0.2
Applied log-prod0.2
Final simplification0.3
herbie shell --seed 2019303
(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)))