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

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

\end{array}
double f(double x, double y) {
        double r187108 = 1.0;
        double r187109 = x;
        double r187110 = exp(r187109);
        double r187111 = r187108 + r187110;
        double r187112 = log(r187111);
        double r187113 = y;
        double r187114 = r187109 * r187113;
        double r187115 = r187112 - r187114;
        return r187115;
}

double f(double x, double y) {
        double r187116 = x;
        double r187117 = -8.057362563360427e-05;
        bool r187118 = r187116 <= r187117;
        double r187119 = 1.0;
        double r187120 = exp(r187116);
        double r187121 = r187119 + r187120;
        double r187122 = cbrt(r187121);
        double r187123 = r187122 * r187122;
        double r187124 = log(r187123);
        double r187125 = r187119 * r187119;
        double r187126 = r187120 * r187120;
        double r187127 = r187125 - r187126;
        double r187128 = cbrt(r187127);
        double r187129 = log(r187128);
        double r187130 = r187119 - r187120;
        double r187131 = cbrt(r187130);
        double r187132 = log(r187131);
        double r187133 = r187129 - r187132;
        double r187134 = y;
        double r187135 = r187116 * r187134;
        double r187136 = r187133 - r187135;
        double r187137 = r187124 + r187136;
        double r187138 = 0.5;
        double r187139 = 2.0;
        double r187140 = pow(r187116, r187139);
        double r187141 = r187138 * r187140;
        double r187142 = 2.0;
        double r187143 = r187116 + r187142;
        double r187144 = r187141 + r187143;
        double r187145 = log(r187144);
        double r187146 = log(r187145);
        double r187147 = cbrt(r187146);
        double r187148 = r187147 * r187147;
        double r187149 = r187148 * r187147;
        double r187150 = exp(r187149);
        double r187151 = r187150 - r187135;
        double r187152 = r187118 ? r187137 : r187151;
        return r187152;
}

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

    1. Initial program 0.2

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

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

      \[\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. Applied associate--l+0.2

      \[\leadsto \color{blue}{\log \left(\sqrt[3]{1 + e^{x}} \cdot \sqrt[3]{1 + e^{x}}\right) + \left(\log \left(\sqrt[3]{1 + e^{x}}\right) - x \cdot y\right)}\]
    6. Using strategy rm
    7. Applied flip-+0.2

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

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

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

    if -8.057362563360427e-05 < x

    1. Initial program 0.7

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

      \[\leadsto \log \color{blue}{\left(\frac{1}{2} \cdot {x}^{2} + \left(x + 2\right)\right)} - x \cdot y\]
    3. Using strategy rm
    4. Applied add-exp-log0.6

      \[\leadsto \color{blue}{e^{\log \left(\log \left(\frac{1}{2} \cdot {x}^{2} + \left(x + 2\right)\right)\right)}} - x \cdot y\]
    5. Using strategy rm
    6. Applied add-cube-cbrt0.6

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

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

Reproduce

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