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 r126096 = 1.0;
        double r126097 = x;
        double r126098 = exp(r126097);
        double r126099 = r126096 + r126098;
        double r126100 = log(r126099);
        double r126101 = y;
        double r126102 = r126097 * r126101;
        double r126103 = r126100 - r126102;
        return r126103;
}

double f(double x, double y) {
        double r126104 = 1.0;
        double r126105 = x;
        double r126106 = exp(r126105);
        double r126107 = r126104 + r126106;
        double r126108 = log(r126107);
        double r126109 = sqrt(r126108);
        double r126110 = r126109 * r126109;
        double r126111 = y;
        double r126112 = r126105 * r126111;
        double r126113 = r126110 - r126112;
        return r126113;
}

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