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

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

\end{array}
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) {
	double VAR;
	if ((x <= -0.000534342795217937)) {
		VAR = ((double) (((double) (((double) (((double) cbrt(((double) log(((double) (1.0 + ((double) exp(x)))))))) * ((double) cbrt(((double) log(((double) (1.0 + ((double) exp(x)))))))))) * ((double) cbrt(((double) log(((double) (1.0 + ((double) exp(x)))))))))) - ((double) (x * y))));
	} else {
		VAR = ((double) (((double) (((double) (((double) log(2.0)) + ((double) (((double) pow(x, 2.0)) * ((double) (0.25 - ((double) (0.5 / ((double) pow(2.0, 2.0)))))))))) + ((double) (0.5 * x)))) - ((double) (x * y))));
	}
	return VAR;
}

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.4
\[\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 < -5.3434279521793701e-4

    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 \color{blue}{\left(\sqrt[3]{\log \left(1 + e^{x}\right)} \cdot \sqrt[3]{\log \left(1 + e^{x}\right)}\right) \cdot \sqrt[3]{\log \left(1 + e^{x}\right)}} - x \cdot y\]

    if -5.3434279521793701e-4 < x

    1. Initial program 0.7

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

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

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

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

Reproduce

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