\log \left(1 + e^{x}\right) - x \cdot y\mathsf{fma}\left(\sqrt{\mathsf{log1p}\left(e^{x}\right)}, \sqrt{\mathsf{log1p}\left(e^{x}\right)}, x \cdot \left(-y\right)\right)double f(double x, double y) {
double r5721452 = 1.0;
double r5721453 = x;
double r5721454 = exp(r5721453);
double r5721455 = r5721452 + r5721454;
double r5721456 = log(r5721455);
double r5721457 = y;
double r5721458 = r5721453 * r5721457;
double r5721459 = r5721456 - r5721458;
return r5721459;
}
double f(double x, double y) {
double r5721460 = x;
double r5721461 = exp(r5721460);
double r5721462 = log1p(r5721461);
double r5721463 = sqrt(r5721462);
double r5721464 = y;
double r5721465 = -r5721464;
double r5721466 = r5721460 * r5721465;
double r5721467 = fma(r5721463, r5721463, r5721466);
return r5721467;
}




Bits error versus x




Bits error versus y
| Original | 0.5 |
|---|---|
| Target | 0.1 |
| Herbie | 1.0 |
Initial program 0.5
Simplified0.5
rmApplied add-sqr-sqrt1.0
Applied fma-neg1.0
Final simplification1.0
herbie shell --seed 2019144 +o rules:numerics
(FPCore (x y)
:name "Logistic regression 2"
:herbie-target
(if (<= x 0) (- (log (+ 1 (exp x))) (* x y)) (- (log (+ 1 (exp (- x)))) (* (- x) (- 1 y))))
(- (log (+ 1 (exp x))) (* x y)))