| Alternative 1 | |
|---|---|
| Accuracy | 81.2% |
| Cost | 260 |
\[\begin{array}{l}
\mathbf{if}\;\mathsf{<=.f64}\left(x, -16500000000000000528482304\right):\\
\;\;\;\;\mathsf{neg.f64}\left(x\right)\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\]
(FPCore (x y z) :precision binary64 (sqrt.f64 (+.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z))))
(FPCore (x y z) :precision binary64 (hypot.f64 z x))
\mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(z, z\right)\right)\right)
\mathsf{hypot.f64}\left(z, x\right)
| Original | 40.9% |
|---|---|
| Target | 69.5% |
| Herbie | 99.2% |
Initial program 40.9%
Taylor expanded in y around 0 40.5%
Simplified99.2%
[Start]40.5 | \[ \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\mathsf{pow.f64}\left(z, 2\right), \mathsf{pow.f64}\left(x, 2\right)\right)\right)
\] |
|---|---|
unpow2 [=>]40.5 | \[ \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\color{blue}{\mathsf{*.f64}\left(z, z\right)}, \mathsf{pow.f64}\left(x, 2\right)\right)\right)
\] |
unpow2 [=>]40.5 | \[ \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(z, z\right), \color{blue}{\mathsf{*.f64}\left(x, x\right)}\right)\right)
\] |
hypot-def [=>]99.2 | \[ \color{blue}{\mathsf{hypot.f64}\left(z, x\right)}
\] |
Final simplification99.2%
| Alternative 1 | |
|---|---|
| Accuracy | 81.2% |
| Cost | 260 |
| Alternative 2 | |
|---|---|
| Accuracy | 51.2% |
| Cost | 64 |
herbie shell --seed 2023144
(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))))