Average Error: 0.4 → 0.4
Time: 10.3s
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 r3134573 = 1.0;
        double r3134574 = x;
        double r3134575 = exp(r3134574);
        double r3134576 = r3134573 + r3134575;
        double r3134577 = log(r3134576);
        double r3134578 = y;
        double r3134579 = r3134574 * r3134578;
        double r3134580 = r3134577 - r3134579;
        return r3134580;
}

double f(double x, double y) {
        double r3134581 = x;
        double r3134582 = exp(r3134581);
        double r3134583 = log1p(r3134582);
        double r3134584 = y;
        double r3134585 = r3134584 * r3134581;
        double r3134586 = r3134583 - r3134585;
        return r3134586;
}

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.4
Target0.1
Herbie0.4
\[\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.4

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

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

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

Reproduce

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