Average Error: 0.5 → 0.5
Time: 13.9s
Precision: 64
\[\log \left(1 + e^{x}\right) - x \cdot y\]
\[\begin{array}{l} \mathbf{if}\;x \le -353769.9819112870027311146259307861328125:\\ \;\;\;\;\left(\log \left(\sqrt[3]{1 + e^{x}}\right) \cdot 2 + \log \left(\sqrt[3]{1 + e^{x}}\right)\right) - y \cdot x\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{1}{2} \cdot {x}^{2} + \left(2 + x\right)\right) - y \cdot x\\ \end{array}\]
\log \left(1 + e^{x}\right) - x \cdot y
\begin{array}{l}
\mathbf{if}\;x \le -353769.9819112870027311146259307861328125:\\
\;\;\;\;\left(\log \left(\sqrt[3]{1 + e^{x}}\right) \cdot 2 + \log \left(\sqrt[3]{1 + e^{x}}\right)\right) - y \cdot x\\

\mathbf{else}:\\
\;\;\;\;\log \left(\frac{1}{2} \cdot {x}^{2} + \left(2 + x\right)\right) - y \cdot x\\

\end{array}
double f(double x, double y) {
        double r211021 = 1.0;
        double r211022 = x;
        double r211023 = exp(r211022);
        double r211024 = r211021 + r211023;
        double r211025 = log(r211024);
        double r211026 = y;
        double r211027 = r211022 * r211026;
        double r211028 = r211025 - r211027;
        return r211028;
}

double f(double x, double y) {
        double r211029 = x;
        double r211030 = -353769.981911287;
        bool r211031 = r211029 <= r211030;
        double r211032 = 1.0;
        double r211033 = exp(r211029);
        double r211034 = r211032 + r211033;
        double r211035 = cbrt(r211034);
        double r211036 = log(r211035);
        double r211037 = 2.0;
        double r211038 = r211036 * r211037;
        double r211039 = r211038 + r211036;
        double r211040 = y;
        double r211041 = r211040 * r211029;
        double r211042 = r211039 - r211041;
        double r211043 = 0.5;
        double r211044 = pow(r211029, r211037);
        double r211045 = r211043 * r211044;
        double r211046 = 2.0;
        double r211047 = r211046 + r211029;
        double r211048 = r211045 + r211047;
        double r211049 = log(r211048);
        double r211050 = r211049 - r211041;
        double r211051 = r211031 ? r211042 : r211050;
        return r211051;
}

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.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. Split input into 2 regimes
  2. if x < -353769.981911287

    1. Initial program 0

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

      \[\leadsto \log \color{blue}{\left(\left(\sqrt[3]{1 + e^{x}} \cdot \sqrt[3]{1 + e^{x}}\right) \cdot \sqrt[3]{1 + e^{x}}\right)} - x \cdot y\]
    4. Applied log-prod0

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

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

    if -353769.981911287 < x

    1. Initial program 0.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -353769.9819112870027311146259307861328125:\\ \;\;\;\;\left(\log \left(\sqrt[3]{1 + e^{x}}\right) \cdot 2 + \log \left(\sqrt[3]{1 + e^{x}}\right)\right) - y \cdot x\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{1}{2} \cdot {x}^{2} + \left(2 + x\right)\right) - y \cdot x\\ \end{array}\]

Reproduce

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