\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
↓
\[\begin{array}{l}
\mathbf{if}\;z \leq -4.488947755092404 \cdot 10^{+128}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 3.9888983964713314 \cdot 10^{+60}:\\
\;\;\;\;\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}\]
\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}
↓
\begin{array}{l}
\mathbf{if}\;z \leq -4.488947755092404 \cdot 10^{+128}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 3.9888983964713314 \cdot 10^{+60}:\\
\;\;\;\;\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
(FPCore (x y z) :precision binary64 (sqrt (+ (+ (* x x) (* y y)) (* z z))))
↓
(FPCore (x y z)
:precision binary64
(if (<= z -4.488947755092404e+128)
(- z)
(if (<= z 3.9888983964713314e+60)
(sqrt (+ (+ (* x x) (* y y)) (* z z)))
z)))
\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
Taylor expanded around -inf 15.3
\[\leadsto \color{blue}{-1 \cdot z}\]
Simplified15.3
\[\leadsto \color{blue}{-z}\]
Simplified15.3
\[\leadsto \color{blue}{-z}\]
if -4.48894775509240362e128 < z < 3.9888983964713314e60
Initial program 29.3
\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
Simplified29.3
\[\leadsto \color{blue}{\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}}\]
if 3.9888983964713314e60 < z
Initial program 50.5
\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
Taylor expanded around inf 20.5
\[\leadsto \color{blue}{z}\]
Simplified20.5
\[\leadsto \color{blue}{z}\]
Recombined 3 regimes into one program.
Final simplification25.5
\[\leadsto \begin{array}{l}
\mathbf{if}\;z \leq -4.488947755092404 \cdot 10^{+128}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 3.9888983964713314 \cdot 10^{+60}:\\
\;\;\;\;\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}\]
Reproduce
herbie shell --seed 2021044
(FPCore (x y z)
:name "FRP.Yampa.Vector3:vector3Rho from Yampa-0.10.2"
:precision binary64
: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))))