
(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%
(FPCore (x y) :precision binary64 (if (<= x -3.5e-97) (+ x (/ (- x y) -2.0)) (if (<= x 5.5e-90) (+ x (/ (fabs y) 2.0)) (+ x (/ (fabs x) 2.0)))))
double code(double x, double y) {
double tmp;
if (x <= -3.5e-97) {
tmp = x + ((x - y) / -2.0);
} else if (x <= 5.5e-90) {
tmp = x + (fabs(y) / 2.0);
} else {
tmp = x + (fabs(x) / 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 <= (-3.5d-97)) then
tmp = x + ((x - y) / (-2.0d0))
else if (x <= 5.5d-90) then
tmp = x + (abs(y) / 2.0d0)
else
tmp = x + (abs(x) / 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -3.5e-97) {
tmp = x + ((x - y) / -2.0);
} else if (x <= 5.5e-90) {
tmp = x + (Math.abs(y) / 2.0);
} else {
tmp = x + (Math.abs(x) / 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3.5e-97: tmp = x + ((x - y) / -2.0) elif x <= 5.5e-90: tmp = x + (math.fabs(y) / 2.0) else: tmp = x + (math.fabs(x) / 2.0) return tmp
function code(x, y) tmp = 0.0 if (x <= -3.5e-97) tmp = Float64(x + Float64(Float64(x - y) / -2.0)); elseif (x <= 5.5e-90) tmp = Float64(x + Float64(abs(y) / 2.0)); else tmp = Float64(x + Float64(abs(x) / 2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3.5e-97) tmp = x + ((x - y) / -2.0); elseif (x <= 5.5e-90) tmp = x + (abs(y) / 2.0); else tmp = x + (abs(x) / 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3.5e-97], N[(x + N[(N[(x - y), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.5e-90], N[(x + N[(N[Abs[y], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Abs[x], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{-97}:\\
\;\;\;\;x + \frac{x - y}{-2}\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-90}:\\
\;\;\;\;x + \frac{\left|y\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{\left|x\right|}{2}\\
\end{array}
\end{array}
if x < -3.50000000000000019e-97Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt92.0%
fabs-sqr92.0%
add-sqr-sqrt92.7%
frac-2neg92.7%
distribute-frac-neg92.7%
fmm-undef92.7%
*-un-lft-identity92.7%
metadata-eval92.7%
Applied egg-rr92.7%
if -3.50000000000000019e-97 < x < 5.5000000000000003e-90Initial program 100.0%
Taylor expanded in y around inf 88.0%
if 5.5000000000000003e-90 < x Initial program 99.7%
Taylor expanded in y around 0 82.4%
neg-mul-182.4%
Simplified82.4%
Taylor expanded in x around -inf 82.4%
neg-mul-182.4%
fabs-neg82.4%
Simplified82.4%
Final simplification87.8%
(FPCore (x y) :precision binary64 (if (<= x 9.5e-90) (+ x (/ (- x y) -2.0)) (+ x (/ (fabs x) 2.0))))
double code(double x, double y) {
double tmp;
if (x <= 9.5e-90) {
tmp = x + ((x - y) / -2.0);
} else {
tmp = x + (fabs(x) / 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 <= 9.5d-90) then
tmp = x + ((x - y) / (-2.0d0))
else
tmp = x + (abs(x) / 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 9.5e-90) {
tmp = x + ((x - y) / -2.0);
} else {
tmp = x + (Math.abs(x) / 2.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 9.5e-90: tmp = x + ((x - y) / -2.0) else: tmp = x + (math.fabs(x) / 2.0) return tmp
function code(x, y) tmp = 0.0 if (x <= 9.5e-90) tmp = Float64(x + Float64(Float64(x - y) / -2.0)); else tmp = Float64(x + Float64(abs(x) / 2.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 9.5e-90) tmp = x + ((x - y) / -2.0); else tmp = x + (abs(x) / 2.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 9.5e-90], N[(x + N[(N[(x - y), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Abs[x], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.5 \cdot 10^{-90}:\\
\;\;\;\;x + \frac{x - y}{-2}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{\left|x\right|}{2}\\
\end{array}
\end{array}
if x < 9.5000000000000003e-90Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt71.8%
fabs-sqr71.8%
add-sqr-sqrt73.5%
frac-2neg73.5%
distribute-frac-neg73.5%
fmm-undef73.5%
*-un-lft-identity73.5%
metadata-eval73.5%
Applied egg-rr73.5%
if 9.5000000000000003e-90 < x Initial program 99.7%
Taylor expanded in y around 0 82.4%
neg-mul-182.4%
Simplified82.4%
Taylor expanded in x around -inf 82.4%
neg-mul-182.4%
fabs-neg82.4%
Simplified82.4%
Final simplification76.2%
(FPCore (x y) :precision binary64 (if (<= x -3.7e-47) (* x 0.5) (if (<= x 1.3e-93) (* y (+ 0.5 (/ x y))) (* x 1.5))))
double code(double x, double y) {
double tmp;
if (x <= -3.7e-47) {
tmp = x * 0.5;
} else if (x <= 1.3e-93) {
tmp = y * (0.5 + (x / y));
} 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 <= (-3.7d-47)) then
tmp = x * 0.5d0
else if (x <= 1.3d-93) then
tmp = y * (0.5d0 + (x / y))
else
tmp = x * 1.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -3.7e-47) {
tmp = x * 0.5;
} else if (x <= 1.3e-93) {
tmp = y * (0.5 + (x / y));
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3.7e-47: tmp = x * 0.5 elif x <= 1.3e-93: tmp = y * (0.5 + (x / y)) else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -3.7e-47) tmp = Float64(x * 0.5); elseif (x <= 1.3e-93) tmp = Float64(y * Float64(0.5 + Float64(x / y))); else tmp = Float64(x * 1.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3.7e-47) tmp = x * 0.5; elseif (x <= 1.3e-93) tmp = y * (0.5 + (x / y)); else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3.7e-47], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.3e-93], N[(y * N[(0.5 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.7 \cdot 10^{-47}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{-93}:\\
\;\;\;\;y \cdot \left(0.5 + \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -3.7e-47Initial program 100.0%
Taylor expanded in y around 0 77.8%
neg-mul-177.8%
Simplified77.8%
Taylor expanded in x around -inf 77.8%
neg-mul-177.8%
rem-square-sqrt77.2%
fabs-sqr77.2%
rem-square-sqrt77.8%
Simplified77.8%
Taylor expanded in x around 0 77.8%
if -3.7e-47 < x < 1.2999999999999999e-93Initial program 99.9%
Taylor expanded in y around inf 86.2%
div-inv86.2%
add-sqr-sqrt50.1%
fabs-sqr50.1%
add-sqr-sqrt52.5%
metadata-eval52.5%
Applied egg-rr52.5%
Taylor expanded in y around inf 52.5%
if 1.2999999999999999e-93 < x Initial program 99.7%
Taylor expanded in y around 0 82.4%
neg-mul-182.4%
Simplified82.4%
clear-num82.4%
inv-pow82.4%
fabs-neg82.4%
Applied egg-rr82.4%
unpow-182.4%
Simplified82.4%
Taylor expanded in x around 0 82.4%
*-commutative82.4%
rem-square-sqrt82.3%
fabs-sqr82.3%
rem-square-sqrt82.4%
*-rgt-identity82.4%
distribute-lft-out82.4%
metadata-eval82.4%
Simplified82.4%
Final simplification69.1%
(FPCore (x y) :precision binary64 (if (<= x -1.26e-45) (* x 0.5) (if (<= x 1.45e-91) (+ x (* y 0.5)) (* x 1.5))))
double code(double x, double y) {
double tmp;
if (x <= -1.26e-45) {
tmp = x * 0.5;
} else if (x <= 1.45e-91) {
tmp = x + (y * 0.5);
} else {
tmp = x * 1.5;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.26d-45)) then
tmp = x * 0.5d0
else if (x <= 1.45d-91) then
tmp = x + (y * 0.5d0)
else
tmp = x * 1.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.26e-45) {
tmp = x * 0.5;
} else if (x <= 1.45e-91) {
tmp = x + (y * 0.5);
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.26e-45: tmp = x * 0.5 elif x <= 1.45e-91: tmp = x + (y * 0.5) else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.26e-45) tmp = Float64(x * 0.5); elseif (x <= 1.45e-91) tmp = Float64(x + 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.26e-45) tmp = x * 0.5; elseif (x <= 1.45e-91) tmp = x + (y * 0.5); else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.26e-45], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.45e-91], N[(x + N[(y * 0.5), $MachinePrecision]), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.26 \cdot 10^{-45}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-91}:\\
\;\;\;\;x + y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -1.26e-45Initial program 100.0%
Taylor expanded in y around 0 77.8%
neg-mul-177.8%
Simplified77.8%
Taylor expanded in x around -inf 77.8%
neg-mul-177.8%
rem-square-sqrt77.2%
fabs-sqr77.2%
rem-square-sqrt77.8%
Simplified77.8%
Taylor expanded in x around 0 77.8%
if -1.26e-45 < x < 1.45e-91Initial program 99.9%
Taylor expanded in y around inf 86.2%
div-inv86.2%
add-sqr-sqrt50.1%
fabs-sqr50.1%
add-sqr-sqrt52.5%
metadata-eval52.5%
Applied egg-rr52.5%
if 1.45e-91 < x Initial program 99.7%
Taylor expanded in y around 0 82.4%
neg-mul-182.4%
Simplified82.4%
clear-num82.4%
inv-pow82.4%
fabs-neg82.4%
Applied egg-rr82.4%
unpow-182.4%
Simplified82.4%
Taylor expanded in x around 0 82.4%
*-commutative82.4%
rem-square-sqrt82.3%
fabs-sqr82.3%
rem-square-sqrt82.4%
*-rgt-identity82.4%
distribute-lft-out82.4%
metadata-eval82.4%
Simplified82.4%
Final simplification69.1%
(FPCore (x y) :precision binary64 (if (<= x -2.2e-46) (* x 0.5) (if (<= x 5.8e-90) (* y 0.5) (* x 1.5))))
double code(double x, double y) {
double tmp;
if (x <= -2.2e-46) {
tmp = x * 0.5;
} else if (x <= 5.8e-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 <= (-2.2d-46)) then
tmp = x * 0.5d0
else if (x <= 5.8d-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 <= -2.2e-46) {
tmp = x * 0.5;
} else if (x <= 5.8e-90) {
tmp = y * 0.5;
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.2e-46: tmp = x * 0.5 elif x <= 5.8e-90: tmp = y * 0.5 else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -2.2e-46) tmp = Float64(x * 0.5); elseif (x <= 5.8e-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 <= -2.2e-46) tmp = x * 0.5; elseif (x <= 5.8e-90) tmp = y * 0.5; else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.2e-46], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 5.8e-90], N[(y * 0.5), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.2 \cdot 10^{-46}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{-90}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -2.2000000000000001e-46Initial program 100.0%
Taylor expanded in y around 0 77.8%
neg-mul-177.8%
Simplified77.8%
Taylor expanded in x around -inf 77.8%
neg-mul-177.8%
rem-square-sqrt77.2%
fabs-sqr77.2%
rem-square-sqrt77.8%
Simplified77.8%
Taylor expanded in x around 0 77.8%
if -2.2000000000000001e-46 < x < 5.79999999999999967e-90Initial program 99.9%
Taylor expanded in y around inf 86.2%
div-inv86.2%
add-sqr-sqrt50.1%
fabs-sqr50.1%
add-sqr-sqrt52.5%
metadata-eval52.5%
Applied egg-rr52.5%
Taylor expanded in x around inf 32.5%
associate-*r/32.5%
Simplified32.5%
Taylor expanded in x around 0 50.3%
if 5.79999999999999967e-90 < x Initial program 99.7%
Taylor expanded in y around 0 82.4%
neg-mul-182.4%
Simplified82.4%
clear-num82.4%
inv-pow82.4%
fabs-neg82.4%
Applied egg-rr82.4%
unpow-182.4%
Simplified82.4%
Taylor expanded in x around 0 82.4%
*-commutative82.4%
rem-square-sqrt82.3%
fabs-sqr82.3%
rem-square-sqrt82.4%
*-rgt-identity82.4%
distribute-lft-out82.4%
metadata-eval82.4%
Simplified82.4%
Final simplification68.2%
(FPCore (x y) :precision binary64 (if (<= x 6.4e-94) (+ x (/ (- x y) -2.0)) (* x 1.5)))
double code(double x, double y) {
double tmp;
if (x <= 6.4e-94) {
tmp = x + ((x - 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 <= 6.4d-94) then
tmp = x + ((x - 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 <= 6.4e-94) {
tmp = x + ((x - y) / -2.0);
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 6.4e-94: tmp = x + ((x - y) / -2.0) else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= 6.4e-94) tmp = Float64(x + Float64(Float64(x - y) / -2.0)); else tmp = Float64(x * 1.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 6.4e-94) tmp = x + ((x - y) / -2.0); else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 6.4e-94], N[(x + N[(N[(x - y), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.4 \cdot 10^{-94}:\\
\;\;\;\;x + \frac{x - y}{-2}\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < 6.39999999999999993e-94Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt71.8%
fabs-sqr71.8%
add-sqr-sqrt73.5%
frac-2neg73.5%
distribute-frac-neg73.5%
fmm-undef73.5%
*-un-lft-identity73.5%
metadata-eval73.5%
Applied egg-rr73.5%
if 6.39999999999999993e-94 < x Initial program 99.7%
Taylor expanded in y around 0 82.4%
neg-mul-182.4%
Simplified82.4%
clear-num82.4%
inv-pow82.4%
fabs-neg82.4%
Applied egg-rr82.4%
unpow-182.4%
Simplified82.4%
Taylor expanded in x around 0 82.4%
*-commutative82.4%
rem-square-sqrt82.3%
fabs-sqr82.3%
rem-square-sqrt82.4%
*-rgt-identity82.4%
distribute-lft-out82.4%
metadata-eval82.4%
Simplified82.4%
Final simplification76.2%
(FPCore (x y) :precision binary64 (if (<= y 8e-115) (* x 0.5) (* y 0.5)))
double code(double x, double y) {
double tmp;
if (y <= 8e-115) {
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-115) 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-115) {
tmp = x * 0.5;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 8e-115: tmp = x * 0.5 else: tmp = y * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= 8e-115) 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-115) tmp = x * 0.5; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 8e-115], N[(x * 0.5), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8 \cdot 10^{-115}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < 8.0000000000000004e-115Initial program 99.9%
Taylor expanded in y around 0 67.1%
neg-mul-167.1%
Simplified67.1%
Taylor expanded in x around -inf 67.1%
neg-mul-167.1%
rem-square-sqrt32.5%
fabs-sqr32.5%
rem-square-sqrt39.6%
Simplified39.6%
Taylor expanded in x around 0 39.6%
if 8.0000000000000004e-115 < y Initial program 99.9%
Taylor expanded in y around inf 70.8%
div-inv70.8%
add-sqr-sqrt70.4%
fabs-sqr70.4%
add-sqr-sqrt70.8%
metadata-eval70.8%
Applied egg-rr70.8%
Taylor expanded in x around inf 48.7%
associate-*r/48.7%
Simplified48.7%
Taylor expanded in x around 0 65.5%
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 99.9%
Taylor expanded in y around 0 55.1%
neg-mul-155.1%
Simplified55.1%
Taylor expanded in x around -inf 55.1%
neg-mul-155.1%
rem-square-sqrt25.8%
fabs-sqr25.8%
rem-square-sqrt32.1%
Simplified32.1%
Taylor expanded in x around 0 32.1%
Final simplification32.1%
(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 12.0%
herbie shell --seed 2024185
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
:precision binary64
(+ x (/ (fabs (- y x)) 2.0)))