Average Error: 0.5 → 1.0
Time: 25.9s
Precision: 64
\[\log \left(1 + e^{x}\right) - x \cdot y\]
\[\left(\log \left(\sqrt{e^{x} + 1}\right) - y \cdot x\right) + \log \left(\sqrt{e^{x} + 1}\right)\]
\log \left(1 + e^{x}\right) - x \cdot y
\left(\log \left(\sqrt{e^{x} + 1}\right) - y \cdot x\right) + \log \left(\sqrt{e^{x} + 1}\right)
double f(double x, double y) {
        double r6626794 = 1.0;
        double r6626795 = x;
        double r6626796 = exp(r6626795);
        double r6626797 = r6626794 + r6626796;
        double r6626798 = log(r6626797);
        double r6626799 = y;
        double r6626800 = r6626795 * r6626799;
        double r6626801 = r6626798 - r6626800;
        return r6626801;
}

double f(double x, double y) {
        double r6626802 = x;
        double r6626803 = exp(r6626802);
        double r6626804 = 1.0;
        double r6626805 = r6626803 + r6626804;
        double r6626806 = sqrt(r6626805);
        double r6626807 = log(r6626806);
        double r6626808 = y;
        double r6626809 = r6626808 * r6626802;
        double r6626810 = r6626807 - r6626809;
        double r6626811 = r6626810 + r6626807;
        return r6626811;
}

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.5
Target0.1
Herbie1.0
\[\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.5

    \[\log \left(1 + e^{x}\right) - x \cdot y\]
  2. Using strategy rm
  3. Applied add-sqr-sqrt1.3

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

    \[\leadsto \color{blue}{\left(\log \left(\sqrt{1 + e^{x}}\right) + \log \left(\sqrt{1 + e^{x}}\right)\right)} - x \cdot y\]
  5. Applied associate--l+1.0

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

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

Reproduce

herbie shell --seed 2019200 +o rules:numerics
(FPCore (x y)
  :name "Logistic regression 2"

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

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