Average Error: 14.6 → 0.3
Time: 39.5s
Precision: 64
Internal Precision: 384
\[\frac{\left(x \cdot 2.0\right) \cdot y}{x - y}\]
↓
\[\begin{array}{l}
\mathbf{if}\;y \le -1.0358178646774055 \cdot 10^{-67}:\\
\;\;\;\;\frac{x \cdot 2.0}{1} \cdot \frac{y}{x - y}\\
\mathbf{if}\;y \le 4.295395118047257 \cdot 10^{-19}:\\
\;\;\;\;\frac{x}{x - y} \cdot \frac{2.0}{\frac{1}{y}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot 2.0}{\frac{x - y}{y}}\\
\end{array}\]
Target
| Original | 14.6 |
|---|
| Target | 0.3 |
|---|
| Herbie | 0.3 |
|---|
\[\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 3 regimes
if y < -1.0358178646774055e-67
Initial program 12.6
\[\frac{\left(x \cdot 2.0\right) \cdot y}{x - y}\]
- Using strategy
rm Applied *-un-lft-identity12.6
\[\leadsto \frac{\left(x \cdot 2.0\right) \cdot y}{\color{blue}{1 \cdot \left(x - y\right)}}\]
Applied times-frac0.4
\[\leadsto \color{blue}{\frac{x \cdot 2.0}{1} \cdot \frac{y}{x - y}}\]
if -1.0358178646774055e-67 < y < 4.295395118047257e-19
Initial program 15.7
\[\frac{\left(x \cdot 2.0\right) \cdot y}{x - y}\]
- Using strategy
rm Applied associate-/l*16.6
\[\leadsto \color{blue}{\frac{x \cdot 2.0}{\frac{x - y}{y}}}\]
- Using strategy
rm Applied div-inv16.8
\[\leadsto \frac{x \cdot 2.0}{\color{blue}{\left(x - y\right) \cdot \frac{1}{y}}}\]
Applied times-frac0.2
\[\leadsto \color{blue}{\frac{x}{x - y} \cdot \frac{2.0}{\frac{1}{y}}}\]
if 4.295395118047257e-19 < y
Initial program 15.2
\[\frac{\left(x \cdot 2.0\right) \cdot y}{x - y}\]
- Using strategy
rm Applied associate-/l*0.2
\[\leadsto \color{blue}{\frac{x \cdot 2.0}{\frac{x - y}{y}}}\]
- Recombined 3 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)
:name "Linear.Projection:perspective from linear-1.19.1.3, B"
:herbie-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)))