Average Error: 32.7 → 5.9
Time: 3.4m
Precision: 64
Internal Precision: 2176
\[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
↓
\[\begin{array}{l}
\mathbf{if}\;z \le -14629085.839866638:\\
\;\;\;\;x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\\
\mathbf{if}\;z \le -1.4288974179262956 \cdot 10^{-63}:\\
\;\;\;\;x - \frac{\log \left(1.0 + \left(z \cdot y + \frac{1}{2} \cdot \left({z}^{2} \cdot y\right)\right)\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \left(\frac{z}{t} \cdot \left(0.5 \cdot z + 1.0\right)\right)\\
\end{array}\]
Target
| Original | 32.7 |
|---|
| Target | 25.1 |
|---|
| Herbie | 5.9 |
|---|
\[\begin{array}{l}
\mathbf{if}\;z \lt -2.8874623088207947 \cdot 10^{+119}:\\
\;\;\;\;\left(x - \frac{\frac{-0.5}{y \cdot t}}{z \cdot z}\right) - \frac{-0.5}{y \cdot t} \cdot \frac{\frac{2.0}{z}}{z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(1.0 + z \cdot y\right)}{t}\\
\end{array}\]
Derivation
- Split input into 3 regimes
if z < -14629085.839866638
Initial program 10.7
\[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
if -14629085.839866638 < z < -1.4288974179262956e-63
Initial program 29.6
\[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
Taylor expanded around 0 11.3
\[\leadsto x - \frac{\log \color{blue}{\left(1.0 + \left(z \cdot y + \frac{1}{2} \cdot \left({z}^{2} \cdot y\right)\right)\right)}}{t}\]
if -1.4288974179262956e-63 < z
Initial program 39.9
\[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
Taylor expanded around 0 6.2
\[\leadsto x - \frac{\color{blue}{1.0 \cdot \left(z \cdot y\right) + \left(0.5 \cdot \left({z}^{2} \cdot y\right) + \log 1.0\right)}}{t}\]
Applied simplify4.0
\[\leadsto \color{blue}{x - \frac{\log 1.0 + \left(z \cdot 0.5 + 1.0\right) \cdot \left(z \cdot y\right)}{t}}\]
Taylor expanded around inf 6.2
\[\leadsto \color{blue}{x - \left(0.5 \cdot \frac{{z}^{2} \cdot y}{t} + 1.0 \cdot \frac{z \cdot y}{t}\right)}\]
Applied simplify6.4
\[\leadsto \color{blue}{x - y \cdot \left(1.0 \cdot \frac{z}{t} + \frac{z \cdot z}{\frac{t}{0.5}}\right)}\]
Applied simplify4.0
\[\leadsto x - \color{blue}{y \cdot \left(\frac{z}{t} \cdot \left(0.5 \cdot z + 1.0\right)\right)}\]
- Recombined 3 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit +o reduce:binary-search
(FPCore (x y z t)
:name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
:herbie-target
(if (< z -2.8874623088207947e+119) (- (- x (/ (/ (- 0.5) (* y t)) (* z z))) (* (/ (- 0.5) (* y t)) (/ (/ 2.0 z) (* z z)))) (- x (/ (log (+ 1.0 (* z y))) t)))
(- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))