Average Error: 15.2 → 0.2
Time: 12.8s
Precision: 64
Internal precision: 128
\[\frac{\left(x \cdot 2.0\right) \cdot y}{x - y}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;y \le -4.28061768498452 \cdot 10^{-40}:\\
\;\;\;\;\frac{x \cdot 2.0}{\frac{x - y}{y}}\\
\mathbf{if}\;y \le 2.945079413730394 \cdot 10^{-59}:\\
\;\;\;\;\frac{x \cdot 2.0}{x - y} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot 2.0}{\frac{x - y}{y}}\\
\end{array}\]
Target
| Original | 15.2 |
| Comparison | 0.4 |
| Herbie | 0.2 |
\[ \begin{array}{l}
\mathbf{if}\;x \lt -1.7210442634149447 \cdot 10^{+81}:\\
\;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\
\mathbf{if}\;x \lt 8.364504563556443 \cdot 10^{+16}:\\
\;\;\;\;\frac{x \cdot 2.0}{\frac{x - y}{y}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\
\end{array} \]
Derivation
- Split input into 2 regimes.
-
if y < -4.28061768498452e-40 or 2.945079413730394e-59 < y
Initial program 13.6
\[\frac{\left(x \cdot 2.0\right) \cdot y}{x - y}\]
- Using strategy
rm
Applied associate-/l* 0.3
\[\leadsto \color{blue}{\frac{x \cdot 2.0}{\frac{x - y}{y}}}\]
if -4.28061768498452e-40 < y < 2.945079413730394e-59
Initial program 17.3
\[\frac{\left(x \cdot 2.0\right) \cdot y}{x - y}\]
- Using strategy
rm
Applied associate-/l* 16.9
\[\leadsto \color{blue}{\frac{x \cdot 2.0}{\frac{x - y}{y}}}\]
- Using strategy
rm
Applied associate-/r/ 0.1
\[\leadsto \color{blue}{\frac{x \cdot 2.0}{x - y} \cdot y}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(3465518169 3568117505 2285758749 1438489002 4254384245 849122935)'
(FPCore (x y)
:name "Linear.Projection:perspective from linear-1.19.1.3, B"
:target
(if (< x -1.7210442634149447e+81) (* (/ (* 2.0 x) (- x y)) y) (if (< x 8.364504563556443e+16) (/ (* x 2.0) (/ (- x y) y)) (* (/ (* 2.0 x) (- x y)) y)))
(/ (* (* x 2.0) y) (- x y)))