
(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 1.2e+157)
(* 0.5 (/ (fma x x (- (* y_m y_m) (* z z))) 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 <= 1.2e+157) {
tmp = 0.5 * (fma(x, x, ((y_m * y_m) - (z * z))) / 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 <= 1.2e+157) tmp = Float64(0.5 * Float64(fma(x, x, Float64(Float64(y_m * y_m) - Float64(z * z))) / y_m)); else tmp = Float64(y_m * 0.5); 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.2e+157], 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[(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 1.2 \cdot 10^{+157}:\\
\;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y\_m \cdot y\_m - z \cdot z\right)}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;y\_m \cdot 0.5\\
\end{array}
\end{array}
if y < 1.2e157Initial program 72.0%
remove-double-neg72.0%
distribute-lft-neg-out72.0%
distribute-frac-neg272.0%
distribute-frac-neg72.0%
neg-mul-172.0%
distribute-lft-neg-out72.0%
*-commutative72.0%
distribute-lft-neg-in72.0%
times-frac72.0%
metadata-eval72.0%
metadata-eval72.0%
associate--l+72.0%
fma-define75.9%
Simplified75.9%
if 1.2e157 < y Initial program 9.7%
remove-double-neg9.7%
distribute-lft-neg-out9.7%
distribute-frac-neg29.7%
distribute-frac-neg9.7%
neg-mul-19.7%
distribute-lft-neg-out9.7%
*-commutative9.7%
distribute-lft-neg-in9.7%
times-frac9.7%
metadata-eval9.7%
metadata-eval9.7%
associate--l+9.7%
fma-define9.7%
Simplified9.7%
Taylor expanded in y around inf 76.0%
Final simplification75.9%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(let* ((t_0 (/ (/ z -2.0) (/ y_m z))))
(*
y_s
(if (<= x 2.05e-251)
t_0
(if (<= x 6e-70)
(* y_m 0.5)
(if (<= x 1.72e+47) t_0 (* 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 t_0 = (z / -2.0) / (y_m / z);
double tmp;
if (x <= 2.05e-251) {
tmp = t_0;
} else if (x <= 6e-70) {
tmp = y_m * 0.5;
} else if (x <= 1.72e+47) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (z / (-2.0d0)) / (y_m / z)
if (x <= 2.05d-251) then
tmp = t_0
else if (x <= 6d-70) then
tmp = y_m * 0.5d0
else if (x <= 1.72d+47) then
tmp = t_0
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 t_0 = (z / -2.0) / (y_m / z);
double tmp;
if (x <= 2.05e-251) {
tmp = t_0;
} else if (x <= 6e-70) {
tmp = y_m * 0.5;
} else if (x <= 1.72e+47) {
tmp = t_0;
} 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): t_0 = (z / -2.0) / (y_m / z) tmp = 0 if x <= 2.05e-251: tmp = t_0 elif x <= 6e-70: tmp = y_m * 0.5 elif x <= 1.72e+47: tmp = t_0 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) t_0 = Float64(Float64(z / -2.0) / Float64(y_m / z)) tmp = 0.0 if (x <= 2.05e-251) tmp = t_0; elseif (x <= 6e-70) tmp = Float64(y_m * 0.5); elseif (x <= 1.72e+47) tmp = t_0; 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) t_0 = (z / -2.0) / (y_m / z); tmp = 0.0; if (x <= 2.05e-251) tmp = t_0; elseif (x <= 6e-70) tmp = y_m * 0.5; elseif (x <= 1.72e+47) tmp = t_0; 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_] := Block[{t$95$0 = N[(N[(z / -2.0), $MachinePrecision] / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[x, 2.05e-251], t$95$0, If[LessEqual[x, 6e-70], N[(y$95$m * 0.5), $MachinePrecision], If[LessEqual[x, 1.72e+47], t$95$0, 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)
\\
\begin{array}{l}
t_0 := \frac{\frac{z}{-2}}{\frac{y\_m}{z}}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;x \leq 2.05 \cdot 10^{-251}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6 \cdot 10^{-70}:\\
\;\;\;\;y\_m \cdot 0.5\\
\mathbf{elif}\;x \leq 1.72 \cdot 10^{+47}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y\_m}\right)\\
\end{array}
\end{array}
\end{array}
if x < 2.0499999999999999e-251 or 6.0000000000000003e-70 < x < 1.72000000000000002e47Initial program 70.7%
remove-double-neg70.7%
distribute-lft-neg-out70.7%
distribute-frac-neg270.7%
distribute-frac-neg70.7%
neg-mul-170.7%
distribute-lft-neg-out70.7%
*-commutative70.7%
distribute-lft-neg-in70.7%
times-frac70.7%
metadata-eval70.7%
metadata-eval70.7%
associate--l+70.7%
fma-define71.9%
Simplified71.9%
Taylor expanded in z around inf 33.7%
*-commutative33.7%
associate-*l/33.7%
Simplified33.7%
pow233.7%
Applied egg-rr33.7%
associate-*l*33.7%
associate-/l*35.9%
Applied egg-rr35.9%
clear-num35.8%
un-div-inv35.9%
*-un-lft-identity35.9%
*-commutative35.9%
times-frac35.9%
metadata-eval35.9%
Applied egg-rr35.9%
rem-cube-cbrt35.4%
associate-/r*35.5%
rem-cube-cbrt35.9%
Simplified35.9%
if 2.0499999999999999e-251 < x < 6.0000000000000003e-70Initial program 50.6%
remove-double-neg50.6%
distribute-lft-neg-out50.6%
distribute-frac-neg250.6%
distribute-frac-neg50.6%
neg-mul-150.6%
distribute-lft-neg-out50.6%
*-commutative50.6%
distribute-lft-neg-in50.6%
times-frac50.6%
metadata-eval50.6%
metadata-eval50.6%
associate--l+50.6%
fma-define50.6%
Simplified50.6%
Taylor expanded in y around inf 60.5%
if 1.72000000000000002e47 < x Initial program 63.0%
remove-double-neg63.0%
distribute-lft-neg-out63.0%
distribute-frac-neg263.0%
distribute-frac-neg63.0%
neg-mul-163.0%
distribute-lft-neg-out63.0%
*-commutative63.0%
distribute-lft-neg-in63.0%
times-frac63.0%
metadata-eval63.0%
metadata-eval63.0%
associate--l+63.0%
fma-define77.9%
Simplified77.9%
clear-num77.9%
un-div-inv77.9%
fma-undefine63.0%
associate--l+63.0%
add-sqr-sqrt63.0%
pow263.0%
hypot-define63.0%
pow263.0%
Applied egg-rr63.0%
Taylor expanded in x around inf 67.3%
associate-/r/67.3%
unpow267.3%
associate-*r*71.0%
Applied egg-rr71.0%
Final simplification46.2%
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.35e+157)
(/ (- (+ (* y_m y_m) (* x x)) (* z z)) (* y_m 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 <= 1.35e+157) {
tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 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 <= 1.35d+157) then
tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 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 <= 1.35e+157) {
tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 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 <= 1.35e+157: tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 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 <= 1.35e+157) tmp = Float64(Float64(Float64(Float64(y_m * y_m) + Float64(x * x)) - Float64(z * z)) / Float64(y_m * 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 <= 1.35e+157) tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 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, 1.35e+157], 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[(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 1.35 \cdot 10^{+157}:\\
\;\;\;\;\frac{\left(y\_m \cdot y\_m + x \cdot x\right) - z \cdot z}{y\_m \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;y\_m \cdot 0.5\\
\end{array}
\end{array}
if y < 1.35e157Initial program 72.0%
if 1.35e157 < y Initial program 9.7%
remove-double-neg9.7%
distribute-lft-neg-out9.7%
distribute-frac-neg29.7%
distribute-frac-neg9.7%
neg-mul-19.7%
distribute-lft-neg-out9.7%
*-commutative9.7%
distribute-lft-neg-in9.7%
times-frac9.7%
metadata-eval9.7%
metadata-eval9.7%
associate--l+9.7%
fma-define9.7%
Simplified9.7%
Taylor expanded in y around inf 76.0%
Final simplification72.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 (<= x 6.8e-252)
(* z (* z (/ -0.5 y_m)))
(if (<= x 1.8e-12) (* y_m 0.5) (* 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 <= 6.8e-252) {
tmp = z * (z * (-0.5 / y_m));
} else if (x <= 1.8e-12) {
tmp = y_m * 0.5;
} 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 <= 6.8d-252) then
tmp = z * (z * ((-0.5d0) / y_m))
else if (x <= 1.8d-12) then
tmp = y_m * 0.5d0
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 <= 6.8e-252) {
tmp = z * (z * (-0.5 / y_m));
} else if (x <= 1.8e-12) {
tmp = y_m * 0.5;
} 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 <= 6.8e-252: tmp = z * (z * (-0.5 / y_m)) elif x <= 1.8e-12: tmp = y_m * 0.5 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 <= 6.8e-252) tmp = Float64(z * Float64(z * Float64(-0.5 / y_m))); elseif (x <= 1.8e-12) tmp = Float64(y_m * 0.5); 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 <= 6.8e-252) tmp = z * (z * (-0.5 / y_m)); elseif (x <= 1.8e-12) tmp = y_m * 0.5; 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[LessEqual[x, 6.8e-252], N[(z * N[(z * N[(-0.5 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.8e-12], N[(y$95$m * 0.5), $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 6.8 \cdot 10^{-252}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y\_m}\right)\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{-12}:\\
\;\;\;\;y\_m \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y\_m}\right)\\
\end{array}
\end{array}
if x < 6.7999999999999999e-252Initial program 68.5%
remove-double-neg68.5%
distribute-lft-neg-out68.5%
distribute-frac-neg268.5%
distribute-frac-neg68.5%
neg-mul-168.5%
distribute-lft-neg-out68.5%
*-commutative68.5%
distribute-lft-neg-in68.5%
times-frac68.5%
metadata-eval68.5%
metadata-eval68.5%
associate--l+68.5%
fma-define69.9%
Simplified69.9%
Taylor expanded in z around inf 30.8%
*-commutative30.8%
associate-*l/30.8%
Simplified30.8%
associate-/l*30.8%
pow230.8%
associate-*l*32.7%
Applied egg-rr32.7%
if 6.7999999999999999e-252 < x < 1.8e-12Initial program 60.2%
remove-double-neg60.2%
distribute-lft-neg-out60.2%
distribute-frac-neg260.2%
distribute-frac-neg60.2%
neg-mul-160.2%
distribute-lft-neg-out60.2%
*-commutative60.2%
distribute-lft-neg-in60.2%
times-frac60.2%
metadata-eval60.2%
metadata-eval60.2%
associate--l+60.2%
fma-define60.2%
Simplified60.2%
Taylor expanded in y around inf 50.7%
if 1.8e-12 < x Initial program 65.8%
remove-double-neg65.8%
distribute-lft-neg-out65.8%
distribute-frac-neg265.8%
distribute-frac-neg65.8%
neg-mul-165.8%
distribute-lft-neg-out65.8%
*-commutative65.8%
distribute-lft-neg-in65.8%
times-frac65.8%
metadata-eval65.8%
metadata-eval65.8%
associate--l+65.8%
fma-define77.1%
Simplified77.1%
clear-num77.0%
un-div-inv77.0%
fma-undefine65.8%
associate--l+65.8%
add-sqr-sqrt65.8%
pow265.8%
hypot-define65.8%
pow265.8%
Applied egg-rr65.8%
Taylor expanded in x around inf 57.6%
associate-/r/57.6%
unpow257.6%
associate-*r*60.4%
Applied egg-rr60.4%
Final simplification43.1%
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 (<= z 5.6e+67) (* 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 <= 5.6e+67) {
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 <= 5.6d+67) 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 <= 5.6e+67) {
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 <= 5.6e+67: 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 <= 5.6e+67) tmp = Float64(y_m * 0.5); else tmp = Float64(z * Float64(Float64(z * -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 <= 5.6e+67) 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, 5.6e+67], N[(y$95$m * 0.5), $MachinePrecision], N[(z * N[(N[(z * -0.5), $MachinePrecision] / y$95$m), $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 5.6 \cdot 10^{+67}:\\
\;\;\;\;y\_m \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{z \cdot -0.5}{y\_m}\\
\end{array}
\end{array}
if z < 5.5999999999999995e67Initial program 67.5%
remove-double-neg67.5%
distribute-lft-neg-out67.5%
distribute-frac-neg267.5%
distribute-frac-neg67.5%
neg-mul-167.5%
distribute-lft-neg-out67.5%
*-commutative67.5%
distribute-lft-neg-in67.5%
times-frac67.5%
metadata-eval67.5%
metadata-eval67.5%
associate--l+67.5%
fma-define69.5%
Simplified69.5%
Taylor expanded in y around inf 42.2%
if 5.5999999999999995e67 < z Initial program 61.0%
remove-double-neg61.0%
distribute-lft-neg-out61.0%
distribute-frac-neg261.0%
distribute-frac-neg61.0%
neg-mul-161.0%
distribute-lft-neg-out61.0%
*-commutative61.0%
distribute-lft-neg-in61.0%
times-frac61.0%
metadata-eval61.0%
metadata-eval61.0%
associate--l+61.0%
fma-define70.1%
Simplified70.1%
Taylor expanded in z around inf 64.2%
*-commutative64.2%
associate-*l/64.2%
Simplified64.2%
pow264.2%
Applied egg-rr64.2%
associate-*l*64.2%
associate-/l*72.7%
Applied egg-rr72.7%
Final simplification48.7%
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 (<= z 7e+65) (* 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 <= 7e+65) {
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 <= 7d+65) 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 <= 7e+65) {
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 <= 7e+65: 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 <= 7e+65) 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 <= 7e+65) 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, 7e+65], 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 7 \cdot 10^{+65}:\\
\;\;\;\;y\_m \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y\_m}\right)\\
\end{array}
\end{array}
if z < 7.0000000000000002e65Initial program 67.5%
remove-double-neg67.5%
distribute-lft-neg-out67.5%
distribute-frac-neg267.5%
distribute-frac-neg67.5%
neg-mul-167.5%
distribute-lft-neg-out67.5%
*-commutative67.5%
distribute-lft-neg-in67.5%
times-frac67.5%
metadata-eval67.5%
metadata-eval67.5%
associate--l+67.5%
fma-define69.5%
Simplified69.5%
Taylor expanded in y around inf 42.2%
if 7.0000000000000002e65 < z Initial program 61.0%
remove-double-neg61.0%
distribute-lft-neg-out61.0%
distribute-frac-neg261.0%
distribute-frac-neg61.0%
neg-mul-161.0%
distribute-lft-neg-out61.0%
*-commutative61.0%
distribute-lft-neg-in61.0%
times-frac61.0%
metadata-eval61.0%
metadata-eval61.0%
associate--l+61.0%
fma-define70.1%
Simplified70.1%
Taylor expanded in z around inf 64.2%
*-commutative64.2%
associate-*l/64.2%
Simplified64.2%
associate-/l*64.3%
pow264.3%
associate-*l*72.7%
Applied egg-rr72.7%
Final simplification48.7%
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 66.1%
remove-double-neg66.1%
distribute-lft-neg-out66.1%
distribute-frac-neg266.1%
distribute-frac-neg66.1%
neg-mul-166.1%
distribute-lft-neg-out66.1%
*-commutative66.1%
distribute-lft-neg-in66.1%
times-frac66.1%
metadata-eval66.1%
metadata-eval66.1%
associate--l+66.1%
fma-define69.7%
Simplified69.7%
Taylor expanded in y around inf 36.0%
Final simplification36.0%
(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 2024177
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
:precision binary64
:alt
(! :herbie-platform default (- (* y 1/2) (* (* (/ 1/2 y) (+ z x)) (- z x))))
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))