
(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}
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
:precision binary64
(let* ((t_0 (* x (sqrt (/ 0.5 y_m)))))
(*
y_s
(if (<= y_m 0.8)
(/ (fma (- y_m z) (+ y_m z) (* x x)) (* y_m 2.0))
(fma t_0 t_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 t_0 = x * sqrt((0.5 / y_m));
double tmp;
if (y_m <= 0.8) {
tmp = fma((y_m - z), (y_m + z), (x * x)) / (y_m * 2.0);
} else {
tmp = fma(t_0, t_0, (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) t_0 = Float64(x * sqrt(Float64(0.5 / y_m))) tmp = 0.0 if (y_m <= 0.8) tmp = Float64(fma(Float64(y_m - z), Float64(y_m + z), Float64(x * x)) / Float64(y_m * 2.0)); else tmp = fma(t_0, t_0, 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_] := Block[{t$95$0 = N[(x * N[Sqrt[N[(0.5 / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[y$95$m, 0.8], N[(N[(N[(y$95$m - z), $MachinePrecision] * N[(y$95$m + z), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * t$95$0 + N[(0.5 * N[(y$95$m - N[(z * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)
\\
\begin{array}{l}
t_0 := x \cdot \sqrt{\frac{0.5}{y_m}}\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;y_m \leq 0.8:\\
\;\;\;\;\frac{\mathsf{fma}\left(y_m - z, y_m + z, x \cdot x\right)}{y_m \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, t_0, 0.5 \cdot \left(y_m - z \cdot \frac{z}{y_m}\right)\right)\\
\end{array}
\end{array}
\end{array}
if y < 0.80000000000000004Initial program 74.0%
associate--l+74.0%
+-commutative74.0%
sqr-neg74.0%
difference-of-squares74.8%
fma-def75.9%
sub-neg75.9%
sub-neg75.9%
remove-double-neg75.9%
Simplified75.9%
if 0.80000000000000004 < y Initial program 39.3%
associate--l+39.3%
difference-of-squares44.0%
*-commutative44.0%
+-commutative44.0%
fma-udef48.0%
add-sqr-sqrt36.9%
pow236.9%
Applied egg-rr29.5%
Taylor expanded in x around inf 69.2%
+-commutative69.2%
add-sqr-sqrt69.2%
fma-def69.2%
Applied egg-rr84.1%
unpow284.1%
*-un-lft-identity84.1%
times-frac99.8%
Applied egg-rr99.8%
Final simplification82.9%
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
:precision binary64
(let* ((t_0
(+
(* (pow (sqrt 0.5) 2.0) (- y_m (/ (pow z 2.0) y_m)))
(* x (/ (* x 0.5) y_m)))))
(*
y_s
(if (<= z 3.5e+63)
t_0
(if (<= z 1.52e+125)
(/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0))
(if (<= z 5.4e+147) t_0 (* (/ (- y_m z) y_m) (/ (+ y_m z) 2.0))))))))y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double t_0 = (pow(sqrt(0.5), 2.0) * (y_m - (pow(z, 2.0) / y_m))) + (x * ((x * 0.5) / y_m));
double tmp;
if (z <= 3.5e+63) {
tmp = t_0;
} else if (z <= 1.52e+125) {
tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
} else if (z <= 5.4e+147) {
tmp = t_0;
} else {
tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
}
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) :: t_0
real(8) :: tmp
t_0 = ((sqrt(0.5d0) ** 2.0d0) * (y_m - ((z ** 2.0d0) / y_m))) + (x * ((x * 0.5d0) / y_m))
if (z <= 3.5d+63) then
tmp = t_0
else if (z <= 1.52d+125) then
tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0d0)
else if (z <= 5.4d+147) then
tmp = t_0
else
tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0d0)
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 t_0 = (Math.pow(Math.sqrt(0.5), 2.0) * (y_m - (Math.pow(z, 2.0) / y_m))) + (x * ((x * 0.5) / y_m));
double tmp;
if (z <= 3.5e+63) {
tmp = t_0;
} else if (z <= 1.52e+125) {
tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
} else if (z <= 5.4e+147) {
tmp = t_0;
} else {
tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
}
return y_s * tmp;
}
y_m = math.fabs(y) y_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): t_0 = (math.pow(math.sqrt(0.5), 2.0) * (y_m - (math.pow(z, 2.0) / y_m))) + (x * ((x * 0.5) / y_m)) tmp = 0 if z <= 3.5e+63: tmp = t_0 elif z <= 1.52e+125: tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0) elif z <= 5.4e+147: tmp = t_0 else: tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0) return y_s * tmp
y_m = abs(y) y_s = copysign(1.0, y) function code(y_s, x, y_m, z) t_0 = Float64(Float64((sqrt(0.5) ^ 2.0) * Float64(y_m - Float64((z ^ 2.0) / y_m))) + Float64(x * Float64(Float64(x * 0.5) / y_m))) tmp = 0.0 if (z <= 3.5e+63) tmp = t_0; elseif (z <= 1.52e+125) tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0)); elseif (z <= 5.4e+147) tmp = t_0; else tmp = Float64(Float64(Float64(y_m - z) / y_m) * Float64(Float64(y_m + z) / 2.0)); 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) t_0 = ((sqrt(0.5) ^ 2.0) * (y_m - ((z ^ 2.0) / y_m))) + (x * ((x * 0.5) / y_m)); tmp = 0.0; if (z <= 3.5e+63) tmp = t_0; elseif (z <= 1.52e+125) tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0); elseif (z <= 5.4e+147) tmp = t_0; else tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0); 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_] := Block[{t$95$0 = N[(N[(N[Power[N[Sqrt[0.5], $MachinePrecision], 2.0], $MachinePrecision] * N[(y$95$m - N[(N[Power[z, 2.0], $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[(N[(x * 0.5), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[z, 3.5e+63], t$95$0, If[LessEqual[z, 1.52e+125], N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y$95$m * y$95$m), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.4e+147], t$95$0, N[(N[(N[(y$95$m - z), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(N[(y$95$m + z), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)
\\
\begin{array}{l}
t_0 := {\left(\sqrt{0.5}\right)}^{2} \cdot \left(y_m - \frac{{z}^{2}}{y_m}\right) + x \cdot \frac{x \cdot 0.5}{y_m}\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 3.5 \cdot 10^{+63}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.52 \cdot 10^{+125}:\\
\;\;\;\;\frac{\left(x \cdot x + y_m \cdot y_m\right) - z \cdot z}{y_m \cdot 2}\\
\mathbf{elif}\;z \leq 5.4 \cdot 10^{+147}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{y_m - z}{y_m} \cdot \frac{y_m + z}{2}\\
\end{array}
\end{array}
\end{array}
if z < 3.50000000000000029e63 or 1.5199999999999999e125 < z < 5.39999999999999995e147Initial program 66.8%
associate--l+66.8%
difference-of-squares67.8%
*-commutative67.8%
+-commutative67.8%
fma-udef68.8%
add-sqr-sqrt33.8%
pow233.8%
Applied egg-rr32.7%
Taylor expanded in x around inf 81.1%
associate-/l*81.0%
div-inv81.0%
unpow281.0%
clear-num81.0%
sqrt-pow281.2%
metadata-eval81.2%
metadata-eval81.2%
associate-*r*87.6%
*-commutative87.6%
metadata-eval87.6%
metadata-eval87.6%
sqrt-pow287.4%
associate-*r/87.4%
sqrt-pow287.7%
metadata-eval87.7%
metadata-eval87.7%
Applied egg-rr87.7%
if 3.50000000000000029e63 < z < 1.5199999999999999e125Initial program 73.4%
if 5.39999999999999995e147 < z Initial program 45.6%
associate--l+45.6%
+-commutative45.6%
sqr-neg45.6%
difference-of-squares52.9%
fma-def60.8%
sub-neg60.8%
sub-neg60.8%
remove-double-neg60.8%
Simplified60.8%
Taylor expanded in x around 0 60.8%
associate-/l*89.6%
div-inv89.6%
*-commutative89.6%
*-un-lft-identity89.6%
times-frac89.6%
metadata-eval89.6%
Applied egg-rr89.6%
expm1-log1p-u35.4%
expm1-udef35.4%
un-div-inv35.4%
*-un-lft-identity35.4%
*-commutative35.4%
times-frac35.4%
clear-num35.4%
Applied egg-rr35.4%
expm1-def35.4%
expm1-log1p89.6%
Simplified89.6%
Final simplification87.6%
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= y_m 1.45e+72)
(/ (fma (- y_m z) (+ y_m z) (* x x)) (* y_m 2.0))
(* (/ (- y_m z) y_m) (/ (+ y_m z) 2.0)))))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.45e+72) {
tmp = fma((y_m - z), (y_m + z), (x * x)) / (y_m * 2.0);
} else {
tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
}
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.45e+72) tmp = Float64(fma(Float64(y_m - z), Float64(y_m + z), Float64(x * x)) / Float64(y_m * 2.0)); else tmp = Float64(Float64(Float64(y_m - z) / y_m) * Float64(Float64(y_m + z) / 2.0)); 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, 1.45e+72], N[(N[(N[(y$95$m - z), $MachinePrecision] * N[(y$95$m + z), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y$95$m - z), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(N[(y$95$m + z), $MachinePrecision] / 2.0), $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.45 \cdot 10^{+72}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y_m - z, y_m + z, x \cdot x\right)}{y_m \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{y_m - z}{y_m} \cdot \frac{y_m + z}{2}\\
\end{array}
\end{array}
if y < 1.45000000000000009e72Initial program 74.5%
associate--l+74.5%
+-commutative74.5%
sqr-neg74.5%
difference-of-squares75.2%
fma-def76.7%
sub-neg76.7%
sub-neg76.7%
remove-double-neg76.7%
Simplified76.7%
if 1.45000000000000009e72 < y Initial program 26.9%
associate--l+26.9%
+-commutative26.9%
sqr-neg26.9%
difference-of-squares33.0%
fma-def36.5%
sub-neg36.5%
sub-neg36.5%
remove-double-neg36.5%
Simplified36.5%
Taylor expanded in x around 0 34.9%
associate-/l*88.2%
div-inv88.3%
*-commutative88.3%
*-un-lft-identity88.3%
times-frac88.3%
metadata-eval88.3%
Applied egg-rr88.3%
expm1-log1p-u63.6%
expm1-udef63.6%
un-div-inv63.6%
*-un-lft-identity63.6%
*-commutative63.6%
times-frac63.6%
clear-num63.6%
Applied egg-rr63.6%
expm1-def63.6%
expm1-log1p88.3%
Simplified88.3%
Final simplification79.3%
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
:precision binary64
(let* ((t_0 (* (- y_m z) (* (+ y_m z) (/ 0.5 y_m)))))
(*
y_s
(if (<= x 1.7e+71)
t_0
(if (<= x 1e+80)
(/ (* x (/ x y_m)) 2.0)
(if (<= x 6.5e+194) t_0 (/ x (* 2.0 (/ y_m x)))))))))y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double t_0 = (y_m - z) * ((y_m + z) * (0.5 / y_m));
double tmp;
if (x <= 1.7e+71) {
tmp = t_0;
} else if (x <= 1e+80) {
tmp = (x * (x / y_m)) / 2.0;
} else if (x <= 6.5e+194) {
tmp = t_0;
} else {
tmp = x / (2.0 * (y_m / 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) :: t_0
real(8) :: tmp
t_0 = (y_m - z) * ((y_m + z) * (0.5d0 / y_m))
if (x <= 1.7d+71) then
tmp = t_0
else if (x <= 1d+80) then
tmp = (x * (x / y_m)) / 2.0d0
else if (x <= 6.5d+194) then
tmp = t_0
else
tmp = x / (2.0d0 * (y_m / 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 t_0 = (y_m - z) * ((y_m + z) * (0.5 / y_m));
double tmp;
if (x <= 1.7e+71) {
tmp = t_0;
} else if (x <= 1e+80) {
tmp = (x * (x / y_m)) / 2.0;
} else if (x <= 6.5e+194) {
tmp = t_0;
} else {
tmp = x / (2.0 * (y_m / 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): t_0 = (y_m - z) * ((y_m + z) * (0.5 / y_m)) tmp = 0 if x <= 1.7e+71: tmp = t_0 elif x <= 1e+80: tmp = (x * (x / y_m)) / 2.0 elif x <= 6.5e+194: tmp = t_0 else: tmp = x / (2.0 * (y_m / x)) return y_s * tmp
y_m = abs(y) y_s = copysign(1.0, y) function code(y_s, x, y_m, z) t_0 = Float64(Float64(y_m - z) * Float64(Float64(y_m + z) * Float64(0.5 / y_m))) tmp = 0.0 if (x <= 1.7e+71) tmp = t_0; elseif (x <= 1e+80) tmp = Float64(Float64(x * Float64(x / y_m)) / 2.0); elseif (x <= 6.5e+194) tmp = t_0; else tmp = Float64(x / Float64(2.0 * Float64(y_m / 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) t_0 = (y_m - z) * ((y_m + z) * (0.5 / y_m)); tmp = 0.0; if (x <= 1.7e+71) tmp = t_0; elseif (x <= 1e+80) tmp = (x * (x / y_m)) / 2.0; elseif (x <= 6.5e+194) tmp = t_0; else tmp = x / (2.0 * (y_m / 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_] := Block[{t$95$0 = N[(N[(y$95$m - z), $MachinePrecision] * N[(N[(y$95$m + z), $MachinePrecision] * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[x, 1.7e+71], t$95$0, If[LessEqual[x, 1e+80], N[(N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 6.5e+194], t$95$0, N[(x / N[(2.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)
\\
\begin{array}{l}
t_0 := \left(y_m - z\right) \cdot \left(\left(y_m + z\right) \cdot \frac{0.5}{y_m}\right)\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 1.7 \cdot 10^{+71}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 10^{+80}:\\
\;\;\;\;\frac{x \cdot \frac{x}{y_m}}{2}\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{+194}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 \cdot \frac{y_m}{x}}\\
\end{array}
\end{array}
\end{array}
if x < 1.6999999999999999e71 or 1e80 < x < 6.50000000000000005e194Initial program 62.5%
associate--l+62.5%
+-commutative62.5%
sqr-neg62.5%
difference-of-squares64.6%
fma-def65.5%
sub-neg65.5%
sub-neg65.5%
remove-double-neg65.5%
Simplified65.5%
Taylor expanded in x around 0 48.5%
div-inv48.4%
*-commutative48.4%
metadata-eval48.4%
metadata-eval48.4%
metadata-eval48.4%
sqrt-pow248.1%
div-inv48.1%
clear-num48.1%
sqrt-pow248.4%
metadata-eval48.4%
metadata-eval48.4%
associate-*l*75.3%
Applied egg-rr75.3%
if 1.6999999999999999e71 < x < 1e80Initial program 100.0%
Taylor expanded in x around inf 100.0%
unpow2100.0%
times-frac99.7%
Applied egg-rr99.7%
associate-*r/99.7%
Simplified99.7%
if 6.50000000000000005e194 < x Initial program 70.6%
Taylor expanded in x around inf 85.6%
div-inv85.6%
*-commutative85.6%
associate-/r*85.6%
metadata-eval85.6%
unpow285.6%
associate-*l*90.2%
Applied egg-rr90.2%
metadata-eval90.2%
metadata-eval90.2%
sqrt-pow290.2%
associate-*r/90.2%
clear-num90.2%
sqrt-pow290.3%
metadata-eval90.3%
metadata-eval90.3%
Applied egg-rr90.3%
un-div-inv90.3%
*-un-lft-identity90.3%
*-commutative90.3%
times-frac90.3%
metadata-eval90.3%
Applied egg-rr90.3%
Final simplification76.9%
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
:precision binary64
(let* ((t_0 (* (/ (- y_m z) y_m) (/ (+ y_m z) 2.0))))
(*
y_s
(if (<= x 1.75e+72)
t_0
(if (<= x 9.5e+79)
(/ (* x (/ x y_m)) 2.0)
(if (<= x 2.2e+195) t_0 (/ x (* 2.0 (/ y_m x)))))))))y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double t_0 = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
double tmp;
if (x <= 1.75e+72) {
tmp = t_0;
} else if (x <= 9.5e+79) {
tmp = (x * (x / y_m)) / 2.0;
} else if (x <= 2.2e+195) {
tmp = t_0;
} else {
tmp = x / (2.0 * (y_m / 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) :: t_0
real(8) :: tmp
t_0 = ((y_m - z) / y_m) * ((y_m + z) / 2.0d0)
if (x <= 1.75d+72) then
tmp = t_0
else if (x <= 9.5d+79) then
tmp = (x * (x / y_m)) / 2.0d0
else if (x <= 2.2d+195) then
tmp = t_0
else
tmp = x / (2.0d0 * (y_m / 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 t_0 = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
double tmp;
if (x <= 1.75e+72) {
tmp = t_0;
} else if (x <= 9.5e+79) {
tmp = (x * (x / y_m)) / 2.0;
} else if (x <= 2.2e+195) {
tmp = t_0;
} else {
tmp = x / (2.0 * (y_m / 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): t_0 = ((y_m - z) / y_m) * ((y_m + z) / 2.0) tmp = 0 if x <= 1.75e+72: tmp = t_0 elif x <= 9.5e+79: tmp = (x * (x / y_m)) / 2.0 elif x <= 2.2e+195: tmp = t_0 else: tmp = x / (2.0 * (y_m / x)) return y_s * tmp
y_m = abs(y) y_s = copysign(1.0, y) function code(y_s, x, y_m, z) t_0 = Float64(Float64(Float64(y_m - z) / y_m) * Float64(Float64(y_m + z) / 2.0)) tmp = 0.0 if (x <= 1.75e+72) tmp = t_0; elseif (x <= 9.5e+79) tmp = Float64(Float64(x * Float64(x / y_m)) / 2.0); elseif (x <= 2.2e+195) tmp = t_0; else tmp = Float64(x / Float64(2.0 * Float64(y_m / 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) t_0 = ((y_m - z) / y_m) * ((y_m + z) / 2.0); tmp = 0.0; if (x <= 1.75e+72) tmp = t_0; elseif (x <= 9.5e+79) tmp = (x * (x / y_m)) / 2.0; elseif (x <= 2.2e+195) tmp = t_0; else tmp = x / (2.0 * (y_m / 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_] := Block[{t$95$0 = N[(N[(N[(y$95$m - z), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(N[(y$95$m + z), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[x, 1.75e+72], t$95$0, If[LessEqual[x, 9.5e+79], N[(N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.2e+195], t$95$0, N[(x / N[(2.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)
\\
\begin{array}{l}
t_0 := \frac{y_m - z}{y_m} \cdot \frac{y_m + z}{2}\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 1.75 \cdot 10^{+72}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+79}:\\
\;\;\;\;\frac{x \cdot \frac{x}{y_m}}{2}\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+195}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2 \cdot \frac{y_m}{x}}\\
\end{array}
\end{array}
\end{array}
if x < 1.75000000000000005e72 or 9.49999999999999994e79 < x < 2.2e195Initial program 62.5%
associate--l+62.5%
+-commutative62.5%
sqr-neg62.5%
difference-of-squares64.6%
fma-def65.5%
sub-neg65.5%
sub-neg65.5%
remove-double-neg65.5%
Simplified65.5%
Taylor expanded in x around 0 48.5%
associate-/l*75.5%
div-inv75.4%
*-commutative75.4%
*-un-lft-identity75.4%
times-frac75.4%
metadata-eval75.4%
Applied egg-rr75.4%
expm1-log1p-u38.9%
expm1-udef33.0%
un-div-inv33.0%
*-un-lft-identity33.0%
*-commutative33.0%
times-frac33.0%
clear-num33.0%
Applied egg-rr33.0%
expm1-def38.9%
expm1-log1p75.4%
Simplified75.4%
if 1.75000000000000005e72 < x < 9.49999999999999994e79Initial program 100.0%
Taylor expanded in x around inf 100.0%
unpow2100.0%
times-frac99.7%
Applied egg-rr99.7%
associate-*r/99.7%
Simplified99.7%
if 2.2e195 < x Initial program 70.6%
Taylor expanded in x around inf 85.6%
div-inv85.6%
*-commutative85.6%
associate-/r*85.6%
metadata-eval85.6%
unpow285.6%
associate-*l*90.2%
Applied egg-rr90.2%
metadata-eval90.2%
metadata-eval90.2%
sqrt-pow290.2%
associate-*r/90.2%
clear-num90.2%
sqrt-pow290.3%
metadata-eval90.3%
metadata-eval90.3%
Applied egg-rr90.3%
un-div-inv90.3%
*-un-lft-identity90.3%
*-commutative90.3%
times-frac90.3%
metadata-eval90.3%
Applied egg-rr90.3%
Final simplification77.1%
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= y_m 3.4e+73)
(/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0))
(* (/ (- y_m z) y_m) (/ (+ y_m z) 2.0)))))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 <= 3.4e+73) {
tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
} else {
tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
}
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 <= 3.4d+73) then
tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0d0)
else
tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0d0)
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 <= 3.4e+73) {
tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0);
} else {
tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0);
}
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 <= 3.4e+73: tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0) else: tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0) 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 <= 3.4e+73) tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0)); else tmp = Float64(Float64(Float64(y_m - z) / y_m) * Float64(Float64(y_m + z) / 2.0)); 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 <= 3.4e+73) tmp = (((x * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0); else tmp = ((y_m - z) / y_m) * ((y_m + z) / 2.0); 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, 3.4e+73], N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y$95$m * y$95$m), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y$95$m - z), $MachinePrecision] / y$95$m), $MachinePrecision] * N[(N[(y$95$m + z), $MachinePrecision] / 2.0), $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 3.4 \cdot 10^{+73}:\\
\;\;\;\;\frac{\left(x \cdot x + y_m \cdot y_m\right) - z \cdot z}{y_m \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{y_m - z}{y_m} \cdot \frac{y_m + z}{2}\\
\end{array}
\end{array}
if y < 3.4000000000000002e73Initial program 74.5%
if 3.4000000000000002e73 < y Initial program 26.9%
associate--l+26.9%
+-commutative26.9%
sqr-neg26.9%
difference-of-squares33.0%
fma-def36.5%
sub-neg36.5%
sub-neg36.5%
remove-double-neg36.5%
Simplified36.5%
Taylor expanded in x around 0 34.9%
associate-/l*88.2%
div-inv88.3%
*-commutative88.3%
*-un-lft-identity88.3%
times-frac88.3%
metadata-eval88.3%
Applied egg-rr88.3%
expm1-log1p-u63.6%
expm1-udef63.6%
un-div-inv63.6%
*-un-lft-identity63.6%
*-commutative63.6%
times-frac63.6%
clear-num63.6%
Applied egg-rr63.6%
expm1-def63.6%
expm1-log1p88.3%
Simplified88.3%
Final simplification77.5%
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
:precision binary64
(let* ((t_0 (* x (* x (/ 0.5 y_m)))))
(*
y_s
(if (<= z 1.7e-207)
(* (+ y_m z) 0.5)
(if (<= z 3.5e-181)
t_0
(if (<= z 4.1e-50)
(* y_m 0.5)
(if (<= z 3e+143) t_0 (* (/ z y_m) (/ z -2.0)))))))))y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double t_0 = x * (x * (0.5 / y_m));
double tmp;
if (z <= 1.7e-207) {
tmp = (y_m + z) * 0.5;
} else if (z <= 3.5e-181) {
tmp = t_0;
} else if (z <= 4.1e-50) {
tmp = y_m * 0.5;
} else if (z <= 3e+143) {
tmp = t_0;
} else {
tmp = (z / y_m) * (z / -2.0);
}
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) :: t_0
real(8) :: tmp
t_0 = x * (x * (0.5d0 / y_m))
if (z <= 1.7d-207) then
tmp = (y_m + z) * 0.5d0
else if (z <= 3.5d-181) then
tmp = t_0
else if (z <= 4.1d-50) then
tmp = y_m * 0.5d0
else if (z <= 3d+143) then
tmp = t_0
else
tmp = (z / y_m) * (z / (-2.0d0))
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 t_0 = x * (x * (0.5 / y_m));
double tmp;
if (z <= 1.7e-207) {
tmp = (y_m + z) * 0.5;
} else if (z <= 3.5e-181) {
tmp = t_0;
} else if (z <= 4.1e-50) {
tmp = y_m * 0.5;
} else if (z <= 3e+143) {
tmp = t_0;
} else {
tmp = (z / y_m) * (z / -2.0);
}
return y_s * tmp;
}
y_m = math.fabs(y) y_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): t_0 = x * (x * (0.5 / y_m)) tmp = 0 if z <= 1.7e-207: tmp = (y_m + z) * 0.5 elif z <= 3.5e-181: tmp = t_0 elif z <= 4.1e-50: tmp = y_m * 0.5 elif z <= 3e+143: tmp = t_0 else: tmp = (z / y_m) * (z / -2.0) return y_s * tmp
y_m = abs(y) y_s = copysign(1.0, y) function code(y_s, x, y_m, z) t_0 = Float64(x * Float64(x * Float64(0.5 / y_m))) tmp = 0.0 if (z <= 1.7e-207) tmp = Float64(Float64(y_m + z) * 0.5); elseif (z <= 3.5e-181) tmp = t_0; elseif (z <= 4.1e-50) tmp = Float64(y_m * 0.5); elseif (z <= 3e+143) tmp = t_0; else tmp = Float64(Float64(z / y_m) * Float64(z / -2.0)); 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) t_0 = x * (x * (0.5 / y_m)); tmp = 0.0; if (z <= 1.7e-207) tmp = (y_m + z) * 0.5; elseif (z <= 3.5e-181) tmp = t_0; elseif (z <= 4.1e-50) tmp = y_m * 0.5; elseif (z <= 3e+143) tmp = t_0; else tmp = (z / y_m) * (z / -2.0); 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_] := Block[{t$95$0 = N[(x * N[(x * N[(0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[z, 1.7e-207], N[(N[(y$95$m + z), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[z, 3.5e-181], t$95$0, If[LessEqual[z, 4.1e-50], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 3e+143], t$95$0, N[(N[(z / y$95$m), $MachinePrecision] * N[(z / -2.0), $MachinePrecision]), $MachinePrecision]]]]]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)
\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot \frac{0.5}{y_m}\right)\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 1.7 \cdot 10^{-207}:\\
\;\;\;\;\left(y_m + z\right) \cdot 0.5\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{-181}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 4.1 \cdot 10^{-50}:\\
\;\;\;\;y_m \cdot 0.5\\
\mathbf{elif}\;z \leq 3 \cdot 10^{+143}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{y_m} \cdot \frac{z}{-2}\\
\end{array}
\end{array}
\end{array}
if z < 1.69999999999999999e-207Initial program 67.1%
associate--l+67.1%
+-commutative67.1%
sqr-neg67.1%
difference-of-squares68.5%
fma-def69.8%
sub-neg69.8%
sub-neg69.8%
remove-double-neg69.8%
Simplified69.8%
Taylor expanded in x around 0 46.8%
associate-/l*68.4%
div-inv68.4%
*-commutative68.4%
*-un-lft-identity68.4%
times-frac68.4%
metadata-eval68.4%
Applied egg-rr68.4%
Taylor expanded in y around inf 38.7%
if 1.69999999999999999e-207 < z < 3.49999999999999996e-181 or 4.09999999999999985e-50 < z < 3.0000000000000001e143Initial program 72.5%
Taylor expanded in x around inf 51.5%
div-inv51.5%
*-commutative51.5%
associate-/r*51.5%
metadata-eval51.5%
unpow251.5%
associate-*l*56.9%
Applied egg-rr56.9%
if 3.49999999999999996e-181 < z < 4.09999999999999985e-50Initial program 58.4%
Taylor expanded in y around inf 67.8%
if 3.0000000000000001e143 < z Initial program 47.0%
associate--l+47.0%
difference-of-squares54.1%
*-commutative54.1%
+-commutative54.1%
fma-udef61.8%
clear-num61.8%
inv-pow61.8%
fma-udef54.1%
+-commutative54.1%
*-commutative54.1%
difference-of-squares47.0%
associate--l+47.0%
add-sqr-sqrt47.0%
pow247.0%
hypot-def47.0%
pow247.0%
Applied egg-rr47.0%
Taylor expanded in z around inf 54.5%
associate-*r/54.5%
*-commutative54.5%
Simplified54.5%
unpow-154.5%
clear-num54.5%
unpow254.5%
times-frac68.7%
Applied egg-rr68.7%
Final simplification48.8%
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
:precision binary64
(let* ((t_0 (/ x (* 2.0 (/ y_m x)))))
(*
y_s
(if (<= z 5.9e-210)
(* (+ y_m z) 0.5)
(if (<= z 1.62e-180)
t_0
(if (<= z 1.02e-50)
(* y_m 0.5)
(if (<= z 7.5e+143) t_0 (* (/ z y_m) (/ z -2.0)))))))))y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double t_0 = x / (2.0 * (y_m / x));
double tmp;
if (z <= 5.9e-210) {
tmp = (y_m + z) * 0.5;
} else if (z <= 1.62e-180) {
tmp = t_0;
} else if (z <= 1.02e-50) {
tmp = y_m * 0.5;
} else if (z <= 7.5e+143) {
tmp = t_0;
} else {
tmp = (z / y_m) * (z / -2.0);
}
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) :: t_0
real(8) :: tmp
t_0 = x / (2.0d0 * (y_m / x))
if (z <= 5.9d-210) then
tmp = (y_m + z) * 0.5d0
else if (z <= 1.62d-180) then
tmp = t_0
else if (z <= 1.02d-50) then
tmp = y_m * 0.5d0
else if (z <= 7.5d+143) then
tmp = t_0
else
tmp = (z / y_m) * (z / (-2.0d0))
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 t_0 = x / (2.0 * (y_m / x));
double tmp;
if (z <= 5.9e-210) {
tmp = (y_m + z) * 0.5;
} else if (z <= 1.62e-180) {
tmp = t_0;
} else if (z <= 1.02e-50) {
tmp = y_m * 0.5;
} else if (z <= 7.5e+143) {
tmp = t_0;
} else {
tmp = (z / y_m) * (z / -2.0);
}
return y_s * tmp;
}
y_m = math.fabs(y) y_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): t_0 = x / (2.0 * (y_m / x)) tmp = 0 if z <= 5.9e-210: tmp = (y_m + z) * 0.5 elif z <= 1.62e-180: tmp = t_0 elif z <= 1.02e-50: tmp = y_m * 0.5 elif z <= 7.5e+143: tmp = t_0 else: tmp = (z / y_m) * (z / -2.0) return y_s * tmp
y_m = abs(y) y_s = copysign(1.0, y) function code(y_s, x, y_m, z) t_0 = Float64(x / Float64(2.0 * Float64(y_m / x))) tmp = 0.0 if (z <= 5.9e-210) tmp = Float64(Float64(y_m + z) * 0.5); elseif (z <= 1.62e-180) tmp = t_0; elseif (z <= 1.02e-50) tmp = Float64(y_m * 0.5); elseif (z <= 7.5e+143) tmp = t_0; else tmp = Float64(Float64(z / y_m) * Float64(z / -2.0)); 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) t_0 = x / (2.0 * (y_m / x)); tmp = 0.0; if (z <= 5.9e-210) tmp = (y_m + z) * 0.5; elseif (z <= 1.62e-180) tmp = t_0; elseif (z <= 1.02e-50) tmp = y_m * 0.5; elseif (z <= 7.5e+143) tmp = t_0; else tmp = (z / y_m) * (z / -2.0); 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_] := Block[{t$95$0 = N[(x / N[(2.0 * N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[z, 5.9e-210], N[(N[(y$95$m + z), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[z, 1.62e-180], t$95$0, If[LessEqual[z, 1.02e-50], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 7.5e+143], t$95$0, N[(N[(z / y$95$m), $MachinePrecision] * N[(z / -2.0), $MachinePrecision]), $MachinePrecision]]]]]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)
\\
\begin{array}{l}
t_0 := \frac{x}{2 \cdot \frac{y_m}{x}}\\
y_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 5.9 \cdot 10^{-210}:\\
\;\;\;\;\left(y_m + z\right) \cdot 0.5\\
\mathbf{elif}\;z \leq 1.62 \cdot 10^{-180}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.02 \cdot 10^{-50}:\\
\;\;\;\;y_m \cdot 0.5\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{+143}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{y_m} \cdot \frac{z}{-2}\\
\end{array}
\end{array}
\end{array}
if z < 5.8999999999999999e-210Initial program 67.1%
associate--l+67.1%
+-commutative67.1%
sqr-neg67.1%
difference-of-squares68.5%
fma-def69.8%
sub-neg69.8%
sub-neg69.8%
remove-double-neg69.8%
Simplified69.8%
Taylor expanded in x around 0 46.8%
associate-/l*68.4%
div-inv68.4%
*-commutative68.4%
*-un-lft-identity68.4%
times-frac68.4%
metadata-eval68.4%
Applied egg-rr68.4%
Taylor expanded in y around inf 38.7%
if 5.8999999999999999e-210 < z < 1.61999999999999996e-180 or 1.0199999999999999e-50 < z < 7.49999999999999974e143Initial program 72.5%
Taylor expanded in x around inf 51.5%
div-inv51.5%
*-commutative51.5%
associate-/r*51.5%
metadata-eval51.5%
unpow251.5%
associate-*l*56.9%
Applied egg-rr56.9%
metadata-eval56.9%
metadata-eval56.9%
sqrt-pow256.6%
associate-*r/56.6%
clear-num56.6%
sqrt-pow256.9%
metadata-eval56.9%
metadata-eval56.9%
Applied egg-rr56.9%
un-div-inv57.0%
*-un-lft-identity57.0%
*-commutative57.0%
times-frac57.0%
metadata-eval57.0%
Applied egg-rr57.0%
if 1.61999999999999996e-180 < z < 1.0199999999999999e-50Initial program 58.4%
Taylor expanded in y around inf 67.8%
if 7.49999999999999974e143 < z Initial program 47.0%
associate--l+47.0%
difference-of-squares54.1%
*-commutative54.1%
+-commutative54.1%
fma-udef61.8%
clear-num61.8%
inv-pow61.8%
fma-udef54.1%
+-commutative54.1%
*-commutative54.1%
difference-of-squares47.0%
associate--l+47.0%
add-sqr-sqrt47.0%
pow247.0%
hypot-def47.0%
pow247.0%
Applied egg-rr47.0%
Taylor expanded in z around inf 54.5%
associate-*r/54.5%
*-commutative54.5%
Simplified54.5%
unpow-154.5%
clear-num54.5%
unpow254.5%
times-frac68.7%
Applied egg-rr68.7%
Final simplification48.8%
y_m = (fabs.f64 y) y_s = (copysign.f64 1 y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= y_m 2e+63) (* 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 <= 2e+63) {
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 <= 2d+63) 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 <= 2e+63) {
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 <= 2e+63: 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 <= 2e+63) 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 <= 2e+63) 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, 2e+63], 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 2 \cdot 10^{+63}:\\
\;\;\;\;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.00000000000000012e63Initial program 74.3%
Taylor expanded in x around inf 36.6%
div-inv36.6%
*-commutative36.6%
associate-/r*36.6%
metadata-eval36.6%
unpow236.6%
associate-*l*38.0%
Applied egg-rr38.0%
if 2.00000000000000012e63 < y Initial program 28.1%
Taylor expanded in y around inf 70.8%
Final simplification45.4%
y_m = (fabs.f64 y) y_s = (copysign.f64 1 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 63.9%
Taylor expanded in y around inf 37.8%
Final simplification37.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 2024010
(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)))