Average Error: 37.3 → 0.0
Time: 9.6s
Precision: 64
\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
\[\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)\]
\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}
\mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)
double f(double x, double y, double z) {
        double r489371 = x;
        double r489372 = r489371 * r489371;
        double r489373 = y;
        double r489374 = r489373 * r489373;
        double r489375 = r489372 + r489374;
        double r489376 = z;
        double r489377 = r489376 * r489376;
        double r489378 = r489375 + r489377;
        double r489379 = sqrt(r489378);
        return r489379;
}

double f(double x, double y, double z) {
        double r489380 = x;
        double r489381 = y;
        double r489382 = hypot(r489380, r489381);
        double r489383 = z;
        double r489384 = hypot(r489382, r489383);
        return r489384;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original37.3
Target24.7
Herbie0.0
\[\begin{array}{l} \mathbf{if}\;z \lt -6.396479394109775845820908799933348003545 \cdot 10^{136}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \lt 7.320293694404182125923160810847974073098 \cdot 10^{117}:\\ \;\;\;\;\sqrt{\left(z \cdot z + x \cdot x\right) + y \cdot y}\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array}\]

Derivation

  1. Initial program 37.3

    \[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
  2. Using strategy rm
  3. Applied add-sqr-sqrt37.3

    \[\leadsto \sqrt{\color{blue}{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}} + z \cdot z}\]
  4. Applied hypot-def27.9

    \[\leadsto \color{blue}{\mathsf{hypot}\left(\sqrt{x \cdot x + y \cdot y}, z\right)}\]
  5. Using strategy rm
  6. Applied hypot-def0.0

    \[\leadsto \mathsf{hypot}\left(\color{blue}{\mathsf{hypot}\left(x, y\right)}, z\right)\]
  7. Final simplification0.0

    \[\leadsto \mathsf{hypot}\left(\mathsf{hypot}\left(x, y\right), z\right)\]

Reproduce

herbie shell --seed 2019303 +o rules:numerics
(FPCore (x y z)
  :name "FRP.Yampa.Vector3:vector3Rho from Yampa-0.10.2"
  :precision binary64

  :herbie-target
  (if (< z -6.3964793941097758e136) (- z) (if (< z 7.3202936944041821e117) (sqrt (+ (+ (* z z) (* x x)) (* y y))) z))

  (sqrt (+ (+ (* x x) (* y y)) (* z z))))