Average Error: 35.7 → 21.0
Time: 29.8s
Precision: 64
Internal Precision: 384
\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \le -2.013881564242057 \cdot 10^{+151}:\\
\;\;\;\;-x\\
\mathbf{if}\;x \le 1.6698180397332825 \cdot 10^{+161}:\\
\;\;\;\;\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}\]
Target
| Original | 35.7 |
|---|
| Target | 25.4 |
|---|
| Herbie | 21.0 |
|---|
\[\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 < -2.013881564242057e+151
Initial program 59.1
\[\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 -2.013881564242057e+151 < x < 1.6698180397332825e+161
Initial program 27.9
\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
if 1.6698180397332825e+161 < 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
(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))))