
(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 12 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 (<= x -8.5e+34)
(- x t_0)
(if (<= x -4.9e-114)
t_0
(if (<= x 2.05e+18) (+ x (/ (fabs y) 2.0)) (fma x 1.5 (* y -0.5)))))))
double code(double x, double y) {
double t_0 = (x + y) * 0.5;
double tmp;
if (x <= -8.5e+34) {
tmp = x - t_0;
} else if (x <= -4.9e-114) {
tmp = t_0;
} else if (x <= 2.05e+18) {
tmp = x + (fabs(y) / 2.0);
} else {
tmp = fma(x, 1.5, (y * -0.5));
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x + y) * 0.5) tmp = 0.0 if (x <= -8.5e+34) tmp = Float64(x - t_0); elseif (x <= -4.9e-114) tmp = t_0; elseif (x <= 2.05e+18) tmp = Float64(x + Float64(abs(y) / 2.0)); else tmp = fma(x, 1.5, Float64(y * -0.5)); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[x, -8.5e+34], N[(x - t$95$0), $MachinePrecision], If[LessEqual[x, -4.9e-114], t$95$0, If[LessEqual[x, 2.05e+18], N[(x + N[(N[Abs[y], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(x * 1.5 + N[(y * -0.5), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + y\right) \cdot 0.5\\
\mathbf{if}\;x \leq -8.5 \cdot 10^{+34}:\\
\;\;\;\;x - t\_0\\
\mathbf{elif}\;x \leq -4.9 \cdot 10^{-114}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{+18}:\\
\;\;\;\;x + \frac{\left|y\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, 1.5, y \cdot -0.5\right)\\
\end{array}
\end{array}
if x < -8.5000000000000003e34Initial program 100.0%
add-cube-cbrt97.7%
fabs-mul97.7%
pow297.7%
Applied egg-rr97.7%
Applied egg-rr96.1%
if -8.5000000000000003e34 < x < -4.8999999999999997e-114Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt88.7%
fabs-sqr88.7%
add-sqr-sqrt89.4%
frac-2neg89.4%
distribute-frac-neg89.4%
fmm-undef89.4%
*-un-lft-identity89.4%
metadata-eval89.4%
Applied egg-rr89.4%
Taylor expanded in x around 0 89.4%
cancel-sign-sub-inv89.4%
metadata-eval89.4%
distribute-lft-in89.4%
+-commutative89.4%
Simplified89.4%
if -4.8999999999999997e-114 < x < 2.05e18Initial program 100.0%
Taylor expanded in y around inf 83.6%
if 2.05e18 < x Initial program 99.8%
add-cube-cbrt98.9%
fabs-mul98.9%
pow298.9%
Applied egg-rr98.9%
add-sqr-sqrt98.8%
sqrt-unprod44.2%
frac-2neg44.2%
metadata-eval44.2%
frac-2neg44.2%
metadata-eval44.2%
frac-times44.2%
Applied egg-rr96.4%
Taylor expanded in x around 0 96.4%
+-commutative96.4%
*-commutative96.4%
fma-define96.7%
*-commutative96.7%
Simplified96.7%
Final simplification90.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (+ x y) 0.5)))
(if (<= x -1.35e+35)
(- x t_0)
(if (<= x -9e-114)
t_0
(if (<= x 5.1e+17) (+ x (/ (fabs y) 2.0)) (+ (* y -0.5) (* x 1.5)))))))
double code(double x, double y) {
double t_0 = (x + y) * 0.5;
double tmp;
if (x <= -1.35e+35) {
tmp = x - t_0;
} else if (x <= -9e-114) {
tmp = t_0;
} else if (x <= 5.1e+17) {
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) :: t_0
real(8) :: tmp
t_0 = (x + y) * 0.5d0
if (x <= (-1.35d+35)) then
tmp = x - t_0
else if (x <= (-9d-114)) then
tmp = t_0
else if (x <= 5.1d+17) 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 t_0 = (x + y) * 0.5;
double tmp;
if (x <= -1.35e+35) {
tmp = x - t_0;
} else if (x <= -9e-114) {
tmp = t_0;
} else if (x <= 5.1e+17) {
tmp = x + (Math.abs(y) / 2.0);
} else {
tmp = (y * -0.5) + (x * 1.5);
}
return tmp;
}
def code(x, y): t_0 = (x + y) * 0.5 tmp = 0 if x <= -1.35e+35: tmp = x - t_0 elif x <= -9e-114: tmp = t_0 elif x <= 5.1e+17: tmp = x + (math.fabs(y) / 2.0) else: tmp = (y * -0.5) + (x * 1.5) return tmp
function code(x, y) t_0 = Float64(Float64(x + y) * 0.5) tmp = 0.0 if (x <= -1.35e+35) tmp = Float64(x - t_0); elseif (x <= -9e-114) tmp = t_0; elseif (x <= 5.1e+17) 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) t_0 = (x + y) * 0.5; tmp = 0.0; if (x <= -1.35e+35) tmp = x - t_0; elseif (x <= -9e-114) tmp = t_0; elseif (x <= 5.1e+17) tmp = x + (abs(y) / 2.0); else tmp = (y * -0.5) + (x * 1.5); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[x, -1.35e+35], N[(x - t$95$0), $MachinePrecision], If[LessEqual[x, -9e-114], t$95$0, If[LessEqual[x, 5.1e+17], 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}
t_0 := \left(x + y\right) \cdot 0.5\\
\mathbf{if}\;x \leq -1.35 \cdot 10^{+35}:\\
\;\;\;\;x - t\_0\\
\mathbf{elif}\;x \leq -9 \cdot 10^{-114}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.1 \cdot 10^{+17}:\\
\;\;\;\;x + \frac{\left|y\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;y \cdot -0.5 + x \cdot 1.5\\
\end{array}
\end{array}
if x < -1.35000000000000001e35Initial program 100.0%
add-cube-cbrt97.7%
fabs-mul97.7%
pow297.7%
Applied egg-rr97.7%
Applied egg-rr96.1%
if -1.35000000000000001e35 < x < -8.99999999999999937e-114Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt88.7%
fabs-sqr88.7%
add-sqr-sqrt89.4%
frac-2neg89.4%
distribute-frac-neg89.4%
fmm-undef89.4%
*-un-lft-identity89.4%
metadata-eval89.4%
Applied egg-rr89.4%
Taylor expanded in x around 0 89.4%
cancel-sign-sub-inv89.4%
metadata-eval89.4%
distribute-lft-in89.4%
+-commutative89.4%
Simplified89.4%
if -8.99999999999999937e-114 < x < 5.1e17Initial program 100.0%
Taylor expanded in y around inf 83.6%
if 5.1e17 < x Initial program 99.8%
add-cube-cbrt98.9%
fabs-mul98.9%
pow298.9%
Applied egg-rr98.9%
add-sqr-sqrt98.8%
sqrt-unprod44.2%
frac-2neg44.2%
metadata-eval44.2%
frac-2neg44.2%
metadata-eval44.2%
frac-times44.2%
Applied egg-rr96.4%
Taylor expanded in x around 0 96.4%
Final simplification90.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (+ x y) 0.5)))
(if (<= y -2.05e-49)
(- x t_0)
(if (<= y 3.6e-7) (+ 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.05e-49) {
tmp = x - t_0;
} else if (y <= 3.6e-7) {
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.05d-49)) then
tmp = x - t_0
else if (y <= 3.6d-7) 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.05e-49) {
tmp = x - t_0;
} else if (y <= 3.6e-7) {
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.05e-49: tmp = x - t_0 elif y <= 3.6e-7: 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.05e-49) tmp = Float64(x - t_0); elseif (y <= 3.6e-7) 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.05e-49) tmp = x - t_0; elseif (y <= 3.6e-7) 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.05e-49], N[(x - t$95$0), $MachinePrecision], If[LessEqual[y, 3.6e-7], 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.05 \cdot 10^{-49}:\\
\;\;\;\;x - t\_0\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-7}:\\
\;\;\;\;x + \frac{\left|x\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -2.0500000000000001e-49Initial program 100.0%
add-cube-cbrt98.0%
fabs-mul98.0%
pow298.0%
Applied egg-rr98.0%
Applied egg-rr90.5%
if -2.0500000000000001e-49 < y < 3.59999999999999994e-7Initial program 99.9%
Taylor expanded in y around 0 84.8%
neg-mul-184.8%
Simplified84.8%
if 3.59999999999999994e-7 < y Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt92.0%
fabs-sqr92.0%
add-sqr-sqrt94.0%
frac-2neg94.0%
distribute-frac-neg94.0%
fmm-undef94.0%
*-un-lft-identity94.0%
metadata-eval94.0%
Applied egg-rr94.0%
Taylor expanded in x around 0 94.0%
cancel-sign-sub-inv94.0%
metadata-eval94.0%
distribute-lft-in94.0%
+-commutative94.0%
Simplified94.0%
Final simplification89.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (+ x y) 0.5)))
(if (<= y -9.6e-178)
(- x t_0)
(if (<= y -4.1e-271) (+ (* y -0.5) (* x 1.5)) t_0))))
double code(double x, double y) {
double t_0 = (x + y) * 0.5;
double tmp;
if (y <= -9.6e-178) {
tmp = x - t_0;
} else if (y <= -4.1e-271) {
tmp = (y * -0.5) + (x * 1.5);
} 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 <= (-9.6d-178)) then
tmp = x - t_0
else if (y <= (-4.1d-271)) then
tmp = (y * (-0.5d0)) + (x * 1.5d0)
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 <= -9.6e-178) {
tmp = x - t_0;
} else if (y <= -4.1e-271) {
tmp = (y * -0.5) + (x * 1.5);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x + y) * 0.5 tmp = 0 if y <= -9.6e-178: tmp = x - t_0 elif y <= -4.1e-271: tmp = (y * -0.5) + (x * 1.5) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x + y) * 0.5) tmp = 0.0 if (y <= -9.6e-178) tmp = Float64(x - t_0); elseif (y <= -4.1e-271) tmp = Float64(Float64(y * -0.5) + Float64(x * 1.5)); 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 <= -9.6e-178) tmp = x - t_0; elseif (y <= -4.1e-271) tmp = (y * -0.5) + (x * 1.5); 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, -9.6e-178], N[(x - t$95$0), $MachinePrecision], If[LessEqual[y, -4.1e-271], N[(N[(y * -0.5), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + y\right) \cdot 0.5\\
\mathbf{if}\;y \leq -9.6 \cdot 10^{-178}:\\
\;\;\;\;x - t\_0\\
\mathbf{elif}\;y \leq -4.1 \cdot 10^{-271}:\\
\;\;\;\;y \cdot -0.5 + x \cdot 1.5\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -9.6000000000000002e-178Initial program 100.0%
add-cube-cbrt98.2%
fabs-mul98.2%
pow298.2%
Applied egg-rr98.2%
Applied egg-rr85.3%
if -9.6000000000000002e-178 < y < -4.1000000000000003e-271Initial program 99.9%
add-cube-cbrt99.0%
fabs-mul99.0%
pow299.0%
Applied egg-rr99.0%
add-sqr-sqrt98.9%
sqrt-unprod53.0%
frac-2neg53.0%
metadata-eval53.0%
frac-2neg53.0%
metadata-eval53.0%
frac-times53.0%
Applied egg-rr80.3%
Taylor expanded in x around 0 80.3%
if -4.1000000000000003e-271 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt77.8%
fabs-sqr77.8%
add-sqr-sqrt82.3%
frac-2neg82.3%
distribute-frac-neg82.3%
fmm-undef82.3%
*-un-lft-identity82.3%
metadata-eval82.3%
Applied egg-rr82.3%
Taylor expanded in x around 0 82.3%
cancel-sign-sub-inv82.3%
metadata-eval82.3%
distribute-lft-in82.3%
+-commutative82.3%
Simplified82.3%
Final simplification83.3%
(FPCore (x y) :precision binary64 (if (<= x -1e-139) (* x 0.5) (if (<= x 1.12e+18) (* y 0.5) (* x 1.5))))
double code(double x, double y) {
double tmp;
if (x <= -1e-139) {
tmp = x * 0.5;
} else if (x <= 1.12e+18) {
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 <= (-1d-139)) then
tmp = x * 0.5d0
else if (x <= 1.12d+18) 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 <= -1e-139) {
tmp = x * 0.5;
} else if (x <= 1.12e+18) {
tmp = y * 0.5;
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1e-139: tmp = x * 0.5 elif x <= 1.12e+18: tmp = y * 0.5 else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -1e-139) tmp = Float64(x * 0.5); elseif (x <= 1.12e+18) 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 <= -1e-139) tmp = x * 0.5; elseif (x <= 1.12e+18) tmp = y * 0.5; else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1e-139], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.12e+18], N[(y * 0.5), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-139}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 1.12 \cdot 10^{+18}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -1.00000000000000003e-139Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt81.2%
fabs-sqr81.2%
add-sqr-sqrt81.9%
frac-2neg81.9%
distribute-frac-neg81.9%
fmm-undef81.9%
*-un-lft-identity81.9%
metadata-eval81.9%
Applied egg-rr81.9%
Taylor expanded in x around inf 66.1%
if -1.00000000000000003e-139 < x < 1.12e18Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt50.1%
fabs-sqr50.1%
add-sqr-sqrt53.0%
frac-2neg53.0%
distribute-frac-neg53.0%
fmm-undef53.0%
*-un-lft-identity53.0%
metadata-eval53.0%
Applied egg-rr53.0%
Taylor expanded in x around 0 44.9%
if 1.12e18 < x Initial program 99.8%
Taylor expanded in y around 0 82.6%
neg-mul-182.6%
Simplified82.6%
add-sqr-sqrt82.4%
associate-/l*82.4%
fabs-neg82.4%
add-sqr-sqrt82.4%
fabs-sqr82.4%
add-sqr-sqrt82.4%
fabs-neg82.4%
add-sqr-sqrt82.4%
fabs-sqr82.4%
add-sqr-sqrt82.4%
Applied egg-rr82.4%
associate-*r/82.4%
rem-square-sqrt82.6%
Simplified82.6%
Taylor expanded in x around 0 82.6%
*-commutative82.6%
Simplified82.6%
Final simplification62.0%
(FPCore (x y) :precision binary64 (if (<= y -3.8e-272) (+ (* y -0.5) (* x 1.5)) (* (+ x y) 0.5)))
double code(double x, double y) {
double tmp;
if (y <= -3.8e-272) {
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 <= (-3.8d-272)) 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 <= -3.8e-272) {
tmp = (y * -0.5) + (x * 1.5);
} else {
tmp = (x + y) * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3.8e-272: tmp = (y * -0.5) + (x * 1.5) else: tmp = (x + y) * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -3.8e-272) 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 <= -3.8e-272) tmp = (y * -0.5) + (x * 1.5); else tmp = (x + y) * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3.8e-272], 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 -3.8 \cdot 10^{-272}:\\
\;\;\;\;y \cdot -0.5 + x \cdot 1.5\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) \cdot 0.5\\
\end{array}
\end{array}
if y < -3.7999999999999997e-272Initial program 100.0%
add-cube-cbrt98.3%
fabs-mul98.3%
pow298.3%
Applied egg-rr98.3%
add-sqr-sqrt98.2%
sqrt-unprod46.5%
frac-2neg46.5%
metadata-eval46.5%
frac-2neg46.5%
metadata-eval46.5%
frac-times46.5%
Applied egg-rr80.4%
Taylor expanded in x around 0 80.4%
if -3.7999999999999997e-272 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt77.8%
fabs-sqr77.8%
add-sqr-sqrt82.3%
frac-2neg82.3%
distribute-frac-neg82.3%
fmm-undef82.3%
*-un-lft-identity82.3%
metadata-eval82.3%
Applied egg-rr82.3%
Taylor expanded in x around 0 82.3%
cancel-sign-sub-inv82.3%
metadata-eval82.3%
distribute-lft-in82.3%
+-commutative82.3%
Simplified82.3%
Final simplification81.3%
(FPCore (x y) :precision binary64 (if (<= y -6e-126) (+ x (* y -0.5)) (* (+ x y) 0.5)))
double code(double x, double y) {
double tmp;
if (y <= -6e-126) {
tmp = x + (y * -0.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 <= (-6d-126)) then
tmp = x + (y * (-0.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 <= -6e-126) {
tmp = x + (y * -0.5);
} else {
tmp = (x + y) * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -6e-126: tmp = x + (y * -0.5) else: tmp = (x + y) * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -6e-126) tmp = Float64(x + Float64(y * -0.5)); else tmp = Float64(Float64(x + y) * 0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -6e-126) tmp = x + (y * -0.5); else tmp = (x + y) * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -6e-126], N[(x + N[(y * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{-126}:\\
\;\;\;\;x + y \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) \cdot 0.5\\
\end{array}
\end{array}
if y < -6.0000000000000003e-126Initial program 99.9%
add-cube-cbrt98.1%
fabs-mul98.1%
pow298.1%
Applied egg-rr98.1%
add-sqr-sqrt98.1%
sqrt-unprod45.1%
frac-2neg45.1%
metadata-eval45.1%
frac-2neg45.1%
metadata-eval45.1%
frac-times45.1%
Applied egg-rr86.5%
Taylor expanded in y around inf 73.6%
*-commutative73.6%
Simplified73.6%
if -6.0000000000000003e-126 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt70.7%
fabs-sqr70.7%
add-sqr-sqrt76.3%
frac-2neg76.3%
distribute-frac-neg76.3%
fmm-undef76.3%
*-un-lft-identity76.3%
metadata-eval76.3%
Applied egg-rr76.3%
Taylor expanded in x around 0 76.3%
cancel-sign-sub-inv76.3%
metadata-eval76.3%
distribute-lft-in76.3%
+-commutative76.3%
Simplified76.3%
Final simplification75.3%
(FPCore (x y) :precision binary64 (if (<= x 1.12e+18) (* (+ x y) 0.5) (* x 1.5)))
double code(double x, double y) {
double tmp;
if (x <= 1.12e+18) {
tmp = (x + 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.12d+18) then
tmp = (x + 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.12e+18) {
tmp = (x + y) * 0.5;
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.12e+18: tmp = (x + y) * 0.5 else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= 1.12e+18) tmp = Float64(Float64(x + 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.12e+18) tmp = (x + y) * 0.5; else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.12e+18], N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.12 \cdot 10^{+18}:\\
\;\;\;\;\left(x + y\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < 1.12e18Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt65.8%
fabs-sqr65.8%
add-sqr-sqrt67.6%
frac-2neg67.6%
distribute-frac-neg67.6%
fmm-undef67.6%
*-un-lft-identity67.6%
metadata-eval67.6%
Applied egg-rr67.6%
Taylor expanded in x around 0 67.6%
cancel-sign-sub-inv67.6%
metadata-eval67.6%
distribute-lft-in67.6%
+-commutative67.6%
Simplified67.6%
if 1.12e18 < x Initial program 99.8%
Taylor expanded in y around 0 82.6%
neg-mul-182.6%
Simplified82.6%
add-sqr-sqrt82.4%
associate-/l*82.4%
fabs-neg82.4%
add-sqr-sqrt82.4%
fabs-sqr82.4%
add-sqr-sqrt82.4%
fabs-neg82.4%
add-sqr-sqrt82.4%
fabs-sqr82.4%
add-sqr-sqrt82.4%
Applied egg-rr82.4%
associate-*r/82.4%
rem-square-sqrt82.6%
Simplified82.6%
Taylor expanded in x around 0 82.6%
*-commutative82.6%
Simplified82.6%
Final simplification71.1%
(FPCore (x y) :precision binary64 (if (<= y 36.0) (* x 0.5) (* y 0.5)))
double code(double x, double y) {
double tmp;
if (y <= 36.0) {
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 <= 36.0d0) 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 <= 36.0) {
tmp = x * 0.5;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 36.0: tmp = x * 0.5 else: tmp = y * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= 36.0) 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 <= 36.0) tmp = x * 0.5; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 36.0], N[(x * 0.5), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 36:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < 36Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt36.4%
fabs-sqr36.4%
add-sqr-sqrt42.2%
frac-2neg42.2%
distribute-frac-neg42.2%
fmm-undef42.2%
*-un-lft-identity42.2%
metadata-eval42.2%
Applied egg-rr42.2%
Taylor expanded in x around inf 37.4%
if 36 < y Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt91.9%
fabs-sqr91.9%
add-sqr-sqrt93.9%
frac-2neg93.9%
distribute-frac-neg93.9%
fmm-undef93.9%
*-un-lft-identity93.9%
metadata-eval93.9%
Applied egg-rr93.9%
Taylor expanded in x around 0 72.8%
Final simplification46.8%
(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-sqrt51.2%
fabs-sqr51.2%
add-sqr-sqrt55.9%
frac-2neg55.9%
distribute-frac-neg55.9%
fmm-undef55.9%
*-un-lft-identity55.9%
metadata-eval55.9%
Applied egg-rr55.9%
Taylor expanded in x around inf 33.4%
Final simplification33.4%
(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 11.4%
herbie shell --seed 2024152
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
:precision binary64
(+ x (/ (fabs (- y x)) 2.0)))