Average Error: 0.6 → 1.1
Time: 4.3s
Precision: 64
\[\log \left(1 + e^{x}\right) - x \cdot y\]
\[\sqrt{\log \left(1 + e^{x}\right)} \cdot \sqrt{\log \left(1 + e^{x}\right)} - x \cdot y\]
\log \left(1 + e^{x}\right) - x \cdot y
\sqrt{\log \left(1 + e^{x}\right)} \cdot \sqrt{\log \left(1 + e^{x}\right)} - x \cdot y
double f(double x, double y) {
        double r221561 = 1.0;
        double r221562 = x;
        double r221563 = exp(r221562);
        double r221564 = r221561 + r221563;
        double r221565 = log(r221564);
        double r221566 = y;
        double r221567 = r221562 * r221566;
        double r221568 = r221565 - r221567;
        return r221568;
}

double f(double x, double y) {
        double r221569 = 1.0;
        double r221570 = x;
        double r221571 = exp(r221570);
        double r221572 = r221569 + r221571;
        double r221573 = log(r221572);
        double r221574 = sqrt(r221573);
        double r221575 = r221574 * r221574;
        double r221576 = y;
        double r221577 = r221570 * r221576;
        double r221578 = r221575 - r221577;
        return r221578;
}

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.0
Herbie1.1
\[\begin{array}{l} \mathbf{if}\;x \le 0.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. Using strategy rm
  3. Applied add-sqr-sqrt1.1

    \[\leadsto \color{blue}{\sqrt{\log \left(1 + e^{x}\right)} \cdot \sqrt{\log \left(1 + e^{x}\right)}} - x \cdot y\]
  4. Final simplification1.1

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

Reproduce

herbie shell --seed 2020060 
(FPCore (x y)
  :name "Logistic regression 2"
  :precision binary64

  :herbie-target
  (if (<= x 0.0) (- (log (+ 1 (exp x))) (* x y)) (- (log (+ 1 (exp (- x)))) (* (- x) (- 1 y))))

  (- (log (+ 1 (exp x))) (* x y)))