Average Error: 0.5 → 0.5
Time: 28.4s
Precision: 64
\[\log \left(1 + e^{x}\right) - x \cdot y\]
\[\frac{y \cdot x + \log \left(e^{x} + 1\right)}{\frac{y \cdot x + \log \left(e^{x} + 1\right)}{\log \left(e^{x} + 1\right) - y \cdot x}}\]
\log \left(1 + e^{x}\right) - x \cdot y
\frac{y \cdot x + \log \left(e^{x} + 1\right)}{\frac{y \cdot x + \log \left(e^{x} + 1\right)}{\log \left(e^{x} + 1\right) - y \cdot x}}
double f(double x, double y) {
        double r6390767 = 1.0;
        double r6390768 = x;
        double r6390769 = exp(r6390768);
        double r6390770 = r6390767 + r6390769;
        double r6390771 = log(r6390770);
        double r6390772 = y;
        double r6390773 = r6390768 * r6390772;
        double r6390774 = r6390771 - r6390773;
        return r6390774;
}

double f(double x, double y) {
        double r6390775 = y;
        double r6390776 = x;
        double r6390777 = r6390775 * r6390776;
        double r6390778 = exp(r6390776);
        double r6390779 = 1.0;
        double r6390780 = r6390778 + r6390779;
        double r6390781 = log(r6390780);
        double r6390782 = r6390777 + r6390781;
        double r6390783 = r6390781 - r6390777;
        double r6390784 = r6390782 / r6390783;
        double r6390785 = r6390782 / r6390784;
        return r6390785;
}

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
Herbie0.5
\[\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 flip--10.6

    \[\leadsto \color{blue}{\frac{\log \left(1 + e^{x}\right) \cdot \log \left(1 + e^{x}\right) - \left(x \cdot y\right) \cdot \left(x \cdot y\right)}{\log \left(1 + e^{x}\right) + x \cdot y}}\]
  4. Using strategy rm
  5. Applied difference-of-squares10.6

    \[\leadsto \frac{\color{blue}{\left(\log \left(1 + e^{x}\right) + x \cdot y\right) \cdot \left(\log \left(1 + e^{x}\right) - x \cdot y\right)}}{\log \left(1 + e^{x}\right) + x \cdot y}\]
  6. Applied associate-/l*0.5

    \[\leadsto \color{blue}{\frac{\log \left(1 + e^{x}\right) + x \cdot y}{\frac{\log \left(1 + e^{x}\right) + x \cdot y}{\log \left(1 + e^{x}\right) - x \cdot y}}}\]
  7. Final simplification0.5

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

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