\log \left(1 + e^{x}\right) - x \cdot y\begin{array}{l}
\mathbf{if}\;x \le -4.14987374688656041 \cdot 10^{-4}:\\
\;\;\;\;\left(\left(\log \left(e^{x} + 1\right) + 1\right) - 1\right) - x \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(\log 2 + \left(\mathsf{fma}\left(0.25, {x}^{2}, 0.5 \cdot x\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{2}^{2}}\right)\right) - x \cdot y\\
\end{array}double f(double x, double y) {
double r141735 = 1.0;
double r141736 = x;
double r141737 = exp(r141736);
double r141738 = r141735 + r141737;
double r141739 = log(r141738);
double r141740 = y;
double r141741 = r141736 * r141740;
double r141742 = r141739 - r141741;
return r141742;
}
double f(double x, double y) {
double r141743 = x;
double r141744 = -0.00041498737468865604;
bool r141745 = r141743 <= r141744;
double r141746 = exp(r141743);
double r141747 = 1.0;
double r141748 = r141746 + r141747;
double r141749 = log(r141748);
double r141750 = 1.0;
double r141751 = r141749 + r141750;
double r141752 = r141751 - r141750;
double r141753 = y;
double r141754 = r141743 * r141753;
double r141755 = r141752 - r141754;
double r141756 = 2.0;
double r141757 = log(r141756);
double r141758 = 0.25;
double r141759 = 2.0;
double r141760 = pow(r141743, r141759);
double r141761 = 0.5;
double r141762 = r141761 * r141743;
double r141763 = fma(r141758, r141760, r141762);
double r141764 = 0.5;
double r141765 = pow(r141756, r141759);
double r141766 = r141760 / r141765;
double r141767 = r141764 * r141766;
double r141768 = r141763 - r141767;
double r141769 = r141757 + r141768;
double r141770 = r141769 - r141754;
double r141771 = r141745 ? r141755 : r141770;
return r141771;
}




Bits error versus x




Bits error versus y
| Original | 0.5 |
|---|---|
| Target | 0.0 |
| Herbie | 0.3 |
if x < -0.00041498737468865604Initial program 0.1
rmApplied expm1-log1p-u0.1
rmApplied expm1-udef0.1
Simplified0.1
if -0.00041498737468865604 < x Initial program 0.6
rmApplied expm1-log1p-u0.6
rmApplied expm1-udef1.3
Simplified1.3
Taylor expanded around 0 0.4
Simplified0.4
Final simplification0.3
herbie shell --seed 2020056 +o rules:numerics
(FPCore (x y)
:name "Logistic regression 2"
:precision binary64
:herbie-target
(if (<= x 0.0) (- (log (+ 1 (exp x))) (* x y)) (- (log (+ 1 (exp (- x)))) (* (- x) (- 1 y))))
(- (log (+ 1 (exp x))) (* x y)))