
(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 7 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}
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= y_m 7e+156)
(* 0.5 (/ (fma x x (- (* y_m y_m) (* z z))) y_m))
(* 0.5 (- y_m (* z (/ z y_m)))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 7e+156) {
tmp = 0.5 * (fma(x, x, ((y_m * y_m) - (z * z))) / y_m);
} else {
tmp = 0.5 * (y_m - (z * (z / y_m)));
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (y_m <= 7e+156) tmp = Float64(0.5 * Float64(fma(x, x, Float64(Float64(y_m * y_m) - Float64(z * z))) / y_m)); else tmp = Float64(0.5 * Float64(y_m - Float64(z * Float64(z / y_m)))); end return Float64(y_s * tmp) end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 7e+156], N[(0.5 * N[(N[(x * x + N[(N[(y$95$m * y$95$m), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y$95$m - N[(z * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 7 \cdot 10^{+156}:\\
\;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y\_m \cdot y\_m - z \cdot z\right)}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y\_m - z \cdot \frac{z}{y\_m}\right)\\
\end{array}
\end{array}
if y < 7.0000000000000006e156Initial program 79.7%
remove-double-neg79.7%
distribute-lft-neg-out79.7%
distribute-frac-neg279.7%
distribute-frac-neg79.7%
neg-mul-179.7%
distribute-lft-neg-out79.7%
*-commutative79.7%
distribute-lft-neg-in79.7%
times-frac79.7%
metadata-eval79.7%
metadata-eval79.7%
associate--l+79.7%
fma-define84.5%
Simplified84.5%
if 7.0000000000000006e156 < y Initial program 14.1%
remove-double-neg14.1%
distribute-lft-neg-out14.1%
distribute-frac-neg214.1%
distribute-frac-neg14.1%
neg-mul-114.1%
distribute-lft-neg-out14.1%
*-commutative14.1%
distribute-lft-neg-in14.1%
times-frac14.1%
metadata-eval14.1%
metadata-eval14.1%
associate--l+14.1%
fma-define14.1%
Simplified14.1%
Taylor expanded in x around 0 14.1%
div-sub14.1%
unpow214.1%
associate-/l*68.7%
*-inverses68.7%
*-rgt-identity68.7%
Simplified68.7%
clear-num68.7%
unpow268.7%
associate-/r*83.1%
associate-/r/83.1%
clear-num83.1%
Applied egg-rr83.1%
Final simplification84.4%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (or (<= x 8.8e+132) (and (not (<= x 2.2e+168)) (<= x 2.5e+188)))
(* 0.5 (- y_m (* z (/ z y_m))))
(/ 1.0 (* (/ y_m x) (/ 2.0 x))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if ((x <= 8.8e+132) || (!(x <= 2.2e+168) && (x <= 2.5e+188))) {
tmp = 0.5 * (y_m - (z * (z / y_m)));
} else {
tmp = 1.0 / ((y_m / x) * (2.0 / x));
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= 8.8d+132) .or. (.not. (x <= 2.2d+168)) .and. (x <= 2.5d+188)) then
tmp = 0.5d0 * (y_m - (z * (z / y_m)))
else
tmp = 1.0d0 / ((y_m / x) * (2.0d0 / x))
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if ((x <= 8.8e+132) || (!(x <= 2.2e+168) && (x <= 2.5e+188))) {
tmp = 0.5 * (y_m - (z * (z / y_m)));
} else {
tmp = 1.0 / ((y_m / x) * (2.0 / x));
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): tmp = 0 if (x <= 8.8e+132) or (not (x <= 2.2e+168) and (x <= 2.5e+188)): tmp = 0.5 * (y_m - (z * (z / y_m))) else: tmp = 1.0 / ((y_m / x) * (2.0 / x)) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if ((x <= 8.8e+132) || (!(x <= 2.2e+168) && (x <= 2.5e+188))) tmp = Float64(0.5 * Float64(y_m - Float64(z * Float64(z / y_m)))); else tmp = Float64(1.0 / Float64(Float64(y_m / x) * Float64(2.0 / x))); end return Float64(y_s * tmp) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) tmp = 0.0; if ((x <= 8.8e+132) || (~((x <= 2.2e+168)) && (x <= 2.5e+188))) tmp = 0.5 * (y_m - (z * (z / y_m))); else tmp = 1.0 / ((y_m / x) * (2.0 / x)); end tmp_2 = y_s * tmp; end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[Or[LessEqual[x, 8.8e+132], And[N[Not[LessEqual[x, 2.2e+168]], $MachinePrecision], LessEqual[x, 2.5e+188]]], N[(0.5 * N[(y$95$m - N[(z * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(y$95$m / x), $MachinePrecision] * N[(2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 8.8 \cdot 10^{+132} \lor \neg \left(x \leq 2.2 \cdot 10^{+168}\right) \land x \leq 2.5 \cdot 10^{+188}:\\
\;\;\;\;0.5 \cdot \left(y\_m - z \cdot \frac{z}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{y\_m}{x} \cdot \frac{2}{x}}\\
\end{array}
\end{array}
if x < 8.79999999999999954e132 or 2.2000000000000002e168 < x < 2.5000000000000001e188Initial program 74.2%
remove-double-neg74.2%
distribute-lft-neg-out74.2%
distribute-frac-neg274.2%
distribute-frac-neg74.2%
neg-mul-174.2%
distribute-lft-neg-out74.2%
*-commutative74.2%
distribute-lft-neg-in74.2%
times-frac74.2%
metadata-eval74.2%
metadata-eval74.2%
associate--l+74.2%
fma-define76.5%
Simplified76.5%
Taylor expanded in x around 0 54.1%
div-sub54.1%
unpow254.1%
associate-/l*69.7%
*-inverses69.7%
*-rgt-identity69.7%
Simplified69.7%
clear-num69.7%
unpow269.7%
associate-/r*74.5%
associate-/r/74.4%
clear-num74.5%
Applied egg-rr74.5%
if 8.79999999999999954e132 < x < 2.2000000000000002e168 or 2.5000000000000001e188 < x Initial program 60.9%
clear-num60.9%
inv-pow60.9%
associate-/l*60.9%
add-sqr-sqrt60.9%
pow260.9%
hypot-define60.9%
pow260.9%
Applied egg-rr60.9%
unpow-160.9%
associate-*r/61.0%
Simplified61.0%
Taylor expanded in x around inf 72.7%
unpow272.7%
times-frac75.7%
Applied egg-rr75.7%
Final simplification74.6%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (or (<= x 8.8e+132) (and (not (<= x 2.4e+171)) (<= x 4.6e+188)))
(* 0.5 (- y_m (* z (/ z y_m))))
(* x (* x (/ 0.5 y_m))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if ((x <= 8.8e+132) || (!(x <= 2.4e+171) && (x <= 4.6e+188))) {
tmp = 0.5 * (y_m - (z * (z / y_m)));
} else {
tmp = x * (x * (0.5 / y_m));
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= 8.8d+132) .or. (.not. (x <= 2.4d+171)) .and. (x <= 4.6d+188)) then
tmp = 0.5d0 * (y_m - (z * (z / y_m)))
else
tmp = x * (x * (0.5d0 / y_m))
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if ((x <= 8.8e+132) || (!(x <= 2.4e+171) && (x <= 4.6e+188))) {
tmp = 0.5 * (y_m - (z * (z / y_m)));
} else {
tmp = x * (x * (0.5 / y_m));
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): tmp = 0 if (x <= 8.8e+132) or (not (x <= 2.4e+171) and (x <= 4.6e+188)): tmp = 0.5 * (y_m - (z * (z / y_m))) else: tmp = x * (x * (0.5 / y_m)) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if ((x <= 8.8e+132) || (!(x <= 2.4e+171) && (x <= 4.6e+188))) tmp = Float64(0.5 * Float64(y_m - Float64(z * Float64(z / y_m)))); else tmp = Float64(x * Float64(x * Float64(0.5 / y_m))); end return Float64(y_s * tmp) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) tmp = 0.0; if ((x <= 8.8e+132) || (~((x <= 2.4e+171)) && (x <= 4.6e+188))) tmp = 0.5 * (y_m - (z * (z / y_m))); else tmp = x * (x * (0.5 / y_m)); end tmp_2 = y_s * tmp; end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[Or[LessEqual[x, 8.8e+132], And[N[Not[LessEqual[x, 2.4e+171]], $MachinePrecision], LessEqual[x, 4.6e+188]]], N[(0.5 * N[(y$95$m - N[(z * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(x * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 8.8 \cdot 10^{+132} \lor \neg \left(x \leq 2.4 \cdot 10^{+171}\right) \land x \leq 4.6 \cdot 10^{+188}:\\
\;\;\;\;0.5 \cdot \left(y\_m - z \cdot \frac{z}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y\_m}\right)\\
\end{array}
\end{array}
if x < 8.79999999999999954e132 or 2.39999999999999998e171 < x < 4.60000000000000023e188Initial program 74.2%
remove-double-neg74.2%
distribute-lft-neg-out74.2%
distribute-frac-neg274.2%
distribute-frac-neg74.2%
neg-mul-174.2%
distribute-lft-neg-out74.2%
*-commutative74.2%
distribute-lft-neg-in74.2%
times-frac74.2%
metadata-eval74.2%
metadata-eval74.2%
associate--l+74.2%
fma-define76.5%
Simplified76.5%
Taylor expanded in x around 0 54.1%
div-sub54.1%
unpow254.1%
associate-/l*69.7%
*-inverses69.7%
*-rgt-identity69.7%
Simplified69.7%
clear-num69.7%
unpow269.7%
associate-/r*74.5%
associate-/r/74.4%
clear-num74.5%
Applied egg-rr74.5%
if 8.79999999999999954e132 < x < 2.39999999999999998e171 or 4.60000000000000023e188 < x Initial program 60.9%
clear-num60.9%
inv-pow60.9%
associate-/l*60.9%
add-sqr-sqrt60.9%
pow260.9%
hypot-define60.9%
pow260.9%
Applied egg-rr60.9%
unpow-160.9%
associate-*r/61.0%
Simplified61.0%
Taylor expanded in x around inf 72.7%
associate-/r/72.6%
unpow272.6%
associate-*r*75.6%
*-commutative75.6%
associate-/r*75.6%
metadata-eval75.6%
Applied egg-rr75.6%
Final simplification74.6%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= y_m 1.25e+18)
(/ (- (+ (* y_m y_m) (* x x)) (* z z)) (* y_m 2.0))
(* 0.5 (- y_m (* z (/ z y_m)))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 1.25e+18) {
tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0);
} else {
tmp = 0.5 * (y_m - (z * (z / y_m)));
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (y_m <= 1.25d+18) then
tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0d0)
else
tmp = 0.5d0 * (y_m - (z * (z / y_m)))
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 1.25e+18) {
tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0);
} else {
tmp = 0.5 * (y_m - (z * (z / y_m)));
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): tmp = 0 if y_m <= 1.25e+18: tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0) else: tmp = 0.5 * (y_m - (z * (z / y_m))) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (y_m <= 1.25e+18) tmp = Float64(Float64(Float64(Float64(y_m * y_m) + Float64(x * x)) - Float64(z * z)) / Float64(y_m * 2.0)); else tmp = Float64(0.5 * Float64(y_m - Float64(z * Float64(z / y_m)))); end return Float64(y_s * tmp) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) tmp = 0.0; if (y_m <= 1.25e+18) tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0); else tmp = 0.5 * (y_m - (z * (z / y_m))); end tmp_2 = y_s * tmp; end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 1.25e+18], N[(N[(N[(N[(y$95$m * y$95$m), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y$95$m - N[(z * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 1.25 \cdot 10^{+18}:\\
\;\;\;\;\frac{\left(y\_m \cdot y\_m + x \cdot x\right) - z \cdot z}{y\_m \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y\_m - z \cdot \frac{z}{y\_m}\right)\\
\end{array}
\end{array}
if y < 1.25e18Initial program 78.6%
if 1.25e18 < y Initial program 49.1%
remove-double-neg49.1%
distribute-lft-neg-out49.1%
distribute-frac-neg249.1%
distribute-frac-neg49.1%
neg-mul-149.1%
distribute-lft-neg-out49.1%
*-commutative49.1%
distribute-lft-neg-in49.1%
times-frac49.1%
metadata-eval49.1%
metadata-eval49.1%
associate--l+49.1%
fma-define49.1%
Simplified49.1%
Taylor expanded in x around 0 43.9%
div-sub43.9%
unpow243.9%
associate-/l*72.7%
*-inverses72.7%
*-rgt-identity72.7%
Simplified72.7%
clear-num72.7%
unpow272.7%
associate-/r*82.0%
associate-/r/82.0%
clear-num82.0%
Applied egg-rr82.0%
Final simplification79.3%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= y_m 235000000.0) (* (/ x y_m) (/ x 2.0)) (* y_m 0.5))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 235000000.0) {
tmp = (x / y_m) * (x / 2.0);
} else {
tmp = y_m * 0.5;
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (y_m <= 235000000.0d0) then
tmp = (x / y_m) * (x / 2.0d0)
else
tmp = y_m * 0.5d0
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 235000000.0) {
tmp = (x / y_m) * (x / 2.0);
} else {
tmp = y_m * 0.5;
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): tmp = 0 if y_m <= 235000000.0: tmp = (x / y_m) * (x / 2.0) else: tmp = y_m * 0.5 return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (y_m <= 235000000.0) tmp = Float64(Float64(x / y_m) * Float64(x / 2.0)); else tmp = Float64(y_m * 0.5); end return Float64(y_s * tmp) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) tmp = 0.0; if (y_m <= 235000000.0) tmp = (x / y_m) * (x / 2.0); else tmp = y_m * 0.5; end tmp_2 = y_s * tmp; end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 235000000.0], N[(N[(x / y$95$m), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision], N[(y$95$m * 0.5), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 235000000:\\
\;\;\;\;\frac{x}{y\_m} \cdot \frac{x}{2}\\
\mathbf{else}:\\
\;\;\;\;y\_m \cdot 0.5\\
\end{array}
\end{array}
if y < 2.35e8Initial program 78.3%
clear-num78.2%
inv-pow78.2%
associate-/l*78.1%
add-sqr-sqrt78.1%
pow278.1%
hypot-define78.1%
pow278.1%
Applied egg-rr78.1%
unpow-178.0%
associate-*r/78.2%
Simplified78.2%
Taylor expanded in x around inf 35.9%
clear-num35.9%
unpow235.9%
times-frac37.3%
Applied egg-rr37.3%
if 2.35e8 < y Initial program 51.9%
Taylor expanded in y around inf 55.9%
*-commutative55.9%
Simplified55.9%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= y_m 290000000.0) (* x (* x (/ 0.5 y_m))) (* y_m 0.5))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 290000000.0) {
tmp = x * (x * (0.5 / y_m));
} else {
tmp = y_m * 0.5;
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (y_m <= 290000000.0d0) then
tmp = x * (x * (0.5d0 / y_m))
else
tmp = y_m * 0.5d0
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 290000000.0) {
tmp = x * (x * (0.5 / y_m));
} else {
tmp = y_m * 0.5;
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): tmp = 0 if y_m <= 290000000.0: tmp = x * (x * (0.5 / y_m)) else: tmp = y_m * 0.5 return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (y_m <= 290000000.0) tmp = Float64(x * Float64(x * Float64(0.5 / y_m))); else tmp = Float64(y_m * 0.5); end return Float64(y_s * tmp) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) tmp = 0.0; if (y_m <= 290000000.0) tmp = x * (x * (0.5 / y_m)); else tmp = y_m * 0.5; end tmp_2 = y_s * tmp; end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 290000000.0], N[(x * N[(x * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y$95$m * 0.5), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 290000000:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;y\_m \cdot 0.5\\
\end{array}
\end{array}
if y < 2.9e8Initial program 78.3%
clear-num78.2%
inv-pow78.2%
associate-/l*78.1%
add-sqr-sqrt78.1%
pow278.1%
hypot-define78.1%
pow278.1%
Applied egg-rr78.1%
unpow-178.0%
associate-*r/78.2%
Simplified78.2%
Taylor expanded in x around inf 35.9%
associate-/r/35.9%
unpow235.9%
associate-*r*37.3%
*-commutative37.3%
associate-/r*37.3%
metadata-eval37.3%
Applied egg-rr37.3%
if 2.9e8 < y Initial program 51.9%
Taylor expanded in y around inf 55.9%
*-commutative55.9%
Simplified55.9%
Final simplification41.3%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (* y_m 0.5)))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
return y_s * (y_m * 0.5);
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
code = y_s * (y_m * 0.5d0)
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
return y_s * (y_m * 0.5);
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): return y_s * (y_m * 0.5)
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) return Float64(y_s * Float64(y_m * 0.5)) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp = code(y_s, x, y_m, z) tmp = y_s * (y_m * 0.5); end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[(y$95$m * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \left(y\_m \cdot 0.5\right)
\end{array}
Initial program 72.5%
Taylor expanded in y around inf 31.9%
*-commutative31.9%
Simplified31.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 2024096
(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)))