
(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 (- 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%
(FPCore (x y) :precision binary64 (if (<= x -5.5e-27) (* 0.5 (+ x y)) (if (<= x 2.6e+47) (+ x (/ (fabs y) 2.0)) (+ x (/ (- x y) 2.0)))))
double code(double x, double y) {
double tmp;
if (x <= -5.5e-27) {
tmp = 0.5 * (x + y);
} else if (x <= 2.6e+47) {
tmp = x + (fabs(y) / 2.0);
} else {
tmp = x + ((x - y) / 2.0);
}
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-27)) then
tmp = 0.5d0 * (x + y)
else if (x <= 2.6d+47) then
tmp = x + (abs(y) / 2.0d0)
else
tmp = x + ((x - y) / 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -5.5e-27) {
tmp = 0.5 * (x + y);
} else if (x <= 2.6e+47) {
tmp = x + (Math.abs(y) / 2.0);
} else {
tmp = x + ((x - y) / 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5.5e-27: tmp = 0.5 * (x + y) elif x <= 2.6e+47: tmp = x + (math.fabs(y) / 2.0) else: tmp = x + ((x - y) / 2.0) return tmp
function code(x, y) tmp = 0.0 if (x <= -5.5e-27) tmp = Float64(0.5 * Float64(x + y)); elseif (x <= 2.6e+47) tmp = Float64(x + Float64(abs(y) / 2.0)); else tmp = Float64(x + Float64(Float64(x - y) / 2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5.5e-27) tmp = 0.5 * (x + y); elseif (x <= 2.6e+47) tmp = x + (abs(y) / 2.0); else tmp = x + ((x - y) / 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5.5e-27], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.6e+47], N[(x + N[(N[Abs[y], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(x - y), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{-27}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{+47}:\\
\;\;\;\;x + \frac{\left|y\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{x - y}{2}\\
\end{array}
\end{array}
if x < -5.5000000000000002e-27Initial program 100.0%
clear-num99.8%
inv-pow99.8%
add-sqr-sqrt90.7%
fabs-sqr90.7%
add-sqr-sqrt91.2%
Applied egg-rr91.2%
Taylor expanded in x around 0 91.4%
distribute-lft-out91.4%
+-commutative91.4%
Simplified91.4%
if -5.5000000000000002e-27 < x < 2.60000000000000003e47Initial program 99.9%
Taylor expanded in y around inf 80.1%
if 2.60000000000000003e47 < x Initial program 99.9%
clear-num99.8%
inv-pow99.8%
add-sqr-sqrt5.6%
fabs-sqr5.6%
add-sqr-sqrt20.7%
Applied egg-rr20.7%
add-sqr-sqrt5.6%
fabs-sqr5.6%
add-sqr-sqrt99.8%
fabs-sub99.8%
Applied egg-rr99.8%
unpow-199.8%
clear-num99.8%
remove-double-div99.9%
add-sqr-sqrt94.0%
fabs-sqr94.0%
add-sqr-sqrt94.2%
Applied egg-rr94.2%
Final simplification86.1%
(FPCore (x y) :precision binary64 (if (<= x -2.7e-27) (* 0.5 (+ x y)) (if (<= x 1e-215) (* 0.5 (fabs y)) (+ x (/ (- x y) 2.0)))))
double code(double x, double y) {
double tmp;
if (x <= -2.7e-27) {
tmp = 0.5 * (x + y);
} else if (x <= 1e-215) {
tmp = 0.5 * fabs(y);
} else {
tmp = x + ((x - y) / 2.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-2.7d-27)) then
tmp = 0.5d0 * (x + y)
else if (x <= 1d-215) then
tmp = 0.5d0 * abs(y)
else
tmp = x + ((x - y) / 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -2.7e-27) {
tmp = 0.5 * (x + y);
} else if (x <= 1e-215) {
tmp = 0.5 * Math.abs(y);
} else {
tmp = x + ((x - y) / 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.7e-27: tmp = 0.5 * (x + y) elif x <= 1e-215: tmp = 0.5 * math.fabs(y) else: tmp = x + ((x - y) / 2.0) return tmp
function code(x, y) tmp = 0.0 if (x <= -2.7e-27) tmp = Float64(0.5 * Float64(x + y)); elseif (x <= 1e-215) tmp = Float64(0.5 * abs(y)); else tmp = Float64(x + Float64(Float64(x - y) / 2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.7e-27) tmp = 0.5 * (x + y); elseif (x <= 1e-215) tmp = 0.5 * abs(y); else tmp = x + ((x - y) / 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.7e-27], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1e-215], N[(0.5 * N[Abs[y], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(x - y), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{-27}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\mathbf{elif}\;x \leq 10^{-215}:\\
\;\;\;\;0.5 \cdot \left|y\right|\\
\mathbf{else}:\\
\;\;\;\;x + \frac{x - y}{2}\\
\end{array}
\end{array}
if x < -2.69999999999999989e-27Initial program 100.0%
clear-num99.8%
inv-pow99.8%
add-sqr-sqrt90.7%
fabs-sqr90.7%
add-sqr-sqrt91.2%
Applied egg-rr91.2%
Taylor expanded in x around 0 91.4%
distribute-lft-out91.4%
+-commutative91.4%
Simplified91.4%
if -2.69999999999999989e-27 < x < 1.00000000000000004e-215Initial program 100.0%
Taylor expanded in y around inf 86.3%
Taylor expanded in x around 0 84.3%
if 1.00000000000000004e-215 < x Initial program 99.8%
clear-num99.7%
inv-pow99.7%
add-sqr-sqrt18.1%
fabs-sqr18.1%
add-sqr-sqrt29.1%
Applied egg-rr29.1%
add-sqr-sqrt18.1%
fabs-sqr18.1%
add-sqr-sqrt99.7%
fabs-sub99.7%
Applied egg-rr99.7%
unpow-199.7%
clear-num99.7%
remove-double-div99.8%
add-sqr-sqrt81.4%
fabs-sqr81.4%
add-sqr-sqrt81.8%
Applied egg-rr81.8%
Final simplification85.2%
(FPCore (x y) :precision binary64 (if (<= x -230.0) (* x 0.5) (if (<= x -8e-247) (* y 0.5) (if (<= x 5.8e-179) (/ y -2.0) (* x 1.5)))))
double code(double x, double y) {
double tmp;
if (x <= -230.0) {
tmp = x * 0.5;
} else if (x <= -8e-247) {
tmp = y * 0.5;
} else if (x <= 5.8e-179) {
tmp = y / -2.0;
} 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 <= (-230.0d0)) then
tmp = x * 0.5d0
else if (x <= (-8d-247)) then
tmp = y * 0.5d0
else if (x <= 5.8d-179) then
tmp = y / (-2.0d0)
else
tmp = x * 1.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -230.0) {
tmp = x * 0.5;
} else if (x <= -8e-247) {
tmp = y * 0.5;
} else if (x <= 5.8e-179) {
tmp = y / -2.0;
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -230.0: tmp = x * 0.5 elif x <= -8e-247: tmp = y * 0.5 elif x <= 5.8e-179: tmp = y / -2.0 else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -230.0) tmp = Float64(x * 0.5); elseif (x <= -8e-247) tmp = Float64(y * 0.5); elseif (x <= 5.8e-179) tmp = Float64(y / -2.0); else tmp = Float64(x * 1.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -230.0) tmp = x * 0.5; elseif (x <= -8e-247) tmp = y * 0.5; elseif (x <= 5.8e-179) tmp = y / -2.0; else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -230.0], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, -8e-247], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, 5.8e-179], N[(y / -2.0), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -230:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq -8 \cdot 10^{-247}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{-179}:\\
\;\;\;\;\frac{y}{-2}\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -230Initial program 100.0%
clear-num99.8%
inv-pow99.8%
add-sqr-sqrt90.0%
fabs-sqr90.0%
add-sqr-sqrt90.5%
Applied egg-rr90.5%
Taylor expanded in x around inf 75.8%
if -230 < x < -8.0000000000000002e-247Initial program 100.0%
Taylor expanded in y around inf 81.5%
Taylor expanded in x around 0 78.5%
rem-square-sqrt46.7%
fabs-sqr46.7%
rem-square-sqrt47.9%
Simplified47.9%
if -8.0000000000000002e-247 < x < 5.7999999999999998e-179Initial program 99.9%
Taylor expanded in y around inf 88.1%
Taylor expanded in x around 0 86.5%
rem-square-sqrt29.7%
fabs-sqr29.7%
rem-square-sqrt31.5%
Simplified31.5%
*-commutative31.5%
metadata-eval31.5%
div-inv31.5%
frac-2neg31.5%
add-sqr-sqrt1.5%
sqrt-unprod2.9%
sqr-neg2.9%
sqrt-unprod1.2%
add-sqr-sqrt57.7%
metadata-eval57.7%
Applied egg-rr57.7%
if 5.7999999999999998e-179 < x Initial program 99.9%
clear-num99.7%
inv-pow99.7%
add-sqr-sqrt18.7%
fabs-sqr18.7%
add-sqr-sqrt30.1%
Applied egg-rr30.1%
add-sqr-sqrt18.7%
fabs-sqr18.7%
add-sqr-sqrt99.7%
fabs-sub99.7%
Applied egg-rr99.7%
unpow-199.7%
clear-num99.7%
remove-double-div99.9%
add-sqr-sqrt80.7%
fabs-sqr80.7%
add-sqr-sqrt81.1%
Applied egg-rr81.1%
Taylor expanded in x around inf 63.7%
*-commutative63.7%
Simplified63.7%
Final simplification62.8%
(FPCore (x y) :precision binary64 (if (<= y -5.2e-232) (- x (/ y 2.0)) (if (<= y 1.5e-231) (+ x (/ 1.0 (/ 2.0 x))) (* 0.5 (+ x y)))))
double code(double x, double y) {
double tmp;
if (y <= -5.2e-232) {
tmp = x - (y / 2.0);
} else if (y <= 1.5e-231) {
tmp = x + (1.0 / (2.0 / x));
} 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 <= (-5.2d-232)) then
tmp = x - (y / 2.0d0)
else if (y <= 1.5d-231) then
tmp = x + (1.0d0 / (2.0d0 / x))
else
tmp = 0.5d0 * (x + y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -5.2e-232) {
tmp = x - (y / 2.0);
} else if (y <= 1.5e-231) {
tmp = x + (1.0 / (2.0 / x));
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5.2e-232: tmp = x - (y / 2.0) elif y <= 1.5e-231: tmp = x + (1.0 / (2.0 / x)) else: tmp = 0.5 * (x + y) return tmp
function code(x, y) tmp = 0.0 if (y <= -5.2e-232) tmp = Float64(x - Float64(y / 2.0)); elseif (y <= 1.5e-231) tmp = Float64(x + Float64(1.0 / Float64(2.0 / x))); else tmp = Float64(0.5 * Float64(x + y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -5.2e-232) tmp = x - (y / 2.0); elseif (y <= 1.5e-231) tmp = x + (1.0 / (2.0 / x)); else tmp = 0.5 * (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5.2e-232], N[(x - N[(y / 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.5e-231], N[(x + N[(1.0 / N[(2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{-232}:\\
\;\;\;\;x - \frac{y}{2}\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{-231}:\\
\;\;\;\;x + \frac{1}{\frac{2}{x}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < -5.19999999999999992e-232Initial program 100.0%
clear-num99.7%
inv-pow99.7%
add-sqr-sqrt21.7%
fabs-sqr21.7%
add-sqr-sqrt26.3%
Applied egg-rr26.3%
add-sqr-sqrt21.7%
fabs-sqr21.7%
add-sqr-sqrt99.7%
fabs-sub99.7%
Applied egg-rr99.7%
unpow-199.7%
clear-num99.7%
remove-double-div100.0%
add-sqr-sqrt77.7%
fabs-sqr77.7%
add-sqr-sqrt82.0%
Applied egg-rr82.0%
Taylor expanded in x around 0 63.8%
neg-mul-163.8%
Simplified63.8%
if -5.19999999999999992e-232 < y < 1.5000000000000001e-231Initial program 99.7%
Taylor expanded in y around inf 68.5%
mul-1-neg68.5%
unsub-neg68.5%
Simplified68.5%
Taylor expanded in x around inf 60.6%
neg-mul-160.6%
distribute-neg-frac260.6%
Simplified60.6%
clear-num60.5%
inv-pow60.5%
add-sqr-sqrt22.1%
fabs-sqr22.1%
add-sqr-sqrt29.5%
clear-num29.5%
un-div-inv29.5%
add-sqr-sqrt18.5%
sqrt-unprod2.1%
sqr-neg2.1%
sqrt-unprod20.4%
add-sqr-sqrt43.3%
Applied egg-rr43.3%
unpow-143.3%
associate-/r/64.0%
*-inverses64.0%
*-lft-identity64.0%
Simplified64.0%
if 1.5000000000000001e-231 < y Initial program 99.9%
clear-num99.7%
inv-pow99.7%
add-sqr-sqrt79.9%
fabs-sqr79.9%
add-sqr-sqrt83.7%
Applied egg-rr83.7%
Taylor expanded in x around 0 84.0%
distribute-lft-out84.0%
+-commutative84.0%
Simplified84.0%
Final simplification72.3%
(FPCore (x y) :precision binary64 (if (<= y -1.15e-230) (- x (/ y 2.0)) (if (<= y 1.85e-230) (* x 1.5) (* 0.5 (+ x y)))))
double code(double x, double y) {
double tmp;
if (y <= -1.15e-230) {
tmp = x - (y / 2.0);
} else if (y <= 1.85e-230) {
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 <= (-1.15d-230)) then
tmp = x - (y / 2.0d0)
else if (y <= 1.85d-230) 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 <= -1.15e-230) {
tmp = x - (y / 2.0);
} else if (y <= 1.85e-230) {
tmp = x * 1.5;
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.15e-230: tmp = x - (y / 2.0) elif y <= 1.85e-230: tmp = x * 1.5 else: tmp = 0.5 * (x + y) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.15e-230) tmp = Float64(x - Float64(y / 2.0)); elseif (y <= 1.85e-230) 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 <= -1.15e-230) tmp = x - (y / 2.0); elseif (y <= 1.85e-230) tmp = x * 1.5; else tmp = 0.5 * (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.15e-230], N[(x - N[(y / 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.85e-230], N[(x * 1.5), $MachinePrecision], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{-230}:\\
\;\;\;\;x - \frac{y}{2}\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{-230}:\\
\;\;\;\;x \cdot 1.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < -1.1499999999999999e-230Initial program 100.0%
clear-num99.7%
inv-pow99.7%
add-sqr-sqrt21.7%
fabs-sqr21.7%
add-sqr-sqrt26.3%
Applied egg-rr26.3%
add-sqr-sqrt21.7%
fabs-sqr21.7%
add-sqr-sqrt99.7%
fabs-sub99.7%
Applied egg-rr99.7%
unpow-199.7%
clear-num99.7%
remove-double-div100.0%
add-sqr-sqrt77.7%
fabs-sqr77.7%
add-sqr-sqrt82.0%
Applied egg-rr82.0%
Taylor expanded in x around 0 63.8%
neg-mul-163.8%
Simplified63.8%
if -1.1499999999999999e-230 < y < 1.84999999999999991e-230Initial program 99.7%
clear-num99.5%
inv-pow99.5%
add-sqr-sqrt37.8%
fabs-sqr37.8%
add-sqr-sqrt48.6%
Applied egg-rr48.6%
add-sqr-sqrt37.8%
fabs-sqr37.8%
add-sqr-sqrt99.5%
fabs-sub99.5%
Applied egg-rr99.5%
unpow-199.5%
clear-num99.5%
remove-double-div99.7%
add-sqr-sqrt61.5%
fabs-sqr61.5%
add-sqr-sqrt67.9%
Applied egg-rr67.9%
Taylor expanded in x around inf 64.0%
*-commutative64.0%
Simplified64.0%
if 1.84999999999999991e-230 < y Initial program 99.9%
clear-num99.7%
inv-pow99.7%
add-sqr-sqrt79.9%
fabs-sqr79.9%
add-sqr-sqrt83.7%
Applied egg-rr83.7%
Taylor expanded in x around 0 84.0%
distribute-lft-out84.0%
+-commutative84.0%
Simplified84.0%
Final simplification72.3%
(FPCore (x y) :precision binary64 (if (<= x -1.28e-270) (* 0.5 (+ x y)) (if (<= x 9.8e-175) (/ y -2.0) (* x 1.5))))
double code(double x, double y) {
double tmp;
if (x <= -1.28e-270) {
tmp = 0.5 * (x + y);
} else if (x <= 9.8e-175) {
tmp = y / -2.0;
} 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.28d-270)) then
tmp = 0.5d0 * (x + y)
else if (x <= 9.8d-175) then
tmp = y / (-2.0d0)
else
tmp = x * 1.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.28e-270) {
tmp = 0.5 * (x + y);
} else if (x <= 9.8e-175) {
tmp = y / -2.0;
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.28e-270: tmp = 0.5 * (x + y) elif x <= 9.8e-175: tmp = y / -2.0 else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.28e-270) tmp = Float64(0.5 * Float64(x + y)); elseif (x <= 9.8e-175) tmp = Float64(y / -2.0); else tmp = Float64(x * 1.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.28e-270) tmp = 0.5 * (x + y); elseif (x <= 9.8e-175) tmp = y / -2.0; else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.28e-270], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 9.8e-175], N[(y / -2.0), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.28 \cdot 10^{-270}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\mathbf{elif}\;x \leq 9.8 \cdot 10^{-175}:\\
\;\;\;\;\frac{y}{-2}\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -1.27999999999999991e-270Initial program 100.0%
clear-num99.7%
inv-pow99.7%
add-sqr-sqrt79.2%
fabs-sqr79.2%
add-sqr-sqrt79.8%
Applied egg-rr79.8%
Taylor expanded in x around 0 80.1%
distribute-lft-out80.1%
+-commutative80.1%
Simplified80.1%
if -1.27999999999999991e-270 < x < 9.79999999999999996e-175Initial program 99.9%
Taylor expanded in y around inf 89.8%
Taylor expanded in x around 0 88.3%
rem-square-sqrt28.2%
fabs-sqr28.2%
rem-square-sqrt29.8%
Simplified29.8%
*-commutative29.8%
metadata-eval29.8%
div-inv29.8%
frac-2neg29.8%
add-sqr-sqrt1.5%
sqrt-unprod2.7%
sqr-neg2.7%
sqrt-unprod0.9%
add-sqr-sqrt60.9%
metadata-eval60.9%
Applied egg-rr60.9%
if 9.79999999999999996e-175 < x Initial program 99.9%
clear-num99.7%
inv-pow99.7%
add-sqr-sqrt18.7%
fabs-sqr18.7%
add-sqr-sqrt30.1%
Applied egg-rr30.1%
add-sqr-sqrt18.7%
fabs-sqr18.7%
add-sqr-sqrt99.7%
fabs-sub99.7%
Applied egg-rr99.7%
unpow-199.7%
clear-num99.7%
remove-double-div99.9%
add-sqr-sqrt80.7%
fabs-sqr80.7%
add-sqr-sqrt81.1%
Applied egg-rr81.1%
Taylor expanded in x around inf 63.7%
*-commutative63.7%
Simplified63.7%
Final simplification70.8%
(FPCore (x y) :precision binary64 (if (<= x -61.0) (* x 0.5) (if (<= x 6e-217) (* y 0.5) (* x 1.5))))
double code(double x, double y) {
double tmp;
if (x <= -61.0) {
tmp = x * 0.5;
} else if (x <= 6e-217) {
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 <= (-61.0d0)) then
tmp = x * 0.5d0
else if (x <= 6d-217) 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 <= -61.0) {
tmp = x * 0.5;
} else if (x <= 6e-217) {
tmp = y * 0.5;
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -61.0: tmp = x * 0.5 elif x <= 6e-217: tmp = y * 0.5 else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -61.0) tmp = Float64(x * 0.5); elseif (x <= 6e-217) 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 <= -61.0) tmp = x * 0.5; elseif (x <= 6e-217) tmp = y * 0.5; else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -61.0], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 6e-217], N[(y * 0.5), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -61:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 6 \cdot 10^{-217}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -61Initial program 100.0%
clear-num99.8%
inv-pow99.8%
add-sqr-sqrt90.0%
fabs-sqr90.0%
add-sqr-sqrt90.5%
Applied egg-rr90.5%
Taylor expanded in x around inf 75.8%
if -61 < x < 6.00000000000000009e-217Initial program 100.0%
Taylor expanded in y around inf 86.1%
Taylor expanded in x around 0 84.0%
rem-square-sqrt40.5%
fabs-sqr40.5%
rem-square-sqrt42.0%
Simplified42.0%
if 6.00000000000000009e-217 < x Initial program 99.8%
clear-num99.7%
inv-pow99.7%
add-sqr-sqrt18.1%
fabs-sqr18.1%
add-sqr-sqrt29.1%
Applied egg-rr29.1%
add-sqr-sqrt18.1%
fabs-sqr18.1%
add-sqr-sqrt99.7%
fabs-sub99.7%
Applied egg-rr99.7%
unpow-199.7%
clear-num99.7%
remove-double-div99.8%
add-sqr-sqrt81.4%
fabs-sqr81.4%
add-sqr-sqrt81.8%
Applied egg-rr81.8%
Taylor expanded in x around inf 61.3%
*-commutative61.3%
Simplified61.3%
Final simplification58.4%
(FPCore (x y) :precision binary64 (if (<= y 1.4e-230) (+ x (/ (- x y) 2.0)) (* 0.5 (+ x y))))
double code(double x, double y) {
double tmp;
if (y <= 1.4e-230) {
tmp = x + ((x - y) / 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 <= 1.4d-230) then
tmp = x + ((x - y) / 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 <= 1.4e-230) {
tmp = x + ((x - y) / 2.0);
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.4e-230: tmp = x + ((x - y) / 2.0) else: tmp = 0.5 * (x + y) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.4e-230) tmp = Float64(x + Float64(Float64(x - y) / 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 <= 1.4e-230) tmp = x + ((x - y) / 2.0); else tmp = 0.5 * (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.4e-230], N[(x + N[(N[(x - y), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.4 \cdot 10^{-230}:\\
\;\;\;\;x + \frac{x - y}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < 1.4e-230Initial program 99.9%
clear-num99.7%
inv-pow99.7%
add-sqr-sqrt25.4%
fabs-sqr25.4%
add-sqr-sqrt31.4%
Applied egg-rr31.4%
add-sqr-sqrt25.4%
fabs-sqr25.4%
add-sqr-sqrt99.7%
fabs-sub99.7%
Applied egg-rr99.7%
unpow-199.7%
clear-num99.7%
remove-double-div99.9%
add-sqr-sqrt74.0%
fabs-sqr74.0%
add-sqr-sqrt78.7%
Applied egg-rr78.7%
if 1.4e-230 < y Initial program 99.9%
clear-num99.7%
inv-pow99.7%
add-sqr-sqrt79.9%
fabs-sqr79.9%
add-sqr-sqrt83.7%
Applied egg-rr83.7%
Taylor expanded in x around 0 84.0%
distribute-lft-out84.0%
+-commutative84.0%
Simplified84.0%
Final simplification81.0%
(FPCore (x y) :precision binary64 (if (<= y 7.4e-90) (* x 0.5) (* y 0.5)))
double code(double x, double y) {
double tmp;
if (y <= 7.4e-90) {
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 <= 7.4d-90) 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 <= 7.4e-90) {
tmp = x * 0.5;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 7.4e-90: tmp = x * 0.5 else: tmp = y * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= 7.4e-90) 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 <= 7.4e-90) tmp = x * 0.5; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 7.4e-90], N[(x * 0.5), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.4 \cdot 10^{-90}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < 7.40000000000000035e-90Initial program 99.9%
clear-num99.7%
inv-pow99.7%
add-sqr-sqrt32.5%
fabs-sqr32.5%
add-sqr-sqrt38.3%
Applied egg-rr38.3%
Taylor expanded in x around inf 34.7%
if 7.40000000000000035e-90 < y Initial program 100.0%
Taylor expanded in y around inf 72.2%
Taylor expanded in x around 0 66.8%
rem-square-sqrt66.3%
fabs-sqr66.3%
rem-square-sqrt66.8%
Simplified66.8%
Final simplification45.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%
clear-num99.7%
inv-pow99.7%
add-sqr-sqrt48.4%
fabs-sqr48.4%
add-sqr-sqrt53.5%
Applied egg-rr53.5%
Taylor expanded in x around inf 29.6%
Final simplification29.6%
(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 2024146
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
:precision binary64
(+ x (/ (fabs (- y x)) 2.0)))