Average Error: 24.8 → 6.6
Time: 1.7m
Precision: 64
Internal Precision: 1920
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
↓
\[\begin{array}{l}
\mathbf{if}\;t \le -7.564860689693754 \cdot 10^{+187}:\\
\;\;\;\;y - \left(y - x\right) \cdot \frac{z}{t}\\
\mathbf{if}\;t \le 8.081559980459926 \cdot 10^{+183}:\\
\;\;\;\;x + \frac{y - x}{1} \cdot \frac{z - t}{a - t}\\
\mathbf{else}:\\
\;\;\;\;y - \left(y - x\right) \cdot \frac{z}{t}\\
\end{array}\]
Target
| Original | 24.8 |
|---|
| Target | 11.0 |
|---|
| Herbie | 6.6 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a \lt -1.6153062845442575 \cdot 10^{-142}:\\
\;\;\;\;x + \frac{y - x}{1} \cdot \frac{z - t}{a - t}\\
\mathbf{if}\;a \lt 3.774403170083174 \cdot 10^{-182}:\\
\;\;\;\;y - \frac{z}{t} \cdot \left(y - x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y - x}{1} \cdot \frac{z - t}{a - t}\\
\end{array}\]
Derivation
- Split input into 2 regimes
if t < -7.564860689693754e+187 or 8.081559980459926e+183 < t
Initial program 50.3
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
Taylor expanded around inf 10.9
\[\leadsto \color{blue}{\left(\frac{z \cdot x}{t} + y\right) - \frac{z \cdot y}{t}}\]
Applied simplify1.4
\[\leadsto \color{blue}{y - \left(y - x\right) \cdot \frac{z}{t}}\]
if -7.564860689693754e+187 < t < 8.081559980459926e+183
Initial program 17.2
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
- Using strategy
rm Applied *-un-lft-identity17.2
\[\leadsto x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{\color{blue}{1 \cdot \left(a - t\right)}}\]
Applied times-frac8.1
\[\leadsto x + \color{blue}{\frac{y - x}{1} \cdot \frac{z - t}{a - 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
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.Axis.Types:linMap from Chart-1.5.3"
:herbie-target
(if (< a -1.6153062845442575e-142) (+ x (* (/ (- y x) 1) (/ (- z t) (- a t)))) (if (< a 3.774403170083174e-182) (- y (* (/ z t) (- y x))) (+ x (* (/ (- y x) 1) (/ (- z t) (- a t))))))
(+ x (/ (* (- y x) (- z t)) (- a t))))