Average Error: 0.5 → 0.5
Time: 21.8s
Precision: 64
Internal Precision: 1088
\[\log \left(1 + e^{x}\right) - x \cdot y\]
↓
\[\begin{array}{l}
\mathbf{if}\;\log \left(1 + e^{x}\right) - x \cdot y \le 6.4500049228439084 \cdot 10^{-15}:\\
\;\;\;\;(\left(\sqrt[3]{\log_* (1 + e^{x})} \cdot \sqrt[3]{\log_* (1 + e^{x})}\right) \cdot \left(\sqrt[3]{\log_* (1 + e^{x})}\right) + \left(-y \cdot x\right))_*\\
\mathbf{if}\;\log \left(1 + e^{x}\right) - x \cdot y \le 47.67902510472408:\\
\;\;\;\;e^{\log \left(\log_* (1 + e^{x}) - y \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;(\left(\sqrt[3]{\log_* (1 + e^{x})} \cdot \sqrt[3]{\log_* (1 + e^{x})}\right) \cdot \left(\sqrt[3]{\log_* (1 + e^{x})}\right) + \left(-y \cdot x\right))_*\\
\end{array}\]
Target
| Original | 0.5 |
|---|
| Target | 0.0 |
|---|
| Herbie | 0.5 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \le 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
- Split input into 2 regimes
if (- (log (+ 1 (exp x))) (* x y)) < 6.4500049228439084e-15 or 47.67902510472408 < (- (log (+ 1 (exp x))) (* x y))
Initial program 1.1
\[\log \left(1 + e^{x}\right) - x \cdot y\]
Applied simplify1.0
\[\leadsto \color{blue}{\log_* (1 + e^{x}) - y \cdot x}\]
- Using strategy
rm Applied add-cube-cbrt1.0
\[\leadsto \color{blue}{\left(\sqrt[3]{\log_* (1 + e^{x})} \cdot \sqrt[3]{\log_* (1 + e^{x})}\right) \cdot \sqrt[3]{\log_* (1 + e^{x})}} - y \cdot x\]
Applied fma-neg1.0
\[\leadsto \color{blue}{(\left(\sqrt[3]{\log_* (1 + e^{x})} \cdot \sqrt[3]{\log_* (1 + e^{x})}\right) \cdot \left(\sqrt[3]{\log_* (1 + e^{x})}\right) + \left(-y \cdot x\right))_*}\]
if 6.4500049228439084e-15 < (- (log (+ 1 (exp x))) (* x y)) < 47.67902510472408
Initial program 0.0
\[\log \left(1 + e^{x}\right) - x \cdot y\]
Applied simplify0.0
\[\leadsto \color{blue}{\log_* (1 + e^{x}) - y \cdot x}\]
- Using strategy
rm Applied add-exp-log0.0
\[\leadsto \color{blue}{e^{\log \left(\log_* (1 + e^{x}) - y \cdot x\right)}}\]
- Recombined 2 regimes into one program.
Runtime
herbie shell --seed '#(1071979731 1496239409 439705970 2863295848 982327776 189749553)' +o rules:numerics
(FPCore (x y)
:name "Logistic regression 2"
:herbie-target
(if (<= x 0) (- (log (+ 1 (exp x))) (* x y)) (- (log (+ 1 (exp (- x)))) (* (- x) (- 1 y))))
(- (log (+ 1 (exp x))) (* x y)))