\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.0000000771282975:\\
\;\;\;\;\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 r60924 = 1.0;
double r60925 = x;
double r60926 = r60924 + r60925;
double r60927 = log(r60926);
return r60927;
}
double f(double x) {
double r60928 = 1.0;
double r60929 = x;
double r60930 = r60928 + r60929;
double r60931 = 1.0000000771282975;
bool r60932 = r60930 <= r60931;
double r60933 = log(r60928);
double r60934 = 0.5;
double r60935 = 2.0;
double r60936 = pow(r60929, r60935);
double r60937 = pow(r60928, r60935);
double r60938 = r60936 / r60937;
double r60939 = r60934 * r60938;
double r60940 = r60933 - r60939;
double r60941 = fma(r60929, r60928, r60940);
double r60942 = sqrt(r60930);
double r60943 = log(r60942);
double r60944 = r60943 + r60943;
double r60945 = r60932 ? r60941 : r60944;
return r60945;
}




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