Average Error: 12.0 → 2.9
Time: 31.5s
Precision: 64
Internal Precision: 384
\[\frac{x \cdot \left(y - z\right)}{y}\]
↓
\[\begin{array}{l}
\mathbf{if}\;y \le -5.751058404072405 \cdot 10^{-38}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\
\mathbf{if}\;y \le -4.4149063663654 \cdot 10^{-296}:\\
\;\;\;\;\frac{\frac{x}{y}}{\frac{1}{y - z}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\
\end{array}\]
Target
| Original | 12.0 |
|---|
| Target | 2.8 |
|---|
| Herbie | 2.9 |
|---|
\[\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 y < -5.751058404072405e-38 or -4.4149063663654e-296 < y
Initial program 13.0
\[\frac{x \cdot \left(y - z\right)}{y}\]
- Using strategy
rm Applied associate-/l*1.9
\[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
if -5.751058404072405e-38 < y < -4.4149063663654e-296
Initial program 7.3
\[\frac{x \cdot \left(y - z\right)}{y}\]
- Using strategy
rm Applied associate-/l*8.3
\[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
- Using strategy
rm Applied div-inv8.4
\[\leadsto \frac{x}{\color{blue}{y \cdot \frac{1}{y - z}}}\]
Applied associate-/r*7.5
\[\leadsto \color{blue}{\frac{\frac{x}{y}}{\frac{1}{y - z}}}\]
- 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)
: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))