
(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 9 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
(let* ((t_0 (hypot x (+ y z))))
(if (<= (* x x) 1e+303)
(* 0.5 (+ y (/ (- (pow x 2.0) (pow z 2.0)) y)))
(* 0.5 (* t_0 (/ t_0 y))))))
double code(double x, double y, double z) {
double t_0 = hypot(x, (y + z));
double tmp;
if ((x * x) <= 1e+303) {
tmp = 0.5 * (y + ((pow(x, 2.0) - pow(z, 2.0)) / y));
} else {
tmp = 0.5 * (t_0 * (t_0 / y));
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = Math.hypot(x, (y + z));
double tmp;
if ((x * x) <= 1e+303) {
tmp = 0.5 * (y + ((Math.pow(x, 2.0) - Math.pow(z, 2.0)) / y));
} else {
tmp = 0.5 * (t_0 * (t_0 / y));
}
return tmp;
}
def code(x, y, z): t_0 = math.hypot(x, (y + z)) tmp = 0 if (x * x) <= 1e+303: tmp = 0.5 * (y + ((math.pow(x, 2.0) - math.pow(z, 2.0)) / y)) else: tmp = 0.5 * (t_0 * (t_0 / y)) return tmp
function code(x, y, z) t_0 = hypot(x, Float64(y + z)) tmp = 0.0 if (Float64(x * x) <= 1e+303) tmp = Float64(0.5 * Float64(y + Float64(Float64((x ^ 2.0) - (z ^ 2.0)) / y))); else tmp = Float64(0.5 * Float64(t_0 * Float64(t_0 / y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = hypot(x, (y + z)); tmp = 0.0; if ((x * x) <= 1e+303) tmp = 0.5 * (y + (((x ^ 2.0) - (z ^ 2.0)) / y)); else tmp = 0.5 * (t_0 * (t_0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y + z), $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 1e+303], N[(0.5 * N[(y + N[(N[(N[Power[x, 2.0], $MachinePrecision] - N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(t$95$0 * N[(t$95$0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y + z\right)\\
\mathbf{if}\;x \cdot x \leq 10^{+303}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{{x}^{2} - {z}^{2}}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(t\_0 \cdot \frac{t\_0}{y}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 1e303Initial program 78.7%
remove-double-neg78.7%
distribute-lft-neg-out78.7%
distribute-frac-neg278.7%
distribute-frac-neg78.7%
neg-mul-178.7%
distribute-lft-neg-out78.7%
*-commutative78.7%
distribute-lft-neg-in78.7%
times-frac78.7%
metadata-eval78.7%
metadata-eval78.7%
associate--l+78.7%
fma-define78.7%
Simplified78.7%
Taylor expanded in x around 0 92.5%
associate--l+92.5%
div-sub97.8%
Simplified97.8%
if 1e303 < (*.f64 x x) Initial program 55.1%
remove-double-neg55.1%
distribute-lft-neg-out55.1%
distribute-frac-neg255.1%
distribute-frac-neg55.1%
neg-mul-155.1%
distribute-lft-neg-out55.1%
*-commutative55.1%
distribute-lft-neg-in55.1%
times-frac55.3%
metadata-eval55.3%
metadata-eval55.3%
associate--l+55.3%
fma-define65.5%
Simplified65.5%
prod-diff55.3%
fma-neg55.3%
difference-of-squares55.5%
fma-define68.5%
pow268.5%
Applied egg-rr68.5%
add-sqr-sqrt68.5%
associate-/l*68.5%
Applied egg-rr89.8%
Final simplification95.6%
(FPCore (x y z) :precision binary64 (if (<= x 6.7e+152) (* 0.5 (+ y (/ (- (pow x 2.0) (pow z 2.0)) y))) (* x (* x (/ 0.5 y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 6.7e+152) {
tmp = 0.5 * (y + ((pow(x, 2.0) - pow(z, 2.0)) / y));
} else {
tmp = x * (x * (0.5 / 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 (x <= 6.7d+152) then
tmp = 0.5d0 * (y + (((x ** 2.0d0) - (z ** 2.0d0)) / y))
else
tmp = x * (x * (0.5d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 6.7e+152) {
tmp = 0.5 * (y + ((Math.pow(x, 2.0) - Math.pow(z, 2.0)) / y));
} else {
tmp = x * (x * (0.5 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 6.7e+152: tmp = 0.5 * (y + ((math.pow(x, 2.0) - math.pow(z, 2.0)) / y)) else: tmp = x * (x * (0.5 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 6.7e+152) tmp = Float64(0.5 * Float64(y + Float64(Float64((x ^ 2.0) - (z ^ 2.0)) / y))); else tmp = Float64(x * Float64(x * Float64(0.5 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 6.7e+152) tmp = 0.5 * (y + (((x ^ 2.0) - (z ^ 2.0)) / y)); else tmp = x * (x * (0.5 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 6.7e+152], N[(0.5 * N[(y + N[(N[(N[Power[x, 2.0], $MachinePrecision] - N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.7 \cdot 10^{+152}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{{x}^{2} - {z}^{2}}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\end{array}
\end{array}
if x < 6.69999999999999987e152Initial program 77.3%
remove-double-neg77.3%
distribute-lft-neg-out77.3%
distribute-frac-neg277.3%
distribute-frac-neg77.3%
neg-mul-177.3%
distribute-lft-neg-out77.3%
*-commutative77.3%
distribute-lft-neg-in77.3%
times-frac77.3%
metadata-eval77.3%
metadata-eval77.3%
associate--l+77.3%
fma-define78.7%
Simplified78.7%
Taylor expanded in x around 0 87.4%
associate--l+87.4%
div-sub94.0%
Simplified94.0%
if 6.69999999999999987e152 < x Initial program 47.2%
remove-double-neg47.2%
distribute-lft-neg-out47.2%
distribute-frac-neg247.2%
distribute-frac-neg47.2%
neg-mul-147.2%
distribute-lft-neg-out47.2%
*-commutative47.2%
distribute-lft-neg-in47.2%
times-frac47.6%
metadata-eval47.6%
metadata-eval47.6%
associate--l+47.6%
fma-define57.1%
Simplified57.1%
clear-num57.1%
un-div-inv57.1%
fma-undefine47.6%
associate--l+47.6%
add-sqr-sqrt47.6%
pow247.6%
hypot-define47.6%
pow247.6%
Applied egg-rr47.6%
Taylor expanded in x around inf 62.1%
associate-/r/62.1%
add-sqr-sqrt44.8%
sqrt-undiv44.8%
sqrt-undiv44.8%
pow244.8%
unpow244.8%
associate-*r*53.3%
pow253.3%
sqrt-undiv53.3%
sqrt-undiv53.3%
add-sqr-sqrt75.9%
Applied egg-rr75.9%
Final simplification91.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))) (if (<= t_0 5e+120) t_0 (* 0.5 (+ y (+ (* 2.0 z) (/ (pow x 2.0) y)))))))
double code(double x, double y, double z) {
double t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
double tmp;
if (t_0 <= 5e+120) {
tmp = t_0;
} else {
tmp = 0.5 * (y + ((2.0 * z) + (pow(x, 2.0) / 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) :: t_0
real(8) :: tmp
t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
if (t_0 <= 5d+120) then
tmp = t_0
else
tmp = 0.5d0 * (y + ((2.0d0 * z) + ((x ** 2.0d0) / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
double tmp;
if (t_0 <= 5e+120) {
tmp = t_0;
} else {
tmp = 0.5 * (y + ((2.0 * z) + (Math.pow(x, 2.0) / y)));
}
return tmp;
}
def code(x, y, z): t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0) tmp = 0 if t_0 <= 5e+120: tmp = t_0 else: tmp = 0.5 * (y + ((2.0 * z) + (math.pow(x, 2.0) / y))) return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) tmp = 0.0 if (t_0 <= 5e+120) tmp = t_0; else tmp = Float64(0.5 * Float64(y + Float64(Float64(2.0 * z) + Float64((x ^ 2.0) / y)))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); tmp = 0.0; if (t_0 <= 5e+120) tmp = t_0; else tmp = 0.5 * (y + ((2.0 * z) + ((x ^ 2.0) / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e+120], t$95$0, N[(0.5 * N[(y + N[(N[(2.0 * z), $MachinePrecision] + N[(N[Power[x, 2.0], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{+120}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y + \left(2 \cdot z + \frac{{x}^{2}}{y}\right)\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < 5.00000000000000019e120Initial program 88.2%
if 5.00000000000000019e120 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) Initial program 54.6%
remove-double-neg54.6%
distribute-lft-neg-out54.6%
distribute-frac-neg254.6%
distribute-frac-neg54.6%
neg-mul-154.6%
distribute-lft-neg-out54.6%
*-commutative54.6%
distribute-lft-neg-in54.6%
times-frac54.8%
metadata-eval54.8%
metadata-eval54.8%
associate--l+54.8%
fma-define60.6%
Simplified60.6%
prod-diff44.9%
fma-neg44.9%
difference-of-squares45.1%
fma-define52.5%
pow252.5%
Applied egg-rr52.5%
Applied egg-rr65.8%
Taylor expanded in z around 0 58.8%
(FPCore (x y z) :precision binary64 (if (<= y 4.1e+145) (* 0.5 (/ (fma x x (- (* y y) (* z z))) y)) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.1e+145) {
tmp = 0.5 * (fma(x, x, ((y * y) - (z * z))) / y);
} else {
tmp = 0.5 * y;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 4.1e+145) tmp = Float64(0.5 * Float64(fma(x, x, Float64(Float64(y * y) - Float64(z * z))) / y)); else tmp = Float64(0.5 * y); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 4.1e+145], N[(0.5 * N[(N[(x * x + N[(N[(y * y), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.1 \cdot 10^{+145}:\\
\;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y \cdot y - z \cdot z\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 4.1000000000000001e145Initial program 83.0%
remove-double-neg83.0%
distribute-lft-neg-out83.0%
distribute-frac-neg283.0%
distribute-frac-neg83.0%
neg-mul-183.0%
distribute-lft-neg-out83.0%
*-commutative83.0%
distribute-lft-neg-in83.0%
times-frac83.0%
metadata-eval83.0%
metadata-eval83.0%
associate--l+83.0%
fma-define86.2%
Simplified86.2%
if 4.1000000000000001e145 < y Initial program 12.9%
Taylor expanded in y around inf 80.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* z (/ z y)) -0.5)) (t_1 (* x (* x (/ 0.5 y)))))
(if (<= y 1.8e-292)
t_0
(if (<= y 5.4e-267)
t_1
(if (<= y 1.35e-169)
t_0
(if (<= y 3.2e-69) t_1 (if (<= y 0.085) t_0 (* 0.5 y))))))))
double code(double x, double y, double z) {
double t_0 = (z * (z / y)) * -0.5;
double t_1 = x * (x * (0.5 / y));
double tmp;
if (y <= 1.8e-292) {
tmp = t_0;
} else if (y <= 5.4e-267) {
tmp = t_1;
} else if (y <= 1.35e-169) {
tmp = t_0;
} else if (y <= 3.2e-69) {
tmp = t_1;
} else if (y <= 0.085) {
tmp = t_0;
} else {
tmp = 0.5 * 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (z * (z / y)) * (-0.5d0)
t_1 = x * (x * (0.5d0 / y))
if (y <= 1.8d-292) then
tmp = t_0
else if (y <= 5.4d-267) then
tmp = t_1
else if (y <= 1.35d-169) then
tmp = t_0
else if (y <= 3.2d-69) then
tmp = t_1
else if (y <= 0.085d0) then
tmp = t_0
else
tmp = 0.5d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (z * (z / y)) * -0.5;
double t_1 = x * (x * (0.5 / y));
double tmp;
if (y <= 1.8e-292) {
tmp = t_0;
} else if (y <= 5.4e-267) {
tmp = t_1;
} else if (y <= 1.35e-169) {
tmp = t_0;
} else if (y <= 3.2e-69) {
tmp = t_1;
} else if (y <= 0.085) {
tmp = t_0;
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): t_0 = (z * (z / y)) * -0.5 t_1 = x * (x * (0.5 / y)) tmp = 0 if y <= 1.8e-292: tmp = t_0 elif y <= 5.4e-267: tmp = t_1 elif y <= 1.35e-169: tmp = t_0 elif y <= 3.2e-69: tmp = t_1 elif y <= 0.085: tmp = t_0 else: tmp = 0.5 * y return tmp
function code(x, y, z) t_0 = Float64(Float64(z * Float64(z / y)) * -0.5) t_1 = Float64(x * Float64(x * Float64(0.5 / y))) tmp = 0.0 if (y <= 1.8e-292) tmp = t_0; elseif (y <= 5.4e-267) tmp = t_1; elseif (y <= 1.35e-169) tmp = t_0; elseif (y <= 3.2e-69) tmp = t_1; elseif (y <= 0.085) tmp = t_0; else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z * (z / y)) * -0.5; t_1 = x * (x * (0.5 / y)); tmp = 0.0; if (y <= 1.8e-292) tmp = t_0; elseif (y <= 5.4e-267) tmp = t_1; elseif (y <= 1.35e-169) tmp = t_0; elseif (y <= 3.2e-69) tmp = t_1; elseif (y <= 0.085) tmp = t_0; else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 1.8e-292], t$95$0, If[LessEqual[y, 5.4e-267], t$95$1, If[LessEqual[y, 1.35e-169], t$95$0, If[LessEqual[y, 3.2e-69], t$95$1, If[LessEqual[y, 0.085], t$95$0, N[(0.5 * y), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(z \cdot \frac{z}{y}\right) \cdot -0.5\\
t_1 := x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\mathbf{if}\;y \leq 1.8 \cdot 10^{-292}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5.4 \cdot 10^{-267}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-169}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{-69}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 0.085:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 1.8000000000000001e-292 or 5.39999999999999975e-267 < y < 1.3500000000000001e-169 or 3.19999999999999999e-69 < y < 0.0850000000000000061Initial program 81.8%
Taylor expanded in z around inf 41.2%
*-commutative41.2%
Simplified41.2%
unpow241.2%
associate-/l*41.8%
Applied egg-rr41.8%
if 1.8000000000000001e-292 < y < 5.39999999999999975e-267 or 1.3500000000000001e-169 < y < 3.19999999999999999e-69Initial program 93.9%
remove-double-neg93.9%
distribute-lft-neg-out93.9%
distribute-frac-neg293.9%
distribute-frac-neg93.9%
neg-mul-193.9%
distribute-lft-neg-out93.9%
*-commutative93.9%
distribute-lft-neg-in93.9%
times-frac93.9%
metadata-eval93.9%
metadata-eval93.9%
associate--l+93.9%
fma-define96.9%
Simplified96.9%
clear-num96.7%
un-div-inv96.7%
fma-undefine93.7%
associate--l+93.7%
add-sqr-sqrt93.7%
pow293.7%
hypot-define93.7%
pow293.7%
Applied egg-rr93.7%
Taylor expanded in x around inf 69.9%
associate-/r/69.8%
add-sqr-sqrt69.7%
sqrt-undiv69.6%
sqrt-undiv69.5%
pow269.5%
unpow269.5%
associate-*r*69.5%
pow269.5%
sqrt-undiv69.7%
sqrt-undiv69.6%
add-sqr-sqrt69.8%
Applied egg-rr69.8%
if 0.0850000000000000061 < y Initial program 37.7%
Taylor expanded in y around inf 69.1%
Final simplification52.2%
(FPCore (x y z) :precision binary64 (if (<= y 4.1e+145) (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.1e+145) {
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
} else {
tmp = 0.5 * 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 (y <= 4.1d+145) then
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
else
tmp = 0.5d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 4.1e+145) {
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4.1e+145: tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4.1e+145) tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4.1e+145) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4.1e+145], N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.1 \cdot 10^{+145}:\\
\;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 4.1000000000000001e145Initial program 83.0%
if 4.1000000000000001e145 < y Initial program 12.9%
Taylor expanded in y around inf 80.9%
(FPCore (x y z) :precision binary64 (if (<= y 0.11) (* (* z (/ z y)) -0.5) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.11) {
tmp = (z * (z / y)) * -0.5;
} else {
tmp = 0.5 * 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 (y <= 0.11d0) then
tmp = (z * (z / y)) * (-0.5d0)
else
tmp = 0.5d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 0.11) {
tmp = (z * (z / y)) * -0.5;
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 0.11: tmp = (z * (z / y)) * -0.5 else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 0.11) tmp = Float64(Float64(z * Float64(z / y)) * -0.5); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 0.11) tmp = (z * (z / y)) * -0.5; else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 0.11], N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.11:\\
\;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 0.110000000000000001Initial program 83.9%
Taylor expanded in z around inf 39.5%
*-commutative39.5%
Simplified39.5%
unpow239.5%
associate-/l*39.9%
Applied egg-rr39.9%
if 0.110000000000000001 < y Initial program 37.7%
Taylor expanded in y around inf 69.1%
(FPCore (x y z) :precision binary64 (* y (+ 0.5 (/ z y))))
double code(double x, double y, double z) {
return y * (0.5 + (z / y));
}
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 + (z / y))
end function
public static double code(double x, double y, double z) {
return y * (0.5 + (z / y));
}
def code(x, y, z): return y * (0.5 + (z / y))
function code(x, y, z) return Float64(y * Float64(0.5 + Float64(z / y))) end
function tmp = code(x, y, z) tmp = y * (0.5 + (z / y)); end
code[x_, y_, z_] := N[(y * N[(0.5 + N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(0.5 + \frac{z}{y}\right)
\end{array}
Initial program 72.3%
remove-double-neg72.3%
distribute-lft-neg-out72.3%
distribute-frac-neg272.3%
distribute-frac-neg72.3%
neg-mul-172.3%
distribute-lft-neg-out72.3%
*-commutative72.3%
distribute-lft-neg-in72.3%
times-frac72.4%
metadata-eval72.4%
metadata-eval72.4%
associate--l+72.4%
fma-define75.1%
Simplified75.1%
prod-diff61.9%
fma-neg61.9%
difference-of-squares62.0%
fma-define65.4%
pow265.4%
Applied egg-rr65.4%
Applied egg-rr67.5%
Taylor expanded in y around inf 41.5%
(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 72.3%
Taylor expanded in y around inf 34.9%
(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 2024111
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
:precision binary64
:alt
(- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))