\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.0000001235874896:\\
\;\;\;\;\left(0.333333333333333315 \cdot \frac{{x}^{3}}{{1}^{3}} + \left(1 \cdot {x}^{3} + 0.5 \cdot \frac{{x}^{2}}{{1}^{2}}\right)\right) + 1 \cdot \left(x - \left({x}^{2} + \frac{{x}^{3}}{{1}^{2}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\
\end{array}double f(double x) {
double r79860 = 1.0;
double r79861 = x;
double r79862 = r79860 + r79861;
double r79863 = log(r79862);
return r79863;
}
double f(double x) {
double r79864 = 1.0;
double r79865 = x;
double r79866 = r79864 + r79865;
double r79867 = 1.0000001235874896;
bool r79868 = r79866 <= r79867;
double r79869 = 0.3333333333333333;
double r79870 = 3.0;
double r79871 = pow(r79865, r79870);
double r79872 = pow(r79864, r79870);
double r79873 = r79871 / r79872;
double r79874 = r79869 * r79873;
double r79875 = r79864 * r79871;
double r79876 = 0.5;
double r79877 = 2.0;
double r79878 = pow(r79865, r79877);
double r79879 = pow(r79864, r79877);
double r79880 = r79878 / r79879;
double r79881 = r79876 * r79880;
double r79882 = r79875 + r79881;
double r79883 = r79874 + r79882;
double r79884 = r79871 / r79879;
double r79885 = r79878 + r79884;
double r79886 = r79865 - r79885;
double r79887 = r79864 * r79886;
double r79888 = r79883 + r79887;
double r79889 = log(r79866);
double r79890 = r79868 ? r79888 : r79889;
return r79890;
}




Bits error versus x
Results
| Original | 39.1 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
if (+ 1.0 x) < 1.0000001235874896Initial program 59.2
rmApplied flip3-+59.2
Applied log-div59.2
Taylor expanded around 0 0.3
Simplified0.3
if 1.0000001235874896 < (+ 1.0 x) Initial program 0.2
Final simplification0.3
herbie shell --seed 2020059
(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)))