?

Average Error: 38.6 → 0.5
Time: 6.2s
Precision: binary64
Cost: 6528

?

\[\left(\left(-1.79 \cdot 10^{+308} \leq x \land x \leq 1.79 \cdot 10^{+308}\right) \land \left(-1.79 \cdot 10^{+308} \leq y \land y \leq 1.79 \cdot 10^{+308}\right)\right) \land \left(-1.79 \cdot 10^{+308} \leq z \land z \leq 1.79 \cdot 10^{+308}\right)\]
\[ \begin{array}{c}[x, y, z] = \mathsf{sort}([x, y, z])\\ \end{array} \]
\[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z} \]
\[\mathsf{hypot}\left(z, x\right) \]
(FPCore (x y z) :precision binary64 (sqrt (+ (+ (* x x) (* y y)) (* z z))))
(FPCore (x y z) :precision binary64 (hypot z x))
double code(double x, double y, double z) {
	return sqrt((((x * x) + (y * y)) + (z * z)));
}
double code(double x, double y, double z) {
	return hypot(z, x);
}
public static double code(double x, double y, double z) {
	return Math.sqrt((((x * x) + (y * y)) + (z * z)));
}
public static double code(double x, double y, double z) {
	return Math.hypot(z, x);
}
def code(x, y, z):
	return math.sqrt((((x * x) + (y * y)) + (z * z)))
def code(x, y, z):
	return math.hypot(z, x)
function code(x, y, z)
	return sqrt(Float64(Float64(Float64(x * x) + Float64(y * y)) + Float64(z * z)))
end
function code(x, y, z)
	return hypot(z, x)
end
function tmp = code(x, y, z)
	tmp = sqrt((((x * x) + (y * y)) + (z * z)));
end
function tmp = code(x, y, z)
	tmp = hypot(z, x);
end
code[x_, y_, z_] := N[Sqrt[N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_, y_, z_] := N[Sqrt[z ^ 2 + x ^ 2], $MachinePrecision]
\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z}
\mathsf{hypot}\left(z, x\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 38.6

    \[\sqrt{\left(x \cdot x + y \cdot y\right) + z \cdot z} \]
  2. Taylor expanded in y around 0 38.9

    \[\leadsto \color{blue}{\sqrt{{z}^{2} + {x}^{2}}} \]
  3. Simplified0.5

    \[\leadsto \color{blue}{\mathsf{hypot}\left(z, x\right)} \]
    Proof

    [Start]38.9

    \[ \sqrt{{z}^{2} + {x}^{2}} \]

    unpow2 [=>]38.9

    \[ \sqrt{\color{blue}{z \cdot z} + {x}^{2}} \]

    unpow2 [=>]38.9

    \[ \sqrt{z \cdot z + \color{blue}{x \cdot x}} \]

    hypot-def [=>]0.5

    \[ \color{blue}{\mathsf{hypot}\left(z, x\right)} \]
  4. Final simplification0.5

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

Alternatives

Alternative 1
Error13.4
Cost6924
\[\begin{array}{l} \mathbf{if}\;z \leq 2.4 \cdot 10^{-10}:\\ \;\;\;\;\mathsf{hypot}\left(y, x\right)\\ \mathbf{elif}\;z \leq 7200000000000:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{+93}:\\ \;\;\;\;\mathsf{hypot}\left(y, x\right)\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 2
Error13.8
Cost524
\[\begin{array}{l} \mathbf{if}\;z \leq 8 \cdot 10^{-11}:\\ \;\;\;\;-x\\ \mathbf{elif}\;z \leq 4 \cdot 10^{+33}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{+93}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 3
Error30.4
Cost64
\[z \]

Error

Reproduce?

herbie shell --seed 1 
(FPCore (x y z)
  :name "sqrt(x*x + y*y + z*z)"
  :precision binary64
  :pre (and (and (and (<= -1.79e+308 x) (<= x 1.79e+308)) (and (<= -1.79e+308 y) (<= y 1.79e+308))) (and (<= -1.79e+308 z) (<= z 1.79e+308)))
  (sqrt (+ (+ (* x x) (* y y)) (* z z))))