
(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 10 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 (if (or (<= y -1.48e+113) (not (<= y 3.2e+163))) (* (/ (hypot x y) y) (/ (hypot y (hypot x z)) 2.0)) (/ (fma y y (fma x x (- (* z z)))) (* y 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.48e+113) || !(y <= 3.2e+163)) {
tmp = (hypot(x, y) / y) * (hypot(y, hypot(x, z)) / 2.0);
} else {
tmp = fma(y, y, fma(x, x, -(z * z))) / (y * 2.0);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -1.48e+113) || !(y <= 3.2e+163)) tmp = Float64(Float64(hypot(x, y) / y) * Float64(hypot(y, hypot(x, z)) / 2.0)); else tmp = Float64(fma(y, y, fma(x, x, Float64(-Float64(z * z)))) / Float64(y * 2.0)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.48e+113], N[Not[LessEqual[y, 3.2e+163]], $MachinePrecision]], N[(N[(N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision] / y), $MachinePrecision] * N[(N[Sqrt[y ^ 2 + N[Sqrt[x ^ 2 + z ^ 2], $MachinePrecision] ^ 2], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(y * y + N[(x * x + (-N[(z * z), $MachinePrecision])), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.48 \cdot 10^{+113} \lor \neg \left(y \leq 3.2 \cdot 10^{+163}\right):\\
\;\;\;\;\frac{\mathsf{hypot}\left(x, y\right)}{y} \cdot \frac{\mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, -z \cdot z\right)\right)}{y \cdot 2}\\
\end{array}
\end{array}
if y < -1.48000000000000002e113 or 3.1999999999999998e163 < y Initial program 15.5%
add-sqr-sqrt15.5%
times-frac15.5%
Applied egg-rr89.5%
Taylor expanded in z around 0 19.3%
associate-*l/19.4%
*-lft-identity19.4%
unpow219.4%
unpow219.4%
hypot-def89.5%
Simplified89.5%
if -1.48000000000000002e113 < y < 3.1999999999999998e163Initial program 90.6%
sqr-neg90.6%
sqr-neg90.6%
+-commutative90.6%
associate--l+90.6%
fma-def91.2%
fma-neg92.4%
distribute-rgt-neg-in92.4%
Simplified92.4%
Final simplification91.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (hypot y (hypot x z))))
(if (<= y -7.4e+160)
(/ (- t_0) 2.0)
(if (<= y 3.2e+163)
(/ (fma y y (fma x x (- (* z z)))) (* y 2.0))
(/ t_0 2.0)))))
double code(double x, double y, double z) {
double t_0 = hypot(y, hypot(x, z));
double tmp;
if (y <= -7.4e+160) {
tmp = -t_0 / 2.0;
} else if (y <= 3.2e+163) {
tmp = fma(y, y, fma(x, x, -(z * z))) / (y * 2.0);
} else {
tmp = t_0 / 2.0;
}
return tmp;
}
function code(x, y, z) t_0 = hypot(y, hypot(x, z)) tmp = 0.0 if (y <= -7.4e+160) tmp = Float64(Float64(-t_0) / 2.0); elseif (y <= 3.2e+163) tmp = Float64(fma(y, y, fma(x, x, Float64(-Float64(z * z)))) / Float64(y * 2.0)); else tmp = Float64(t_0 / 2.0); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Sqrt[y ^ 2 + N[Sqrt[x ^ 2 + z ^ 2], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[y, -7.4e+160], N[((-t$95$0) / 2.0), $MachinePrecision], If[LessEqual[y, 3.2e+163], N[(N[(y * y + N[(x * x + (-N[(z * z), $MachinePrecision])), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)\\
\mathbf{if}\;y \leq -7.4 \cdot 10^{+160}:\\
\;\;\;\;\frac{-t_0}{2}\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+163}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, -z \cdot z\right)\right)}{y \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{2}\\
\end{array}
\end{array}
if y < -7.40000000000000033e160Initial program 5.6%
add-sqr-sqrt5.6%
times-frac5.6%
Applied egg-rr95.8%
Taylor expanded in y around -inf 81.2%
if -7.40000000000000033e160 < y < 3.1999999999999998e163Initial program 86.9%
sqr-neg86.9%
sqr-neg86.9%
+-commutative86.9%
associate--l+86.9%
fma-def88.5%
fma-neg90.1%
distribute-rgt-neg-in90.1%
Simplified90.1%
if 3.1999999999999998e163 < y Initial program 9.5%
add-sqr-sqrt9.5%
times-frac9.5%
Applied egg-rr91.5%
Taylor expanded in y around inf 68.8%
Final simplification85.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (hypot y (hypot x z))))
(if (<= y -7e+143)
(/ (- t_0) 2.0)
(if (<= y 1.8e+146)
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0))
(/ t_0 2.0)))))
double code(double x, double y, double z) {
double t_0 = hypot(y, hypot(x, z));
double tmp;
if (y <= -7e+143) {
tmp = -t_0 / 2.0;
} else if (y <= 1.8e+146) {
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
} else {
tmp = t_0 / 2.0;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = Math.hypot(y, Math.hypot(x, z));
double tmp;
if (y <= -7e+143) {
tmp = -t_0 / 2.0;
} else if (y <= 1.8e+146) {
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
} else {
tmp = t_0 / 2.0;
}
return tmp;
}
def code(x, y, z): t_0 = math.hypot(y, math.hypot(x, z)) tmp = 0 if y <= -7e+143: tmp = -t_0 / 2.0 elif y <= 1.8e+146: tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0) else: tmp = t_0 / 2.0 return tmp
function code(x, y, z) t_0 = hypot(y, hypot(x, z)) tmp = 0.0 if (y <= -7e+143) tmp = Float64(Float64(-t_0) / 2.0); elseif (y <= 1.8e+146) tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)); else tmp = Float64(t_0 / 2.0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = hypot(y, hypot(x, z)); tmp = 0.0; if (y <= -7e+143) tmp = -t_0 / 2.0; elseif (y <= 1.8e+146) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); else tmp = t_0 / 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[Sqrt[y ^ 2 + N[Sqrt[x ^ 2 + z ^ 2], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[y, -7e+143], N[((-t$95$0) / 2.0), $MachinePrecision], If[LessEqual[y, 1.8e+146], N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)\\
\mathbf{if}\;y \leq -7 \cdot 10^{+143}:\\
\;\;\;\;\frac{-t_0}{2}\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+146}:\\
\;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{2}\\
\end{array}
\end{array}
if y < -7.00000000000000017e143Initial program 4.8%
add-sqr-sqrt4.8%
times-frac4.8%
Applied egg-rr83.3%
Taylor expanded in y around -inf 71.6%
if -7.00000000000000017e143 < y < 1.7999999999999999e146Initial program 90.5%
if 1.7999999999999999e146 < y Initial program 13.2%
add-sqr-sqrt13.2%
times-frac13.2%
Applied egg-rr90.0%
Taylor expanded in y around inf 69.4%
Final simplification84.6%
(FPCore (x y z)
:precision binary64
(if (<= y -7e+143)
(/ (- (hypot y (hypot x z))) 2.0)
(if (<= y 1.8e+146)
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0))
(* y 0.5))))
double code(double x, double y, double z) {
double tmp;
if (y <= -7e+143) {
tmp = -hypot(y, hypot(x, z)) / 2.0;
} else if (y <= 1.8e+146) {
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
} else {
tmp = y * 0.5;
}
return tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (y <= -7e+143) {
tmp = -Math.hypot(y, Math.hypot(x, z)) / 2.0;
} else if (y <= 1.8e+146) {
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7e+143: tmp = -math.hypot(y, math.hypot(x, z)) / 2.0 elif y <= 1.8e+146: tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0) else: tmp = y * 0.5 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7e+143) tmp = Float64(Float64(-hypot(y, hypot(x, z))) / 2.0); elseif (y <= 1.8e+146) tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)); else tmp = Float64(y * 0.5); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7e+143) tmp = -hypot(y, hypot(x, z)) / 2.0; elseif (y <= 1.8e+146) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7e+143], N[((-N[Sqrt[y ^ 2 + N[Sqrt[x ^ 2 + z ^ 2], $MachinePrecision] ^ 2], $MachinePrecision]) / 2.0), $MachinePrecision], If[LessEqual[y, 1.8e+146], N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+143}:\\
\;\;\;\;\frac{-\mathsf{hypot}\left(y, \mathsf{hypot}\left(x, z\right)\right)}{2}\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+146}:\\
\;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < -7.00000000000000017e143Initial program 4.8%
add-sqr-sqrt4.8%
times-frac4.8%
Applied egg-rr83.3%
Taylor expanded in y around -inf 71.6%
if -7.00000000000000017e143 < y < 1.7999999999999999e146Initial program 90.5%
if 1.7999999999999999e146 < y Initial program 13.2%
Taylor expanded in y around inf 68.8%
Final simplification84.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* z (/ z y)) -0.5)))
(if (<= x 2.55e-232)
t_0
(if (<= x 1.8e-104)
(* y 0.5)
(if (<= x 9e-62)
t_0
(if (<= x 6e+19)
(* y 0.5)
(if (or (<= x 3.1e+62) (and (not (<= x 2.2e+99)) (<= x 1.8e+115)))
t_0
(* x (* x (/ 0.5 y))))))))))
double code(double x, double y, double z) {
double t_0 = (z * (z / y)) * -0.5;
double tmp;
if (x <= 2.55e-232) {
tmp = t_0;
} else if (x <= 1.8e-104) {
tmp = y * 0.5;
} else if (x <= 9e-62) {
tmp = t_0;
} else if (x <= 6e+19) {
tmp = y * 0.5;
} else if ((x <= 3.1e+62) || (!(x <= 2.2e+99) && (x <= 1.8e+115))) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (z * (z / y)) * (-0.5d0)
if (x <= 2.55d-232) then
tmp = t_0
else if (x <= 1.8d-104) then
tmp = y * 0.5d0
else if (x <= 9d-62) then
tmp = t_0
else if (x <= 6d+19) then
tmp = y * 0.5d0
else if ((x <= 3.1d+62) .or. (.not. (x <= 2.2d+99)) .and. (x <= 1.8d+115)) then
tmp = t_0
else
tmp = x * (x * (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 tmp;
if (x <= 2.55e-232) {
tmp = t_0;
} else if (x <= 1.8e-104) {
tmp = y * 0.5;
} else if (x <= 9e-62) {
tmp = t_0;
} else if (x <= 6e+19) {
tmp = y * 0.5;
} else if ((x <= 3.1e+62) || (!(x <= 2.2e+99) && (x <= 1.8e+115))) {
tmp = t_0;
} else {
tmp = x * (x * (0.5 / y));
}
return tmp;
}
def code(x, y, z): t_0 = (z * (z / y)) * -0.5 tmp = 0 if x <= 2.55e-232: tmp = t_0 elif x <= 1.8e-104: tmp = y * 0.5 elif x <= 9e-62: tmp = t_0 elif x <= 6e+19: tmp = y * 0.5 elif (x <= 3.1e+62) or (not (x <= 2.2e+99) and (x <= 1.8e+115)): tmp = t_0 else: tmp = x * (x * (0.5 / y)) return tmp
function code(x, y, z) t_0 = Float64(Float64(z * Float64(z / y)) * -0.5) tmp = 0.0 if (x <= 2.55e-232) tmp = t_0; elseif (x <= 1.8e-104) tmp = Float64(y * 0.5); elseif (x <= 9e-62) tmp = t_0; elseif (x <= 6e+19) tmp = Float64(y * 0.5); elseif ((x <= 3.1e+62) || (!(x <= 2.2e+99) && (x <= 1.8e+115))) tmp = t_0; else tmp = Float64(x * Float64(x * Float64(0.5 / y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z * (z / y)) * -0.5; tmp = 0.0; if (x <= 2.55e-232) tmp = t_0; elseif (x <= 1.8e-104) tmp = y * 0.5; elseif (x <= 9e-62) tmp = t_0; elseif (x <= 6e+19) tmp = y * 0.5; elseif ((x <= 3.1e+62) || (~((x <= 2.2e+99)) && (x <= 1.8e+115))) tmp = t_0; else tmp = x * (x * (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]}, If[LessEqual[x, 2.55e-232], t$95$0, If[LessEqual[x, 1.8e-104], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, 9e-62], t$95$0, If[LessEqual[x, 6e+19], N[(y * 0.5), $MachinePrecision], If[Or[LessEqual[x, 3.1e+62], And[N[Not[LessEqual[x, 2.2e+99]], $MachinePrecision], LessEqual[x, 1.8e+115]]], t$95$0, N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(z \cdot \frac{z}{y}\right) \cdot -0.5\\
\mathbf{if}\;x \leq 2.55 \cdot 10^{-232}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{-104}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-62}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 6 \cdot 10^{+19}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{+62} \lor \neg \left(x \leq 2.2 \cdot 10^{+99}\right) \land x \leq 1.8 \cdot 10^{+115}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\end{array}
\end{array}
if x < 2.55000000000000014e-232 or 1.7999999999999999e-104 < x < 9.00000000000000036e-62 or 6e19 < x < 3.10000000000000014e62 or 2.19999999999999978e99 < x < 1.8e115Initial program 72.1%
Taylor expanded in z around inf 36.9%
*-commutative36.9%
Simplified36.9%
div-inv36.8%
unpow236.8%
associate-*l*39.0%
div-inv39.1%
Applied egg-rr39.1%
if 2.55000000000000014e-232 < x < 1.7999999999999999e-104 or 9.00000000000000036e-62 < x < 6e19Initial program 55.9%
Taylor expanded in y around inf 60.6%
if 3.10000000000000014e62 < x < 2.19999999999999978e99 or 1.8e115 < x Initial program 59.0%
Taylor expanded in x around inf 63.4%
associate-*r/63.4%
associate-/l*63.4%
Simplified63.4%
associate-/r/63.4%
unpow263.4%
associate-*r*76.8%
Applied egg-rr76.8%
Final simplification49.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* z (/ z y)) -0.5)))
(if (<= x 3.05e-232)
t_0
(if (<= x 7e-108)
(* y 0.5)
(if (<= x 6.2e-61)
t_0
(if (<= x 5.5e+17)
(* y 0.5)
(if (or (<= x 2.7e+63) (and (not (<= x 1.15e+99)) (<= x 9e+114)))
t_0
(* x (/ (* x 0.5) y)))))))))
double code(double x, double y, double z) {
double t_0 = (z * (z / y)) * -0.5;
double tmp;
if (x <= 3.05e-232) {
tmp = t_0;
} else if (x <= 7e-108) {
tmp = y * 0.5;
} else if (x <= 6.2e-61) {
tmp = t_0;
} else if (x <= 5.5e+17) {
tmp = y * 0.5;
} else if ((x <= 2.7e+63) || (!(x <= 1.15e+99) && (x <= 9e+114))) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (z * (z / y)) * (-0.5d0)
if (x <= 3.05d-232) then
tmp = t_0
else if (x <= 7d-108) then
tmp = y * 0.5d0
else if (x <= 6.2d-61) then
tmp = t_0
else if (x <= 5.5d+17) then
tmp = y * 0.5d0
else if ((x <= 2.7d+63) .or. (.not. (x <= 1.15d+99)) .and. (x <= 9d+114)) then
tmp = t_0
else
tmp = x * ((x * 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 tmp;
if (x <= 3.05e-232) {
tmp = t_0;
} else if (x <= 7e-108) {
tmp = y * 0.5;
} else if (x <= 6.2e-61) {
tmp = t_0;
} else if (x <= 5.5e+17) {
tmp = y * 0.5;
} else if ((x <= 2.7e+63) || (!(x <= 1.15e+99) && (x <= 9e+114))) {
tmp = t_0;
} else {
tmp = x * ((x * 0.5) / y);
}
return tmp;
}
def code(x, y, z): t_0 = (z * (z / y)) * -0.5 tmp = 0 if x <= 3.05e-232: tmp = t_0 elif x <= 7e-108: tmp = y * 0.5 elif x <= 6.2e-61: tmp = t_0 elif x <= 5.5e+17: tmp = y * 0.5 elif (x <= 2.7e+63) or (not (x <= 1.15e+99) and (x <= 9e+114)): tmp = t_0 else: tmp = x * ((x * 0.5) / y) return tmp
function code(x, y, z) t_0 = Float64(Float64(z * Float64(z / y)) * -0.5) tmp = 0.0 if (x <= 3.05e-232) tmp = t_0; elseif (x <= 7e-108) tmp = Float64(y * 0.5); elseif (x <= 6.2e-61) tmp = t_0; elseif (x <= 5.5e+17) tmp = Float64(y * 0.5); elseif ((x <= 2.7e+63) || (!(x <= 1.15e+99) && (x <= 9e+114))) tmp = t_0; else tmp = Float64(x * Float64(Float64(x * 0.5) / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z * (z / y)) * -0.5; tmp = 0.0; if (x <= 3.05e-232) tmp = t_0; elseif (x <= 7e-108) tmp = y * 0.5; elseif (x <= 6.2e-61) tmp = t_0; elseif (x <= 5.5e+17) tmp = y * 0.5; elseif ((x <= 2.7e+63) || (~((x <= 1.15e+99)) && (x <= 9e+114))) tmp = t_0; else tmp = x * ((x * 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]}, If[LessEqual[x, 3.05e-232], t$95$0, If[LessEqual[x, 7e-108], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, 6.2e-61], t$95$0, If[LessEqual[x, 5.5e+17], N[(y * 0.5), $MachinePrecision], If[Or[LessEqual[x, 2.7e+63], And[N[Not[LessEqual[x, 1.15e+99]], $MachinePrecision], LessEqual[x, 9e+114]]], t$95$0, N[(x * N[(N[(x * 0.5), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(z \cdot \frac{z}{y}\right) \cdot -0.5\\
\mathbf{if}\;x \leq 3.05 \cdot 10^{-232}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-108}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{-61}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+17}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{+63} \lor \neg \left(x \leq 1.15 \cdot 10^{+99}\right) \land x \leq 9 \cdot 10^{+114}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{x \cdot 0.5}{y}\\
\end{array}
\end{array}
if x < 3.0500000000000001e-232 or 6.9999999999999997e-108 < x < 6.1999999999999999e-61 or 5.5e17 < x < 2.70000000000000017e63 or 1.1500000000000001e99 < x < 9.0000000000000001e114Initial program 72.1%
Taylor expanded in z around inf 36.9%
*-commutative36.9%
Simplified36.9%
div-inv36.8%
unpow236.8%
associate-*l*39.0%
div-inv39.1%
Applied egg-rr39.1%
if 3.0500000000000001e-232 < x < 6.9999999999999997e-108 or 6.1999999999999999e-61 < x < 5.5e17Initial program 55.9%
Taylor expanded in y around inf 60.6%
if 2.70000000000000017e63 < x < 1.1500000000000001e99 or 9.0000000000000001e114 < x Initial program 59.0%
Taylor expanded in x around inf 63.4%
associate-*r/63.4%
associate-/l*63.4%
Simplified63.4%
associate-/r/63.4%
unpow263.4%
associate-*r*76.8%
Applied egg-rr76.8%
*-commutative76.8%
associate-*r/76.8%
Applied egg-rr76.8%
Final simplification49.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* z (/ z y)) -0.5)))
(if (<= x 2.65e-233)
t_0
(if (<= x 3.2e-104)
(* y 0.5)
(if (<= x 5.2e-61)
t_0
(if (<= x 1.05e+20)
(* y 0.5)
(if (<= x 2.6e+63)
t_0
(if (<= x 1.25e+99)
(/ 0.5 (/ (/ y x) x))
(if (<= x 1.15e+115) t_0 (* x (/ (* x 0.5) y)))))))))))
double code(double x, double y, double z) {
double t_0 = (z * (z / y)) * -0.5;
double tmp;
if (x <= 2.65e-233) {
tmp = t_0;
} else if (x <= 3.2e-104) {
tmp = y * 0.5;
} else if (x <= 5.2e-61) {
tmp = t_0;
} else if (x <= 1.05e+20) {
tmp = y * 0.5;
} else if (x <= 2.6e+63) {
tmp = t_0;
} else if (x <= 1.25e+99) {
tmp = 0.5 / ((y / x) / x);
} else if (x <= 1.15e+115) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (z * (z / y)) * (-0.5d0)
if (x <= 2.65d-233) then
tmp = t_0
else if (x <= 3.2d-104) then
tmp = y * 0.5d0
else if (x <= 5.2d-61) then
tmp = t_0
else if (x <= 1.05d+20) then
tmp = y * 0.5d0
else if (x <= 2.6d+63) then
tmp = t_0
else if (x <= 1.25d+99) then
tmp = 0.5d0 / ((y / x) / x)
else if (x <= 1.15d+115) then
tmp = t_0
else
tmp = x * ((x * 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 tmp;
if (x <= 2.65e-233) {
tmp = t_0;
} else if (x <= 3.2e-104) {
tmp = y * 0.5;
} else if (x <= 5.2e-61) {
tmp = t_0;
} else if (x <= 1.05e+20) {
tmp = y * 0.5;
} else if (x <= 2.6e+63) {
tmp = t_0;
} else if (x <= 1.25e+99) {
tmp = 0.5 / ((y / x) / x);
} else if (x <= 1.15e+115) {
tmp = t_0;
} else {
tmp = x * ((x * 0.5) / y);
}
return tmp;
}
def code(x, y, z): t_0 = (z * (z / y)) * -0.5 tmp = 0 if x <= 2.65e-233: tmp = t_0 elif x <= 3.2e-104: tmp = y * 0.5 elif x <= 5.2e-61: tmp = t_0 elif x <= 1.05e+20: tmp = y * 0.5 elif x <= 2.6e+63: tmp = t_0 elif x <= 1.25e+99: tmp = 0.5 / ((y / x) / x) elif x <= 1.15e+115: tmp = t_0 else: tmp = x * ((x * 0.5) / y) return tmp
function code(x, y, z) t_0 = Float64(Float64(z * Float64(z / y)) * -0.5) tmp = 0.0 if (x <= 2.65e-233) tmp = t_0; elseif (x <= 3.2e-104) tmp = Float64(y * 0.5); elseif (x <= 5.2e-61) tmp = t_0; elseif (x <= 1.05e+20) tmp = Float64(y * 0.5); elseif (x <= 2.6e+63) tmp = t_0; elseif (x <= 1.25e+99) tmp = Float64(0.5 / Float64(Float64(y / x) / x)); elseif (x <= 1.15e+115) tmp = t_0; else tmp = Float64(x * Float64(Float64(x * 0.5) / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z * (z / y)) * -0.5; tmp = 0.0; if (x <= 2.65e-233) tmp = t_0; elseif (x <= 3.2e-104) tmp = y * 0.5; elseif (x <= 5.2e-61) tmp = t_0; elseif (x <= 1.05e+20) tmp = y * 0.5; elseif (x <= 2.6e+63) tmp = t_0; elseif (x <= 1.25e+99) tmp = 0.5 / ((y / x) / x); elseif (x <= 1.15e+115) tmp = t_0; else tmp = x * ((x * 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]}, If[LessEqual[x, 2.65e-233], t$95$0, If[LessEqual[x, 3.2e-104], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, 5.2e-61], t$95$0, If[LessEqual[x, 1.05e+20], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, 2.6e+63], t$95$0, If[LessEqual[x, 1.25e+99], N[(0.5 / N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.15e+115], t$95$0, N[(x * N[(N[(x * 0.5), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(z \cdot \frac{z}{y}\right) \cdot -0.5\\
\mathbf{if}\;x \leq 2.65 \cdot 10^{-233}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-104}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-61}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{+20}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{+63}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{+99}:\\
\;\;\;\;\frac{0.5}{\frac{\frac{y}{x}}{x}}\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{+115}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{x \cdot 0.5}{y}\\
\end{array}
\end{array}
if x < 2.64999999999999986e-233 or 3.19999999999999989e-104 < x < 5.20000000000000021e-61 or 1.05e20 < x < 2.6000000000000001e63 or 1.25000000000000002e99 < x < 1.15000000000000002e115Initial program 72.1%
Taylor expanded in z around inf 36.9%
*-commutative36.9%
Simplified36.9%
div-inv36.8%
unpow236.8%
associate-*l*39.0%
div-inv39.1%
Applied egg-rr39.1%
if 2.64999999999999986e-233 < x < 3.19999999999999989e-104 or 5.20000000000000021e-61 < x < 1.05e20Initial program 55.9%
Taylor expanded in y around inf 60.6%
if 2.6000000000000001e63 < x < 1.25000000000000002e99Initial program 81.4%
Taylor expanded in x around inf 80.2%
associate-*r/80.2%
associate-/l*80.5%
Simplified80.5%
*-un-lft-identity80.5%
unpow280.5%
times-frac80.5%
Applied egg-rr80.5%
associate-*l/80.5%
*-lft-identity80.5%
Simplified80.5%
if 1.15000000000000002e115 < x Initial program 56.2%
Taylor expanded in x around inf 61.4%
associate-*r/61.4%
associate-/l*61.4%
Simplified61.4%
associate-/r/61.4%
unpow261.4%
associate-*r*76.4%
Applied egg-rr76.4%
*-commutative76.4%
associate-*r/76.4%
Applied egg-rr76.4%
Final simplification49.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -7e+143) (not (<= y 1.8e+146))) (* y 0.5) (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7e+143) || !(y <= 1.8e+146)) {
tmp = y * 0.5;
} else {
tmp = (((x * x) + (y * y)) - (z * z)) / (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 ((y <= (-7d+143)) .or. (.not. (y <= 1.8d+146))) then
tmp = y * 0.5d0
else
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -7e+143) || !(y <= 1.8e+146)) {
tmp = y * 0.5;
} else {
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7e+143) or not (y <= 1.8e+146): tmp = y * 0.5 else: tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7e+143) || !(y <= 1.8e+146)) tmp = Float64(y * 0.5); else tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -7e+143) || ~((y <= 1.8e+146))) tmp = y * 0.5; else tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7e+143], N[Not[LessEqual[y, 1.8e+146]], $MachinePrecision]], N[(y * 0.5), $MachinePrecision], 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}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+143} \lor \neg \left(y \leq 1.8 \cdot 10^{+146}\right):\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\
\end{array}
\end{array}
if y < -7.00000000000000017e143 or 1.7999999999999999e146 < y Initial program 9.8%
Taylor expanded in y around inf 69.9%
if -7.00000000000000017e143 < y < 1.7999999999999999e146Initial program 90.5%
Final simplification84.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -8.5e+93) (not (<= y 6.1e+100))) (* y 0.5) (* (* z (/ z y)) -0.5)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8.5e+93) || !(y <= 6.1e+100)) {
tmp = y * 0.5;
} 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 ((y <= (-8.5d+93)) .or. (.not. (y <= 6.1d+100))) then
tmp = y * 0.5d0
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 ((y <= -8.5e+93) || !(y <= 6.1e+100)) {
tmp = y * 0.5;
} else {
tmp = (z * (z / y)) * -0.5;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8.5e+93) or not (y <= 6.1e+100): tmp = y * 0.5 else: tmp = (z * (z / y)) * -0.5 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8.5e+93) || !(y <= 6.1e+100)) tmp = Float64(y * 0.5); else tmp = Float64(Float64(z * Float64(z / y)) * -0.5); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -8.5e+93) || ~((y <= 6.1e+100))) tmp = y * 0.5; else tmp = (z * (z / y)) * -0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -8.5e+93], N[Not[LessEqual[y, 6.1e+100]], $MachinePrecision]], N[(y * 0.5), $MachinePrecision], N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.5 \cdot 10^{+93} \lor \neg \left(y \leq 6.1 \cdot 10^{+100}\right):\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\
\end{array}
\end{array}
if y < -8.5000000000000005e93 or 6.0999999999999999e100 < y Initial program 25.7%
Taylor expanded in y around inf 67.5%
if -8.5000000000000005e93 < y < 6.0999999999999999e100Initial program 91.6%
Taylor expanded in z around inf 43.6%
*-commutative43.6%
Simplified43.6%
div-inv43.5%
unpow243.5%
associate-*l*45.7%
div-inv45.8%
Applied egg-rr45.8%
Final simplification53.9%
(FPCore (x y z) :precision binary64 (* y 0.5))
double code(double x, double y, double z) {
return y * 0.5;
}
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
end function
public static double code(double x, double y, double z) {
return y * 0.5;
}
def code(x, y, z): return y * 0.5
function code(x, y, z) return Float64(y * 0.5) end
function tmp = code(x, y, z) tmp = y * 0.5; end
code[x_, y_, z_] := N[(y * 0.5), $MachinePrecision]
\begin{array}{l}
\\
y \cdot 0.5
\end{array}
Initial program 66.9%
Taylor expanded in y around inf 34.1%
Final simplification34.1%
(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 2023308
(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)))