Average Error: 12.0 → 2.5
Time: 31.5s
Precision: 64
Internal Precision: 384
\[\frac{x \cdot \left(y - z\right)}{y}\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \le -1.7878811049930048 \cdot 10^{-150}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\
\mathbf{if}\;x \le 7.043732350482196 \cdot 10^{-293}:\\
\;\;\;\;x - \frac{z \cdot x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\
\end{array}\]
Target
| Original | 12.0 |
|---|
| Target | 2.8 |
|---|
| Herbie | 2.5 |
|---|
\[\begin{array}{l}
\mathbf{if}\;z \lt -2.060202331921739 \cdot 10^{+104}:\\
\;\;\;\;x - \frac{z \cdot x}{y}\\
\mathbf{if}\;z \lt 1.6939766013828526 \cdot 10^{+213}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\
\mathbf{else}:\\
\;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\
\end{array}\]
Derivation
- Split input into 2 regimes
if x < -1.7878811049930048e-150 or 7.043732350482196e-293 < x
Initial program 12.8
\[\frac{x \cdot \left(y - z\right)}{y}\]
- Using strategy
rm Applied associate-/l*2.2
\[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
if -1.7878811049930048e-150 < x < 7.043732350482196e-293
Initial program 7.8
\[\frac{x \cdot \left(y - z\right)}{y}\]
Taylor expanded around 0 4.1
\[\leadsto \color{blue}{x - \frac{z \cdot x}{y}}\]
- 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)
:name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
:herbie-target
(if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))
(/ (* x (- y z)) y))