Average Error: 12.0 → 3.0
Time: 27.4s
Precision: 64
Internal Precision: 384
\[\frac{x \cdot \left(y - z\right)}{y}\]
↓
\[\begin{array}{l}
\mathbf{if}\;y \le -5.235037785810511 \cdot 10^{-38}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\
\mathbf{if}\;y \le -1.6124878300552078 \cdot 10^{-296}:\\
\;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\
\end{array}\]
Target
| Original | 12.0 |
|---|
| Target | 2.8 |
|---|
| Herbie | 3.0 |
|---|
\[\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.235037785810511e-38 or -1.6124878300552078e-296 < y
Initial program 13.0
\[\frac{x \cdot \left(y - z\right)}{y}\]
- Using strategy
rm Applied associate-/l*2.0
\[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
if -5.235037785810511e-38 < y < -1.6124878300552078e-296
Initial program 7.2
\[\frac{x \cdot \left(y - z\right)}{y}\]
Taylor expanded around 0 7.2
\[\leadsto \frac{\color{blue}{y \cdot x - z \cdot x}}{y}\]
Applied simplify7.7
\[\leadsto \color{blue}{\left(y - z\right) \cdot \frac{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))