Average Error: 0.4 → 0.9
Time: 24.2s
Precision: 64
\[\log \left(1 + e^{x}\right) - x \cdot y\]
\[(e^{\log \left(\log_* (1 + e^{x}) + 1\right)} - 1)^* - x \cdot y\]
\log \left(1 + e^{x}\right) - x \cdot y
(e^{\log \left(\log_* (1 + e^{x}) + 1\right)} - 1)^* - x \cdot y
double f(double x, double y) {
        double r25528202 = 1.0;
        double r25528203 = x;
        double r25528204 = exp(r25528203);
        double r25528205 = r25528202 + r25528204;
        double r25528206 = log(r25528205);
        double r25528207 = y;
        double r25528208 = r25528203 * r25528207;
        double r25528209 = r25528206 - r25528208;
        return r25528209;
}

double f(double x, double y) {
        double r25528210 = x;
        double r25528211 = exp(r25528210);
        double r25528212 = log1p(r25528211);
        double r25528213 = 1.0;
        double r25528214 = r25528212 + r25528213;
        double r25528215 = log(r25528214);
        double r25528216 = expm1(r25528215);
        double r25528217 = y;
        double r25528218 = r25528210 * r25528217;
        double r25528219 = r25528216 - r25528218;
        return r25528219;
}

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.9
\[\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}{\log_* (1 + e^{x}) - y \cdot x}\]
  3. Using strategy rm
  4. Applied expm1-log1p-u0.4

    \[\leadsto \color{blue}{(e^{\log_* (1 + \log_* (1 + e^{x}))} - 1)^*} - y \cdot x\]
  5. Using strategy rm
  6. Applied log1p-udef0.9

    \[\leadsto (e^{\color{blue}{\log \left(1 + \log_* (1 + e^{x})\right)}} - 1)^* - y \cdot x\]
  7. Final simplification0.9

    \[\leadsto (e^{\log \left(\log_* (1 + e^{x}) + 1\right)} - 1)^* - x \cdot y\]

Reproduce

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