Average Error: 38.1 → 0.0
Time: 12.7s
Precision: 64
\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}\]
\[\mathsf{hypot}\left(z, \mathsf{hypot}\left(x, y\right)\right)\]
\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}
\mathsf{hypot}\left(z, \mathsf{hypot}\left(x, y\right)\right)
double f(double x, double y, double z) {
        double r426814 = x;
        double r426815 = r426814 * r426814;
        double r426816 = y;
        double r426817 = r426816 * r426816;
        double r426818 = r426815 + r426817;
        double r426819 = z;
        double r426820 = r426819 * r426819;
        double r426821 = r426818 + r426820;
        double r426822 = sqrt(r426821);
        return r426822;
}

double f(double x, double y, double z) {
        double r426823 = z;
        double r426824 = x;
        double r426825 = y;
        double r426826 = hypot(r426824, r426825);
        double r426827 = hypot(r426823, r426826);
        return r426827;
}

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.3
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. Simplified38.1

    \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(z, z, \mathsf{fma}\left(x, x, y \cdot y\right)\right)}}\]
  3. Using strategy rm
  4. Applied fma-udef38.1

    \[\leadsto \sqrt{\color{blue}{z \cdot z + \mathsf{fma}\left(x, x, y \cdot y\right)}}\]
  5. Using strategy rm
  6. Applied add-sqr-sqrt38.1

    \[\leadsto \sqrt{z \cdot z + \color{blue}{\sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)} \cdot \sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)}}}\]
  7. Applied hypot-def28.5

    \[\leadsto \color{blue}{\mathsf{hypot}\left(z, \sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)}\right)}\]
  8. Using strategy rm
  9. Applied fma-udef28.5

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

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

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

Reproduce

herbie shell --seed 2019323 +o rules:numerics
(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))))