Average Error: 30.0 → 13.9
Time: 13.9s
Precision: 64
Internal Precision: 384
\[\sqrt{x \cdot x + y \cdot y}\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \le -9.5730411458898 \cdot 10^{+118}:\\
\;\;\;\;-x\\
\mathbf{if}\;x \le 2.4528332963254056 \cdot 10^{-195}:\\
\;\;\;\;\sqrt{x \cdot x + y \cdot y}\\
\mathbf{if}\;x \le 4.8611610197161825 \cdot 10^{-177}:\\
\;\;\;\;x\\
\mathbf{if}\;x \le 3.214839002159321 \cdot 10^{+154}:\\
\;\;\;\;\sqrt{x \cdot x + y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}\]
Target
| Original | 30.0 |
|---|
| Target | 15.1 |
|---|
| Herbie | 13.9 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \lt -1.1236950826599826 \cdot 10^{+145}:\\
\;\;\;\;-x\\
\mathbf{if}\;x \lt 1.116557621183362 \cdot 10^{+93}:\\
\;\;\;\;\sqrt{x \cdot x + y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}\]
Derivation
- Split input into 3 regimes
if x < -9.5730411458898e+118
Initial program 51.6
\[\sqrt{x \cdot x + y \cdot y}\]
Taylor expanded around -inf 0
\[\leadsto \color{blue}{-1 \cdot x}\]
Applied simplify0
\[\leadsto \color{blue}{-x}\]
if -9.5730411458898e+118 < x < 2.4528332963254056e-195 or 4.8611610197161825e-177 < x < 3.214839002159321e+154
Initial program 19.6
\[\sqrt{x \cdot x + y \cdot y}\]
if 2.4528332963254056e-195 < x < 4.8611610197161825e-177 or 3.214839002159321e+154 < x
Initial program 59.7
\[\sqrt{x \cdot x + y \cdot y}\]
Taylor expanded around inf 0
\[\leadsto \color{blue}{x}\]
- Recombined 3 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)
:name "Data.Octree.Internal:octantDistance from Octree-0.5.4.2"
:herbie-target
(if (< x -1.1236950826599826e+145) (- x) (if (< x 1.116557621183362e+93) (sqrt (+ (* x x) (* y y))) x))
(sqrt (+ (* x x) (* y y))))