
(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 (if (<= y -2.1e-180) (+ (* y -0.5) (* x 1.5)) (if (<= y 6e-189) (+ x (/ (fabs x) 2.0)) (* 0.5 (+ x y)))))
double code(double x, double y) {
double tmp;
if (y <= -2.1e-180) {
tmp = (y * -0.5) + (x * 1.5);
} else if (y <= 6e-189) {
tmp = x + (fabs(x) / 2.0);
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-2.1d-180)) then
tmp = (y * (-0.5d0)) + (x * 1.5d0)
else if (y <= 6d-189) then
tmp = x + (abs(x) / 2.0d0)
else
tmp = 0.5d0 * (x + y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2.1e-180) {
tmp = (y * -0.5) + (x * 1.5);
} else if (y <= 6e-189) {
tmp = x + (Math.abs(x) / 2.0);
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.1e-180: tmp = (y * -0.5) + (x * 1.5) elif y <= 6e-189: tmp = x + (math.fabs(x) / 2.0) else: tmp = 0.5 * (x + y) return tmp
function code(x, y) tmp = 0.0 if (y <= -2.1e-180) tmp = Float64(Float64(y * -0.5) + Float64(x * 1.5)); elseif (y <= 6e-189) tmp = Float64(x + Float64(abs(x) / 2.0)); else tmp = Float64(0.5 * Float64(x + y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.1e-180) tmp = (y * -0.5) + (x * 1.5); elseif (y <= 6e-189) tmp = x + (abs(x) / 2.0); else tmp = 0.5 * (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.1e-180], N[(N[(y * -0.5), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6e-189], N[(x + N[(N[Abs[x], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{-180}:\\
\;\;\;\;y \cdot -0.5 + x \cdot 1.5\\
\mathbf{elif}\;y \leq 6 \cdot 10^{-189}:\\
\;\;\;\;x + \frac{\left|x\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < -2.0999999999999999e-180Initial program 99.9%
add-cube-cbrt98.2%
fabs-mul98.2%
pow298.2%
Applied egg-rr98.2%
add-sqr-sqrt98.1%
sqrt-unprod53.1%
frac-2neg53.1%
metadata-eval53.1%
frac-2neg53.1%
metadata-eval53.1%
frac-times53.1%
Applied egg-rr86.2%
Taylor expanded in x around 0 86.2%
if -2.0999999999999999e-180 < y < 6e-189Initial program 99.9%
Taylor expanded in y around 0 92.9%
neg-mul-192.9%
Simplified92.9%
if 6e-189 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt82.5%
fabs-sqr82.5%
add-sqr-sqrt86.0%
frac-2neg86.0%
distribute-frac-neg86.0%
fmm-undef86.0%
*-un-lft-identity86.0%
metadata-eval86.0%
Applied egg-rr86.0%
Taylor expanded in x around 0 86.0%
cancel-sign-sub-inv86.0%
metadata-eval86.0%
distribute-lft-in86.0%
+-commutative86.0%
Simplified86.0%
Final simplification87.5%
(FPCore (x y)
:precision binary64
(if (<= x -75000000000.0)
(* 0.5 (+ x y))
(if (<= x 8000000.0)
(+ x (/ (fabs y) 2.0))
(* x (+ 1.5 (* -0.5 (/ y x)))))))
double code(double x, double y) {
double tmp;
if (x <= -75000000000.0) {
tmp = 0.5 * (x + y);
} else if (x <= 8000000.0) {
tmp = x + (fabs(y) / 2.0);
} else {
tmp = x * (1.5 + (-0.5 * (y / x)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-75000000000.0d0)) then
tmp = 0.5d0 * (x + y)
else if (x <= 8000000.0d0) then
tmp = x + (abs(y) / 2.0d0)
else
tmp = x * (1.5d0 + ((-0.5d0) * (y / x)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -75000000000.0) {
tmp = 0.5 * (x + y);
} else if (x <= 8000000.0) {
tmp = x + (Math.abs(y) / 2.0);
} else {
tmp = x * (1.5 + (-0.5 * (y / x)));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -75000000000.0: tmp = 0.5 * (x + y) elif x <= 8000000.0: tmp = x + (math.fabs(y) / 2.0) else: tmp = x * (1.5 + (-0.5 * (y / x))) return tmp
function code(x, y) tmp = 0.0 if (x <= -75000000000.0) tmp = Float64(0.5 * Float64(x + y)); elseif (x <= 8000000.0) tmp = Float64(x + Float64(abs(y) / 2.0)); else tmp = Float64(x * Float64(1.5 + Float64(-0.5 * Float64(y / x)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -75000000000.0) tmp = 0.5 * (x + y); elseif (x <= 8000000.0) tmp = x + (abs(y) / 2.0); else tmp = x * (1.5 + (-0.5 * (y / x))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -75000000000.0], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8000000.0], N[(x + N[(N[Abs[y], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.5 + N[(-0.5 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -75000000000:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\mathbf{elif}\;x \leq 8000000:\\
\;\;\;\;x + \frac{\left|y\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1.5 + -0.5 \cdot \frac{y}{x}\right)\\
\end{array}
\end{array}
if x < -7.5e10Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt93.3%
fabs-sqr93.3%
add-sqr-sqrt94.1%
frac-2neg94.1%
distribute-frac-neg94.1%
fmm-undef94.1%
*-un-lft-identity94.1%
metadata-eval94.1%
Applied egg-rr94.1%
Taylor expanded in x around 0 94.1%
cancel-sign-sub-inv94.1%
metadata-eval94.1%
distribute-lft-in94.1%
+-commutative94.1%
Simplified94.1%
if -7.5e10 < x < 8e6Initial program 99.9%
Taylor expanded in y around inf 79.2%
if 8e6 < x Initial program 99.7%
add-cube-cbrt98.8%
fabs-mul98.8%
pow298.8%
Applied egg-rr98.8%
add-sqr-sqrt98.8%
sqrt-unprod29.1%
frac-2neg29.1%
metadata-eval29.1%
frac-2neg29.1%
metadata-eval29.1%
frac-times29.1%
Applied egg-rr92.0%
Taylor expanded in x around inf 92.0%
*-commutative92.0%
Simplified92.0%
Final simplification85.4%
(FPCore (x y) :precision binary64 (if (<= y -5e-90) (* y -0.5) (if (<= y 8.5e-245) (* x 1.5) (if (<= y 5.2e-117) (* x 0.5) (* y 0.5)))))
double code(double x, double y) {
double tmp;
if (y <= -5e-90) {
tmp = y * -0.5;
} else if (y <= 8.5e-245) {
tmp = x * 1.5;
} else if (y <= 5.2e-117) {
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 <= (-5d-90)) then
tmp = y * (-0.5d0)
else if (y <= 8.5d-245) then
tmp = x * 1.5d0
else if (y <= 5.2d-117) 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 <= -5e-90) {
tmp = y * -0.5;
} else if (y <= 8.5e-245) {
tmp = x * 1.5;
} else if (y <= 5.2e-117) {
tmp = x * 0.5;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5e-90: tmp = y * -0.5 elif y <= 8.5e-245: tmp = x * 1.5 elif y <= 5.2e-117: tmp = x * 0.5 else: tmp = y * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -5e-90) tmp = Float64(y * -0.5); elseif (y <= 8.5e-245) tmp = Float64(x * 1.5); elseif (y <= 5.2e-117) 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 <= -5e-90) tmp = y * -0.5; elseif (y <= 8.5e-245) tmp = x * 1.5; elseif (y <= 5.2e-117) tmp = x * 0.5; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5e-90], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 8.5e-245], N[(x * 1.5), $MachinePrecision], If[LessEqual[y, 5.2e-117], N[(x * 0.5), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-90}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-245}:\\
\;\;\;\;x \cdot 1.5\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{-117}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < -5.00000000000000019e-90Initial program 99.9%
add-cube-cbrt98.2%
fabs-mul98.2%
pow298.2%
Applied egg-rr98.2%
add-sqr-sqrt98.2%
sqrt-unprod52.0%
frac-2neg52.0%
metadata-eval52.0%
frac-2neg52.0%
metadata-eval52.0%
frac-times52.0%
Applied egg-rr87.6%
Taylor expanded in x around inf 76.0%
*-commutative76.0%
Simplified76.0%
Taylor expanded in x around 0 68.2%
*-commutative68.2%
Simplified68.2%
if -5.00000000000000019e-90 < y < 8.50000000000000022e-245Initial program 99.9%
Taylor expanded in y around 0 83.8%
neg-mul-183.8%
Simplified83.8%
add-sqr-sqrt83.4%
associate-/l*83.4%
fabs-neg83.4%
add-sqr-sqrt49.2%
fabs-sqr49.2%
add-sqr-sqrt49.2%
fabs-neg49.2%
add-sqr-sqrt49.2%
fabs-sqr49.2%
add-sqr-sqrt49.2%
Applied egg-rr49.2%
associate-*r/49.2%
rem-square-sqrt55.9%
Simplified55.9%
Taylor expanded in x around 0 55.9%
*-commutative55.9%
Simplified55.9%
if 8.50000000000000022e-245 < y < 5.19999999999999966e-117Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt67.4%
fabs-sqr67.4%
add-sqr-sqrt73.7%
frac-2neg73.7%
distribute-frac-neg73.7%
fmm-undef73.7%
*-un-lft-identity73.7%
metadata-eval73.7%
Applied egg-rr73.7%
Taylor expanded in x around inf 58.4%
if 5.19999999999999966e-117 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt83.1%
fabs-sqr83.1%
add-sqr-sqrt86.5%
frac-2neg86.5%
distribute-frac-neg86.5%
fmm-undef86.5%
*-un-lft-identity86.5%
metadata-eval86.5%
Applied egg-rr86.5%
Taylor expanded in x around 0 69.5%
Final simplification64.9%
(FPCore (x y) :precision binary64 (if (<= y -3.6e-182) (+ x (* y -0.5)) (if (<= y 8e-284) (* x 1.5) (* 0.5 (+ x y)))))
double code(double x, double y) {
double tmp;
if (y <= -3.6e-182) {
tmp = x + (y * -0.5);
} else if (y <= 8e-284) {
tmp = x * 1.5;
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-3.6d-182)) then
tmp = x + (y * (-0.5d0))
else if (y <= 8d-284) then
tmp = x * 1.5d0
else
tmp = 0.5d0 * (x + y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -3.6e-182) {
tmp = x + (y * -0.5);
} else if (y <= 8e-284) {
tmp = x * 1.5;
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3.6e-182: tmp = x + (y * -0.5) elif y <= 8e-284: tmp = x * 1.5 else: tmp = 0.5 * (x + y) return tmp
function code(x, y) tmp = 0.0 if (y <= -3.6e-182) tmp = Float64(x + Float64(y * -0.5)); elseif (y <= 8e-284) tmp = Float64(x * 1.5); else tmp = Float64(0.5 * Float64(x + y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -3.6e-182) tmp = x + (y * -0.5); elseif (y <= 8e-284) tmp = x * 1.5; else tmp = 0.5 * (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3.6e-182], N[(x + N[(y * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8e-284], N[(x * 1.5), $MachinePrecision], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.6 \cdot 10^{-182}:\\
\;\;\;\;x + y \cdot -0.5\\
\mathbf{elif}\;y \leq 8 \cdot 10^{-284}:\\
\;\;\;\;x \cdot 1.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < -3.59999999999999977e-182Initial program 99.9%
add-cube-cbrt98.1%
fabs-mul98.1%
pow298.1%
Applied egg-rr98.1%
add-sqr-sqrt98.1%
sqrt-unprod53.6%
frac-2neg53.6%
metadata-eval53.6%
frac-2neg53.6%
metadata-eval53.6%
frac-times53.6%
Applied egg-rr85.5%
Taylor expanded in y around inf 68.8%
*-commutative68.8%
Simplified68.8%
if -3.59999999999999977e-182 < y < 8.00000000000000029e-284Initial program 99.8%
Taylor expanded in y around 0 92.6%
neg-mul-192.6%
Simplified92.6%
add-sqr-sqrt92.2%
associate-/l*92.2%
fabs-neg92.2%
add-sqr-sqrt57.5%
fabs-sqr57.5%
add-sqr-sqrt57.5%
fabs-neg57.5%
add-sqr-sqrt57.5%
fabs-sqr57.5%
add-sqr-sqrt57.5%
Applied egg-rr57.5%
associate-*r/57.5%
rem-square-sqrt64.1%
Simplified64.1%
Taylor expanded in x around 0 64.1%
*-commutative64.1%
Simplified64.1%
if 8.00000000000000029e-284 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt76.1%
fabs-sqr76.1%
add-sqr-sqrt80.8%
frac-2neg80.8%
distribute-frac-neg80.8%
fmm-undef80.8%
*-un-lft-identity80.8%
metadata-eval80.8%
Applied egg-rr80.8%
Taylor expanded in x around 0 80.8%
cancel-sign-sub-inv80.8%
metadata-eval80.8%
distribute-lft-in80.8%
+-commutative80.8%
Simplified80.8%
Final simplification74.5%
(FPCore (x y) :precision binary64 (if (<= x -5.5e-164) (* x 0.5) (if (<= x 8000000.0) (* y 0.5) (* x 1.5))))
double code(double x, double y) {
double tmp;
if (x <= -5.5e-164) {
tmp = x * 0.5;
} else if (x <= 8000000.0) {
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 <= (-5.5d-164)) then
tmp = x * 0.5d0
else if (x <= 8000000.0d0) 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 <= -5.5e-164) {
tmp = x * 0.5;
} else if (x <= 8000000.0) {
tmp = y * 0.5;
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5.5e-164: tmp = x * 0.5 elif x <= 8000000.0: tmp = y * 0.5 else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -5.5e-164) tmp = Float64(x * 0.5); elseif (x <= 8000000.0) 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 <= -5.5e-164) tmp = x * 0.5; elseif (x <= 8000000.0) tmp = y * 0.5; else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5.5e-164], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 8000000.0], N[(y * 0.5), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{-164}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 8000000:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -5.50000000000000027e-164Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt81.3%
fabs-sqr81.3%
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 inf 63.0%
if -5.50000000000000027e-164 < x < 8e6Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt48.3%
fabs-sqr48.3%
add-sqr-sqrt52.0%
frac-2neg52.0%
distribute-frac-neg52.0%
fmm-undef52.0%
*-un-lft-identity52.0%
metadata-eval52.0%
Applied egg-rr52.0%
Taylor expanded in x around 0 47.1%
if 8e6 < x Initial program 99.7%
Taylor expanded in y around 0 76.5%
neg-mul-176.5%
Simplified76.5%
add-sqr-sqrt76.4%
associate-/l*76.4%
fabs-neg76.4%
add-sqr-sqrt76.4%
fabs-sqr76.4%
add-sqr-sqrt76.4%
fabs-neg76.4%
add-sqr-sqrt76.4%
fabs-sqr76.4%
add-sqr-sqrt76.4%
Applied egg-rr76.4%
associate-*r/76.4%
rem-square-sqrt76.5%
Simplified76.5%
Taylor expanded in x around 0 76.5%
*-commutative76.5%
Simplified76.5%
Final simplification60.0%
(FPCore (x y) :precision binary64 (if (<= y 1.12e-282) (+ (* y -0.5) (* x 1.5)) (* 0.5 (+ x y))))
double code(double x, double y) {
double tmp;
if (y <= 1.12e-282) {
tmp = (y * -0.5) + (x * 1.5);
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.12d-282) then
tmp = (y * (-0.5d0)) + (x * 1.5d0)
else
tmp = 0.5d0 * (x + y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.12e-282) {
tmp = (y * -0.5) + (x * 1.5);
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.12e-282: tmp = (y * -0.5) + (x * 1.5) else: tmp = 0.5 * (x + y) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.12e-282) tmp = Float64(Float64(y * -0.5) + Float64(x * 1.5)); else tmp = Float64(0.5 * Float64(x + y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.12e-282) tmp = (y * -0.5) + (x * 1.5); else tmp = 0.5 * (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.12e-282], N[(N[(y * -0.5), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.12 \cdot 10^{-282}:\\
\;\;\;\;y \cdot -0.5 + x \cdot 1.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < 1.11999999999999992e-282Initial program 99.9%
add-cube-cbrt98.2%
fabs-mul98.2%
pow298.2%
Applied egg-rr98.2%
add-sqr-sqrt98.1%
sqrt-unprod52.1%
frac-2neg52.1%
metadata-eval52.1%
frac-2neg52.1%
metadata-eval52.1%
frac-times52.1%
Applied egg-rr82.5%
Taylor expanded in x around 0 82.5%
if 1.11999999999999992e-282 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt76.1%
fabs-sqr76.1%
add-sqr-sqrt80.8%
frac-2neg80.8%
distribute-frac-neg80.8%
fmm-undef80.8%
*-un-lft-identity80.8%
metadata-eval80.8%
Applied egg-rr80.8%
Taylor expanded in x around 0 80.8%
cancel-sign-sub-inv80.8%
metadata-eval80.8%
distribute-lft-in80.8%
+-commutative80.8%
Simplified80.8%
Final simplification81.6%
(FPCore (x y) :precision binary64 (if (<= y -8.8e-75) (* y -0.5) (* 0.5 (+ x y))))
double code(double x, double y) {
double tmp;
if (y <= -8.8e-75) {
tmp = y * -0.5;
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-8.8d-75)) then
tmp = y * (-0.5d0)
else
tmp = 0.5d0 * (x + y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -8.8e-75) {
tmp = y * -0.5;
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -8.8e-75: tmp = y * -0.5 else: tmp = 0.5 * (x + y) return tmp
function code(x, y) tmp = 0.0 if (y <= -8.8e-75) tmp = Float64(y * -0.5); else tmp = Float64(0.5 * Float64(x + y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -8.8e-75) tmp = y * -0.5; else tmp = 0.5 * (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -8.8e-75], N[(y * -0.5), $MachinePrecision], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.8 \cdot 10^{-75}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < -8.80000000000000022e-75Initial program 99.9%
add-cube-cbrt98.2%
fabs-mul98.2%
pow298.2%
Applied egg-rr98.2%
add-sqr-sqrt98.2%
sqrt-unprod50.8%
frac-2neg50.8%
metadata-eval50.8%
frac-2neg50.8%
metadata-eval50.8%
frac-times50.8%
Applied egg-rr90.2%
Taylor expanded in x around inf 77.9%
*-commutative77.9%
Simplified77.9%
Taylor expanded in x around 0 70.8%
*-commutative70.8%
Simplified70.8%
if -8.80000000000000022e-75 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt65.6%
fabs-sqr65.6%
add-sqr-sqrt71.4%
frac-2neg71.4%
distribute-frac-neg71.4%
fmm-undef71.4%
*-un-lft-identity71.4%
metadata-eval71.4%
Applied egg-rr71.4%
Taylor expanded in x around 0 71.4%
cancel-sign-sub-inv71.4%
metadata-eval71.4%
distribute-lft-in71.4%
+-commutative71.4%
Simplified71.4%
Final simplification71.2%
(FPCore (x y) :precision binary64 (if (<= y 8e-117) (* x 0.5) (* y 0.5)))
double code(double x, double y) {
double tmp;
if (y <= 8e-117) {
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 <= 8d-117) 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 <= 8e-117) {
tmp = x * 0.5;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 8e-117: tmp = x * 0.5 else: tmp = y * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= 8e-117) 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 <= 8e-117) tmp = x * 0.5; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 8e-117], N[(x * 0.5), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8 \cdot 10^{-117}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < 8.00000000000000024e-117Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt30.8%
fabs-sqr30.8%
add-sqr-sqrt37.0%
frac-2neg37.0%
distribute-frac-neg37.0%
fmm-undef37.0%
*-un-lft-identity37.0%
metadata-eval37.0%
Applied egg-rr37.0%
Taylor expanded in x around inf 34.3%
if 8.00000000000000024e-117 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt83.1%
fabs-sqr83.1%
add-sqr-sqrt86.5%
frac-2neg86.5%
distribute-frac-neg86.5%
fmm-undef86.5%
*-un-lft-identity86.5%
metadata-eval86.5%
Applied egg-rr86.5%
Taylor expanded in x around 0 69.5%
Final simplification47.0%
(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.6%
fabs-sqr49.6%
add-sqr-sqrt54.8%
frac-2neg54.8%
distribute-frac-neg54.8%
fmm-undef54.8%
*-un-lft-identity54.8%
metadata-eval54.8%
Applied egg-rr54.8%
Taylor expanded in x around inf 29.0%
Final simplification29.0%
(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.3%
herbie shell --seed 2024163
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
:precision binary64
(+ x (/ (fabs (- y x)) 2.0)))