
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
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)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
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)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
(FPCore (x y z) :precision binary64 (* 0.5 (+ y (/ (+ x z) (/ y (- x z))))))
double code(double x, double y, double z) {
return 0.5 * (y + ((x + z) / (y / (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 = 0.5d0 * (y + ((x + z) / (y / (x - z))))
end function
public static double code(double x, double y, double z) {
return 0.5 * (y + ((x + z) / (y / (x - z))));
}
def code(x, y, z): return 0.5 * (y + ((x + z) / (y / (x - z))))
function code(x, y, z) return Float64(0.5 * Float64(y + Float64(Float64(x + z) / Float64(y / Float64(x - z))))) end
function tmp = code(x, y, z) tmp = 0.5 * (y + ((x + z) / (y / (x - z)))); end
code[x_, y_, z_] := N[(0.5 * N[(y + N[(N[(x + z), $MachinePrecision] / N[(y / N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(y + \frac{x + z}{\frac{y}{x - z}}\right)
\end{array}
Initial program 67.5%
Taylor expanded in x around inf 74.5%
distribute-lft-out74.5%
+-commutative74.5%
unpow274.5%
unpow274.5%
associate-/l*81.9%
Simplified81.9%
Taylor expanded in x around 0 74.5%
associate--l+74.5%
div-sub80.3%
unpow280.3%
unpow280.3%
difference-of-squares86.6%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= (* x x) 5e-154)
(* z (* z (/ -0.5 y)))
(if (<= (* x x) 5e-79)
(* 0.5 y)
(if (<= (* x x) 0.02)
(* z (* (/ z y) -0.5))
(if (<= (* x x) 1e+155) (* 0.5 y) (* x (/ x (* y 2.0))))))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e-154) {
tmp = z * (z * (-0.5 / y));
} else if ((x * x) <= 5e-79) {
tmp = 0.5 * y;
} else if ((x * x) <= 0.02) {
tmp = z * ((z / y) * -0.5);
} else if ((x * x) <= 1e+155) {
tmp = 0.5 * y;
} else {
tmp = x * (x / (y * 2.0));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x * x) <= 5d-154) then
tmp = z * (z * ((-0.5d0) / y))
else if ((x * x) <= 5d-79) then
tmp = 0.5d0 * y
else if ((x * x) <= 0.02d0) then
tmp = z * ((z / y) * (-0.5d0))
else if ((x * x) <= 1d+155) then
tmp = 0.5d0 * y
else
tmp = x * (x / (y * 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e-154) {
tmp = z * (z * (-0.5 / y));
} else if ((x * x) <= 5e-79) {
tmp = 0.5 * y;
} else if ((x * x) <= 0.02) {
tmp = z * ((z / y) * -0.5);
} else if ((x * x) <= 1e+155) {
tmp = 0.5 * y;
} else {
tmp = x * (x / (y * 2.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 5e-154: tmp = z * (z * (-0.5 / y)) elif (x * x) <= 5e-79: tmp = 0.5 * y elif (x * x) <= 0.02: tmp = z * ((z / y) * -0.5) elif (x * x) <= 1e+155: tmp = 0.5 * y else: tmp = x * (x / (y * 2.0)) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 5e-154) tmp = Float64(z * Float64(z * Float64(-0.5 / y))); elseif (Float64(x * x) <= 5e-79) tmp = Float64(0.5 * y); elseif (Float64(x * x) <= 0.02) tmp = Float64(z * Float64(Float64(z / y) * -0.5)); elseif (Float64(x * x) <= 1e+155) tmp = Float64(0.5 * y); else tmp = Float64(x * Float64(x / Float64(y * 2.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 5e-154) tmp = z * (z * (-0.5 / y)); elseif ((x * x) <= 5e-79) tmp = 0.5 * y; elseif ((x * x) <= 0.02) tmp = z * ((z / y) * -0.5); elseif ((x * x) <= 1e+155) tmp = 0.5 * y; else tmp = x * (x / (y * 2.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e-154], N[(z * N[(z * N[(-0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 5e-79], N[(0.5 * y), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 0.02], N[(z * N[(N[(z / y), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e+155], N[(0.5 * y), $MachinePrecision], N[(x * N[(x / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-154}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-79}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;x \cdot x \leq 0.02:\\
\;\;\;\;z \cdot \left(\frac{z}{y} \cdot -0.5\right)\\
\mathbf{elif}\;x \cdot x \leq 10^{+155}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{x}{y \cdot 2}\\
\end{array}
\end{array}
if (*.f64 x x) < 5.0000000000000002e-154Initial program 68.9%
Taylor expanded in z around inf 48.9%
mul-1-neg48.9%
unpow248.9%
distribute-rgt-neg-in48.9%
Simplified48.9%
times-frac55.9%
metadata-eval55.9%
frac-2neg55.9%
div-inv55.9%
metadata-eval55.9%
*-commutative55.9%
associate-*r*55.9%
div-inv55.9%
associate-*l*55.9%
metadata-eval55.9%
div-inv55.9%
associate-/l/55.9%
associate-/r*55.9%
metadata-eval55.9%
Applied egg-rr55.9%
if 5.0000000000000002e-154 < (*.f64 x x) < 4.99999999999999999e-79 or 0.0200000000000000004 < (*.f64 x x) < 1.00000000000000001e155Initial program 70.4%
Taylor expanded in y around inf 55.1%
if 4.99999999999999999e-79 < (*.f64 x x) < 0.0200000000000000004Initial program 64.7%
Taylor expanded in z around inf 51.4%
associate-*r/51.4%
unpow251.4%
associate-*r*51.4%
*-commutative51.4%
metadata-eval51.4%
distribute-rgt-neg-in51.4%
associate-*r/57.0%
distribute-rgt-neg-in57.0%
metadata-eval57.0%
associate-*l*57.0%
Simplified57.0%
if 1.00000000000000001e155 < (*.f64 x x) Initial program 65.3%
Taylor expanded in x around inf 64.3%
unpow264.3%
Simplified64.3%
associate-/l*69.0%
associate-/r/69.0%
Applied egg-rr69.0%
Final simplification61.1%
(FPCore (x y z)
:precision binary64
(if (<= (* x x) 5e-154)
(* z (* z (/ -0.5 y)))
(if (<= (* x x) 5e-79)
(* 0.5 y)
(if (<= (* x x) 0.02)
(/ (/ z y) (/ -2.0 z))
(if (<= (* x x) 1e+155) (* 0.5 y) (* x (/ x (* y 2.0))))))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e-154) {
tmp = z * (z * (-0.5 / y));
} else if ((x * x) <= 5e-79) {
tmp = 0.5 * y;
} else if ((x * x) <= 0.02) {
tmp = (z / y) / (-2.0 / z);
} else if ((x * x) <= 1e+155) {
tmp = 0.5 * y;
} else {
tmp = x * (x / (y * 2.0));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x * x) <= 5d-154) then
tmp = z * (z * ((-0.5d0) / y))
else if ((x * x) <= 5d-79) then
tmp = 0.5d0 * y
else if ((x * x) <= 0.02d0) then
tmp = (z / y) / ((-2.0d0) / z)
else if ((x * x) <= 1d+155) then
tmp = 0.5d0 * y
else
tmp = x * (x / (y * 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e-154) {
tmp = z * (z * (-0.5 / y));
} else if ((x * x) <= 5e-79) {
tmp = 0.5 * y;
} else if ((x * x) <= 0.02) {
tmp = (z / y) / (-2.0 / z);
} else if ((x * x) <= 1e+155) {
tmp = 0.5 * y;
} else {
tmp = x * (x / (y * 2.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 5e-154: tmp = z * (z * (-0.5 / y)) elif (x * x) <= 5e-79: tmp = 0.5 * y elif (x * x) <= 0.02: tmp = (z / y) / (-2.0 / z) elif (x * x) <= 1e+155: tmp = 0.5 * y else: tmp = x * (x / (y * 2.0)) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 5e-154) tmp = Float64(z * Float64(z * Float64(-0.5 / y))); elseif (Float64(x * x) <= 5e-79) tmp = Float64(0.5 * y); elseif (Float64(x * x) <= 0.02) tmp = Float64(Float64(z / y) / Float64(-2.0 / z)); elseif (Float64(x * x) <= 1e+155) tmp = Float64(0.5 * y); else tmp = Float64(x * Float64(x / Float64(y * 2.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 5e-154) tmp = z * (z * (-0.5 / y)); elseif ((x * x) <= 5e-79) tmp = 0.5 * y; elseif ((x * x) <= 0.02) tmp = (z / y) / (-2.0 / z); elseif ((x * x) <= 1e+155) tmp = 0.5 * y; else tmp = x * (x / (y * 2.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e-154], N[(z * N[(z * N[(-0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 5e-79], N[(0.5 * y), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 0.02], N[(N[(z / y), $MachinePrecision] / N[(-2.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e+155], N[(0.5 * y), $MachinePrecision], N[(x * N[(x / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-154}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\
\mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-79}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;x \cdot x \leq 0.02:\\
\;\;\;\;\frac{\frac{z}{y}}{\frac{-2}{z}}\\
\mathbf{elif}\;x \cdot x \leq 10^{+155}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{x}{y \cdot 2}\\
\end{array}
\end{array}
if (*.f64 x x) < 5.0000000000000002e-154Initial program 68.9%
Taylor expanded in z around inf 48.9%
mul-1-neg48.9%
unpow248.9%
distribute-rgt-neg-in48.9%
Simplified48.9%
times-frac55.9%
metadata-eval55.9%
frac-2neg55.9%
div-inv55.9%
metadata-eval55.9%
*-commutative55.9%
associate-*r*55.9%
div-inv55.9%
associate-*l*55.9%
metadata-eval55.9%
div-inv55.9%
associate-/l/55.9%
associate-/r*55.9%
metadata-eval55.9%
Applied egg-rr55.9%
if 5.0000000000000002e-154 < (*.f64 x x) < 4.99999999999999999e-79 or 0.0200000000000000004 < (*.f64 x x) < 1.00000000000000001e155Initial program 70.4%
Taylor expanded in y around inf 55.1%
if 4.99999999999999999e-79 < (*.f64 x x) < 0.0200000000000000004Initial program 64.7%
Taylor expanded in z around inf 51.4%
*-commutative51.4%
unpow251.4%
associate-/l*56.9%
Simplified56.9%
associate-/r/57.0%
associate-*l*57.0%
metadata-eval57.0%
div-inv57.0%
frac-2neg57.0%
metadata-eval57.0%
associate-*r/57.0%
associate-/l*57.1%
metadata-eval57.1%
frac-2neg57.1%
Applied egg-rr57.1%
if 1.00000000000000001e155 < (*.f64 x x) Initial program 65.3%
Taylor expanded in x around inf 64.3%
unpow264.3%
Simplified64.3%
associate-/l*69.0%
associate-/r/69.0%
Applied egg-rr69.0%
Final simplification61.1%
(FPCore (x y z)
:precision binary64
(if (<= (* z z) 5e-9)
(* 0.5 (+ y (/ x (/ y x))))
(if (<= (* z z) 2e+307)
(* (/ 0.5 y) (- (* x x) (* z z)))
(* 0.5 (- y (* z (/ z y)))))))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-9) {
tmp = 0.5 * (y + (x / (y / x)));
} else if ((z * z) <= 2e+307) {
tmp = (0.5 / y) * ((x * x) - (z * z));
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 5d-9) then
tmp = 0.5d0 * (y + (x / (y / x)))
else if ((z * z) <= 2d+307) then
tmp = (0.5d0 / y) * ((x * x) - (z * z))
else
tmp = 0.5d0 * (y - (z * (z / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-9) {
tmp = 0.5 * (y + (x / (y / x)));
} else if ((z * z) <= 2e+307) {
tmp = (0.5 / y) * ((x * x) - (z * z));
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 5e-9: tmp = 0.5 * (y + (x / (y / x))) elif (z * z) <= 2e+307: tmp = (0.5 / y) * ((x * x) - (z * z)) else: tmp = 0.5 * (y - (z * (z / y))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e-9) tmp = Float64(0.5 * Float64(y + Float64(x / Float64(y / x)))); elseif (Float64(z * z) <= 2e+307) tmp = Float64(Float64(0.5 / y) * Float64(Float64(x * x) - Float64(z * z))); else tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 5e-9) tmp = 0.5 * (y + (x / (y / x))); elseif ((z * z) <= 2e+307) tmp = (0.5 / y) * ((x * x) - (z * z)); else tmp = 0.5 * (y - (z * (z / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e-9], N[(0.5 * N[(y + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 2e+307], N[(N[(0.5 / y), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-9}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{x}{\frac{y}{x}}\right)\\
\mathbf{elif}\;z \cdot z \leq 2 \cdot 10^{+307}:\\
\;\;\;\;\frac{0.5}{y} \cdot \left(x \cdot x - z \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 5.0000000000000001e-9Initial program 73.8%
Taylor expanded in x around inf 89.7%
distribute-lft-out89.7%
+-commutative89.7%
unpow289.7%
unpow289.7%
associate-/l*90.9%
Simplified90.9%
Taylor expanded in x around 0 89.7%
associate--l+89.7%
div-sub89.7%
unpow289.7%
unpow289.7%
difference-of-squares89.7%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 82.7%
unpow282.7%
associate-/l*91.5%
Simplified91.5%
if 5.0000000000000001e-9 < (*.f64 z z) < 1.99999999999999997e307Initial program 83.4%
Taylor expanded in y around 0 78.8%
unpow278.8%
unpow278.8%
Simplified78.8%
div-inv78.9%
*-commutative78.9%
*-commutative78.9%
associate-/r*78.9%
metadata-eval78.9%
Applied egg-rr78.9%
if 1.99999999999999997e307 < (*.f64 z z) Initial program 43.6%
Taylor expanded in x around inf 44.1%
distribute-lft-out44.1%
+-commutative44.1%
unpow244.1%
unpow244.1%
associate-/l*68.2%
Simplified68.2%
Taylor expanded in x around 0 64.9%
unpow264.9%
associate-*r/89.0%
Simplified89.0%
Final simplification88.0%
(FPCore (x y z) :precision binary64 (if (<= (* z z) 5e-9) (* 0.5 (+ y (/ x (/ y x)))) (/ (/ (+ x z) (/ y (- x z))) 2.0)))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-9) {
tmp = 0.5 * (y + (x / (y / x)));
} else {
tmp = ((x + z) / (y / (x - z))) / 2.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 5d-9) then
tmp = 0.5d0 * (y + (x / (y / x)))
else
tmp = ((x + z) / (y / (x - z))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-9) {
tmp = 0.5 * (y + (x / (y / x)));
} else {
tmp = ((x + z) / (y / (x - z))) / 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 5e-9: tmp = 0.5 * (y + (x / (y / x))) else: tmp = ((x + z) / (y / (x - z))) / 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e-9) tmp = Float64(0.5 * Float64(y + Float64(x / Float64(y / x)))); else tmp = Float64(Float64(Float64(x + z) / Float64(y / Float64(x - z))) / 2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 5e-9) tmp = 0.5 * (y + (x / (y / x))); else tmp = ((x + z) / (y / (x - z))) / 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e-9], N[(0.5 * N[(y + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + z), $MachinePrecision] / N[(y / N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-9}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{x}{\frac{y}{x}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x + z}{\frac{y}{x - z}}}{2}\\
\end{array}
\end{array}
if (*.f64 z z) < 5.0000000000000001e-9Initial program 73.8%
Taylor expanded in x around inf 89.7%
distribute-lft-out89.7%
+-commutative89.7%
unpow289.7%
unpow289.7%
associate-/l*90.9%
Simplified90.9%
Taylor expanded in x around 0 89.7%
associate--l+89.7%
div-sub89.7%
unpow289.7%
unpow289.7%
difference-of-squares89.7%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 82.7%
unpow282.7%
associate-/l*91.5%
Simplified91.5%
if 5.0000000000000001e-9 < (*.f64 z z) Initial program 61.2%
Taylor expanded in y around 0 64.1%
unpow264.1%
unpow264.1%
Simplified64.1%
add-exp-log_binary6432.3%
Applied rewrite-once32.3%
rem-exp-log64.1%
associate-/r*64.1%
difference-of-squares76.6%
associate-/l*83.8%
Simplified83.8%
Final simplification87.6%
(FPCore (x y z) :precision binary64 (if (<= (* z z) 2e+234) (* 0.5 (+ y (* x (/ x y)))) (* z (* (/ z y) -0.5))))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+234) {
tmp = 0.5 * (y + (x * (x / y)));
} else {
tmp = z * ((z / y) * -0.5);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 2d+234) then
tmp = 0.5d0 * (y + (x * (x / y)))
else
tmp = z * ((z / y) * (-0.5d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+234) {
tmp = 0.5 * (y + (x * (x / y)));
} else {
tmp = z * ((z / y) * -0.5);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 2e+234: tmp = 0.5 * (y + (x * (x / y))) else: tmp = z * ((z / y) * -0.5) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e+234) tmp = Float64(0.5 * Float64(y + Float64(x * Float64(x / y)))); else tmp = Float64(z * Float64(Float64(z / y) * -0.5)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 2e+234) tmp = 0.5 * (y + (x * (x / y))); else tmp = z * ((z / y) * -0.5); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+234], N[(0.5 * N[(y + N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(z / y), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+234}:\\
\;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(\frac{z}{y} \cdot -0.5\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 2.00000000000000004e234Initial program 74.7%
Taylor expanded in x around inf 87.2%
distribute-lft-out87.2%
+-commutative87.2%
unpow287.2%
unpow287.2%
associate-/l*88.2%
Simplified88.2%
Taylor expanded in z around 0 77.4%
unpow277.4%
associate-*r/85.2%
Simplified85.2%
if 2.00000000000000004e234 < (*.f64 z z) Initial program 54.3%
Taylor expanded in z around inf 63.7%
associate-*r/63.7%
unpow263.7%
associate-*r*63.7%
*-commutative63.7%
metadata-eval63.7%
distribute-rgt-neg-in63.7%
associate-*r/71.7%
distribute-rgt-neg-in71.7%
metadata-eval71.7%
associate-*l*71.7%
Simplified71.7%
Final simplification80.4%
(FPCore (x y z) :precision binary64 (if (<= (* z z) 4e+180) (* 0.5 y) (* z (* (/ z y) -0.5))))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 4e+180) {
tmp = 0.5 * y;
} else {
tmp = z * ((z / y) * -0.5);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 4d+180) then
tmp = 0.5d0 * y
else
tmp = z * ((z / y) * (-0.5d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 4e+180) {
tmp = 0.5 * y;
} else {
tmp = z * ((z / y) * -0.5);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 4e+180: tmp = 0.5 * y else: tmp = z * ((z / y) * -0.5) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 4e+180) tmp = Float64(0.5 * y); else tmp = Float64(z * Float64(Float64(z / y) * -0.5)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 4e+180) tmp = 0.5 * y; else tmp = z * ((z / y) * -0.5); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 4e+180], N[(0.5 * y), $MachinePrecision], N[(z * N[(N[(z / y), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 4 \cdot 10^{+180}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(\frac{z}{y} \cdot -0.5\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 4e180Initial program 74.1%
Taylor expanded in y around inf 42.9%
if 4e180 < (*.f64 z z) Initial program 57.4%
Taylor expanded in z around inf 61.8%
associate-*r/61.8%
unpow261.8%
associate-*r*61.8%
*-commutative61.8%
metadata-eval61.8%
distribute-rgt-neg-in61.8%
associate-*r/68.9%
distribute-rgt-neg-in68.9%
metadata-eval68.9%
associate-*l*68.9%
Simplified68.9%
Final simplification53.3%
(FPCore (x y z) :precision binary64 (if (<= z 1.3e+120) (* 0.5 (+ y (/ x (/ y x)))) (* z (* (/ z y) -0.5))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1.3e+120) {
tmp = 0.5 * (y + (x / (y / x)));
} else {
tmp = z * ((z / y) * -0.5);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 1.3d+120) then
tmp = 0.5d0 * (y + (x / (y / x)))
else
tmp = z * ((z / y) * (-0.5d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1.3e+120) {
tmp = 0.5 * (y + (x / (y / x)));
} else {
tmp = z * ((z / y) * -0.5);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1.3e+120: tmp = 0.5 * (y + (x / (y / x))) else: tmp = z * ((z / y) * -0.5) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1.3e+120) tmp = Float64(0.5 * Float64(y + Float64(x / Float64(y / x)))); else tmp = Float64(z * Float64(Float64(z / y) * -0.5)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 1.3e+120) tmp = 0.5 * (y + (x / (y / x))); else tmp = z * ((z / y) * -0.5); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1.3e+120], N[(0.5 * N[(y + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(z / y), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.3 \cdot 10^{+120}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{x}{\frac{y}{x}}\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(\frac{z}{y} \cdot -0.5\right)\\
\end{array}
\end{array}
if z < 1.2999999999999999e120Initial program 70.4%
Taylor expanded in x around inf 80.4%
distribute-lft-out80.4%
+-commutative80.4%
unpow280.4%
unpow280.4%
associate-/l*84.9%
Simplified84.9%
Taylor expanded in x around 0 80.4%
associate--l+80.4%
div-sub85.7%
unpow285.7%
unpow285.7%
difference-of-squares88.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 66.3%
unpow266.3%
associate-/l*73.0%
Simplified73.0%
if 1.2999999999999999e120 < z Initial program 54.7%
Taylor expanded in z around inf 61.9%
associate-*r/61.9%
unpow261.9%
associate-*r*61.9%
*-commutative61.9%
metadata-eval61.9%
distribute-rgt-neg-in61.9%
associate-*r/71.3%
distribute-rgt-neg-in71.3%
metadata-eval71.3%
associate-*l*71.3%
Simplified71.3%
Final simplification72.7%
(FPCore (x y z) :precision binary64 (if (<= z 1.06e+86) (* 0.5 (+ y (/ x (/ y x)))) (* 0.5 (- y (* z (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1.06e+86) {
tmp = 0.5 * (y + (x / (y / x)));
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 1.06d+86) then
tmp = 0.5d0 * (y + (x / (y / x)))
else
tmp = 0.5d0 * (y - (z * (z / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1.06e+86) {
tmp = 0.5 * (y + (x / (y / x)));
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1.06e+86: tmp = 0.5 * (y + (x / (y / x))) else: tmp = 0.5 * (y - (z * (z / y))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1.06e+86) tmp = Float64(0.5 * Float64(y + Float64(x / Float64(y / x)))); else tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 1.06e+86) tmp = 0.5 * (y + (x / (y / x))); else tmp = 0.5 * (y - (z * (z / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1.06e+86], N[(0.5 * N[(y + N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.06 \cdot 10^{+86}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{x}{\frac{y}{x}}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\
\end{array}
\end{array}
if z < 1.06e86Initial program 70.4%
Taylor expanded in x around inf 80.3%
distribute-lft-out80.3%
+-commutative80.3%
unpow280.3%
unpow280.3%
associate-/l*84.9%
Simplified84.9%
Taylor expanded in x around 0 80.3%
associate--l+80.3%
div-sub85.3%
unpow285.3%
unpow285.3%
difference-of-squares88.3%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in x around inf 66.3%
unpow266.3%
associate-/l*73.2%
Simplified73.2%
if 1.06e86 < z Initial program 56.3%
Taylor expanded in x around inf 52.6%
distribute-lft-out52.6%
+-commutative52.6%
unpow252.6%
unpow252.6%
associate-/l*70.5%
Simplified70.5%
Taylor expanded in x around 0 62.5%
unpow262.5%
associate-*r/80.3%
Simplified80.3%
Final simplification74.7%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 1e+304) (* 0.5 y) (* x x)))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e+304) {
tmp = 0.5 * y;
} else {
tmp = x * x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x * x) <= 1d+304) then
tmp = 0.5d0 * y
else
tmp = x * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e+304) {
tmp = 0.5 * y;
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 1e+304: tmp = 0.5 * y else: tmp = x * x return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 1e+304) tmp = Float64(0.5 * y); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 1e+304) tmp = 0.5 * y; else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e+304], N[(0.5 * y), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{+304}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 9.9999999999999994e303Initial program 70.7%
Taylor expanded in y around inf 37.3%
if 9.9999999999999994e303 < (*.f64 x x) Initial program 59.0%
Taylor expanded in x around inf 69.1%
unpow269.1%
Simplified69.1%
associate-/l*75.8%
associate-/r/75.9%
Applied egg-rr75.9%
Applied egg-rr47.3%
fma-udef47.3%
+-rgt-identity47.3%
Simplified47.3%
Final simplification40.1%
(FPCore (x y z) :precision binary64 (* 0.5 y))
double code(double x, double y, double z) {
return 0.5 * y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.5d0 * y
end function
public static double code(double x, double y, double z) {
return 0.5 * y;
}
def code(x, y, z): return 0.5 * y
function code(x, y, z) return Float64(0.5 * y) end
function tmp = code(x, y, z) tmp = 0.5 * y; end
code[x_, y_, z_] := N[(0.5 * y), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot y
\end{array}
Initial program 67.5%
Taylor expanded in y around inf 30.5%
Final simplification30.5%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 67.5%
Taylor expanded in x around inf 33.1%
unpow233.1%
Simplified33.1%
associate-/l*36.1%
associate-/r/36.1%
Applied egg-rr36.1%
Applied egg-rr2.8%
+-lft-identity2.8%
Simplified2.8%
Final simplification2.8%
(FPCore (x y z) :precision binary64 (- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x))))
double code(double x, double y, double z) {
return (y * 0.5) - (((0.5 / y) * (z + x)) * (z - x));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y * 0.5d0) - (((0.5d0 / y) * (z + x)) * (z - x))
end function
public static double code(double x, double y, double z) {
return (y * 0.5) - (((0.5 / y) * (z + x)) * (z - x));
}
def code(x, y, z): return (y * 0.5) - (((0.5 / y) * (z + x)) * (z - x))
function code(x, y, z) return Float64(Float64(y * 0.5) - Float64(Float64(Float64(0.5 / y) * Float64(z + x)) * Float64(z - x))) end
function tmp = code(x, y, z) tmp = (y * 0.5) - (((0.5 / y) * (z + x)) * (z - x)); end
code[x_, y_, z_] := N[(N[(y * 0.5), $MachinePrecision] - N[(N[(N[(0.5 / y), $MachinePrecision] * N[(z + x), $MachinePrecision]), $MachinePrecision] * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot 0.5 - \left(\frac{0.5}{y} \cdot \left(z + x\right)\right) \cdot \left(z - x\right)
\end{array}
herbie shell --seed 2023297
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
:precision binary64
:herbie-target
(- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))