Average Error: 0.6 → 0.5
Time: 27.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 r5442049 = 1.0;
        double r5442050 = x;
        double r5442051 = exp(r5442050);
        double r5442052 = r5442049 + r5442051;
        double r5442053 = log(r5442052);
        double r5442054 = y;
        double r5442055 = r5442050 * r5442054;
        double r5442056 = r5442053 - r5442055;
        return r5442056;
}

double f(double x, double y) {
        double r5442057 = x;
        double r5442058 = exp(r5442057);
        double r5442059 = log1p(r5442058);
        double r5442060 = y;
        double r5442061 = r5442060 * r5442057;
        double r5442062 = r5442059 - r5442061;
        return r5442062;
}

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.6
Target0.1
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.6

    \[\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 2019151 +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)))