Average Error: 0.5 → 0.5
Time: 29.6s
Precision: 64
\[\log \left(1 + e^{x}\right) - x \cdot y\]
\[\left(\log \left(\mathsf{fma}\left(1 \cdot 1, 1, e^{x \cdot 3}\right)\right) - \sqrt[3]{\log \left(\mathsf{fma}\left(e^{x} - 1, e^{x}, 1 \cdot 1\right)\right) \cdot \left(\log \left(\mathsf{fma}\left(e^{x} - 1, e^{x}, 1 \cdot 1\right)\right) \cdot \log \left(\mathsf{fma}\left(e^{x} - 1, e^{x}, 1 \cdot 1\right)\right)\right)}\right) - x \cdot y\]
\log \left(1 + e^{x}\right) - x \cdot y
\left(\log \left(\mathsf{fma}\left(1 \cdot 1, 1, e^{x \cdot 3}\right)\right) - \sqrt[3]{\log \left(\mathsf{fma}\left(e^{x} - 1, e^{x}, 1 \cdot 1\right)\right) \cdot \left(\log \left(\mathsf{fma}\left(e^{x} - 1, e^{x}, 1 \cdot 1\right)\right) \cdot \log \left(\mathsf{fma}\left(e^{x} - 1, e^{x}, 1 \cdot 1\right)\right)\right)}\right) - x \cdot y
double f(double x, double y) {
        double r6418843 = 1.0;
        double r6418844 = x;
        double r6418845 = exp(r6418844);
        double r6418846 = r6418843 + r6418845;
        double r6418847 = log(r6418846);
        double r6418848 = y;
        double r6418849 = r6418844 * r6418848;
        double r6418850 = r6418847 - r6418849;
        return r6418850;
}

double f(double x, double y) {
        double r6418851 = 1.0;
        double r6418852 = r6418851 * r6418851;
        double r6418853 = x;
        double r6418854 = 3.0;
        double r6418855 = r6418853 * r6418854;
        double r6418856 = exp(r6418855);
        double r6418857 = fma(r6418852, r6418851, r6418856);
        double r6418858 = log(r6418857);
        double r6418859 = exp(r6418853);
        double r6418860 = r6418859 - r6418851;
        double r6418861 = fma(r6418860, r6418859, r6418852);
        double r6418862 = log(r6418861);
        double r6418863 = r6418862 * r6418862;
        double r6418864 = r6418862 * r6418863;
        double r6418865 = cbrt(r6418864);
        double r6418866 = r6418858 - r6418865;
        double r6418867 = y;
        double r6418868 = r6418853 * r6418867;
        double r6418869 = r6418866 - r6418868;
        return r6418869;
}

Error

Bits error versus x

Bits error versus y

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 flip3-+0.5

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

    \[\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. Simplified0.5

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

    \[\leadsto \left(\log \left(\mathsf{fma}\left(1 \cdot 1, 1, e^{x \cdot 3}\right)\right) - \color{blue}{\log \left(\mathsf{fma}\left(e^{x} - 1, e^{x}, 1 \cdot 1\right)\right)}\right) - x \cdot y\]
  7. Using strategy rm
  8. Applied add-cbrt-cube0.5

    \[\leadsto \left(\log \left(\mathsf{fma}\left(1 \cdot 1, 1, e^{x \cdot 3}\right)\right) - \color{blue}{\sqrt[3]{\left(\log \left(\mathsf{fma}\left(e^{x} - 1, e^{x}, 1 \cdot 1\right)\right) \cdot \log \left(\mathsf{fma}\left(e^{x} - 1, e^{x}, 1 \cdot 1\right)\right)\right) \cdot \log \left(\mathsf{fma}\left(e^{x} - 1, e^{x}, 1 \cdot 1\right)\right)}}\right) - x \cdot y\]
  9. Final simplification0.5

    \[\leadsto \left(\log \left(\mathsf{fma}\left(1 \cdot 1, 1, e^{x \cdot 3}\right)\right) - \sqrt[3]{\log \left(\mathsf{fma}\left(e^{x} - 1, e^{x}, 1 \cdot 1\right)\right) \cdot \left(\log \left(\mathsf{fma}\left(e^{x} - 1, e^{x}, 1 \cdot 1\right)\right) \cdot \log \left(\mathsf{fma}\left(e^{x} - 1, e^{x}, 1 \cdot 1\right)\right)\right)}\right) - x \cdot y\]

Reproduce

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