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 r157449 = 1.0;
        double r157450 = x;
        double r157451 = exp(r157450);
        double r157452 = r157449 + r157451;
        double r157453 = log(r157452);
        double r157454 = y;
        double r157455 = r157450 * r157454;
        double r157456 = r157453 - r157455;
        return r157456;
}

double f(double x, double y) {
        double r157457 = 1.0;
        double r157458 = x;
        double r157459 = exp(r157458);
        double r157460 = r157457 + r157459;
        double r157461 = log(r157460);
        double r157462 = sqrt(r157461);
        double r157463 = r157462 * r157462;
        double r157464 = y;
        double r157465 = r157458 * r157464;
        double r157466 = r157463 - r157465;
        return r157466;
}

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)))