\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.000105430709032683367354366055224090815:\\
\;\;\;\;\left(0.3333333333333333148296162562473909929395 \cdot \frac{{x}^{3}}{{1}^{3}} + \left(1 \cdot {x}^{3} + \left(0.5 \cdot \frac{{x}^{2}}{{1}^{2}} + 1 \cdot x\right)\right)\right) - 1 \cdot \left(x \cdot x + \frac{{x}^{3}}{{1}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\sqrt{1 + x}\right) + \log \left(\sqrt{1 + x}\right)\\
\end{array}double f(double x) {
double r57719 = 1.0;
double r57720 = x;
double r57721 = r57719 + r57720;
double r57722 = log(r57721);
return r57722;
}
double f(double x) {
double r57723 = 1.0;
double r57724 = x;
double r57725 = r57723 + r57724;
double r57726 = 1.0001054307090327;
bool r57727 = r57725 <= r57726;
double r57728 = 0.3333333333333333;
double r57729 = 3.0;
double r57730 = pow(r57724, r57729);
double r57731 = pow(r57723, r57729);
double r57732 = r57730 / r57731;
double r57733 = r57728 * r57732;
double r57734 = r57723 * r57730;
double r57735 = 0.5;
double r57736 = 2.0;
double r57737 = pow(r57724, r57736);
double r57738 = pow(r57723, r57736);
double r57739 = r57737 / r57738;
double r57740 = r57735 * r57739;
double r57741 = r57723 * r57724;
double r57742 = r57740 + r57741;
double r57743 = r57734 + r57742;
double r57744 = r57733 + r57743;
double r57745 = r57724 * r57724;
double r57746 = r57730 / r57738;
double r57747 = r57745 + r57746;
double r57748 = r57723 * r57747;
double r57749 = r57744 - r57748;
double r57750 = sqrt(r57725);
double r57751 = log(r57750);
double r57752 = r57751 + r57751;
double r57753 = r57727 ? r57749 : r57752;
return r57753;
}




Bits error versus x
Results
| Original | 38.8 |
|---|---|
| Target | 0.2 |
| Herbie | 0.2 |
if (+ 1.0 x) < 1.0001054307090327Initial program 58.9
rmApplied flip3-+59.0
Applied log-div59.0
Simplified59.0
Taylor expanded around 0 0.2
Simplified0.2
if 1.0001054307090327 < (+ 1.0 x) Initial program 0.1
rmApplied add-sqr-sqrt0.1
Applied log-prod0.1
Final simplification0.2
herbie shell --seed 2019212
(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)))