?

Average Error: 27.2 → 0.3
Time: 10.9s
Precision: binary64
Cost: 960

?

\[\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] = \mathsf{sort}([x, y])\\ \end{array} \]
\[\frac{x \cdot x + y \cdot y}{z \cdot z} \]
\[\frac{\frac{y}{z}}{\frac{z}{y}} + \frac{x}{z} \cdot \frac{x}{z} \]
(FPCore (x y z) :precision binary64 (/ (+ (* x x) (* y y)) (* z z)))
(FPCore (x y z)
 :precision binary64
 (+ (/ (/ y z) (/ z y)) (* (/ x z) (/ x z))))
double code(double x, double y, double z) {
	return ((x * x) + (y * y)) / (z * z);
}
double code(double x, double y, double z) {
	return ((y / z) / (z / y)) + ((x / z) * (x / z));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((x * x) + (y * y)) / (z * z)
end function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((y / z) / (z / y)) + ((x / z) * (x / z))
end function
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 ((y / z) / (z / y)) + ((x / z) * (x / z));
}
def code(x, y, z):
	return ((x * x) + (y * y)) / (z * z)
def code(x, y, z):
	return ((y / z) / (z / y)) + ((x / z) * (x / z))
function code(x, y, z)
	return Float64(Float64(Float64(x * x) + Float64(y * y)) / Float64(z * z))
end
function code(x, y, z)
	return Float64(Float64(Float64(y / z) / Float64(z / y)) + Float64(Float64(x / z) * Float64(x / z)))
end
function tmp = code(x, y, z)
	tmp = ((x * x) + (y * y)) / (z * z);
end
function tmp = code(x, y, z)
	tmp = ((y / z) / (z / y)) + ((x / z) * (x / z));
end
code[x_, y_, z_] := N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] / N[(z * z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(N[(N[(y / z), $MachinePrecision] / N[(z / y), $MachinePrecision]), $MachinePrecision] + N[(N[(x / z), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x \cdot x + y \cdot y}{z \cdot z}
\frac{\frac{y}{z}}{\frac{z}{y}} + \frac{x}{z} \cdot \frac{x}{z}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 27.2

    \[\frac{x \cdot x + y \cdot y}{z \cdot z} \]
  2. Taylor expanded in x around 0 27.2

    \[\leadsto \color{blue}{\frac{{y}^{2}}{{z}^{2}} + \frac{{x}^{2}}{{z}^{2}}} \]
  3. Simplified0.4

    \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{y}{z} + \frac{x}{z} \cdot \frac{x}{z}} \]
    Proof

    [Start]27.2

    \[ \frac{{y}^{2}}{{z}^{2}} + \frac{{x}^{2}}{{z}^{2}} \]

    unpow2 [=>]27.2

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

    unpow2 [=>]27.2

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

    times-frac [=>]16.9

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

    unpow2 [=>]16.9

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

    unpow2 [=>]16.9

    \[ \frac{y}{z} \cdot \frac{y}{z} + \frac{x \cdot x}{\color{blue}{z \cdot z}} \]

    times-frac [=>]0.4

    \[ \frac{y}{z} \cdot \frac{y}{z} + \color{blue}{\frac{x}{z} \cdot \frac{x}{z}} \]
  4. Applied egg-rr0.3

    \[\leadsto \color{blue}{\frac{\frac{y}{z}}{\frac{z}{y}}} + \frac{x}{z} \cdot \frac{x}{z} \]
  5. Final simplification0.3

    \[\leadsto \frac{\frac{y}{z}}{\frac{z}{y}} + \frac{x}{z} \cdot \frac{x}{z} \]

Alternatives

Alternative 1
Error3.3
Cost1224
\[\begin{array}{l} \mathbf{if}\;x \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{z}{x}}\\ \mathbf{elif}\;x \leq -6.4 \cdot 10^{-141}:\\ \;\;\;\;\frac{1}{z} \cdot \left(\frac{x \cdot x}{z} + y \cdot \frac{y}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{y}{z}\\ \end{array} \]
Alternative 2
Error7.2
Cost968
\[\begin{array}{l} \mathbf{if}\;x \leq -1.9 \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
Error0.4
Cost960
\[\frac{x}{z} \cdot \frac{x}{z} + \frac{y}{z} \cdot \frac{y}{z} \]
Alternative 4
Error8.1
Cost580
\[\begin{array}{l} \mathbf{if}\;x \leq -1.3 \cdot 10^{-80}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{y}{z}\\ \end{array} \]
Alternative 5
Error8.0
Cost580
\[\begin{array}{l} \mathbf{if}\;x \leq -9.2 \cdot 10^{-81}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{y}{z}\\ \end{array} \]
Alternative 6
Error23.5
Cost448
\[\frac{x}{z} \cdot \frac{x}{z} \]

Error

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)))