
(FPCore (x y) :precision binary64 (+ x (/ (fabs (- y x)) 2.0)))
double code(double x, double y) {
return x + (fabs((y - x)) / 2.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (abs((y - x)) / 2.0d0)
end function
public static double code(double x, double y) {
return x + (Math.abs((y - x)) / 2.0);
}
def code(x, y): return x + (math.fabs((y - x)) / 2.0)
function code(x, y) return Float64(x + Float64(abs(Float64(y - x)) / 2.0)) end
function tmp = code(x, y) tmp = x + (abs((y - x)) / 2.0); end
code[x_, y_] := N[(x + N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left|y - x\right|}{2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (+ x (/ (fabs (- y x)) 2.0)))
double code(double x, double y) {
return x + (fabs((y - x)) / 2.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (abs((y - x)) / 2.0d0)
end function
public static double code(double x, double y) {
return x + (Math.abs((y - x)) / 2.0);
}
def code(x, y): return x + (math.fabs((y - x)) / 2.0)
function code(x, y) return Float64(x + Float64(abs(Float64(y - x)) / 2.0)) end
function tmp = code(x, y) tmp = x + (abs((y - x)) / 2.0); end
code[x_, y_] := N[(x + N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left|y - x\right|}{2}
\end{array}
(FPCore (x y) :precision binary64 (+ x (/ (fabs (- x y)) 2.0)))
double code(double x, double y) {
return x + (fabs((x - y)) / 2.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (abs((x - y)) / 2.0d0)
end function
public static double code(double x, double y) {
return x + (Math.abs((x - y)) / 2.0);
}
def code(x, y): return x + (math.fabs((x - y)) / 2.0)
function code(x, y) return Float64(x + Float64(abs(Float64(x - y)) / 2.0)) end
function tmp = code(x, y) tmp = x + (abs((x - y)) / 2.0); end
code[x_, y_] := N[(x + N[(N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left|x - y\right|}{2}
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (+ x y) 0.5)))
(if (<= y -1.05e-140)
(- x t_0)
(if (<= y 3.5e-168) (+ x (/ (fabs x) 2.0)) t_0))))
double code(double x, double y) {
double t_0 = (x + y) * 0.5;
double tmp;
if (y <= -1.05e-140) {
tmp = x - t_0;
} else if (y <= 3.5e-168) {
tmp = x + (fabs(x) / 2.0);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x + y) * 0.5d0
if (y <= (-1.05d-140)) then
tmp = x - t_0
else if (y <= 3.5d-168) then
tmp = x + (abs(x) / 2.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x + y) * 0.5;
double tmp;
if (y <= -1.05e-140) {
tmp = x - t_0;
} else if (y <= 3.5e-168) {
tmp = x + (Math.abs(x) / 2.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x + y) * 0.5 tmp = 0 if y <= -1.05e-140: tmp = x - t_0 elif y <= 3.5e-168: tmp = x + (math.fabs(x) / 2.0) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x + y) * 0.5) tmp = 0.0 if (y <= -1.05e-140) tmp = Float64(x - t_0); elseif (y <= 3.5e-168) tmp = Float64(x + Float64(abs(x) / 2.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x + y) * 0.5; tmp = 0.0; if (y <= -1.05e-140) tmp = x - t_0; elseif (y <= 3.5e-168) tmp = x + (abs(x) / 2.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[y, -1.05e-140], N[(x - t$95$0), $MachinePrecision], If[LessEqual[y, 3.5e-168], N[(x + N[(N[Abs[x], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + y\right) \cdot 0.5\\
\mathbf{if}\;y \leq -1.05 \cdot 10^{-140}:\\
\;\;\;\;x - t\_0\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{-168}:\\
\;\;\;\;x + \frac{\left|x\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.05000000000000009e-140Initial program 99.9%
add-cube-cbrt98.1%
fabs-mul98.1%
pow298.1%
Applied egg-rr98.1%
Applied egg-rr85.0%
if -1.05000000000000009e-140 < y < 3.49999999999999982e-168Initial program 99.9%
Taylor expanded in y around 0 97.1%
neg-mul-197.1%
Simplified97.1%
if 3.49999999999999982e-168 < y Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt85.1%
fabs-sqr85.1%
add-sqr-sqrt88.4%
frac-2neg88.4%
distribute-frac-neg88.4%
fmm-undef88.4%
*-un-lft-identity88.4%
metadata-eval88.4%
Applied egg-rr88.4%
Taylor expanded in x around 0 88.4%
cancel-sign-sub-inv88.4%
metadata-eval88.4%
distribute-lft-in88.4%
+-commutative88.4%
Simplified88.4%
Final simplification89.5%
(FPCore (x y) :precision binary64 (if (<= x -1.8e-107) (- x (* (+ x y) 0.5)) (if (<= x 11500000.0) (+ x (/ (fabs y) 2.0)) (+ x (* 0.5 (- x y))))))
double code(double x, double y) {
double tmp;
if (x <= -1.8e-107) {
tmp = x - ((x + y) * 0.5);
} else if (x <= 11500000.0) {
tmp = x + (fabs(y) / 2.0);
} 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 <= (-1.8d-107)) then
tmp = x - ((x + y) * 0.5d0)
else if (x <= 11500000.0d0) then
tmp = x + (abs(y) / 2.0d0)
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 <= -1.8e-107) {
tmp = x - ((x + y) * 0.5);
} else if (x <= 11500000.0) {
tmp = x + (Math.abs(y) / 2.0);
} else {
tmp = x + (0.5 * (x - y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.8e-107: tmp = x - ((x + y) * 0.5) elif x <= 11500000.0: tmp = x + (math.fabs(y) / 2.0) else: tmp = x + (0.5 * (x - y)) return tmp
function code(x, y) tmp = 0.0 if (x <= -1.8e-107) tmp = Float64(x - Float64(Float64(x + y) * 0.5)); elseif (x <= 11500000.0) tmp = Float64(x + Float64(abs(y) / 2.0)); 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 <= -1.8e-107) tmp = x - ((x + y) * 0.5); elseif (x <= 11500000.0) tmp = x + (abs(y) / 2.0); else tmp = x + (0.5 * (x - y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.8e-107], N[(x - N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 11500000.0], N[(x + N[(N[Abs[y], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(0.5 * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.8 \cdot 10^{-107}:\\
\;\;\;\;x - \left(x + y\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 11500000:\\
\;\;\;\;x + \frac{\left|y\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;x + 0.5 \cdot \left(x - y\right)\\
\end{array}
\end{array}
if x < -1.79999999999999988e-107Initial program 100.0%
add-cube-cbrt97.9%
fabs-mul97.9%
pow297.9%
Applied egg-rr97.9%
Applied egg-rr89.8%
if -1.79999999999999988e-107 < x < 1.15e7Initial program 100.0%
Taylor expanded in y around inf 91.2%
if 1.15e7 < x Initial program 99.8%
add-cube-cbrt98.9%
fabs-mul98.9%
pow298.9%
Applied egg-rr98.9%
add-sqr-sqrt98.7%
sqrt-unprod37.8%
frac-2neg37.8%
metadata-eval37.8%
frac-2neg37.8%
metadata-eval37.8%
frac-times37.8%
Applied egg-rr85.6%
Taylor expanded in y around 0 85.6%
mul-1-neg85.6%
sub-neg85.6%
Simplified85.6%
Final simplification89.3%
(FPCore (x y)
:precision binary64
(if (<= x -1.25e-106)
(* x 0.5)
(if (<= x 1.9e-259)
(* y 0.5)
(if (<= x 1.3e-82) (* y -0.5) (if (<= x 3.8e-35) (* y 0.5) (* x 1.5))))))
double code(double x, double y) {
double tmp;
if (x <= -1.25e-106) {
tmp = x * 0.5;
} else if (x <= 1.9e-259) {
tmp = y * 0.5;
} else if (x <= 1.3e-82) {
tmp = y * -0.5;
} else if (x <= 3.8e-35) {
tmp = y * 0.5;
} else {
tmp = x * 1.5;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.25d-106)) then
tmp = x * 0.5d0
else if (x <= 1.9d-259) then
tmp = y * 0.5d0
else if (x <= 1.3d-82) then
tmp = y * (-0.5d0)
else if (x <= 3.8d-35) then
tmp = y * 0.5d0
else
tmp = x * 1.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.25e-106) {
tmp = x * 0.5;
} else if (x <= 1.9e-259) {
tmp = y * 0.5;
} else if (x <= 1.3e-82) {
tmp = y * -0.5;
} else if (x <= 3.8e-35) {
tmp = y * 0.5;
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.25e-106: tmp = x * 0.5 elif x <= 1.9e-259: tmp = y * 0.5 elif x <= 1.3e-82: tmp = y * -0.5 elif x <= 3.8e-35: tmp = y * 0.5 else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.25e-106) tmp = Float64(x * 0.5); elseif (x <= 1.9e-259) tmp = Float64(y * 0.5); elseif (x <= 1.3e-82) tmp = Float64(y * -0.5); elseif (x <= 3.8e-35) tmp = Float64(y * 0.5); else tmp = Float64(x * 1.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.25e-106) tmp = x * 0.5; elseif (x <= 1.9e-259) tmp = y * 0.5; elseif (x <= 1.3e-82) tmp = y * -0.5; elseif (x <= 3.8e-35) tmp = y * 0.5; else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.25e-106], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.9e-259], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, 1.3e-82], N[(y * -0.5), $MachinePrecision], If[LessEqual[x, 3.8e-35], N[(y * 0.5), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25 \cdot 10^{-106}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-259}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{-82}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{-35}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -1.24999999999999996e-106Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt86.1%
fabs-sqr86.1%
add-sqr-sqrt86.9%
frac-2neg86.9%
distribute-frac-neg86.9%
fmm-undef86.9%
*-un-lft-identity86.9%
metadata-eval86.9%
Applied egg-rr86.9%
Taylor expanded in x around inf 76.9%
if -1.24999999999999996e-106 < x < 1.9e-259 or 1.3e-82 < x < 3.8000000000000001e-35Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt66.2%
fabs-sqr66.2%
add-sqr-sqrt67.6%
frac-2neg67.6%
distribute-frac-neg67.6%
fmm-undef67.6%
*-un-lft-identity67.6%
metadata-eval67.6%
Applied egg-rr67.6%
Taylor expanded in x around 0 59.9%
if 1.9e-259 < x < 1.3e-82Initial program 100.0%
add-cube-cbrt97.8%
fabs-mul97.8%
pow297.8%
Applied egg-rr97.8%
Applied egg-rr64.0%
Taylor expanded in x around 0 63.2%
*-commutative63.2%
Simplified63.2%
if 3.8000000000000001e-35 < x Initial program 99.8%
Taylor expanded in y around 0 79.6%
neg-mul-179.6%
Simplified79.6%
add-sqr-sqrt79.5%
associate-/l*79.5%
fabs-neg79.5%
add-sqr-sqrt79.5%
fabs-sqr79.5%
add-sqr-sqrt79.5%
fabs-neg79.5%
add-sqr-sqrt79.5%
fabs-sqr79.5%
add-sqr-sqrt79.5%
Applied egg-rr79.5%
associate-*r/79.5%
rem-square-sqrt79.6%
Simplified79.6%
Taylor expanded in x around 0 79.6%
*-commutative79.6%
Simplified79.6%
Final simplification72.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (+ x y) 0.5)))
(if (<= y 9.8e-225)
(- x t_0)
(if (<= y 7.5e-180) (+ x (/ 1.0 (/ 2.0 x))) t_0))))
double code(double x, double y) {
double t_0 = (x + y) * 0.5;
double tmp;
if (y <= 9.8e-225) {
tmp = x - t_0;
} else if (y <= 7.5e-180) {
tmp = x + (1.0 / (2.0 / x));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x + y) * 0.5d0
if (y <= 9.8d-225) then
tmp = x - t_0
else if (y <= 7.5d-180) then
tmp = x + (1.0d0 / (2.0d0 / x))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x + y) * 0.5;
double tmp;
if (y <= 9.8e-225) {
tmp = x - t_0;
} else if (y <= 7.5e-180) {
tmp = x + (1.0 / (2.0 / x));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x + y) * 0.5 tmp = 0 if y <= 9.8e-225: tmp = x - t_0 elif y <= 7.5e-180: tmp = x + (1.0 / (2.0 / x)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x + y) * 0.5) tmp = 0.0 if (y <= 9.8e-225) tmp = Float64(x - t_0); elseif (y <= 7.5e-180) tmp = Float64(x + Float64(1.0 / Float64(2.0 / x))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x + y) * 0.5; tmp = 0.0; if (y <= 9.8e-225) tmp = x - t_0; elseif (y <= 7.5e-180) tmp = x + (1.0 / (2.0 / x)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[y, 9.8e-225], N[(x - t$95$0), $MachinePrecision], If[LessEqual[y, 7.5e-180], N[(x + N[(1.0 / N[(2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + y\right) \cdot 0.5\\
\mathbf{if}\;y \leq 9.8 \cdot 10^{-225}:\\
\;\;\;\;x - t\_0\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-180}:\\
\;\;\;\;x + \frac{1}{\frac{2}{x}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < 9.79999999999999942e-225Initial program 100.0%
add-cube-cbrt98.2%
fabs-mul98.2%
pow298.2%
Applied egg-rr98.2%
Applied egg-rr80.5%
if 9.79999999999999942e-225 < y < 7.50000000000000015e-180Initial program 99.8%
Taylor expanded in y around 0 92.5%
neg-mul-192.5%
Simplified92.5%
clear-num92.5%
inv-pow92.5%
fabs-neg92.5%
add-sqr-sqrt77.0%
fabs-sqr77.0%
add-sqr-sqrt80.0%
Applied egg-rr80.0%
unpow-180.0%
Simplified80.0%
if 7.50000000000000015e-180 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt84.5%
fabs-sqr84.5%
add-sqr-sqrt87.9%
frac-2neg87.9%
distribute-frac-neg87.9%
fmm-undef87.9%
*-un-lft-identity87.9%
metadata-eval87.9%
Applied egg-rr87.9%
Taylor expanded in x around 0 87.9%
cancel-sign-sub-inv87.9%
metadata-eval87.9%
distribute-lft-in87.9%
+-commutative87.9%
Simplified87.9%
Final simplification83.4%
(FPCore (x y) :precision binary64 (if (<= x -7e-106) (* x 0.5) (if (<= x 3.7e-22) (* y 0.5) (* x 1.5))))
double code(double x, double y) {
double tmp;
if (x <= -7e-106) {
tmp = x * 0.5;
} else if (x <= 3.7e-22) {
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 <= (-7d-106)) then
tmp = x * 0.5d0
else if (x <= 3.7d-22) 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 <= -7e-106) {
tmp = x * 0.5;
} else if (x <= 3.7e-22) {
tmp = y * 0.5;
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -7e-106: tmp = x * 0.5 elif x <= 3.7e-22: tmp = y * 0.5 else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -7e-106) tmp = Float64(x * 0.5); elseif (x <= 3.7e-22) 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 <= -7e-106) tmp = x * 0.5; elseif (x <= 3.7e-22) tmp = y * 0.5; else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -7e-106], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 3.7e-22], N[(y * 0.5), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{-106}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 3.7 \cdot 10^{-22}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -7e-106Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt86.1%
fabs-sqr86.1%
add-sqr-sqrt86.9%
frac-2neg86.9%
distribute-frac-neg86.9%
fmm-undef86.9%
*-un-lft-identity86.9%
metadata-eval86.9%
Applied egg-rr86.9%
Taylor expanded in x around inf 76.9%
if -7e-106 < x < 3.7e-22Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt52.3%
fabs-sqr52.3%
add-sqr-sqrt54.1%
frac-2neg54.1%
distribute-frac-neg54.1%
fmm-undef54.1%
*-un-lft-identity54.1%
metadata-eval54.1%
Applied egg-rr54.1%
Taylor expanded in x around 0 49.0%
if 3.7e-22 < x Initial program 99.8%
Taylor expanded in y around 0 79.6%
neg-mul-179.6%
Simplified79.6%
add-sqr-sqrt79.5%
associate-/l*79.5%
fabs-neg79.5%
add-sqr-sqrt79.5%
fabs-sqr79.5%
add-sqr-sqrt79.5%
fabs-neg79.5%
add-sqr-sqrt79.5%
fabs-sqr79.5%
add-sqr-sqrt79.5%
Applied egg-rr79.5%
associate-*r/79.5%
rem-square-sqrt79.6%
Simplified79.6%
Taylor expanded in x around 0 79.6%
*-commutative79.6%
Simplified79.6%
Final simplification67.7%
(FPCore (x y) :precision binary64 (if (<= x -3.25e-106) (* x 0.5) (if (<= x 1.35e+178) (* y 0.5) x)))
double code(double x, double y) {
double tmp;
if (x <= -3.25e-106) {
tmp = x * 0.5;
} else if (x <= 1.35e+178) {
tmp = y * 0.5;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-3.25d-106)) then
tmp = x * 0.5d0
else if (x <= 1.35d+178) then
tmp = y * 0.5d0
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -3.25e-106) {
tmp = x * 0.5;
} else if (x <= 1.35e+178) {
tmp = y * 0.5;
} else {
tmp = x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3.25e-106: tmp = x * 0.5 elif x <= 1.35e+178: tmp = y * 0.5 else: tmp = x return tmp
function code(x, y) tmp = 0.0 if (x <= -3.25e-106) tmp = Float64(x * 0.5); elseif (x <= 1.35e+178) tmp = Float64(y * 0.5); else tmp = x; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3.25e-106) tmp = x * 0.5; elseif (x <= 1.35e+178) tmp = y * 0.5; else tmp = x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3.25e-106], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.35e+178], N[(y * 0.5), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.25 \cdot 10^{-106}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{+178}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -3.2499999999999998e-106Initial program 100.0%
*-un-lft-identity100.0%
fma-define100.0%
add-sqr-sqrt86.1%
fabs-sqr86.1%
add-sqr-sqrt86.9%
frac-2neg86.9%
distribute-frac-neg86.9%
fmm-undef86.9%
*-un-lft-identity86.9%
metadata-eval86.9%
Applied egg-rr86.9%
Taylor expanded in x around inf 76.9%
if -3.2499999999999998e-106 < x < 1.35000000000000009e178Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt44.1%
fabs-sqr44.1%
add-sqr-sqrt48.7%
frac-2neg48.7%
distribute-frac-neg48.7%
fmm-undef48.7%
*-un-lft-identity48.7%
metadata-eval48.7%
Applied egg-rr48.7%
Taylor expanded in x around 0 41.9%
if 1.35000000000000009e178 < x Initial program 99.8%
Taylor expanded in x around inf 19.5%
Final simplification52.7%
(FPCore (x y) :precision binary64 (if (<= y -3.1e-141) (+ x (* 0.5 (- x y))) (* (+ x y) 0.5)))
double code(double x, double y) {
double tmp;
if (y <= -3.1e-141) {
tmp = x + (0.5 * (x - y));
} else {
tmp = (x + y) * 0.5;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-3.1d-141)) then
tmp = x + (0.5d0 * (x - y))
else
tmp = (x + y) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -3.1e-141) {
tmp = x + (0.5 * (x - y));
} else {
tmp = (x + y) * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3.1e-141: tmp = x + (0.5 * (x - y)) else: tmp = (x + y) * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -3.1e-141) tmp = Float64(x + Float64(0.5 * Float64(x - y))); else tmp = Float64(Float64(x + y) * 0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -3.1e-141) tmp = x + (0.5 * (x - y)); else tmp = (x + y) * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3.1e-141], N[(x + N[(0.5 * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{-141}:\\
\;\;\;\;x + 0.5 \cdot \left(x - y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) \cdot 0.5\\
\end{array}
\end{array}
if y < -3.10000000000000027e-141Initial program 99.9%
add-cube-cbrt98.1%
fabs-mul98.1%
pow298.1%
Applied egg-rr98.1%
add-sqr-sqrt98.0%
sqrt-unprod53.6%
frac-2neg53.6%
metadata-eval53.6%
frac-2neg53.6%
metadata-eval53.6%
frac-times53.6%
Applied egg-rr81.7%
Taylor expanded in y around 0 81.7%
mul-1-neg81.7%
sub-neg81.7%
Simplified81.7%
if -3.10000000000000027e-141 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt74.1%
fabs-sqr74.1%
add-sqr-sqrt79.1%
frac-2neg79.1%
distribute-frac-neg79.1%
fmm-undef79.1%
*-un-lft-identity79.1%
metadata-eval79.1%
Applied egg-rr79.1%
Taylor expanded in x around 0 79.1%
cancel-sign-sub-inv79.1%
metadata-eval79.1%
distribute-lft-in79.1%
+-commutative79.1%
Simplified79.1%
Final simplification80.0%
(FPCore (x y) :precision binary64 (if (<= y -9.8e-104) (- x (* y 0.5)) (* (+ x y) 0.5)))
double code(double x, double y) {
double tmp;
if (y <= -9.8e-104) {
tmp = x - (y * 0.5);
} else {
tmp = (x + y) * 0.5;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-9.8d-104)) then
tmp = x - (y * 0.5d0)
else
tmp = (x + y) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -9.8e-104) {
tmp = x - (y * 0.5);
} else {
tmp = (x + y) * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -9.8e-104: tmp = x - (y * 0.5) else: tmp = (x + y) * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -9.8e-104) tmp = Float64(x - Float64(y * 0.5)); else tmp = Float64(Float64(x + y) * 0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -9.8e-104) tmp = x - (y * 0.5); else tmp = (x + y) * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -9.8e-104], N[(x - N[(y * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.8 \cdot 10^{-104}:\\
\;\;\;\;x - y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) \cdot 0.5\\
\end{array}
\end{array}
if y < -9.8000000000000006e-104Initial program 100.0%
add-cube-cbrt98.2%
fabs-mul98.2%
pow298.2%
Applied egg-rr98.2%
Applied egg-rr85.5%
Taylor expanded in y around inf 73.5%
if -9.8000000000000006e-104 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt72.2%
fabs-sqr72.2%
add-sqr-sqrt77.2%
frac-2neg77.2%
distribute-frac-neg77.2%
fmm-undef77.2%
*-un-lft-identity77.2%
metadata-eval77.2%
Applied egg-rr77.2%
Taylor expanded in x around 0 77.2%
cancel-sign-sub-inv77.2%
metadata-eval77.2%
distribute-lft-in77.2%
+-commutative77.2%
Simplified77.2%
Final simplification76.1%
(FPCore (x y) :precision binary64 (if (<= y -2.5e-47) (* y -0.5) (* (+ x y) 0.5)))
double code(double x, double y) {
double tmp;
if (y <= -2.5e-47) {
tmp = y * -0.5;
} else {
tmp = (x + y) * 0.5;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-2.5d-47)) then
tmp = y * (-0.5d0)
else
tmp = (x + y) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2.5e-47) {
tmp = y * -0.5;
} else {
tmp = (x + y) * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.5e-47: tmp = y * -0.5 else: tmp = (x + y) * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -2.5e-47) tmp = Float64(y * -0.5); else tmp = Float64(Float64(x + y) * 0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.5e-47) tmp = y * -0.5; else tmp = (x + y) * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.5e-47], N[(y * -0.5), $MachinePrecision], N[(N[(x + y), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{-47}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) \cdot 0.5\\
\end{array}
\end{array}
if y < -2.50000000000000006e-47Initial program 100.0%
add-cube-cbrt98.3%
fabs-mul98.3%
pow298.3%
Applied egg-rr98.3%
Applied egg-rr84.6%
Taylor expanded in x around 0 72.6%
*-commutative72.6%
Simplified72.6%
if -2.50000000000000006e-47 < y Initial program 99.9%
*-un-lft-identity99.9%
fma-define99.9%
add-sqr-sqrt70.4%
fabs-sqr70.4%
add-sqr-sqrt75.3%
frac-2neg75.3%
distribute-frac-neg75.3%
fmm-undef75.3%
*-un-lft-identity75.3%
metadata-eval75.3%
Applied egg-rr75.3%
Taylor expanded in x around 0 75.3%
cancel-sign-sub-inv75.3%
metadata-eval75.3%
distribute-lft-in75.3%
+-commutative75.3%
Simplified75.3%
Final simplification74.6%
(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-sqrt55.8%
fabs-sqr55.8%
add-sqr-sqrt60.4%
frac-2neg60.4%
distribute-frac-neg60.4%
fmm-undef60.4%
*-un-lft-identity60.4%
metadata-eval60.4%
Applied egg-rr60.4%
Taylor expanded in x around inf 36.7%
Final simplification36.7%
(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.9%
herbie shell --seed 2024170
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
:precision binary64
(+ x (/ (fabs (- y x)) 2.0)))