Average Error: 0.5 → 0.5
Time: 14.4s
Precision: 64
\[\log \left(1 + e^{x}\right) - x \cdot y\]
\[\mathsf{log1p}\left(e^{x}\right) - y \cdot x\]
\log \left(1 + e^{x}\right) - x \cdot y
\mathsf{log1p}\left(e^{x}\right) - y \cdot x
double f(double x, double y) {
        double r4383896 = 1.0;
        double r4383897 = x;
        double r4383898 = exp(r4383897);
        double r4383899 = r4383896 + r4383898;
        double r4383900 = log(r4383899);
        double r4383901 = y;
        double r4383902 = r4383897 * r4383901;
        double r4383903 = r4383900 - r4383902;
        return r4383903;
}

double f(double x, double y) {
        double r4383904 = x;
        double r4383905 = exp(r4383904);
        double r4383906 = log1p(r4383905);
        double r4383907 = y;
        double r4383908 = r4383907 * r4383904;
        double r4383909 = r4383906 - r4383908;
        return r4383909;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.5
Target0.0
Herbie0.5
\[\begin{array}{l} \mathbf{if}\;x \le 0:\\ \;\;\;\;\log \left(1 + e^{x}\right) - x \cdot y\\ \mathbf{else}:\\ \;\;\;\;\log \left(1 + e^{-x}\right) - \left(-x\right) \cdot \left(1 - y\right)\\ \end{array}\]

Derivation

  1. Initial program 0.5

    \[\log \left(1 + e^{x}\right) - x \cdot y\]
  2. Simplified0.5

    \[\leadsto \color{blue}{\mathsf{log1p}\left(e^{x}\right) - y \cdot x}\]
  3. Final simplification0.5

    \[\leadsto \mathsf{log1p}\left(e^{x}\right) - y \cdot x\]

Reproduce

herbie shell --seed 2019164 +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)))