Average Error: 0.5 → 0.5
Time: 19.6s
Precision: 64
\[\log \left(1 + e^{x}\right) - x \cdot y\]
\[e^{\log \left(\log \left(1 + e^{x}\right)\right)} - x \cdot y\]
\log \left(1 + e^{x}\right) - x \cdot y
e^{\log \left(\log \left(1 + e^{x}\right)\right)} - x \cdot y
double f(double x, double y) {
        double r169845 = 1.0;
        double r169846 = x;
        double r169847 = exp(r169846);
        double r169848 = r169845 + r169847;
        double r169849 = log(r169848);
        double r169850 = y;
        double r169851 = r169846 * r169850;
        double r169852 = r169849 - r169851;
        return r169852;
}

double f(double x, double y) {
        double r169853 = 1.0;
        double r169854 = x;
        double r169855 = exp(r169854);
        double r169856 = r169853 + r169855;
        double r169857 = log(r169856);
        double r169858 = log(r169857);
        double r169859 = exp(r169858);
        double r169860 = y;
        double r169861 = r169854 * r169860;
        double r169862 = r169859 - r169861;
        return r169862;
}

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 add-exp-log0.5

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

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

Reproduce

herbie shell --seed 2019304 
(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)))