Average Error: 0.6 → 1.1
Time: 4.4s
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 r163288 = 1.0;
        double r163289 = x;
        double r163290 = exp(r163289);
        double r163291 = r163288 + r163290;
        double r163292 = log(r163291);
        double r163293 = y;
        double r163294 = r163289 * r163293;
        double r163295 = r163292 - r163294;
        return r163295;
}

double f(double x, double y) {
        double r163296 = 1.0;
        double r163297 = x;
        double r163298 = exp(r163297);
        double r163299 = r163296 + r163298;
        double r163300 = log(r163299);
        double r163301 = sqrt(r163300);
        double r163302 = r163301 * r163301;
        double r163303 = y;
        double r163304 = r163297 * r163303;
        double r163305 = r163302 - r163304;
        return r163305;
}

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 +o rules:numerics
(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)))