# ?

Average Error: 20.3 → 0.3
Time: 11.9s
Precision: binary64
Cost: 13376

# ?

$\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)$
$\frac{\frac{x \cdot x + y \cdot y}{z}}{z}$
$\frac{\frac{\mathsf{hypot}\left(x, y\right)}{z}}{\frac{z}{\mathsf{hypot}\left(x, y\right)}}$
(FPCore (x y z) :precision binary64 (/ (/ (+ (* x x) (* y y)) z) z))
(FPCore (x y z) :precision binary64 (/ (/ (hypot x y) z) (/ z (hypot x y))))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) / z) / z;
}
double code(double x, double y, double z) {
return (hypot(x, y) / z) / (z / hypot(x, y));
}
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) / z) / z;
}
public static double code(double x, double y, double z) {
return (Math.hypot(x, y) / z) / (z / Math.hypot(x, y));
}
def code(x, y, z):
return (((x * x) + (y * y)) / z) / z
def code(x, y, z):
return (math.hypot(x, y) / z) / (z / math.hypot(x, y))
function code(x, y, z)
return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) / z) / z)
end
function code(x, y, z)
return Float64(Float64(hypot(x, y) / z) / Float64(z / hypot(x, y)))
end
function tmp = code(x, y, z)
tmp = (((x * x) + (y * y)) / z) / z;
end
function tmp = code(x, y, z)
tmp = (hypot(x, y) / z) / (z / hypot(x, y));
end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y),$MachinePrecision]), $MachinePrecision] / z),$MachinePrecision] / z), $MachinePrecision] code[x_, y_, z_] := N[(N[(N[Sqrt[x ^ 2 + y ^ 2],$MachinePrecision] / z), $MachinePrecision] / N[(z / N[Sqrt[x ^ 2 + y ^ 2],$MachinePrecision]), $MachinePrecision]),$MachinePrecision]
\frac{\frac{x \cdot x + y \cdot y}{z}}{z}
\frac{\frac{\mathsf{hypot}\left(x, y\right)}{z}}{\frac{z}{\mathsf{hypot}\left(x, y\right)}}

# Try it out?

Results

 In Out
Enter valid numbers for all inputs

# Derivation?

1. Initial program 20.3

$\frac{\frac{x \cdot x + y \cdot y}{z}}{z}$
2. Applied egg-rr22.1

$\leadsto \color{blue}{e^{\mathsf{log1p}\left({\left(\frac{\mathsf{hypot}\left(x, y\right)}{z}\right)}^{2}\right)} - 1}$
3. Simplified0.4

$\leadsto \color{blue}{{\left(\frac{\mathsf{hypot}\left(x, y\right)}{z}\right)}^{2}}$
Proof
[Start]22.1 $e^{\mathsf{log1p}\left({\left(\frac{\mathsf{hypot}\left(x, y\right)}{z}\right)}^{2}\right)} - 1$ $\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\frac{\mathsf{hypot}\left(x, y\right)}{z}\right)}^{2}\right)\right)}$ $\color{blue}{{\left(\frac{\mathsf{hypot}\left(x, y\right)}{z}\right)}^{2}}$
4. Applied egg-rr0.3

$\leadsto \color{blue}{\frac{\frac{\mathsf{hypot}\left(x, y\right)}{z}}{\frac{z}{\mathsf{hypot}\left(x, y\right)}}}$
5. Final simplification0.3

$\leadsto \frac{\frac{\mathsf{hypot}\left(x, y\right)}{z}}{\frac{z}{\mathsf{hypot}\left(x, y\right)}}$

# Alternatives

Alternative 1
Error0.4
Cost13120
${\left(\frac{\mathsf{hypot}\left(x, y\right)}{z}\right)}^{2}$
Alternative 2
Error16.9
Cost968
$\begin{array}{l} \mathbf{if}\;x \leq -3 \cdot 10^{+33}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{z}{x}}\\ \mathbf{elif}\;x \leq -4.8 \cdot 10^{-139}:\\ \;\;\;\;\frac{x \cdot x + y \cdot y}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{y}{z}\\ \end{array}$
Alternative 3
Error15.4
Cost968
$\begin{array}{l} \mathbf{if}\;x \leq -8 \cdot 10^{+100}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{z}{x}}\\ \mathbf{elif}\;x \leq -4.8 \cdot 10^{-139}:\\ \;\;\;\;\frac{\frac{x \cdot x + y \cdot y}{z}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{y}{z}\\ \end{array}$
Alternative 4
Error0.4
Cost960
$\frac{y}{z} \cdot \frac{y}{z} + \frac{x}{z} \cdot \frac{x}{z}$
Alternative 5
Error17.7
Cost580
$\begin{array}{l} \mathbf{if}\;x \leq -1.42 \cdot 10^{-80}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{y}{z}\\ \end{array}$
Alternative 6
Error17.7
Cost580
$\begin{array}{l} \mathbf{if}\;x \leq -7.4 \cdot 10^{-82}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{y}{z}\\ \end{array}$
Alternative 7
Error24.2
Cost448
$\frac{x}{z} \cdot \frac{x}{z}$

# Reproduce?

herbie shell --seed 1
(FPCore (x y z)
:name "(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)))
(/ (/ (+ (* x x) (* y y)) z) z))