Average Error: 33.2 → 10.8
Time: 53.3s
Precision: 64
Internal precision: 128
\[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;z \le -5.9430640354654945 \cdot 10^{+19}:\\
\;\;\;\;x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\\
\mathbf{if}\;z \le 2.3218028994593566 \cdot 10^{-103}:\\
\;\;\;\;\left(x - \frac{\log 1.0}{t}\right) - \left(\frac{z}{t} \cdot y\right) \cdot \left(0.5 \cdot z + 1.0\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(\frac{1}{2} \cdot \left(y \cdot {z}^2\right) + \left(1.0 + y \cdot z\right)\right)}{t}\\
\end{array}\]
Target
| Original | 33.2 |
| Comparison | 23.5 |
| Herbie | 10.8 |
\[ \begin{array}{l}
\mathbf{if}\;z \lt -2.8874623088207947 \cdot 10^{+119}:\\
\;\;\;\;\left(x - \frac{\frac{-0.5}{y \cdot t}}{{z}^2}\right) - \frac{-0.5}{y \cdot t} \cdot \frac{\frac{2.0}{z}}{{z}^2}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(1.0 + z \cdot y\right)}{t}\\
\end{array} \]
Derivation
- Split input into 3 regimes.
-
if z < -5.9430640354654945e+19
Initial program 11.8
\[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
if -5.9430640354654945e+19 < z < 2.3218028994593566e-103
Initial program 33.6
\[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
Applied taylor 1.7
\[\leadsto x - \left(1.0 \cdot \frac{y \cdot z}{t} + \left(0.5 \cdot \frac{y \cdot {z}^2}{t} + \frac{\log 1.0}{t}\right)\right)\]
Taylor expanded around 0 1.7
\[\leadsto x - \color{blue}{\left(1.0 \cdot \frac{y \cdot z}{t} + \left(0.5 \cdot \frac{y \cdot {z}^2}{t} + \frac{\log 1.0}{t}\right)\right)}\]
Applied simplify 5.9
\[\leadsto \color{blue}{\left(x - \frac{\log 1.0}{t}\right) - z \cdot \left(\frac{y}{t} \cdot \left(z \cdot 0.5 + 1.0\right)\right)}\]
Applied taylor 5.9
\[\leadsto \left(x - \frac{\log 1.0}{t}\right) - z \cdot \left(1.0 \cdot \frac{y}{t} + 0.5 \cdot \frac{y \cdot z}{t}\right)\]
Taylor expanded around 0 5.9
\[\leadsto \left(x - \frac{\log 1.0}{t}\right) - z \cdot \color{blue}{\left(1.0 \cdot \frac{y}{t} + 0.5 \cdot \frac{y \cdot z}{t}\right)}\]
Applied simplify 1.1
\[\leadsto \color{blue}{\left(x - \frac{\log 1.0}{t}\right) - \left(\frac{z}{t} \cdot y\right) \cdot \left(0.5 \cdot z + 1.0\right)}\]
if 2.3218028994593566e-103 < z
Initial program 50.6
\[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
Applied taylor 29.5
\[\leadsto x - \frac{\log \left(\frac{1}{2} \cdot \left(y \cdot {z}^2\right) + \left(1.0 + y \cdot z\right)\right)}{t}\]
Taylor expanded around 0 29.5
\[\leadsto x - \frac{\log \color{blue}{\left(\frac{1}{2} \cdot \left(y \cdot {z}^2\right) + \left(1.0 + y \cdot z\right)\right)}}{t}\]
- Recombined 3 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(3666465132 719130484 1799563395 3905432248 3804154138 1071404319)'
(FPCore (x y z t)
:name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
:target
(if (< z -2.8874623088207947e+119) (- (- x (/ (/ (- 0.5) (* y t)) (sqr z))) (* (/ (- 0.5) (* y t)) (/ (/ 2.0 z) (sqr z)))) (- x (/ (log (+ 1.0 (* z y))) t)))
(- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))