Average Error: 38.1 → 0.0
Time: 18.1s
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 r482899 = x;
        double r482900 = r482899 * r482899;
        double r482901 = y;
        double r482902 = r482901 * r482901;
        double r482903 = r482900 + r482902;
        double r482904 = z;
        double r482905 = r482904 * r482904;
        double r482906 = r482903 + r482905;
        double r482907 = sqrt(r482906);
        return r482907;
}

double f(double x, double y, double z) {
        double r482908 = x;
        double r482909 = y;
        double r482910 = hypot(r482908, r482909);
        double r482911 = z;
        double r482912 = hypot(r482910, r482911);
        return r482912;
}

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

Original38.1
Target25.4
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 38.1

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

    \[\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-def28.7

    \[\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 2019304 +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))))