Average Error: 0.5 → 0.6
Time: 25.4s
Precision: 64
\[\log \left(1 + e^{x}\right) - x \cdot y\]
\[\left(\left(\log \left(\left(e^{\left(x + x\right) + x} \cdot e^{\left(x + x\right) + x}\right) \cdot e^{\left(x + x\right) + x} + 1\right) - \log \left(e^{\left(x + x\right) + x} \cdot e^{\left(x + x\right) + x} + \left(1 - e^{\left(x + x\right) + x}\right)\right)\right) - \log \left(1 + \left(e^{x} \cdot e^{x} - e^{x}\right)\right)\right) - x \cdot y\]
double f(double x, double y) {
        double r16288229 = 1.0;
        double r16288230 = x;
        double r16288231 = exp(r16288230);
        double r16288232 = r16288229 + r16288231;
        double r16288233 = log(r16288232);
        double r16288234 = y;
        double r16288235 = r16288230 * r16288234;
        double r16288236 = r16288233 - r16288235;
        return r16288236;
}

double f(double x, double y) {
        double r16288237 = x;
        double r16288238 = r16288237 + r16288237;
        double r16288239 = r16288238 + r16288237;
        double r16288240 = exp(r16288239);
        double r16288241 = r16288240 * r16288240;
        double r16288242 = r16288241 * r16288240;
        double r16288243 = 1.0;
        double r16288244 = r16288242 + r16288243;
        double r16288245 = log(r16288244);
        double r16288246 = r16288243 - r16288240;
        double r16288247 = r16288241 + r16288246;
        double r16288248 = log(r16288247);
        double r16288249 = r16288245 - r16288248;
        double r16288250 = exp(r16288237);
        double r16288251 = r16288250 * r16288250;
        double r16288252 = r16288251 - r16288250;
        double r16288253 = r16288243 + r16288252;
        double r16288254 = log(r16288253);
        double r16288255 = r16288249 - r16288254;
        double r16288256 = y;
        double r16288257 = r16288237 * r16288256;
        double r16288258 = r16288255 - r16288257;
        return r16288258;
}

\log \left(1 + e^{x}\right) - x \cdot y
\left(\left(\log \left(\left(e^{\left(x + x\right) + x} \cdot e^{\left(x + x\right) + x}\right) \cdot e^{\left(x + x\right) + x} + 1\right) - \log \left(e^{\left(x + x\right) + x} \cdot e^{\left(x + x\right) + x} + \left(1 - e^{\left(x + x\right) + x}\right)\right)\right) - \log \left(1 + \left(e^{x} \cdot e^{x} - e^{x}\right)\right)\right) - x \cdot y

Error

Bits error versus x

Bits error versus y

Target

Original0.5
Target0.1
Herbie0.6
\[\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. Using strategy rm
  3. Applied flip3-+0.6

    \[\leadsto \log \color{blue}{\left(\frac{{1}^{3} + {\left(e^{x}\right)}^{3}}{1 \cdot 1 + \left(e^{x} \cdot e^{x} - 1 \cdot e^{x}\right)}\right)} - x \cdot y\]
  4. Applied log-div0.6

    \[\leadsto \color{blue}{\left(\log \left({1}^{3} + {\left(e^{x}\right)}^{3}\right) - \log \left(1 \cdot 1 + \left(e^{x} \cdot e^{x} - 1 \cdot e^{x}\right)\right)\right)} - x \cdot y\]
  5. Simplified0.6

    \[\leadsto \left(\color{blue}{\log \left(e^{\left(x + x\right) + x} + 1\right)} - \log \left(1 \cdot 1 + \left(e^{x} \cdot e^{x} - 1 \cdot e^{x}\right)\right)\right) - x \cdot y\]
  6. Using strategy rm
  7. Applied flip3-+0.6

    \[\leadsto \left(\log \color{blue}{\left(\frac{{\left(e^{\left(x + x\right) + x}\right)}^{3} + {1}^{3}}{e^{\left(x + x\right) + x} \cdot e^{\left(x + x\right) + x} + \left(1 \cdot 1 - e^{\left(x + x\right) + x} \cdot 1\right)}\right)} - \log \left(1 \cdot 1 + \left(e^{x} \cdot e^{x} - 1 \cdot e^{x}\right)\right)\right) - x \cdot y\]
  8. Applied log-div0.6

    \[\leadsto \left(\color{blue}{\left(\log \left({\left(e^{\left(x + x\right) + x}\right)}^{3} + {1}^{3}\right) - \log \left(e^{\left(x + x\right) + x} \cdot e^{\left(x + x\right) + x} + \left(1 \cdot 1 - e^{\left(x + x\right) + x} \cdot 1\right)\right)\right)} - \log \left(1 \cdot 1 + \left(e^{x} \cdot e^{x} - 1 \cdot e^{x}\right)\right)\right) - x \cdot y\]
  9. Simplified0.6

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

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

Reproduce

herbie shell --seed 2019101 
(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)))