
(FPCore (x y) :precision binary64 (+ x (/ (fabs (- y x)) 2.0)))
double code(double x, double y) {
return x + (fabs((y - x)) / 2.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (abs((y - x)) / 2.0d0)
end function
public static double code(double x, double y) {
return x + (Math.abs((y - x)) / 2.0);
}
def code(x, y): return x + (math.fabs((y - x)) / 2.0)
function code(x, y) return Float64(x + Float64(abs(Float64(y - x)) / 2.0)) end
function tmp = code(x, y) tmp = x + (abs((y - x)) / 2.0); end
code[x_, y_] := N[(x + N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left|y - x\right|}{2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (+ x (/ (fabs (- y x)) 2.0)))
double code(double x, double y) {
return x + (fabs((y - x)) / 2.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (abs((y - x)) / 2.0d0)
end function
public static double code(double x, double y) {
return x + (Math.abs((y - x)) / 2.0);
}
def code(x, y): return x + (math.fabs((y - x)) / 2.0)
function code(x, y) return Float64(x + Float64(abs(Float64(y - x)) / 2.0)) end
function tmp = code(x, y) tmp = x + (abs((y - x)) / 2.0); end
code[x_, y_] := N[(x + N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left|y - x\right|}{2}
\end{array}
(FPCore (x y) :precision binary64 (+ x (/ (fabs (- x y)) 2.0)))
double code(double x, double y) {
return x + (fabs((x - y)) / 2.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (abs((x - y)) / 2.0d0)
end function
public static double code(double x, double y) {
return x + (Math.abs((x - y)) / 2.0);
}
def code(x, y): return x + (math.fabs((x - y)) / 2.0)
function code(x, y) return Float64(x + Float64(abs(Float64(x - y)) / 2.0)) end
function tmp = code(x, y) tmp = x + (abs((x - y)) / 2.0); end
code[x_, y_] := N[(x + N[(N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left|x - y\right|}{2}
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (+ x y) 0.5)))
(if (<= y -2.1e-64)
(- x t_0)
(if (<= y 1.25e-164) (+ x (/ (fabs x) 2.0)) t_0))))
double code(double x, double y) {
double t_0 = (x + y) * 0.5;
double tmp;
if (y <= -2.1e-64) {
tmp = x - t_0;
} else if (y <= 1.25e-164) {
tmp = x + (fabs(x) / 2.0);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x + y) * 0.5d0
if (y <= (-2.1d-64)) then
tmp = x - t_0
else if (y <= 1.25d-164) then
tmp = x + (abs(x) / 2.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x + y) * 0.5;
double tmp;
if (y <= -2.1e-64) {
tmp = x - t_0;
} else if (y <= 1.25e-164) {
tmp = x + (Math.abs(x) / 2.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x + y) * 0.5 tmp = 0 if y <= -2.1e-64: tmp = x - t_0 elif y <= 1.25e-164: tmp = x + (math.fabs(x) / 2.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x + y) * 0.5) tmp = 0.0 if (y <= -2.1e-64) tmp = Float64(x - t_0); elseif (y <= 1.25e-164) tmp = Float64(x + Float64(abs(x) / 2.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x + y) * 0.5; tmp = 0.0; if (y <= -2.1e-64) tmp = x - t_0; elseif (y <= 1.25e-164) tmp = x + (abs(x) / 2.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[y, -2.1e-64], N[(x - t$95$0), $MachinePrecision], If[LessEqual[y, 1.25e-164], N[(x + N[(N[Abs[x], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + y\right) \cdot 0.5\\
\mathbf{if}\;y \leq -2.1 \cdot 10^{-64}:\\
\;\;\;\;x - t\_0\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{-164}:\\
\;\;\;\;x + \frac{\left|x\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -2.10000000000000011e-64Initial program 100.0%
add-cube-cbrt98.1%
fabs-mul98.1%
pow298.1%
Applied egg-rr98.1%
Applied egg-rr91.0%
if -2.10000000000000011e-64 < y < 1.2499999999999999e-164Initial program 99.9%
Taylor expanded in y around 0 90.3%
neg-mul-190.3%
Simplified90.3%
if 1.2499999999999999e-164 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt83.3%
fabs-sqr83.3%
add-sqr-sqrt86.8%
frac-2neg86.8%
distribute-frac-neg86.8%
fmm-undef86.8%
*-un-lft-identity86.8%
metadata-eval86.8%
Applied egg-rr86.8%
Taylor expanded in x around 0 86.8%
cancel-sign-sub-inv86.8%
metadata-eval86.8%
distribute-lft-in86.8%
+-commutative86.8%
Simplified86.8%
Final simplification89.2%
(FPCore (x y) :precision binary64 (if (<= x -1e-115) (* (+ x y) 0.5) (if (<= x 1.35e-93) (+ x (/ (fabs y) 2.0)) (+ (* y -0.5) (* x 1.5)))))
double code(double x, double y) {
double tmp;
if (x <= -1e-115) {
tmp = (x + y) * 0.5;
} else if (x <= 1.35e-93) {
tmp = x + (fabs(y) / 2.0);
} else {
tmp = (y * -0.5) + (x * 1.5);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1d-115)) then
tmp = (x + y) * 0.5d0
else if (x <= 1.35d-93) then
tmp = x + (abs(y) / 2.0d0)
else
tmp = (y * (-0.5d0)) + (x * 1.5d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1e-115) {
tmp = (x + y) * 0.5;
} else if (x <= 1.35e-93) {
tmp = x + (Math.abs(y) / 2.0);
} else {
tmp = (y * -0.5) + (x * 1.5);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1e-115: tmp = (x + y) * 0.5 elif x <= 1.35e-93: tmp = x + (math.fabs(y) / 2.0) else: tmp = (y * -0.5) + (x * 1.5) return tmp
function code(x, y) tmp = 0.0 if (x <= -1e-115) tmp = Float64(Float64(x + y) * 0.5); elseif (x <= 1.35e-93) tmp = Float64(x + Float64(abs(y) / 2.0)); else tmp = Float64(Float64(y * -0.5) + Float64(x * 1.5)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1e-115) tmp = (x + y) * 0.5; elseif (x <= 1.35e-93) tmp = x + (abs(y) / 2.0); else tmp = (y * -0.5) + (x * 1.5); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1e-115], N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 1.35e-93], N[(x + N[(N[Abs[y], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(y * -0.5), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-115}:\\
\;\;\;\;\left(x + y\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-93}:\\
\;\;\;\;x + \frac{\left|y\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;y \cdot -0.5 + x \cdot 1.5\\
\end{array}
\end{array}
if x < -1.0000000000000001e-115Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt81.5%
fabs-sqr81.5%
add-sqr-sqrt82.1%
frac-2neg82.1%
distribute-frac-neg82.1%
fmm-undef82.1%
*-un-lft-identity82.1%
metadata-eval82.1%
Applied egg-rr82.1%
Taylor expanded in x around 0 82.1%
cancel-sign-sub-inv82.1%
metadata-eval82.1%
distribute-lft-in82.1%
+-commutative82.1%
Simplified82.1%
if -1.0000000000000001e-115 < x < 1.3500000000000001e-93Initial program 100.0%
Taylor expanded in y around inf 92.8%
if 1.3500000000000001e-93 < x Initial program 99.8%
add-cube-cbrt98.7%
fabs-mul98.7%
pow298.7%
Applied egg-rr98.7%
add-sqr-sqrt98.6%
sqrt-unprod48.4%
frac-2neg48.4%
metadata-eval48.4%
frac-2neg48.4%
metadata-eval48.4%
frac-times48.4%
Applied egg-rr84.2%
Taylor expanded in x around 0 84.2%
Final simplification86.1%
(FPCore (x y) :precision binary64 (if (<= y -1.45e-64) (- x (* y 0.5)) (if (<= y -7.6e-239) (* x 1.5) (* (+ x y) 0.5))))
double code(double x, double y) {
double tmp;
if (y <= -1.45e-64) {
tmp = x - (y * 0.5);
} else if (y <= -7.6e-239) {
tmp = x * 1.5;
} else {
tmp = (x + y) * 0.5;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.45d-64)) then
tmp = x - (y * 0.5d0)
else if (y <= (-7.6d-239)) then
tmp = x * 1.5d0
else
tmp = (x + y) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.45e-64) {
tmp = x - (y * 0.5);
} else if (y <= -7.6e-239) {
tmp = x * 1.5;
} else {
tmp = (x + y) * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.45e-64: tmp = x - (y * 0.5) elif y <= -7.6e-239: tmp = x * 1.5 else: tmp = (x + y) * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.45e-64) tmp = Float64(x - Float64(y * 0.5)); elseif (y <= -7.6e-239) tmp = Float64(x * 1.5); else tmp = Float64(Float64(x + y) * 0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.45e-64) tmp = x - (y * 0.5); elseif (y <= -7.6e-239) tmp = x * 1.5; else tmp = (x + y) * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.45e-64], N[(x - N[(y * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -7.6e-239], N[(x * 1.5), $MachinePrecision], N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{-64}:\\
\;\;\;\;x - y \cdot 0.5\\
\mathbf{elif}\;y \leq -7.6 \cdot 10^{-239}:\\
\;\;\;\;x \cdot 1.5\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) \cdot 0.5\\
\end{array}
\end{array}
if y < -1.4499999999999999e-64Initial program 100.0%
add-cube-cbrt98.1%
fabs-mul98.1%
pow298.1%
Applied egg-rr98.1%
Applied egg-rr91.1%
Taylor expanded in y around inf 78.8%
if -1.4499999999999999e-64 < y < -7.6000000000000004e-239Initial program 99.9%
add-cube-cbrt98.5%
fabs-mul98.5%
pow298.5%
Applied egg-rr98.5%
mul-fabs98.5%
unpow298.5%
add-cube-cbrt99.9%
add-sqr-sqrt25.6%
fabs-sqr25.6%
add-sqr-sqrt37.0%
flip--27.9%
clear-num27.7%
difference-of-squares27.7%
add-sqr-sqrt8.3%
sqrt-unprod12.5%
sqr-neg12.5%
sqrt-unprod4.1%
add-sqr-sqrt47.8%
sub-neg47.8%
pow247.8%
sub-neg47.8%
add-sqr-sqrt4.1%
sqrt-unprod47.8%
sqr-neg47.8%
sqrt-unprod43.5%
add-sqr-sqrt47.8%
Applied egg-rr47.8%
associate-/r/47.8%
Simplified47.8%
Taylor expanded in x around inf 66.1%
*-commutative66.1%
Simplified66.1%
if -7.6000000000000004e-239 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt74.5%
fabs-sqr74.5%
add-sqr-sqrt79.3%
frac-2neg79.3%
distribute-frac-neg79.3%
fmm-undef79.3%
*-un-lft-identity79.3%
metadata-eval79.3%
Applied egg-rr79.3%
Taylor expanded in x around 0 79.4%
cancel-sign-sub-inv79.4%
metadata-eval79.4%
distribute-lft-in79.4%
+-commutative79.4%
Simplified79.4%
Final simplification77.6%
(FPCore (x y) :precision binary64 (if (<= y -2.6e-63) (* y -0.5) (if (<= y -3.3e-239) (* x 1.5) (* (+ x y) 0.5))))
double code(double x, double y) {
double tmp;
if (y <= -2.6e-63) {
tmp = y * -0.5;
} else if (y <= -3.3e-239) {
tmp = x * 1.5;
} else {
tmp = (x + y) * 0.5;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-2.6d-63)) then
tmp = y * (-0.5d0)
else if (y <= (-3.3d-239)) then
tmp = x * 1.5d0
else
tmp = (x + y) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2.6e-63) {
tmp = y * -0.5;
} else if (y <= -3.3e-239) {
tmp = x * 1.5;
} else {
tmp = (x + y) * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.6e-63: tmp = y * -0.5 elif y <= -3.3e-239: tmp = x * 1.5 else: tmp = (x + y) * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -2.6e-63) tmp = Float64(y * -0.5); elseif (y <= -3.3e-239) tmp = Float64(x * 1.5); else tmp = Float64(Float64(x + y) * 0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.6e-63) tmp = y * -0.5; elseif (y <= -3.3e-239) tmp = x * 1.5; else tmp = (x + y) * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.6e-63], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -3.3e-239], N[(x * 1.5), $MachinePrecision], N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6 \cdot 10^{-63}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq -3.3 \cdot 10^{-239}:\\
\;\;\;\;x \cdot 1.5\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) \cdot 0.5\\
\end{array}
\end{array}
if y < -2.6000000000000001e-63Initial program 100.0%
add-cube-cbrt98.1%
fabs-mul98.1%
pow298.1%
Applied egg-rr98.1%
Applied egg-rr91.0%
Taylor expanded in x around 0 75.6%
*-commutative75.6%
Simplified75.6%
if -2.6000000000000001e-63 < y < -3.29999999999999995e-239Initial program 99.9%
add-cube-cbrt98.5%
fabs-mul98.5%
pow298.5%
Applied egg-rr98.5%
mul-fabs98.5%
unpow298.5%
add-cube-cbrt99.9%
add-sqr-sqrt27.9%
fabs-sqr27.9%
add-sqr-sqrt39.0%
flip--30.1%
clear-num29.9%
difference-of-squares29.9%
add-sqr-sqrt8.1%
sqrt-unprod12.6%
sqr-neg12.6%
sqrt-unprod4.5%
add-sqr-sqrt46.8%
sub-neg46.8%
pow246.8%
sub-neg46.8%
add-sqr-sqrt4.5%
sqrt-unprod46.8%
sqr-neg46.8%
sqrt-unprod42.1%
add-sqr-sqrt46.8%
Applied egg-rr46.8%
associate-/r/46.9%
Simplified46.9%
Taylor expanded in x around inf 64.6%
*-commutative64.6%
Simplified64.6%
if -3.29999999999999995e-239 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt74.5%
fabs-sqr74.5%
add-sqr-sqrt79.3%
frac-2neg79.3%
distribute-frac-neg79.3%
fmm-undef79.3%
*-un-lft-identity79.3%
metadata-eval79.3%
Applied egg-rr79.3%
Taylor expanded in x around 0 79.4%
cancel-sign-sub-inv79.4%
metadata-eval79.4%
distribute-lft-in79.4%
+-commutative79.4%
Simplified79.4%
Final simplification76.3%
(FPCore (x y) :precision binary64 (if (<= y -3.2e-64) (* y -0.5) (if (<= y 1.4e-72) (* x 1.5) (* y 0.5))))
double code(double x, double y) {
double tmp;
if (y <= -3.2e-64) {
tmp = y * -0.5;
} else if (y <= 1.4e-72) {
tmp = x * 1.5;
} else {
tmp = y * 0.5;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-3.2d-64)) then
tmp = y * (-0.5d0)
else if (y <= 1.4d-72) then
tmp = x * 1.5d0
else
tmp = y * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -3.2e-64) {
tmp = y * -0.5;
} else if (y <= 1.4e-72) {
tmp = x * 1.5;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3.2e-64: tmp = y * -0.5 elif y <= 1.4e-72: tmp = x * 1.5 else: tmp = y * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -3.2e-64) tmp = Float64(y * -0.5); elseif (y <= 1.4e-72) tmp = Float64(x * 1.5); else tmp = Float64(y * 0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -3.2e-64) tmp = y * -0.5; elseif (y <= 1.4e-72) tmp = x * 1.5; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3.2e-64], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.4e-72], N[(x * 1.5), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{-64}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{-72}:\\
\;\;\;\;x \cdot 1.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < -3.19999999999999975e-64Initial program 100.0%
add-cube-cbrt98.1%
fabs-mul98.1%
pow298.1%
Applied egg-rr98.1%
Applied egg-rr91.0%
Taylor expanded in x around 0 75.6%
*-commutative75.6%
Simplified75.6%
if -3.19999999999999975e-64 < y < 1.3999999999999999e-72Initial program 99.9%
add-cube-cbrt98.4%
fabs-mul98.4%
pow298.4%
Applied egg-rr98.4%
mul-fabs98.4%
unpow298.4%
add-cube-cbrt99.9%
add-sqr-sqrt45.8%
fabs-sqr45.8%
add-sqr-sqrt54.9%
flip--36.1%
clear-num36.0%
difference-of-squares36.0%
add-sqr-sqrt8.1%
sqrt-unprod17.2%
sqr-neg17.2%
sqrt-unprod9.1%
add-sqr-sqrt40.7%
sub-neg40.7%
pow240.7%
sub-neg40.7%
add-sqr-sqrt9.1%
sqrt-unprod40.7%
sqr-neg40.7%
sqrt-unprod31.5%
add-sqr-sqrt40.7%
Applied egg-rr40.7%
associate-/r/40.7%
Simplified40.7%
Taylor expanded in x around inf 54.6%
*-commutative54.6%
Simplified54.6%
if 1.3999999999999999e-72 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt88.2%
fabs-sqr88.2%
add-sqr-sqrt90.8%
frac-2neg90.8%
distribute-frac-neg90.8%
fmm-undef90.8%
*-un-lft-identity90.8%
metadata-eval90.8%
Applied egg-rr90.8%
Taylor expanded in x around 0 76.4%
Final simplification68.4%
(FPCore (x y) :precision binary64 (if (<= x -1.4e-90) (* x 0.5) (if (<= x 6e-102) (* y 0.5) (* x 1.5))))
double code(double x, double y) {
double tmp;
if (x <= -1.4e-90) {
tmp = x * 0.5;
} else if (x <= 6e-102) {
tmp = y * 0.5;
} else {
tmp = x * 1.5;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.4d-90)) then
tmp = x * 0.5d0
else if (x <= 6d-102) then
tmp = y * 0.5d0
else
tmp = x * 1.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.4e-90) {
tmp = x * 0.5;
} else if (x <= 6e-102) {
tmp = y * 0.5;
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.4e-90: tmp = x * 0.5 elif x <= 6e-102: tmp = y * 0.5 else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.4e-90) tmp = Float64(x * 0.5); elseif (x <= 6e-102) tmp = Float64(y * 0.5); else tmp = Float64(x * 1.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.4e-90) tmp = x * 0.5; elseif (x <= 6e-102) tmp = y * 0.5; else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.4e-90], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 6e-102], N[(y * 0.5), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{-90}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 6 \cdot 10^{-102}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -1.3999999999999999e-90Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt81.4%
fabs-sqr81.4%
add-sqr-sqrt82.0%
frac-2neg82.0%
distribute-frac-neg82.0%
fmm-undef82.0%
*-un-lft-identity82.0%
metadata-eval82.0%
Applied egg-rr82.0%
Taylor expanded in x around inf 63.3%
if -1.3999999999999999e-90 < x < 6e-102Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt53.1%
fabs-sqr53.1%
add-sqr-sqrt55.2%
frac-2neg55.2%
distribute-frac-neg55.2%
fmm-undef55.2%
*-un-lft-identity55.2%
metadata-eval55.2%
Applied egg-rr55.2%
Taylor expanded in x around 0 50.0%
if 6e-102 < x Initial program 99.8%
add-cube-cbrt98.7%
fabs-mul98.7%
pow298.7%
Applied egg-rr98.7%
mul-fabs98.7%
unpow298.7%
add-cube-cbrt99.8%
add-sqr-sqrt15.6%
fabs-sqr15.6%
add-sqr-sqrt26.8%
flip--9.6%
clear-num9.6%
difference-of-squares9.9%
add-sqr-sqrt9.9%
sqrt-unprod10.2%
sqr-neg10.2%
sqrt-unprod0.0%
add-sqr-sqrt36.4%
sub-neg36.4%
pow236.4%
sub-neg36.4%
add-sqr-sqrt0.0%
sqrt-unprod36.4%
sqr-neg36.4%
sqrt-unprod36.3%
add-sqr-sqrt36.4%
Applied egg-rr36.4%
associate-/r/36.5%
Simplified36.5%
Taylor expanded in x around inf 61.1%
*-commutative61.1%
Simplified61.1%
Final simplification58.2%
(FPCore (x y) :precision binary64 (if (<= y -1.32e-285) (+ (* y -0.5) (* x 1.5)) (* (+ x y) 0.5)))
double code(double x, double y) {
double tmp;
if (y <= -1.32e-285) {
tmp = (y * -0.5) + (x * 1.5);
} else {
tmp = (x + y) * 0.5;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.32d-285)) then
tmp = (y * (-0.5d0)) + (x * 1.5d0)
else
tmp = (x + y) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.32e-285) {
tmp = (y * -0.5) + (x * 1.5);
} else {
tmp = (x + y) * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.32e-285: tmp = (y * -0.5) + (x * 1.5) else: tmp = (x + y) * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.32e-285) tmp = Float64(Float64(y * -0.5) + Float64(x * 1.5)); else tmp = Float64(Float64(x + y) * 0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.32e-285) tmp = (y * -0.5) + (x * 1.5); else tmp = (x + y) * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.32e-285], N[(N[(y * -0.5), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision], N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.32 \cdot 10^{-285}:\\
\;\;\;\;y \cdot -0.5 + x \cdot 1.5\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) \cdot 0.5\\
\end{array}
\end{array}
if y < -1.3199999999999999e-285Initial program 100.0%
add-cube-cbrt98.2%
fabs-mul98.2%
pow298.2%
Applied egg-rr98.2%
add-sqr-sqrt98.1%
sqrt-unprod53.5%
frac-2neg53.5%
metadata-eval53.5%
frac-2neg53.5%
metadata-eval53.5%
frac-times53.5%
Applied egg-rr82.3%
Taylor expanded in x around 0 82.3%
if -1.3199999999999999e-285 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt76.4%
fabs-sqr76.4%
add-sqr-sqrt81.0%
frac-2neg81.0%
distribute-frac-neg81.0%
fmm-undef81.0%
*-un-lft-identity81.0%
metadata-eval81.0%
Applied egg-rr81.0%
Taylor expanded in x around 0 81.0%
cancel-sign-sub-inv81.0%
metadata-eval81.0%
distribute-lft-in81.0%
+-commutative81.0%
Simplified81.0%
Final simplification81.7%
(FPCore (x y) :precision binary64 (if (<= y 1.75e-65) (* x 0.5) (* y 0.5)))
double code(double x, double y) {
double tmp;
if (y <= 1.75e-65) {
tmp = x * 0.5;
} else {
tmp = y * 0.5;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.75d-65) then
tmp = x * 0.5d0
else
tmp = y * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.75e-65) {
tmp = x * 0.5;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.75e-65: tmp = x * 0.5 else: tmp = y * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= 1.75e-65) tmp = Float64(x * 0.5); else tmp = Float64(y * 0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.75e-65) tmp = x * 0.5; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.75e-65], N[(x * 0.5), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.75 \cdot 10^{-65}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < 1.75000000000000002e-65Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt32.5%
fabs-sqr32.5%
add-sqr-sqrt38.2%
frac-2neg38.2%
distribute-frac-neg38.2%
fmm-undef38.2%
*-un-lft-identity38.2%
metadata-eval38.2%
Applied egg-rr38.2%
Taylor expanded in x around inf 33.2%
if 1.75000000000000002e-65 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt88.8%
fabs-sqr88.8%
add-sqr-sqrt91.3%
frac-2neg91.3%
distribute-frac-neg91.3%
fmm-undef91.3%
*-un-lft-identity91.3%
metadata-eval91.3%
Applied egg-rr91.3%
Taylor expanded in x around 0 78.7%
Final simplification46.7%
(FPCore (x y) :precision binary64 (* x 0.5))
double code(double x, double y) {
return x * 0.5;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * 0.5d0
end function
public static double code(double x, double y) {
return x * 0.5;
}
def code(x, y): return x * 0.5
function code(x, y) return Float64(x * 0.5) end
function tmp = code(x, y) tmp = x * 0.5; end
code[x_, y_] := N[(x * 0.5), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5
\end{array}
Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt49.2%
fabs-sqr49.2%
add-sqr-sqrt54.0%
frac-2neg54.0%
distribute-frac-neg54.0%
fmm-undef54.0%
*-un-lft-identity54.0%
metadata-eval54.0%
Applied egg-rr54.0%
Taylor expanded in x around inf 27.7%
Final simplification27.7%
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.9%
Taylor expanded in x around inf 10.6%
herbie shell --seed 2024184
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
:precision binary64
(+ x (/ (fabs (- y x)) 2.0)))