Average Error: 0.5 → 0.4
Time: 42.2s
Precision: 64
Internal Precision: 640
\[\log \left(1 + e^{x}\right) - x \cdot y\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \le -4.466556916356668 \cdot 10^{-05}:\\
\;\;\;\;\sqrt{\log \left(1 + e^{x}\right)} \cdot \sqrt{\log \left(1 + e^{x}\right)} - x \cdot y\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{1}{2} \cdot {x}^{2} + \left(2 + x\right)\right) - x \cdot y\\
\end{array}\]
Target
| Original | 0.5 |
|---|
| Target | 0.1 |
|---|
| Herbie | 0.4 |
|---|
\[\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 x < -4.466556916356668e-05
Initial program 0.2
\[\log \left(1 + e^{x}\right) - x \cdot y\]
- Using strategy
rm Applied add-sqr-sqrt0.2
\[\leadsto \color{blue}{\sqrt{\log \left(1 + e^{x}\right)} \cdot \sqrt{\log \left(1 + e^{x}\right)}} - x \cdot y\]
if -4.466556916356668e-05 < x
Initial program 0.6
\[\log \left(1 + e^{x}\right) - x \cdot y\]
Taylor expanded around 0 0.5
\[\leadsto \log \color{blue}{\left(\frac{1}{2} \cdot {x}^{2} + \left(2 + x\right)\right)} - x \cdot y\]
- Recombined 2 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1063282112 2455465480 4141627379 3773598652 1647277307 776739644)'
(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)))