Average Error: 0.5 → 0.6
Time: 4.6s
Precision: 64
\[\log \left(1 + e^{x}\right) - x \cdot y\]
\[\left(\log \left({1}^{3} + {\left(e^{x}\right)}^{3}\right) - \log \left(1 \cdot 1 + \left(e^{x} \cdot e^{x} - 1 \cdot e^{x}\right)\right)\right) - x \cdot y\]
\log \left(1 + e^{x}\right) - x \cdot y
\left(\log \left({1}^{3} + {\left(e^{x}\right)}^{3}\right) - \log \left(1 \cdot 1 + \left(e^{x} \cdot e^{x} - 1 \cdot e^{x}\right)\right)\right) - x \cdot y
double f(double x, double y) {
        double r128812 = 1.0;
        double r128813 = x;
        double r128814 = exp(r128813);
        double r128815 = r128812 + r128814;
        double r128816 = log(r128815);
        double r128817 = y;
        double r128818 = r128813 * r128817;
        double r128819 = r128816 - r128818;
        return r128819;
}

double f(double x, double y) {
        double r128820 = 1.0;
        double r128821 = 3.0;
        double r128822 = pow(r128820, r128821);
        double r128823 = x;
        double r128824 = exp(r128823);
        double r128825 = pow(r128824, r128821);
        double r128826 = r128822 + r128825;
        double r128827 = log(r128826);
        double r128828 = r128820 * r128820;
        double r128829 = r128824 * r128824;
        double r128830 = r128820 * r128824;
        double r128831 = r128829 - r128830;
        double r128832 = r128828 + r128831;
        double r128833 = log(r128832);
        double r128834 = r128827 - r128833;
        double r128835 = y;
        double r128836 = r128823 * r128835;
        double r128837 = r128834 - r128836;
        return r128837;
}

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.0
Herbie0.6
\[\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 flip3-+0.6

    \[\leadsto \log \color{blue}{\left(\frac{{1}^{3} + {\left(e^{x}\right)}^{3}}{1 \cdot 1 + \left(e^{x} \cdot e^{x} - 1 \cdot e^{x}\right)}\right)} - x \cdot y\]
  4. Applied log-div0.6

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

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

Reproduce

herbie shell --seed 2020025 +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)))