
(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 10 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 (- 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}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= x -5.5e-72) (* 0.5 (+ x y)) (if (<= x 2.8e-147) (* (fabs (- y x)) 0.5) (+ x (* 0.5 (- x y))))))
double code(double x, double y) {
double tmp;
if (x <= -5.5e-72) {
tmp = 0.5 * (x + y);
} else if (x <= 2.8e-147) {
tmp = fabs((y - x)) * 0.5;
} else {
tmp = x + (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 (x <= (-5.5d-72)) then
tmp = 0.5d0 * (x + y)
else if (x <= 2.8d-147) then
tmp = abs((y - x)) * 0.5d0
else
tmp = x + (0.5d0 * (x - y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -5.5e-72) {
tmp = 0.5 * (x + y);
} else if (x <= 2.8e-147) {
tmp = Math.abs((y - x)) * 0.5;
} else {
tmp = x + (0.5 * (x - y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5.5e-72: tmp = 0.5 * (x + y) elif x <= 2.8e-147: tmp = math.fabs((y - x)) * 0.5 else: tmp = x + (0.5 * (x - y)) return tmp
function code(x, y) tmp = 0.0 if (x <= -5.5e-72) tmp = Float64(0.5 * Float64(x + y)); elseif (x <= 2.8e-147) tmp = Float64(abs(Float64(y - x)) * 0.5); else tmp = Float64(x + Float64(0.5 * Float64(x - y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5.5e-72) tmp = 0.5 * (x + y); elseif (x <= 2.8e-147) tmp = abs((y - x)) * 0.5; else tmp = x + (0.5 * (x - y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5.5e-72], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.8e-147], N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision], N[(x + N[(0.5 * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{-72}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-147}:\\
\;\;\;\;\left|y - x\right| \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x + 0.5 \cdot \left(x - y\right)\\
\end{array}
\end{array}
if x < -5.49999999999999994e-72Initial program 100.0%
+-commutative100.0%
div-inv100.0%
fma-def100.0%
add-sqr-sqrt86.0%
fabs-sqr86.0%
add-sqr-sqrt86.8%
metadata-eval86.8%
Applied egg-rr86.8%
Taylor expanded in y around 0 86.8%
+-commutative86.8%
associate-+r+86.8%
distribute-lft1-in86.8%
metadata-eval86.8%
distribute-lft-out86.8%
Simplified86.8%
if -5.49999999999999994e-72 < x < 2.8e-147Initial program 100.0%
Taylor expanded in x around 0 87.6%
if 2.8e-147 < x Initial program 99.8%
add-sqr-sqrt99.2%
pow299.2%
+-commutative99.2%
div-inv99.2%
fma-def99.2%
add-sqr-sqrt16.6%
fabs-sqr16.6%
add-sqr-sqrt28.2%
metadata-eval28.2%
Applied egg-rr28.2%
unpow228.2%
add-sqr-sqrt28.4%
fma-udef28.4%
add-sqr-sqrt16.5%
sqrt-prod16.5%
associate-*r*16.5%
fma-def16.5%
pow1/216.5%
pow1/216.5%
pow-prod-down61.4%
Applied egg-rr61.4%
unpow1/261.4%
associate-*l*61.4%
Simplified61.4%
Taylor expanded in y around -inf 83.0%
+-commutative83.0%
mul-1-neg83.0%
unsub-neg83.0%
distribute-lft-out--83.0%
Simplified83.0%
fma-udef82.9%
*-commutative82.9%
associate-*l*82.7%
add-sqr-sqrt83.3%
Applied egg-rr83.3%
Final simplification85.8%
(FPCore (x y) :precision binary64 (if (<= x -6.2e-73) (* 0.5 (+ x y)) (if (<= x 4.3e-147) (* (fabs (- y x)) 0.5) (fma 1.5 x (* y -0.5)))))
double code(double x, double y) {
double tmp;
if (x <= -6.2e-73) {
tmp = 0.5 * (x + y);
} else if (x <= 4.3e-147) {
tmp = fabs((y - x)) * 0.5;
} else {
tmp = fma(1.5, x, (y * -0.5));
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -6.2e-73) tmp = Float64(0.5 * Float64(x + y)); elseif (x <= 4.3e-147) tmp = Float64(abs(Float64(y - x)) * 0.5); else tmp = fma(1.5, x, Float64(y * -0.5)); end return tmp end
code[x_, y_] := If[LessEqual[x, -6.2e-73], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.3e-147], N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision], N[(1.5 * x + N[(y * -0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.2 \cdot 10^{-73}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\mathbf{elif}\;x \leq 4.3 \cdot 10^{-147}:\\
\;\;\;\;\left|y - x\right| \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1.5, x, y \cdot -0.5\right)\\
\end{array}
\end{array}
if x < -6.19999999999999938e-73Initial program 100.0%
+-commutative100.0%
div-inv100.0%
fma-def100.0%
add-sqr-sqrt86.0%
fabs-sqr86.0%
add-sqr-sqrt86.8%
metadata-eval86.8%
Applied egg-rr86.8%
Taylor expanded in y around 0 86.8%
+-commutative86.8%
associate-+r+86.8%
distribute-lft1-in86.8%
metadata-eval86.8%
distribute-lft-out86.8%
Simplified86.8%
if -6.19999999999999938e-73 < x < 4.3000000000000001e-147Initial program 100.0%
Taylor expanded in x around 0 87.6%
if 4.3000000000000001e-147 < x Initial program 99.8%
add-sqr-sqrt99.2%
pow299.2%
+-commutative99.2%
div-inv99.2%
fma-def99.2%
add-sqr-sqrt16.6%
fabs-sqr16.6%
add-sqr-sqrt28.2%
metadata-eval28.2%
Applied egg-rr28.2%
unpow228.2%
add-sqr-sqrt28.4%
fma-udef28.4%
add-sqr-sqrt16.5%
sqrt-prod16.5%
associate-*r*16.5%
fma-def16.5%
pow1/216.5%
pow1/216.5%
pow-prod-down61.4%
Applied egg-rr61.4%
unpow1/261.4%
associate-*l*61.4%
Simplified61.4%
Taylor expanded in y around -inf 82.7%
+-commutative82.7%
associate-+l+82.7%
mul-1-neg82.7%
*-commutative82.7%
unpow282.7%
rem-square-sqrt83.1%
distribute-rgt-neg-in83.1%
fma-def83.1%
metadata-eval83.1%
unpow283.1%
rem-square-sqrt83.3%
distribute-rgt1-in83.3%
metadata-eval83.3%
Simplified83.3%
Taylor expanded in y around 0 83.3%
+-commutative83.3%
*-commutative83.3%
fma-def83.5%
*-commutative83.5%
Simplified83.5%
Final simplification85.9%
(FPCore (x y)
:precision binary64
(if (<= x -8.5e-72)
(* x 0.5)
(if (<= x -2.7e-237)
(* y -0.5)
(if (<= x 8.5e-268)
(* y 0.5)
(if (<= x 3.2e-114) (* y -0.5) (* x 1.5))))))
double code(double x, double y) {
double tmp;
if (x <= -8.5e-72) {
tmp = x * 0.5;
} else if (x <= -2.7e-237) {
tmp = y * -0.5;
} else if (x <= 8.5e-268) {
tmp = y * 0.5;
} else if (x <= 3.2e-114) {
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 <= (-8.5d-72)) then
tmp = x * 0.5d0
else if (x <= (-2.7d-237)) then
tmp = y * (-0.5d0)
else if (x <= 8.5d-268) then
tmp = y * 0.5d0
else if (x <= 3.2d-114) 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 <= -8.5e-72) {
tmp = x * 0.5;
} else if (x <= -2.7e-237) {
tmp = y * -0.5;
} else if (x <= 8.5e-268) {
tmp = y * 0.5;
} else if (x <= 3.2e-114) {
tmp = y * -0.5;
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -8.5e-72: tmp = x * 0.5 elif x <= -2.7e-237: tmp = y * -0.5 elif x <= 8.5e-268: tmp = y * 0.5 elif x <= 3.2e-114: tmp = y * -0.5 else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -8.5e-72) tmp = Float64(x * 0.5); elseif (x <= -2.7e-237) tmp = Float64(y * -0.5); elseif (x <= 8.5e-268) tmp = Float64(y * 0.5); elseif (x <= 3.2e-114) 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 <= -8.5e-72) tmp = x * 0.5; elseif (x <= -2.7e-237) tmp = y * -0.5; elseif (x <= 8.5e-268) tmp = y * 0.5; elseif (x <= 3.2e-114) tmp = y * -0.5; else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -8.5e-72], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, -2.7e-237], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 8.5e-268], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, 3.2e-114], N[(y * -0.5), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{-72}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq -2.7 \cdot 10^{-237}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{-268}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-114}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -8.50000000000000008e-72Initial program 100.0%
+-commutative100.0%
div-inv100.0%
fma-def100.0%
add-sqr-sqrt86.0%
fabs-sqr86.0%
add-sqr-sqrt86.8%
metadata-eval86.8%
Applied egg-rr86.8%
Taylor expanded in y around 0 68.1%
distribute-lft1-in68.1%
metadata-eval68.1%
*-commutative68.1%
Simplified68.1%
if -8.50000000000000008e-72 < x < -2.69999999999999984e-237 or 8.50000000000000052e-268 < x < 3.2000000000000002e-114Initial program 100.0%
add-sqr-sqrt87.5%
pow287.5%
+-commutative87.5%
div-inv87.5%
fma-def87.5%
add-sqr-sqrt29.1%
fabs-sqr29.1%
add-sqr-sqrt30.5%
metadata-eval30.5%
Applied egg-rr30.5%
unpow230.5%
add-sqr-sqrt43.1%
fma-udef43.1%
add-sqr-sqrt40.8%
sqrt-prod40.8%
associate-*r*40.9%
fma-def40.9%
pow1/240.9%
pow1/240.9%
pow-prod-down63.6%
Applied egg-rr63.6%
unpow1/263.6%
associate-*l*63.6%
Simplified63.6%
Taylor expanded in y around -inf 51.9%
associate-*r*51.9%
*-commutative51.9%
unpow251.9%
rem-square-sqrt52.9%
metadata-eval52.9%
Simplified52.9%
if -2.69999999999999984e-237 < x < 8.50000000000000052e-268Initial program 99.9%
+-commutative99.9%
div-inv99.9%
fma-def99.9%
add-sqr-sqrt57.9%
fabs-sqr57.9%
add-sqr-sqrt59.9%
metadata-eval59.9%
Applied egg-rr59.9%
Taylor expanded in y around inf 59.4%
if 3.2000000000000002e-114 < x Initial program 99.8%
add-sqr-sqrt99.2%
pow299.2%
+-commutative99.2%
div-inv99.2%
fma-def99.2%
add-sqr-sqrt16.0%
fabs-sqr16.0%
add-sqr-sqrt28.2%
metadata-eval28.2%
Applied egg-rr28.2%
unpow228.2%
add-sqr-sqrt28.4%
fma-udef28.4%
add-sqr-sqrt15.9%
sqrt-prod15.9%
associate-*r*15.9%
fma-def15.9%
pow1/215.9%
pow1/215.9%
pow-prod-down58.3%
Applied egg-rr58.3%
unpow1/258.3%
associate-*l*58.3%
Simplified58.3%
Taylor expanded in y around -inf 83.4%
+-commutative83.4%
associate-+l+83.3%
mul-1-neg83.3%
*-commutative83.3%
unpow283.3%
rem-square-sqrt83.6%
distribute-rgt-neg-in83.6%
fma-def83.6%
metadata-eval83.6%
unpow283.6%
rem-square-sqrt83.9%
distribute-rgt1-in83.9%
metadata-eval83.9%
Simplified83.9%
Taylor expanded in y around 0 68.0%
Final simplification63.2%
(FPCore (x y)
:precision binary64
(if (<= y -7e+25)
(* y -0.5)
(if (<= y -1.6e-35)
(* x 0.5)
(if (<= y -1.55e-89) (* y -0.5) (* 0.5 (+ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -7e+25) {
tmp = y * -0.5;
} else if (y <= -1.6e-35) {
tmp = x * 0.5;
} else if (y <= -1.55e-89) {
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 <= (-7d+25)) then
tmp = y * (-0.5d0)
else if (y <= (-1.6d-35)) then
tmp = x * 0.5d0
else if (y <= (-1.55d-89)) 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 <= -7e+25) {
tmp = y * -0.5;
} else if (y <= -1.6e-35) {
tmp = x * 0.5;
} else if (y <= -1.55e-89) {
tmp = y * -0.5;
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -7e+25: tmp = y * -0.5 elif y <= -1.6e-35: tmp = x * 0.5 elif y <= -1.55e-89: tmp = y * -0.5 else: tmp = 0.5 * (x + y) return tmp
function code(x, y) tmp = 0.0 if (y <= -7e+25) tmp = Float64(y * -0.5); elseif (y <= -1.6e-35) tmp = Float64(x * 0.5); elseif (y <= -1.55e-89) 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 <= -7e+25) tmp = y * -0.5; elseif (y <= -1.6e-35) tmp = x * 0.5; elseif (y <= -1.55e-89) tmp = y * -0.5; else tmp = 0.5 * (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -7e+25], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, -1.6e-35], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, -1.55e-89], N[(y * -0.5), $MachinePrecision], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+25}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq -1.6 \cdot 10^{-35}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;y \leq -1.55 \cdot 10^{-89}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < -6.99999999999999999e25 or -1.5999999999999999e-35 < y < -1.54999999999999998e-89Initial program 100.0%
add-sqr-sqrt89.8%
pow289.8%
+-commutative89.8%
div-inv89.8%
fma-def89.8%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt2.4%
metadata-eval2.4%
Applied egg-rr2.4%
unpow22.4%
add-sqr-sqrt12.5%
fma-udef12.5%
add-sqr-sqrt9.4%
sqrt-prod9.4%
associate-*r*9.4%
fma-def9.4%
pow1/29.4%
pow1/29.4%
pow-prod-down61.8%
Applied egg-rr61.8%
unpow1/261.8%
associate-*l*61.8%
Simplified61.8%
Taylor expanded in y around -inf 74.7%
associate-*r*74.7%
*-commutative74.7%
unpow274.7%
rem-square-sqrt76.2%
metadata-eval76.2%
Simplified76.2%
if -6.99999999999999999e25 < y < -1.5999999999999999e-35Initial program 99.9%
+-commutative99.9%
div-inv99.9%
fma-def99.9%
add-sqr-sqrt52.1%
fabs-sqr52.1%
add-sqr-sqrt58.5%
metadata-eval58.5%
Applied egg-rr58.5%
Taylor expanded in y around 0 59.1%
distribute-lft1-in59.1%
metadata-eval59.1%
*-commutative59.1%
Simplified59.1%
if -1.54999999999999998e-89 < y Initial program 99.9%
+-commutative99.9%
div-inv99.9%
fma-def99.9%
add-sqr-sqrt67.0%
fabs-sqr67.0%
add-sqr-sqrt72.6%
metadata-eval72.6%
Applied egg-rr72.6%
Taylor expanded in y around 0 72.6%
+-commutative72.6%
associate-+r+72.6%
distribute-lft1-in72.6%
metadata-eval72.6%
distribute-lft-out72.6%
Simplified72.6%
Final simplification72.7%
(FPCore (x y) :precision binary64 (if (<= y 1.4e-282) (+ x (* 0.5 (- x y))) (* 0.5 (+ x y))))
double code(double x, double y) {
double tmp;
if (y <= 1.4e-282) {
tmp = x + (0.5 * (x - y));
} 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.4d-282) then
tmp = x + (0.5d0 * (x - y))
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.4e-282) {
tmp = x + (0.5 * (x - y));
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.4e-282: tmp = x + (0.5 * (x - y)) else: tmp = 0.5 * (x + y) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.4e-282) tmp = Float64(x + Float64(0.5 * Float64(x - y))); else tmp = Float64(0.5 * Float64(x + y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.4e-282) tmp = x + (0.5 * (x - y)); else tmp = 0.5 * (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.4e-282], N[(x + N[(0.5 * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.4 \cdot 10^{-282}:\\
\;\;\;\;x + 0.5 \cdot \left(x - y\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < 1.3999999999999999e-282Initial program 99.9%
add-sqr-sqrt72.9%
pow272.9%
+-commutative72.9%
div-inv72.9%
fma-def72.9%
add-sqr-sqrt0.0%
fabs-sqr0.0%
add-sqr-sqrt4.6%
metadata-eval4.6%
Applied egg-rr4.6%
unpow24.6%
add-sqr-sqrt31.5%
fma-udef31.5%
add-sqr-sqrt26.2%
sqrt-prod26.2%
associate-*r*26.2%
fma-def26.2%
pow1/226.2%
pow1/226.2%
pow-prod-down61.4%
Applied egg-rr61.4%
unpow1/261.4%
associate-*l*61.4%
Simplified61.4%
Taylor expanded in y around -inf 77.5%
+-commutative77.5%
mul-1-neg77.5%
unsub-neg77.5%
distribute-lft-out--77.5%
Simplified77.5%
fma-udef77.5%
*-commutative77.5%
associate-*l*77.2%
add-sqr-sqrt78.2%
Applied egg-rr78.2%
if 1.3999999999999999e-282 < y Initial program 100.0%
+-commutative100.0%
div-inv100.0%
fma-def100.0%
add-sqr-sqrt77.1%
fabs-sqr77.1%
add-sqr-sqrt81.5%
metadata-eval81.5%
Applied egg-rr81.5%
Taylor expanded in y around 0 81.5%
+-commutative81.5%
associate-+r+81.6%
distribute-lft1-in81.6%
metadata-eval81.6%
distribute-lft-out81.6%
Simplified81.6%
Final simplification79.7%
(FPCore (x y) :precision binary64 (if (<= x -3e-106) (* x 0.5) (if (<= x 3.3e-120) (* y 0.5) (* x 1.5))))
double code(double x, double y) {
double tmp;
if (x <= -3e-106) {
tmp = x * 0.5;
} else if (x <= 3.3e-120) {
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 <= (-3d-106)) then
tmp = x * 0.5d0
else if (x <= 3.3d-120) 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 <= -3e-106) {
tmp = x * 0.5;
} else if (x <= 3.3e-120) {
tmp = y * 0.5;
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3e-106: tmp = x * 0.5 elif x <= 3.3e-120: tmp = y * 0.5 else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -3e-106) tmp = Float64(x * 0.5); elseif (x <= 3.3e-120) 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 <= -3e-106) tmp = x * 0.5; elseif (x <= 3.3e-120) tmp = y * 0.5; else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3e-106], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 3.3e-120], N[(y * 0.5), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3 \cdot 10^{-106}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{-120}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -3.00000000000000019e-106Initial program 100.0%
+-commutative100.0%
div-inv100.0%
fma-def100.0%
add-sqr-sqrt82.8%
fabs-sqr82.8%
add-sqr-sqrt83.6%
metadata-eval83.6%
Applied egg-rr83.6%
Taylor expanded in y around 0 64.6%
distribute-lft1-in64.6%
metadata-eval64.6%
*-commutative64.6%
Simplified64.6%
if -3.00000000000000019e-106 < x < 3.29999999999999967e-120Initial program 100.0%
+-commutative100.0%
div-inv100.0%
fma-def100.0%
add-sqr-sqrt45.5%
fabs-sqr45.5%
add-sqr-sqrt47.7%
metadata-eval47.7%
Applied egg-rr47.7%
Taylor expanded in y around inf 41.3%
if 3.29999999999999967e-120 < x Initial program 99.8%
add-sqr-sqrt99.2%
pow299.2%
+-commutative99.2%
div-inv99.2%
fma-def99.2%
add-sqr-sqrt15.8%
fabs-sqr15.8%
add-sqr-sqrt27.9%
metadata-eval27.9%
Applied egg-rr27.9%
unpow227.9%
add-sqr-sqrt28.1%
fma-udef28.1%
add-sqr-sqrt15.7%
sqrt-prod15.7%
associate-*r*15.7%
fma-def15.7%
pow1/215.7%
pow1/215.7%
pow-prod-down58.8%
Applied egg-rr58.8%
unpow1/258.8%
associate-*l*58.8%
Simplified58.8%
Taylor expanded in y around -inf 83.5%
+-commutative83.5%
associate-+l+83.5%
mul-1-neg83.5%
*-commutative83.5%
unpow283.5%
rem-square-sqrt83.8%
distribute-rgt-neg-in83.8%
fma-def83.8%
metadata-eval83.8%
unpow283.8%
rem-square-sqrt84.1%
distribute-rgt1-in84.1%
metadata-eval84.1%
Simplified84.1%
Taylor expanded in y around 0 67.3%
Final simplification57.9%
(FPCore (x y) :precision binary64 (if (<= y 1.3e-199) x (* y 0.5)))
double code(double x, double y) {
double tmp;
if (y <= 1.3e-199) {
tmp = x;
} 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.3d-199) then
tmp = x
else
tmp = y * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.3e-199) {
tmp = x;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.3e-199: tmp = x else: tmp = y * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= 1.3e-199) tmp = x; else tmp = Float64(y * 0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.3e-199) tmp = x; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.3e-199], x, N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.3 \cdot 10^{-199}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < 1.3e-199Initial program 99.9%
Taylor expanded in x around inf 12.3%
if 1.3e-199 < y Initial program 100.0%
+-commutative100.0%
div-inv100.0%
fma-def100.0%
add-sqr-sqrt78.5%
fabs-sqr78.5%
add-sqr-sqrt82.7%
metadata-eval82.7%
Applied egg-rr82.7%
Taylor expanded in y around inf 60.5%
Final simplification31.1%
(FPCore (x y) :precision binary64 (if (<= y 2.1e-92) (* x 1.5) (* y 0.5)))
double code(double x, double y) {
double tmp;
if (y <= 2.1e-92) {
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 <= 2.1d-92) 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 <= 2.1e-92) {
tmp = x * 1.5;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.1e-92: tmp = x * 1.5 else: tmp = y * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= 2.1e-92) 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 <= 2.1e-92) tmp = x * 1.5; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.1e-92], N[(x * 1.5), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.1 \cdot 10^{-92}:\\
\;\;\;\;x \cdot 1.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < 2.1e-92Initial program 99.9%
add-sqr-sqrt69.9%
pow269.9%
+-commutative69.9%
div-inv69.9%
fma-def69.9%
add-sqr-sqrt2.3%
fabs-sqr2.3%
add-sqr-sqrt7.5%
metadata-eval7.5%
Applied egg-rr7.5%
unpow27.5%
add-sqr-sqrt37.5%
fma-udef37.5%
add-sqr-sqrt31.6%
sqrt-prod31.5%
associate-*r*31.5%
fma-def31.5%
pow1/231.5%
pow1/231.5%
pow-prod-down61.7%
Applied egg-rr61.7%
unpow1/261.7%
associate-*l*61.7%
Simplified61.7%
Taylor expanded in y around -inf 72.6%
+-commutative72.6%
associate-+l+72.6%
mul-1-neg72.6%
*-commutative72.6%
unpow272.6%
rem-square-sqrt73.3%
distribute-rgt-neg-in73.3%
fma-def73.3%
metadata-eval73.3%
unpow273.3%
rem-square-sqrt73.4%
distribute-rgt1-in73.4%
metadata-eval73.4%
Simplified73.4%
Taylor expanded in y around 0 34.0%
if 2.1e-92 < y Initial program 100.0%
+-commutative100.0%
div-inv100.0%
fma-def100.0%
add-sqr-sqrt86.2%
fabs-sqr86.2%
add-sqr-sqrt89.1%
metadata-eval89.1%
Applied egg-rr89.1%
Taylor expanded in y around inf 68.5%
Final simplification45.2%
(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.2%
Final simplification11.2%
herbie shell --seed 2023257
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
:precision binary64
(+ x (/ (fabs (- y x)) 2.0)))