Average Error: 35.7 → 21.1
Time: 43.6s
Precision: 64
Internal Precision: 384
\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \le -1.2462366172629023 \cdot 10^{+154}:\\
\;\;\;\;-x\\
\mathbf{if}\;x \le 1.8809713604828146 \cdot 10^{+158}:\\
\;\;\;\;\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}\]
Target
| Original | 35.7 |
|---|
| Target | 25.5 |
|---|
| Herbie | 21.1 |
|---|
\[\begin{array}{l}
\mathbf{if}\;z \lt -6.396479394109776 \cdot 10^{+136}:\\
\;\;\;\;-z\\
\mathbf{if}\;z \lt 7.320293694404182 \cdot 10^{+117}:\\
\;\;\;\;\sqrt{\left(z \cdot z + x \cdot x\right) + y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}\]
Derivation
- Split input into 3 regimes
if x < -1.2462366172629023e+154
Initial program 59.5
\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
Taylor expanded around -inf 0
\[\leadsto \color{blue}{-1 \cdot x}\]
Applied simplify0
\[\leadsto \color{blue}{-x}\]
if -1.2462366172629023e+154 < x < 1.8809713604828146e+158
Initial program 27.9
\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
if 1.8809713604828146e+158 < x
Initial program 59.5
\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
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 +o reduce:binary-search
(FPCore (x y z)
:name "FRP.Yampa.Vector3:vector3Rho from Yampa-0.10.2"
:herbie-target
(if (< z -6.396479394109776e+136) (- z) (if (< z 7.320293694404182e+117) (sqrt (+ (+ (* z z) (* x x)) (* y y))) z))
(sqrt (+ (+ (* x x) (* y y)) (* z z))))