\log \left(1 + e^{x}\right) - x \cdot y\begin{array}{l}
\mathbf{if}\;x \le -8.61400379247107798 \cdot 10^{-4}:\\
\;\;\;\;\left(\log \left(\sqrt{1 + e^{x}}\right) + \left(\log \left(\sqrt{1 \cdot 1 - e^{x} \cdot e^{x}}\right) - \log \left(\sqrt{1 - e^{x}}\right)\right)\right) - x \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\log 2 + {x}^{2} \cdot \left(0.25 - \frac{\frac{1}{2}}{{2}^{2}}\right)\right) + 0.5 \cdot x\right) - x \cdot y\\
\end{array}double code(double x, double y) {
return (log((1.0 + exp(x))) - (x * y));
}
double code(double x, double y) {
double VAR;
if ((x <= -0.0008614003792471078)) {
VAR = ((log(sqrt((1.0 + exp(x)))) + (log(sqrt(((1.0 * 1.0) - (exp(x) * exp(x))))) - log(sqrt((1.0 - exp(x)))))) - (x * y));
} else {
VAR = (((log(2.0) + (pow(x, 2.0) * (0.25 - (0.5 / pow(2.0, 2.0))))) + (0.5 * x)) - (x * y));
}
return VAR;
}




Bits error versus x




Bits error versus y
Results
| Original | 0.5 |
|---|---|
| Target | 0.1 |
| Herbie | 0.4 |
if x < -0.0008614003792471078Initial program 0.1
rmApplied add-sqr-sqrt0.1
Applied log-prod0.1
rmApplied flip-+0.2
Applied sqrt-div0.2
Applied log-div0.1
if -0.0008614003792471078 < x Initial program 0.7
Taylor expanded around 0 0.5
Simplified0.5
Final simplification0.4
herbie shell --seed 2020105
(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)))