Average Error: 1.9 → 2.1
Time: 1.5m
Precision: 64
Internal Precision: 384
\[\frac{x}{y} \cdot \left(z - t\right) + t\]
↓
\[\begin{array}{l}
\mathbf{if}\;t \le -4.436992858070483 \cdot 10^{-38}:\\
\;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\
\mathbf{if}\;t \le 1.4830043097274956 \cdot 10^{-188}:\\
\;\;\;\;\left(x \cdot \left(z - t\right)\right) \cdot \frac{1}{y} + t\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\
\end{array}\]
Target
| Original | 1.9 |
|---|
| Target | 2.2 |
|---|
| Herbie | 2.1 |
|---|
\[\begin{array}{l}
\mathbf{if}\;z \lt 2.759456554562692 \cdot 10^{-282}:\\
\;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\
\mathbf{if}\;z \lt 2.326994450874436 \cdot 10^{-110}:\\
\;\;\;\;x \cdot \frac{z - t}{y} + t\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\
\end{array}\]
Derivation
- Split input into 2 regimes
if t < -4.436992858070483e-38 or 1.4830043097274956e-188 < t
Initial program 0.7
\[\frac{x}{y} \cdot \left(z - t\right) + t\]
if -4.436992858070483e-38 < t < 1.4830043097274956e-188
Initial program 4.2
\[\frac{x}{y} \cdot \left(z - t\right) + t\]
- Using strategy
rm Applied associate-*l/4.7
\[\leadsto \color{blue}{\frac{x \cdot \left(z - t\right)}{y}} + t\]
- Using strategy
rm Applied div-inv4.8
\[\leadsto \color{blue}{\left(x \cdot \left(z - t\right)\right) \cdot \frac{1}{y}} + t\]
- Recombined 2 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 "Numeric.Signal.Multichannel:$cget from hsignal-0.2.7.1"
:herbie-target
(if (< z 2.759456554562692e-282) (+ (* (/ x y) (- z t)) t) (if (< z 2.326994450874436e-110) (+ (* x (/ (- z t) y)) t) (+ (* (/ x y) (- z t)) t)))
(+ (* (/ x y) (- z t)) t))