Average Error: 12.4 → 2.0
Time: 13.8s
Precision: 64
Internal precision: 128
\[\frac{x \cdot \left(y - z\right)}{y}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \le 2.0215657871095714 \cdot 10^{+19}:\\
\;\;\;\;x - \frac{z}{y} \cdot x\\
\mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \le 8.388051692914339 \cdot 10^{+250}:\\
\;\;\;\;x - \frac{z \cdot x}{y}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{z}{y} \cdot x\\
\end{array}\]
Target
| Original | 12.4 |
| Comparison | 3.1 |
| Herbie | 2.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 (/ (* x (- y z)) y) < 2.0215657871095714e+19 or 8.388051692914339e+250 < (/ (* x (- y z)) y)
Initial program 14.7
\[\frac{x \cdot \left(y - z\right)}{y}\]
Applied taylor 5.7
\[\leadsto x - \frac{z \cdot x}{y}\]
Taylor expanded around 0 5.7
\[\leadsto \color{blue}{x - \frac{z \cdot x}{y}}\]
- Using strategy
rm
Applied associate-/l* 4.4
\[\leadsto x - \color{blue}{\frac{z}{\frac{y}{x}}}\]
- Using strategy
rm
Applied associate-/r/ 2.3
\[\leadsto x - \color{blue}{\frac{z}{y} \cdot x}\]
if 2.0215657871095714e+19 < (/ (* x (- y z)) y) < 8.388051692914339e+250
Initial program 0.2
\[\frac{x \cdot \left(y - z\right)}{y}\]
Applied taylor 0.1
\[\leadsto x - \frac{z \cdot x}{y}\]
Taylor expanded around 0 0.1
\[\leadsto \color{blue}{x - \frac{z \cdot x}{y}}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(2326311576 2153080410 3212614167 3035849282 4056716154 2223879648)'
(FPCore (x y z)
:name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
: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))