Average Error: 0.5 → 1.0
Time: 3.1s
Precision: binary64
\[\log \left(1 + e^{x}\right) - x \cdot y\]
\[\left(\log \left(\sqrt{1 + e^{x}}\right) + \frac{1}{2} \cdot {e}^{\left(\log \left(\log \left(1 + e^{x}\right)\right)\right)}\right) - x \cdot y\]
\log \left(1 + e^{x}\right) - x \cdot y
\left(\log \left(\sqrt{1 + e^{x}}\right) + \frac{1}{2} \cdot {e}^{\left(\log \left(\log \left(1 + e^{x}\right)\right)\right)}\right) - x \cdot y
double code(double x, double y) {
	return ((double) (((double) log(((double) (1.0 + ((double) exp(x)))))) - ((double) (x * y))));
}
double code(double x, double y) {
	return ((double) (((double) (((double) log(((double) sqrt(((double) (1.0 + ((double) exp(x)))))))) + ((double) (0.5 * ((double) pow(((double) M_E), ((double) log(((double) log(((double) (1.0 + ((double) exp(x)))))))))))))) - ((double) (x * y))));
}

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
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. Using strategy rm
  6. Applied pow1/21.0

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

    \[\leadsto \left(\log \left(\sqrt{1 + e^{x}}\right) + \color{blue}{\frac{1}{2} \cdot \log \left(1 + e^{x}\right)}\right) - x \cdot y\]
  8. Using strategy rm
  9. Applied add-exp-log1.0

    \[\leadsto \left(\log \left(\sqrt{1 + e^{x}}\right) + \frac{1}{2} \cdot \color{blue}{e^{\log \left(\log \left(1 + e^{x}\right)\right)}}\right) - x \cdot y\]
  10. Using strategy rm
  11. Applied pow11.0

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

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

    \[\leadsto \left(\log \left(\sqrt{1 + e^{x}}\right) + \frac{1}{2} \cdot \color{blue}{{\left(e^{1}\right)}^{\left(\log \left(\log \left(1 + e^{x}\right)\right)\right)}}\right) - x \cdot y\]
  14. Simplified1.0

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

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

Reproduce

herbie shell --seed 2020162 
(FPCore (x y)
  :name "Logistic regression 2"
  :precision binary64

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

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