
(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 5 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
(*
y_s
(if (<= (/ (- (+ (* x x) (* y_m y_m)) (* z z)) (* y_m 2.0)) 0.0)
(* z (* z (/ -0.5 y_m)))
(* 0.5 (+ y_m (* x (/ x 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 * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= 0.0) {
tmp = z * (z * (-0.5 / y_m));
} else {
tmp = 0.5 * (y_m + (x * (x / 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 * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0d0)) <= 0.0d0) then
tmp = z * (z * ((-0.5d0) / y_m))
else
tmp = 0.5d0 * (y_m + (x * (x / 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 * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= 0.0) {
tmp = z * (z * (-0.5 / y_m));
} else {
tmp = 0.5 * (y_m + (x * (x / 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 * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= 0.0: tmp = z * (z * (-0.5 / y_m)) else: tmp = 0.5 * (y_m + (x * (x / 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 (Float64(Float64(Float64(Float64(x * x) + Float64(y_m * y_m)) - Float64(z * z)) / Float64(y_m * 2.0)) <= 0.0) tmp = Float64(z * Float64(z * Float64(-0.5 / y_m))); else tmp = Float64(0.5 * Float64(y_m + Float64(x * Float64(x / 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 * x) + (y_m * y_m)) - (z * z)) / (y_m * 2.0)) <= 0.0) tmp = z * (z * (-0.5 / y_m)); else tmp = 0.5 * (y_m + (x * (x / 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[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], 0.0], N[(z * N[(z * N[(-0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y$95$m + N[(x * N[(x / 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}\;\frac{\left(x \cdot x + y\_m \cdot y\_m\right) - z \cdot z}{y\_m \cdot 2} \leq 0:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y\_m + x \cdot \frac{x}{y\_m}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y 2)) < 0.0Initial program 74.6%
clear-num74.6%
inv-pow74.6%
associate-/l*74.6%
add-sqr-sqrt74.6%
pow274.6%
hypot-define74.6%
pow274.6%
Applied egg-rr74.6%
unpow-174.6%
associate-*r/74.6%
Simplified74.6%
add-sqr-sqrt74.6%
sqrt-unprod58.0%
pow-prod-up58.0%
metadata-eval58.0%
Applied egg-rr58.0%
hypot-undefine58.0%
unpow258.0%
unpow258.0%
+-commutative58.0%
unpow258.0%
unpow258.0%
hypot-define58.0%
Simplified58.0%
Taylor expanded in z around inf 29.1%
associate-*r/29.1%
*-commutative29.1%
Simplified29.1%
associate-/r/29.1%
unpow229.1%
associate-*r*32.3%
*-commutative32.3%
associate-/r*32.3%
metadata-eval32.3%
Applied egg-rr32.3%
if 0.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y 2)) Initial program 69.3%
remove-double-neg69.3%
distribute-lft-neg-out69.3%
distribute-frac-neg269.3%
distribute-frac-neg69.3%
neg-mul-169.3%
distribute-lft-neg-out69.3%
*-commutative69.3%
distribute-lft-neg-in69.3%
times-frac69.3%
metadata-eval69.3%
metadata-eval69.3%
associate--l+69.3%
fma-define70.8%
Simplified70.8%
Taylor expanded in z around inf 51.6%
associate--l+51.6%
unpow251.6%
associate-/l*54.4%
fma-neg54.4%
distribute-neg-frac54.4%
metadata-eval54.4%
Simplified54.4%
Taylor expanded in z around 0 59.7%
unpow259.7%
associate-/l*67.1%
Applied egg-rr67.1%
Final simplification51.1%
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 (* y_m 2.0)))))
(*
y_s
(if (<= z 1.6e-294)
(* y_m 0.5)
(if (<= z 5.7e-158)
t_0
(if (<= z 3.8e-128)
(* y_m 0.5)
(if (<= z 9e-107)
t_0
(if (<= z 3.3e-37)
(* y_m 0.5)
(if (<= z 1.45e+124) t_0 (* z (* z (/ -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 t_0 = x * (x / (y_m * 2.0));
double tmp;
if (z <= 1.6e-294) {
tmp = y_m * 0.5;
} else if (z <= 5.7e-158) {
tmp = t_0;
} else if (z <= 3.8e-128) {
tmp = y_m * 0.5;
} else if (z <= 9e-107) {
tmp = t_0;
} else if (z <= 3.3e-37) {
tmp = y_m * 0.5;
} else if (z <= 1.45e+124) {
tmp = t_0;
} else {
tmp = z * (z * (-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) :: t_0
real(8) :: tmp
t_0 = x * (x / (y_m * 2.0d0))
if (z <= 1.6d-294) then
tmp = y_m * 0.5d0
else if (z <= 5.7d-158) then
tmp = t_0
else if (z <= 3.8d-128) then
tmp = y_m * 0.5d0
else if (z <= 9d-107) then
tmp = t_0
else if (z <= 3.3d-37) then
tmp = y_m * 0.5d0
else if (z <= 1.45d+124) then
tmp = t_0
else
tmp = z * (z * ((-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 t_0 = x * (x / (y_m * 2.0));
double tmp;
if (z <= 1.6e-294) {
tmp = y_m * 0.5;
} else if (z <= 5.7e-158) {
tmp = t_0;
} else if (z <= 3.8e-128) {
tmp = y_m * 0.5;
} else if (z <= 9e-107) {
tmp = t_0;
} else if (z <= 3.3e-37) {
tmp = y_m * 0.5;
} else if (z <= 1.45e+124) {
tmp = t_0;
} else {
tmp = z * (z * (-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): t_0 = x * (x / (y_m * 2.0)) tmp = 0 if z <= 1.6e-294: tmp = y_m * 0.5 elif z <= 5.7e-158: tmp = t_0 elif z <= 3.8e-128: tmp = y_m * 0.5 elif z <= 9e-107: tmp = t_0 elif z <= 3.3e-37: tmp = y_m * 0.5 elif z <= 1.45e+124: tmp = t_0 else: tmp = z * (z * (-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) t_0 = Float64(x * Float64(x / Float64(y_m * 2.0))) tmp = 0.0 if (z <= 1.6e-294) tmp = Float64(y_m * 0.5); elseif (z <= 5.7e-158) tmp = t_0; elseif (z <= 3.8e-128) tmp = Float64(y_m * 0.5); elseif (z <= 9e-107) tmp = t_0; elseif (z <= 3.3e-37) tmp = Float64(y_m * 0.5); elseif (z <= 1.45e+124) tmp = t_0; else tmp = Float64(z * Float64(z * 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) t_0 = x * (x / (y_m * 2.0)); tmp = 0.0; if (z <= 1.6e-294) tmp = y_m * 0.5; elseif (z <= 5.7e-158) tmp = t_0; elseif (z <= 3.8e-128) tmp = y_m * 0.5; elseif (z <= 9e-107) tmp = t_0; elseif (z <= 3.3e-37) tmp = y_m * 0.5; elseif (z <= 1.45e+124) tmp = t_0; else tmp = z * (z * (-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_] := Block[{t$95$0 = N[(x * N[(x / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[z, 1.6e-294], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 5.7e-158], t$95$0, If[LessEqual[z, 3.8e-128], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 9e-107], t$95$0, If[LessEqual[z, 3.3e-37], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 1.45e+124], t$95$0, N[(z * N[(z * 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)
\\
\begin{array}{l}
t_0 := x \cdot \frac{x}{y\_m \cdot 2}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 1.6 \cdot 10^{-294}:\\
\;\;\;\;y\_m \cdot 0.5\\
\mathbf{elif}\;z \leq 5.7 \cdot 10^{-158}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{-128}:\\
\;\;\;\;y\_m \cdot 0.5\\
\mathbf{elif}\;z \leq 9 \cdot 10^{-107}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.3 \cdot 10^{-37}:\\
\;\;\;\;y\_m \cdot 0.5\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{+124}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y\_m}\right)\\
\end{array}
\end{array}
\end{array}
if z < 1.6000000000000001e-294 or 5.69999999999999982e-158 < z < 3.8000000000000002e-128 or 9.00000000000000032e-107 < z < 3.29999999999999982e-37Initial program 70.0%
Taylor expanded in y around inf 38.1%
*-commutative38.1%
Simplified38.1%
if 1.6000000000000001e-294 < z < 5.69999999999999982e-158 or 3.8000000000000002e-128 < z < 9.00000000000000032e-107 or 3.29999999999999982e-37 < z < 1.45000000000000011e124Initial program 77.2%
clear-num77.1%
inv-pow77.1%
associate-/l*77.1%
add-sqr-sqrt77.1%
pow277.1%
hypot-define77.1%
pow277.1%
Applied egg-rr77.1%
unpow-177.1%
associate-*r/77.1%
Simplified77.1%
Taylor expanded in x around inf 45.3%
associate-*r/45.3%
*-commutative45.3%
unpow245.3%
associate-/r*51.3%
*-commutative51.3%
Applied egg-rr51.3%
associate-/r/51.3%
clear-num51.3%
*-commutative51.3%
Applied egg-rr51.3%
if 1.45000000000000011e124 < z Initial program 70.4%
clear-num70.4%
inv-pow70.4%
associate-/l*70.4%
add-sqr-sqrt70.4%
pow270.4%
hypot-define70.4%
pow270.4%
Applied egg-rr70.4%
unpow-170.4%
associate-*r/70.4%
Simplified70.4%
add-sqr-sqrt70.4%
sqrt-unprod42.4%
pow-prod-up42.4%
metadata-eval42.4%
Applied egg-rr42.4%
hypot-undefine42.4%
unpow242.4%
unpow242.4%
+-commutative42.4%
unpow242.4%
unpow242.4%
hypot-define42.4%
Simplified42.4%
Taylor expanded in z around inf 73.4%
associate-*r/73.4%
*-commutative73.4%
Simplified73.4%
associate-/r/73.4%
unpow273.4%
associate-*r*81.8%
*-commutative81.8%
associate-/r*81.8%
metadata-eval81.8%
Applied egg-rr81.8%
Final simplification47.0%
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 1.5e-294)
(* y_m 0.5)
(if (<= z 4.8e-157)
t_0
(if (<= z 5.8e-128)
(* y_m 0.5)
(if (<= z 3e-107)
(* x (/ x (* y_m 2.0)))
(if (<= z 1.6e-37)
(* y_m 0.5)
(if (<= z 4.3e+123) t_0 (* z (* z (/ -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 t_0 = (x / 2.0) / (y_m / x);
double tmp;
if (z <= 1.5e-294) {
tmp = y_m * 0.5;
} else if (z <= 4.8e-157) {
tmp = t_0;
} else if (z <= 5.8e-128) {
tmp = y_m * 0.5;
} else if (z <= 3e-107) {
tmp = x * (x / (y_m * 2.0));
} else if (z <= 1.6e-37) {
tmp = y_m * 0.5;
} else if (z <= 4.3e+123) {
tmp = t_0;
} else {
tmp = z * (z * (-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) :: t_0
real(8) :: tmp
t_0 = (x / 2.0d0) / (y_m / x)
if (z <= 1.5d-294) then
tmp = y_m * 0.5d0
else if (z <= 4.8d-157) then
tmp = t_0
else if (z <= 5.8d-128) then
tmp = y_m * 0.5d0
else if (z <= 3d-107) then
tmp = x * (x / (y_m * 2.0d0))
else if (z <= 1.6d-37) then
tmp = y_m * 0.5d0
else if (z <= 4.3d+123) then
tmp = t_0
else
tmp = z * (z * ((-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 t_0 = (x / 2.0) / (y_m / x);
double tmp;
if (z <= 1.5e-294) {
tmp = y_m * 0.5;
} else if (z <= 4.8e-157) {
tmp = t_0;
} else if (z <= 5.8e-128) {
tmp = y_m * 0.5;
} else if (z <= 3e-107) {
tmp = x * (x / (y_m * 2.0));
} else if (z <= 1.6e-37) {
tmp = y_m * 0.5;
} else if (z <= 4.3e+123) {
tmp = t_0;
} else {
tmp = z * (z * (-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): t_0 = (x / 2.0) / (y_m / x) tmp = 0 if z <= 1.5e-294: tmp = y_m * 0.5 elif z <= 4.8e-157: tmp = t_0 elif z <= 5.8e-128: tmp = y_m * 0.5 elif z <= 3e-107: tmp = x * (x / (y_m * 2.0)) elif z <= 1.6e-37: tmp = y_m * 0.5 elif z <= 4.3e+123: tmp = t_0 else: tmp = z * (z * (-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) t_0 = Float64(Float64(x / 2.0) / Float64(y_m / x)) tmp = 0.0 if (z <= 1.5e-294) tmp = Float64(y_m * 0.5); elseif (z <= 4.8e-157) tmp = t_0; elseif (z <= 5.8e-128) tmp = Float64(y_m * 0.5); elseif (z <= 3e-107) tmp = Float64(x * Float64(x / Float64(y_m * 2.0))); elseif (z <= 1.6e-37) tmp = Float64(y_m * 0.5); elseif (z <= 4.3e+123) tmp = t_0; else tmp = Float64(z * Float64(z * 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) t_0 = (x / 2.0) / (y_m / x); tmp = 0.0; if (z <= 1.5e-294) tmp = y_m * 0.5; elseif (z <= 4.8e-157) tmp = t_0; elseif (z <= 5.8e-128) tmp = y_m * 0.5; elseif (z <= 3e-107) tmp = x * (x / (y_m * 2.0)); elseif (z <= 1.6e-37) tmp = y_m * 0.5; elseif (z <= 4.3e+123) tmp = t_0; else tmp = z * (z * (-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_] := Block[{t$95$0 = N[(N[(x / 2.0), $MachinePrecision] / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[z, 1.5e-294], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 4.8e-157], t$95$0, If[LessEqual[z, 5.8e-128], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 3e-107], N[(x * N[(x / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.6e-37], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[z, 4.3e+123], t$95$0, N[(z * N[(z * 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)
\\
\begin{array}{l}
t_0 := \frac{\frac{x}{2}}{\frac{y\_m}{x}}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 1.5 \cdot 10^{-294}:\\
\;\;\;\;y\_m \cdot 0.5\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{-157}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{-128}:\\
\;\;\;\;y\_m \cdot 0.5\\
\mathbf{elif}\;z \leq 3 \cdot 10^{-107}:\\
\;\;\;\;x \cdot \frac{x}{y\_m \cdot 2}\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{-37}:\\
\;\;\;\;y\_m \cdot 0.5\\
\mathbf{elif}\;z \leq 4.3 \cdot 10^{+123}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y\_m}\right)\\
\end{array}
\end{array}
\end{array}
if z < 1.4999999999999999e-294 or 4.8e-157 < z < 5.8000000000000001e-128 or 2.9999999999999997e-107 < z < 1.5999999999999999e-37Initial program 70.0%
Taylor expanded in y around inf 38.1%
*-commutative38.1%
Simplified38.1%
if 1.4999999999999999e-294 < z < 4.8e-157 or 1.5999999999999999e-37 < z < 4.29999999999999986e123Initial program 77.5%
clear-num77.5%
inv-pow77.5%
associate-/l*77.4%
add-sqr-sqrt77.4%
pow277.4%
hypot-define77.4%
pow277.4%
Applied egg-rr77.4%
unpow-177.4%
associate-*r/77.5%
Simplified77.5%
Taylor expanded in x around inf 44.1%
add-sqr-sqrt28.5%
pow228.5%
associate-/r*28.5%
metadata-eval28.5%
sqrt-div28.2%
sqrt-div28.2%
sqrt-pow131.4%
metadata-eval31.4%
pow131.4%
Applied egg-rr31.4%
unpow231.4%
div-inv31.3%
clear-num31.3%
div-inv31.3%
clear-num31.3%
swap-sqr31.3%
rem-square-sqrt31.3%
metadata-eval31.3%
times-frac28.2%
add-sqr-sqrt44.1%
associate-*r/48.8%
clear-num48.8%
un-div-inv48.8%
times-frac48.8%
*-un-lft-identity48.8%
associate-/r*48.8%
Applied egg-rr48.8%
if 5.8000000000000001e-128 < z < 2.9999999999999997e-107Initial program 70.5%
clear-num69.9%
inv-pow69.9%
associate-/l*70.5%
add-sqr-sqrt70.5%
pow270.5%
hypot-define70.5%
pow270.5%
Applied egg-rr70.5%
unpow-170.5%
associate-*r/69.9%
Simplified69.9%
Taylor expanded in x around inf 69.9%
associate-*r/69.9%
*-commutative69.9%
unpow269.9%
associate-/r*99.5%
*-commutative99.5%
Applied egg-rr99.5%
associate-/r/99.5%
clear-num100.0%
*-commutative100.0%
Applied egg-rr100.0%
if 4.29999999999999986e123 < z Initial program 70.4%
clear-num70.4%
inv-pow70.4%
associate-/l*70.4%
add-sqr-sqrt70.4%
pow270.4%
hypot-define70.4%
pow270.4%
Applied egg-rr70.4%
unpow-170.4%
associate-*r/70.4%
Simplified70.4%
add-sqr-sqrt70.4%
sqrt-unprod42.4%
pow-prod-up42.4%
metadata-eval42.4%
Applied egg-rr42.4%
hypot-undefine42.4%
unpow242.4%
unpow242.4%
+-commutative42.4%
unpow242.4%
unpow242.4%
hypot-define42.4%
Simplified42.4%
Taylor expanded in z around inf 73.4%
associate-*r/73.4%
*-commutative73.4%
Simplified73.4%
associate-/r/73.4%
unpow273.4%
associate-*r*81.8%
*-commutative81.8%
associate-/r*81.8%
metadata-eval81.8%
Applied egg-rr81.8%
Final simplification47.0%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 1 y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= z 6.8e+26) (* y_m 0.5) (* z (* z (/ -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 (z <= 6.8e+26) {
tmp = y_m * 0.5;
} else {
tmp = z * (z * (-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 (z <= 6.8d+26) then
tmp = y_m * 0.5d0
else
tmp = z * (z * ((-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 (z <= 6.8e+26) {
tmp = y_m * 0.5;
} else {
tmp = z * (z * (-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 z <= 6.8e+26: tmp = y_m * 0.5 else: tmp = z * (z * (-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 (z <= 6.8e+26) tmp = Float64(y_m * 0.5); else tmp = Float64(z * Float64(z * 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 (z <= 6.8e+26) tmp = y_m * 0.5; else tmp = z * (z * (-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[LessEqual[z, 6.8e+26], N[(y$95$m * 0.5), $MachinePrecision], N[(z * N[(z * 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}\;z \leq 6.8 \cdot 10^{+26}:\\
\;\;\;\;y\_m \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y\_m}\right)\\
\end{array}
\end{array}
if z < 6.8000000000000005e26Initial program 71.1%
Taylor expanded in y around inf 37.8%
*-commutative37.8%
Simplified37.8%
if 6.8000000000000005e26 < z Initial program 74.2%
clear-num74.1%
inv-pow74.1%
associate-/l*74.1%
add-sqr-sqrt74.1%
pow274.1%
hypot-define74.1%
pow274.1%
Applied egg-rr74.1%
unpow-174.1%
associate-*r/74.1%
Simplified74.1%
add-sqr-sqrt74.1%
sqrt-unprod52.5%
pow-prod-up52.5%
metadata-eval52.5%
Applied egg-rr52.5%
hypot-undefine52.5%
unpow252.5%
unpow252.5%
+-commutative52.5%
unpow252.5%
unpow252.5%
hypot-define52.5%
Simplified52.5%
Taylor expanded in z around inf 58.7%
associate-*r/58.7%
*-commutative58.7%
Simplified58.7%
associate-/r/58.8%
unpow258.8%
associate-*r*63.7%
*-commutative63.7%
associate-/r*63.7%
metadata-eval63.7%
Applied egg-rr63.7%
Final simplification43.5%
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 71.8%
Taylor expanded in y around inf 32.1%
*-commutative32.1%
Simplified32.1%
Final simplification32.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 2024055
(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)))