Average Error: 0.5 → 0.8
Time: 40.5s
Precision: 64
\[\log \left(1.0 + e^{x}\right) - x \cdot y\]
\[\begin{array}{l} \mathbf{if}\;x \le -16179825.06434172:\\ \;\;\;\;\sqrt[3]{\log \left(1.0 + e^{x}\right)} \cdot \left(\sqrt[3]{\log \left(1.0 + e^{x}\right)} \cdot \sqrt[3]{\log \left(1.0 + e^{x}\right)}\right) - x \cdot y\\ \mathbf{elif}\;x \le 9.261101280752574 \cdot 10^{-07}:\\ \;\;\;\;\left(\left(0.5 \cdot x + \left(x \cdot x\right) \cdot 0.25\right) + \left(\log 2.0 - \frac{x}{2.0} \cdot \left(\frac{x}{2.0} \cdot \frac{1}{2}\right)\right)\right) - x \cdot y\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\log \left(1.0 + e^{x}\right)} \cdot \left(\sqrt[3]{\log \left(1.0 + e^{x}\right)} \cdot \sqrt[3]{\log \left(1.0 + e^{x}\right)}\right) - x \cdot y\\ \end{array}\]
\log \left(1.0 + e^{x}\right) - x \cdot y
\begin{array}{l}
\mathbf{if}\;x \le -16179825.06434172:\\
\;\;\;\;\sqrt[3]{\log \left(1.0 + e^{x}\right)} \cdot \left(\sqrt[3]{\log \left(1.0 + e^{x}\right)} \cdot \sqrt[3]{\log \left(1.0 + e^{x}\right)}\right) - x \cdot y\\

\mathbf{elif}\;x \le 9.261101280752574 \cdot 10^{-07}:\\
\;\;\;\;\left(\left(0.5 \cdot x + \left(x \cdot x\right) \cdot 0.25\right) + \left(\log 2.0 - \frac{x}{2.0} \cdot \left(\frac{x}{2.0} \cdot \frac{1}{2}\right)\right)\right) - x \cdot y\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\log \left(1.0 + e^{x}\right)} \cdot \left(\sqrt[3]{\log \left(1.0 + e^{x}\right)} \cdot \sqrt[3]{\log \left(1.0 + e^{x}\right)}\right) - x \cdot y\\

\end{array}
double f(double x, double y) {
        double r8179279 = 1.0;
        double r8179280 = x;
        double r8179281 = exp(r8179280);
        double r8179282 = r8179279 + r8179281;
        double r8179283 = log(r8179282);
        double r8179284 = y;
        double r8179285 = r8179280 * r8179284;
        double r8179286 = r8179283 - r8179285;
        return r8179286;
}

double f(double x, double y) {
        double r8179287 = x;
        double r8179288 = -16179825.06434172;
        bool r8179289 = r8179287 <= r8179288;
        double r8179290 = 1.0;
        double r8179291 = exp(r8179287);
        double r8179292 = r8179290 + r8179291;
        double r8179293 = log(r8179292);
        double r8179294 = cbrt(r8179293);
        double r8179295 = r8179294 * r8179294;
        double r8179296 = r8179294 * r8179295;
        double r8179297 = y;
        double r8179298 = r8179287 * r8179297;
        double r8179299 = r8179296 - r8179298;
        double r8179300 = 9.261101280752574e-07;
        bool r8179301 = r8179287 <= r8179300;
        double r8179302 = 0.5;
        double r8179303 = r8179302 * r8179287;
        double r8179304 = r8179287 * r8179287;
        double r8179305 = 0.25;
        double r8179306 = r8179304 * r8179305;
        double r8179307 = r8179303 + r8179306;
        double r8179308 = 2.0;
        double r8179309 = log(r8179308);
        double r8179310 = r8179287 / r8179308;
        double r8179311 = 0.5;
        double r8179312 = r8179310 * r8179311;
        double r8179313 = r8179310 * r8179312;
        double r8179314 = r8179309 - r8179313;
        double r8179315 = r8179307 + r8179314;
        double r8179316 = r8179315 - r8179298;
        double r8179317 = r8179301 ? r8179316 : r8179299;
        double r8179318 = r8179289 ? r8179299 : r8179317;
        return r8179318;
}

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.8
\[\begin{array}{l} \mathbf{if}\;x \le 0.0:\\ \;\;\;\;\log \left(1.0 + e^{x}\right) - x \cdot y\\ \mathbf{else}:\\ \;\;\;\;\log \left(1.0 + e^{-x}\right) - \left(-x\right) \cdot \left(1.0 - y\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -16179825.06434172 or 9.261101280752574e-07 < x

    1. Initial program 1.6

      \[\log \left(1.0 + e^{x}\right) - x \cdot y\]
    2. Using strategy rm
    3. Applied add-cube-cbrt1.6

      \[\leadsto \color{blue}{\left(\sqrt[3]{\log \left(1.0 + e^{x}\right)} \cdot \sqrt[3]{\log \left(1.0 + e^{x}\right)}\right) \cdot \sqrt[3]{\log \left(1.0 + e^{x}\right)}} - x \cdot y\]

    if -16179825.06434172 < x < 9.261101280752574e-07

    1. Initial program 0.0

      \[\log \left(1.0 + e^{x}\right) - x \cdot y\]
    2. Taylor expanded around 0 0.5

      \[\leadsto \log \color{blue}{\left(x + \left(\frac{1}{2} \cdot {x}^{2} + 2.0\right)\right)} - x \cdot y\]
    3. Simplified0.5

      \[\leadsto \log \color{blue}{\left(\left(2.0 + x\right) + \left(x \cdot x\right) \cdot \frac{1}{2}\right)} - x \cdot y\]
    4. Taylor expanded around 0 0.5

      \[\leadsto \color{blue}{\left(\left(0.5 \cdot x + \left(0.25 \cdot {x}^{2} + \log 2.0\right)\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{2.0}^{2}}\right)} - x \cdot y\]
    5. Simplified0.5

      \[\leadsto \color{blue}{\left(\left(0.5 \cdot x + 0.25 \cdot \left(x \cdot x\right)\right) + \left(\log 2.0 - \left(\frac{1}{2} \cdot \frac{x}{2.0}\right) \cdot \frac{x}{2.0}\right)\right)} - x \cdot y\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -16179825.06434172:\\ \;\;\;\;\sqrt[3]{\log \left(1.0 + e^{x}\right)} \cdot \left(\sqrt[3]{\log \left(1.0 + e^{x}\right)} \cdot \sqrt[3]{\log \left(1.0 + e^{x}\right)}\right) - x \cdot y\\ \mathbf{elif}\;x \le 9.261101280752574 \cdot 10^{-07}:\\ \;\;\;\;\left(\left(0.5 \cdot x + \left(x \cdot x\right) \cdot 0.25\right) + \left(\log 2.0 - \frac{x}{2.0} \cdot \left(\frac{x}{2.0} \cdot \frac{1}{2}\right)\right)\right) - x \cdot y\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\log \left(1.0 + e^{x}\right)} \cdot \left(\sqrt[3]{\log \left(1.0 + e^{x}\right)} \cdot \sqrt[3]{\log \left(1.0 + e^{x}\right)}\right) - x \cdot y\\ \end{array}\]

Reproduce

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