Average Error: 0.5 → 1.0
Time: 15.1s
Precision: 64
\[\log \left(1 + e^{x}\right) - x \cdot y\]
\[\left(e^{\log \left(\log \left(\sqrt{1 + e^{x}}\right)\right)} + \log \left(\sqrt{1 + e^{x}}\right)\right) - x \cdot y\]
\log \left(1 + e^{x}\right) - x \cdot y
\left(e^{\log \left(\log \left(\sqrt{1 + e^{x}}\right)\right)} + \log \left(\sqrt{1 + e^{x}}\right)\right) - x \cdot y
double f(double x, double y) {
        double r149168 = 1.0;
        double r149169 = x;
        double r149170 = exp(r149169);
        double r149171 = r149168 + r149170;
        double r149172 = log(r149171);
        double r149173 = y;
        double r149174 = r149169 * r149173;
        double r149175 = r149172 - r149174;
        return r149175;
}

double f(double x, double y) {
        double r149176 = 1.0;
        double r149177 = x;
        double r149178 = exp(r149177);
        double r149179 = r149176 + r149178;
        double r149180 = sqrt(r149179);
        double r149181 = log(r149180);
        double r149182 = log(r149181);
        double r149183 = exp(r149182);
        double r149184 = r149183 + r149181;
        double r149185 = y;
        double r149186 = r149177 * r149185;
        double r149187 = r149184 - r149186;
        return r149187;
}

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.4

    \[\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. Using strategy rm
  6. Applied add-exp-log1.0

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

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

Reproduce

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