\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.000001719073508876789446730981580913067:\\
\;\;\;\;\left(1 \cdot x + \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \log \left(1 + x\right) + \left(\log \left(\sqrt{\sqrt{1 + x}}\right) + \log \left(\sqrt{\sqrt{1 + x}}\right)\right)\\
\end{array}double f(double x) {
double r51765 = 1.0;
double r51766 = x;
double r51767 = r51765 + r51766;
double r51768 = log(r51767);
return r51768;
}
double f(double x) {
double r51769 = 1.0;
double r51770 = x;
double r51771 = r51769 + r51770;
double r51772 = 1.0000017190735089;
bool r51773 = r51771 <= r51772;
double r51774 = r51769 * r51770;
double r51775 = log(r51769);
double r51776 = r51774 + r51775;
double r51777 = 0.5;
double r51778 = 2.0;
double r51779 = pow(r51770, r51778);
double r51780 = pow(r51769, r51778);
double r51781 = r51779 / r51780;
double r51782 = r51777 * r51781;
double r51783 = r51776 - r51782;
double r51784 = 1.0;
double r51785 = r51784 / r51778;
double r51786 = log(r51771);
double r51787 = r51785 * r51786;
double r51788 = sqrt(r51771);
double r51789 = sqrt(r51788);
double r51790 = log(r51789);
double r51791 = r51790 + r51790;
double r51792 = r51787 + r51791;
double r51793 = r51773 ? r51783 : r51792;
return r51793;
}




Bits error versus x
Results
| Original | 38.8 |
|---|---|
| Target | 0.2 |
| Herbie | 0.3 |
if (+ 1.0 x) < 1.0000017190735089Initial program 59.0
Taylor expanded around 0 0.4
if 1.0000017190735089 < (+ 1.0 x) Initial program 0.1
rmApplied add-sqr-sqrt0.2
Applied log-prod0.2
rmApplied pow10.2
Applied sqrt-pow10.2
Applied log-pow0.1
rmApplied add-sqr-sqrt0.1
Applied sqrt-prod0.2
Applied log-prod0.2
Final simplification0.3
herbie shell --seed 2019291
(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)))