
(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 100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (+ x y) 0.5)))
(if (<= y -5.5e-201)
(- x t_0)
(if (<= y 3.65e-146) (+ x (/ (fabs x) 2.0)) t_0))))
double code(double x, double y) {
double t_0 = (x + y) * 0.5;
double tmp;
if (y <= -5.5e-201) {
tmp = x - t_0;
} else if (y <= 3.65e-146) {
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 <= (-5.5d-201)) then
tmp = x - t_0
else if (y <= 3.65d-146) 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 <= -5.5e-201) {
tmp = x - t_0;
} else if (y <= 3.65e-146) {
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 <= -5.5e-201: tmp = x - t_0 elif y <= 3.65e-146: 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 <= -5.5e-201) tmp = Float64(x - t_0); elseif (y <= 3.65e-146) 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 <= -5.5e-201) tmp = x - t_0; elseif (y <= 3.65e-146) 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, -5.5e-201], N[(x - t$95$0), $MachinePrecision], If[LessEqual[y, 3.65e-146], 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 -5.5 \cdot 10^{-201}:\\
\;\;\;\;x - t\_0\\
\mathbf{elif}\;y \leq 3.65 \cdot 10^{-146}:\\
\;\;\;\;x + \frac{\left|x\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -5.50000000000000034e-201Initial program 100.0%
add-cube-cbrt98.1%
fabs-mul98.1%
pow298.1%
Applied egg-rr98.1%
Applied egg-rr87.2%
if -5.50000000000000034e-201 < y < 3.64999999999999982e-146Initial program 99.9%
Taylor expanded in y around 0 91.4%
neg-mul-191.4%
Simplified91.4%
if 3.64999999999999982e-146 < y Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt81.5%
fabs-sqr81.5%
add-sqr-sqrt85.3%
frac-2neg85.3%
distribute-frac-neg85.3%
fmm-undef85.3%
*-un-lft-identity85.3%
metadata-eval85.3%
Applied egg-rr85.3%
Taylor expanded in x around 0 85.3%
cancel-sign-sub-inv85.3%
metadata-eval85.3%
distribute-lft-in85.3%
+-commutative85.3%
Simplified85.3%
Final simplification87.4%
(FPCore (x y) :precision binary64 (if (<= x -2.55e-24) (- x (* (+ x y) 0.5)) (if (<= x 2.6e+20) (+ x (/ (fabs y) 2.0)) (+ (* x 1.5) (* y -0.5)))))
double code(double x, double y) {
double tmp;
if (x <= -2.55e-24) {
tmp = x - ((x + y) * 0.5);
} else if (x <= 2.6e+20) {
tmp = x + (fabs(y) / 2.0);
} else {
tmp = (x * 1.5) + (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 (x <= (-2.55d-24)) then
tmp = x - ((x + y) * 0.5d0)
else if (x <= 2.6d+20) then
tmp = x + (abs(y) / 2.0d0)
else
tmp = (x * 1.5d0) + (y * (-0.5d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -2.55e-24) {
tmp = x - ((x + y) * 0.5);
} else if (x <= 2.6e+20) {
tmp = x + (Math.abs(y) / 2.0);
} else {
tmp = (x * 1.5) + (y * -0.5);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.55e-24: tmp = x - ((x + y) * 0.5) elif x <= 2.6e+20: tmp = x + (math.fabs(y) / 2.0) else: tmp = (x * 1.5) + (y * -0.5) return tmp
function code(x, y) tmp = 0.0 if (x <= -2.55e-24) tmp = Float64(x - Float64(Float64(x + y) * 0.5)); elseif (x <= 2.6e+20) tmp = Float64(x + Float64(abs(y) / 2.0)); else tmp = Float64(Float64(x * 1.5) + Float64(y * -0.5)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.55e-24) tmp = x - ((x + y) * 0.5); elseif (x <= 2.6e+20) tmp = x + (abs(y) / 2.0); else tmp = (x * 1.5) + (y * -0.5); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.55e-24], N[(x - N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.6e+20], N[(x + N[(N[Abs[y], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(x * 1.5), $MachinePrecision] + N[(y * -0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.55 \cdot 10^{-24}:\\
\;\;\;\;x - \left(x + y\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{+20}:\\
\;\;\;\;x + \frac{\left|y\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5 + y \cdot -0.5\\
\end{array}
\end{array}
if x < -2.55000000000000013e-24Initial program 100.0%
add-cube-cbrt98.0%
fabs-mul98.0%
pow298.0%
Applied egg-rr98.0%
Applied egg-rr89.7%
if -2.55000000000000013e-24 < x < 2.6e20Initial program 100.0%
Taylor expanded in y around inf 83.3%
if 2.6e20 < x Initial program 99.9%
add-cube-cbrt98.8%
fabs-mul98.8%
pow298.8%
Applied egg-rr98.8%
add-sqr-sqrt98.8%
sqrt-unprod52.1%
frac-2neg52.1%
metadata-eval52.1%
frac-2neg52.1%
metadata-eval52.1%
frac-times52.1%
Applied egg-rr91.1%
Taylor expanded in x around 0 91.1%
Final simplification86.7%
(FPCore (x y) :precision binary64 (if (<= y -1.2e-217) (* y -0.5) (if (<= y 5e-130) (* x 0.5) (* y 0.5))))
double code(double x, double y) {
double tmp;
if (y <= -1.2e-217) {
tmp = y * -0.5;
} else if (y <= 5e-130) {
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.2d-217)) then
tmp = y * (-0.5d0)
else if (y <= 5d-130) 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.2e-217) {
tmp = y * -0.5;
} else if (y <= 5e-130) {
tmp = x * 0.5;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.2e-217: tmp = y * -0.5 elif y <= 5e-130: tmp = x * 0.5 else: tmp = y * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.2e-217) tmp = Float64(y * -0.5); elseif (y <= 5e-130) 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.2e-217) tmp = y * -0.5; elseif (y <= 5e-130) tmp = x * 0.5; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.2e-217], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 5e-130], N[(x * 0.5), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.2 \cdot 10^{-217}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 5 \cdot 10^{-130}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < -1.1999999999999999e-217Initial program 100.0%
add-cube-cbrt98.1%
fabs-mul98.1%
pow298.1%
Applied egg-rr98.1%
Applied egg-rr85.9%
Taylor expanded in x around 0 63.3%
*-commutative63.3%
Simplified63.3%
if -1.1999999999999999e-217 < y < 4.9999999999999996e-130Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt55.2%
fabs-sqr55.2%
add-sqr-sqrt63.4%
frac-2neg63.4%
distribute-frac-neg63.4%
fmm-undef63.4%
*-un-lft-identity63.4%
metadata-eval63.4%
Applied egg-rr63.4%
Taylor expanded in x around inf 55.8%
if 4.9999999999999996e-130 < y Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt82.5%
fabs-sqr82.5%
add-sqr-sqrt86.1%
frac-2neg86.1%
distribute-frac-neg86.1%
fmm-undef86.1%
*-un-lft-identity86.1%
metadata-eval86.1%
Applied egg-rr86.1%
Taylor expanded in x around 0 69.9%
Final simplification64.0%
(FPCore (x y) :precision binary64 (if (<= x -1.55e-23) (* x 0.5) (if (<= x 1.55e-90) (* y 0.5) (* x 1.5))))
double code(double x, double y) {
double tmp;
if (x <= -1.55e-23) {
tmp = x * 0.5;
} else if (x <= 1.55e-90) {
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.55d-23)) then
tmp = x * 0.5d0
else if (x <= 1.55d-90) 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.55e-23) {
tmp = x * 0.5;
} else if (x <= 1.55e-90) {
tmp = y * 0.5;
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.55e-23: tmp = x * 0.5 elif x <= 1.55e-90: tmp = y * 0.5 else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.55e-23) tmp = Float64(x * 0.5); elseif (x <= 1.55e-90) 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.55e-23) tmp = x * 0.5; elseif (x <= 1.55e-90) tmp = y * 0.5; else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.55e-23], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.55e-90], N[(y * 0.5), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{-23}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{-90}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -1.5499999999999999e-23Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt87.5%
fabs-sqr87.5%
add-sqr-sqrt88.3%
frac-2neg88.3%
distribute-frac-neg88.3%
fmm-undef88.3%
*-un-lft-identity88.3%
metadata-eval88.3%
Applied egg-rr88.3%
Taylor expanded in x around inf 78.1%
if -1.5499999999999999e-23 < x < 1.5500000000000001e-90Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt54.9%
fabs-sqr54.9%
add-sqr-sqrt57.1%
frac-2neg57.1%
distribute-frac-neg57.1%
fmm-undef57.1%
*-un-lft-identity57.1%
metadata-eval57.1%
Applied egg-rr57.1%
Taylor expanded in x around 0 46.7%
if 1.5500000000000001e-90 < x Initial program 99.9%
Taylor expanded in y around 0 67.3%
neg-mul-167.3%
Simplified67.3%
add-sqr-sqrt67.2%
associate-/l*67.2%
fabs-neg67.2%
add-sqr-sqrt67.2%
fabs-sqr67.2%
add-sqr-sqrt67.2%
fabs-neg67.2%
add-sqr-sqrt67.2%
fabs-sqr67.2%
add-sqr-sqrt67.2%
Applied egg-rr67.2%
associate-*r/67.2%
rem-square-sqrt67.3%
Simplified67.3%
Taylor expanded in x around 0 67.3%
*-commutative67.3%
Simplified67.3%
Final simplification61.1%
(FPCore (x y) :precision binary64 (let* ((t_0 (* (+ x y) 0.5))) (if (<= y -5e-298) (- x t_0) t_0)))
double code(double x, double y) {
double t_0 = (x + y) * 0.5;
double tmp;
if (y <= -5e-298) {
tmp = x - t_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 <= (-5d-298)) then
tmp = x - t_0
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 <= -5e-298) {
tmp = x - t_0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x + y) * 0.5 tmp = 0 if y <= -5e-298: tmp = x - t_0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x + y) * 0.5) tmp = 0.0 if (y <= -5e-298) tmp = Float64(x - t_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 <= -5e-298) tmp = x - t_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, -5e-298], N[(x - t$95$0), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + y\right) \cdot 0.5\\
\mathbf{if}\;y \leq -5 \cdot 10^{-298}:\\
\;\;\;\;x - t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -5.0000000000000002e-298Initial program 100.0%
add-cube-cbrt98.2%
fabs-mul98.2%
pow298.2%
Applied egg-rr98.2%
Applied egg-rr81.8%
if -5.0000000000000002e-298 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt75.5%
fabs-sqr75.5%
add-sqr-sqrt80.3%
frac-2neg80.3%
distribute-frac-neg80.3%
fmm-undef80.3%
*-un-lft-identity80.3%
metadata-eval80.3%
Applied egg-rr80.3%
Taylor expanded in x around 0 80.3%
cancel-sign-sub-inv80.3%
metadata-eval80.3%
distribute-lft-in80.3%
+-commutative80.3%
Simplified80.3%
Final simplification81.0%
(FPCore (x y) :precision binary64 (if (<= y -3.5e-298) (+ (* x 1.5) (* y -0.5)) (* (+ x y) 0.5)))
double code(double x, double y) {
double tmp;
if (y <= -3.5e-298) {
tmp = (x * 1.5) + (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 <= (-3.5d-298)) then
tmp = (x * 1.5d0) + (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 <= -3.5e-298) {
tmp = (x * 1.5) + (y * -0.5);
} else {
tmp = (x + y) * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3.5e-298: tmp = (x * 1.5) + (y * -0.5) else: tmp = (x + y) * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -3.5e-298) tmp = Float64(Float64(x * 1.5) + 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 <= -3.5e-298) tmp = (x * 1.5) + (y * -0.5); else tmp = (x + y) * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3.5e-298], N[(N[(x * 1.5), $MachinePrecision] + N[(y * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{-298}:\\
\;\;\;\;x \cdot 1.5 + y \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) \cdot 0.5\\
\end{array}
\end{array}
if y < -3.4999999999999998e-298Initial program 100.0%
add-cube-cbrt98.2%
fabs-mul98.2%
pow298.2%
Applied egg-rr98.2%
add-sqr-sqrt98.2%
sqrt-unprod53.3%
frac-2neg53.3%
metadata-eval53.3%
frac-2neg53.3%
metadata-eval53.3%
frac-times53.3%
Applied egg-rr79.8%
Taylor expanded in x around 0 79.8%
if -3.4999999999999998e-298 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt75.5%
fabs-sqr75.5%
add-sqr-sqrt80.3%
frac-2neg80.3%
distribute-frac-neg80.3%
fmm-undef80.3%
*-un-lft-identity80.3%
metadata-eval80.3%
Applied egg-rr80.3%
Taylor expanded in x around 0 80.3%
cancel-sign-sub-inv80.3%
metadata-eval80.3%
distribute-lft-in80.3%
+-commutative80.3%
Simplified80.3%
Final simplification80.1%
(FPCore (x y) :precision binary64 (if (<= y -1.2e-217) (- x (* y 0.5)) (* (+ x y) 0.5)))
double code(double x, double y) {
double tmp;
if (y <= -1.2e-217) {
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 <= (-1.2d-217)) 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 <= -1.2e-217) {
tmp = x - (y * 0.5);
} else {
tmp = (x + y) * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.2e-217: tmp = x - (y * 0.5) else: tmp = (x + y) * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.2e-217) 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 <= -1.2e-217) tmp = x - (y * 0.5); else tmp = (x + y) * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.2e-217], 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 -1.2 \cdot 10^{-217}:\\
\;\;\;\;x - y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) \cdot 0.5\\
\end{array}
\end{array}
if y < -1.1999999999999999e-217Initial program 100.0%
add-cube-cbrt98.1%
fabs-mul98.1%
pow298.1%
Applied egg-rr98.1%
Applied egg-rr85.9%
Taylor expanded in y around inf 69.3%
if -1.1999999999999999e-217 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt71.8%
fabs-sqr71.8%
add-sqr-sqrt77.2%
frac-2neg77.2%
distribute-frac-neg77.2%
fmm-undef77.2%
*-un-lft-identity77.2%
metadata-eval77.2%
Applied egg-rr77.2%
Taylor expanded in x around 0 77.3%
cancel-sign-sub-inv77.3%
metadata-eval77.3%
distribute-lft-in77.3%
+-commutative77.3%
Simplified77.3%
Final simplification74.1%
(FPCore (x y) :precision binary64 (if (<= y -1e-218) (* y -0.5) (* (+ x y) 0.5)))
double code(double x, double y) {
double tmp;
if (y <= -1e-218) {
tmp = 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 <= (-1d-218)) then
tmp = 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 <= -1e-218) {
tmp = y * -0.5;
} else {
tmp = (x + y) * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1e-218: tmp = y * -0.5 else: tmp = (x + y) * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -1e-218) tmp = 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 <= -1e-218) tmp = y * -0.5; else tmp = (x + y) * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1e-218], N[(y * -0.5), $MachinePrecision], N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{-218}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) \cdot 0.5\\
\end{array}
\end{array}
if y < -1e-218Initial program 100.0%
add-cube-cbrt98.1%
fabs-mul98.1%
pow298.1%
Applied egg-rr98.1%
Applied egg-rr85.9%
Taylor expanded in x around 0 63.3%
*-commutative63.3%
Simplified63.3%
if -1e-218 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt71.8%
fabs-sqr71.8%
add-sqr-sqrt77.2%
frac-2neg77.2%
distribute-frac-neg77.2%
fmm-undef77.2%
*-un-lft-identity77.2%
metadata-eval77.2%
Applied egg-rr77.2%
Taylor expanded in x around 0 77.3%
cancel-sign-sub-inv77.3%
metadata-eval77.3%
distribute-lft-in77.3%
+-commutative77.3%
Simplified77.3%
Final simplification71.8%
(FPCore (x y) :precision binary64 (if (<= y 1.6e-130) (* x 0.5) (* y 0.5)))
double code(double x, double y) {
double tmp;
if (y <= 1.6e-130) {
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.6d-130) 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.6e-130) {
tmp = x * 0.5;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.6e-130: tmp = x * 0.5 else: tmp = y * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= 1.6e-130) 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.6e-130) tmp = x * 0.5; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.6e-130], N[(x * 0.5), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.6 \cdot 10^{-130}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < 1.6e-130Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt33.9%
fabs-sqr33.9%
add-sqr-sqrt39.2%
frac-2neg39.2%
distribute-frac-neg39.2%
fmm-undef39.2%
*-un-lft-identity39.2%
metadata-eval39.2%
Applied egg-rr39.2%
Taylor expanded in x around inf 37.3%
if 1.6e-130 < y Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt82.5%
fabs-sqr82.5%
add-sqr-sqrt86.1%
frac-2neg86.1%
distribute-frac-neg86.1%
fmm-undef86.1%
*-un-lft-identity86.1%
metadata-eval86.1%
Applied egg-rr86.1%
Taylor expanded in x around 0 69.9%
Final simplification49.4%
(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 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt51.9%
fabs-sqr51.9%
add-sqr-sqrt56.6%
frac-2neg56.6%
distribute-frac-neg56.6%
fmm-undef56.6%
*-un-lft-identity56.6%
metadata-eval56.6%
Applied egg-rr56.6%
Taylor expanded in x around inf 30.4%
Final simplification30.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 100.0%
Taylor expanded in x around inf 10.9%
herbie shell --seed 2024181
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
:precision binary64
(+ x (/ (fabs (- y x)) 2.0)))