
(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 9 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 (fma (fabs (- y x)) 0.5 x))
double code(double x, double y) {
return fma(fabs((y - x)), 0.5, x);
}
function code(x, y) return fma(abs(Float64(y - x)), 0.5, x) end
code[x_, y_] := N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] * 0.5 + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left|y - x\right|, 0.5, x\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
div-invN/A
lower-fma.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (+ x (/ (fabs (- y x)) 2.0)) 1e-266) (* 0.5 x) (fma (- x y) 0.5 x)))
double code(double x, double y) {
double tmp;
if ((x + (fabs((y - x)) / 2.0)) <= 1e-266) {
tmp = 0.5 * x;
} else {
tmp = fma((x - y), 0.5, x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(x + Float64(abs(Float64(y - x)) / 2.0)) <= 1e-266) tmp = Float64(0.5 * x); else tmp = fma(Float64(x - y), 0.5, x); end return tmp end
code[x_, y_] := If[LessEqual[N[(x + N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], 1e-266], N[(0.5 * x), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * 0.5 + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + \frac{\left|y - x\right|}{2} \leq 10^{-266}:\\
\;\;\;\;0.5 \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x - y, 0.5, x\right)\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (fabs.f64 (-.f64 y x)) #s(literal 2 binary64))) < 9.9999999999999998e-267Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
sub-negN/A
mul-1-negN/A
lower-*.f64N/A
+-commutativeN/A
remove-double-negN/A
mul-1-negN/A
neg-mul-1N/A
distribute-lft-inN/A
neg-mul-1N/A
lower-fabs.f64N/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
lower--.f642.9
Applied rewrites2.9%
Applied rewrites97.1%
Taylor expanded in x around inf
Applied rewrites97.2%
if 9.9999999999999998e-267 < (+.f64 x (/.f64 (fabs.f64 (-.f64 y x)) #s(literal 2 binary64))) Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
div-invN/A
lower-fma.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-fabs.f64N/A
unpow1N/A
sqr-powN/A
fabs-sqrN/A
sqr-powN/A
unpow166.3
Applied rewrites66.3%
(FPCore (x y) :precision binary64 (if (<= (+ x (/ (fabs (- y x)) 2.0)) 1e-266) (* 0.5 x) (* -0.5 y)))
double code(double x, double y) {
double tmp;
if ((x + (fabs((y - x)) / 2.0)) <= 1e-266) {
tmp = 0.5 * x;
} else {
tmp = -0.5 * y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x + (abs((y - x)) / 2.0d0)) <= 1d-266) then
tmp = 0.5d0 * x
else
tmp = (-0.5d0) * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x + (Math.abs((y - x)) / 2.0)) <= 1e-266) {
tmp = 0.5 * x;
} else {
tmp = -0.5 * y;
}
return tmp;
}
def code(x, y): tmp = 0 if (x + (math.fabs((y - x)) / 2.0)) <= 1e-266: tmp = 0.5 * x else: tmp = -0.5 * y return tmp
function code(x, y) tmp = 0.0 if (Float64(x + Float64(abs(Float64(y - x)) / 2.0)) <= 1e-266) tmp = Float64(0.5 * x); else tmp = Float64(-0.5 * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x + (abs((y - x)) / 2.0)) <= 1e-266) tmp = 0.5 * x; else tmp = -0.5 * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(x + N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], 1e-266], N[(0.5 * x), $MachinePrecision], N[(-0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + \frac{\left|y - x\right|}{2} \leq 10^{-266}:\\
\;\;\;\;0.5 \cdot x\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot y\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (fabs.f64 (-.f64 y x)) #s(literal 2 binary64))) < 9.9999999999999998e-267Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
sub-negN/A
mul-1-negN/A
lower-*.f64N/A
+-commutativeN/A
remove-double-negN/A
mul-1-negN/A
neg-mul-1N/A
distribute-lft-inN/A
neg-mul-1N/A
lower-fabs.f64N/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
lower--.f642.9
Applied rewrites2.9%
Applied rewrites97.1%
Taylor expanded in x around inf
Applied rewrites97.2%
if 9.9999999999999998e-267 < (+.f64 x (/.f64 (fabs.f64 (-.f64 y x)) #s(literal 2 binary64))) Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
div-invN/A
lower-fma.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
metadata-eval99.9
Applied rewrites99.9%
lift-fabs.f64N/A
unpow1N/A
sqr-powN/A
fabs-sqrN/A
sqr-powN/A
unpow166.3
Applied rewrites66.3%
Taylor expanded in x around 0
lower-*.f6434.4
Applied rewrites34.4%
(FPCore (x y) :precision binary64 (if (<= x -1.22e-58) (* (- x y) 0.5) (if (<= x 2.5e-26) (fma (fabs (- y)) 0.5 x) (fma 1.5 x (* -0.5 y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.22e-58) {
tmp = (x - y) * 0.5;
} else if (x <= 2.5e-26) {
tmp = fma(fabs(-y), 0.5, x);
} else {
tmp = fma(1.5, x, (-0.5 * y));
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -1.22e-58) tmp = Float64(Float64(x - y) * 0.5); elseif (x <= 2.5e-26) tmp = fma(abs(Float64(-y)), 0.5, x); else tmp = fma(1.5, x, Float64(-0.5 * y)); end return tmp end
code[x_, y_] := If[LessEqual[x, -1.22e-58], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2.5e-26], N[(N[Abs[(-y)], $MachinePrecision] * 0.5 + x), $MachinePrecision], N[(1.5 * x + N[(-0.5 * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.22 \cdot 10^{-58}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-26}:\\
\;\;\;\;\mathsf{fma}\left(\left|-y\right|, 0.5, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1.5, x, -0.5 \cdot y\right)\\
\end{array}
\end{array}
if x < -1.2199999999999999e-58Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
sub-negN/A
mul-1-negN/A
lower-*.f64N/A
+-commutativeN/A
remove-double-negN/A
mul-1-negN/A
neg-mul-1N/A
distribute-lft-inN/A
neg-mul-1N/A
lower-fabs.f64N/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
lower--.f6434.3
Applied rewrites34.3%
Applied rewrites83.8%
if -1.2199999999999999e-58 < x < 2.5000000000000001e-26Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
div-invN/A
lower-fma.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6485.0
Applied rewrites85.0%
if 2.5000000000000001e-26 < x Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
div-invN/A
lower-fma.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
metadata-eval99.7
Applied rewrites99.7%
lift-fabs.f64N/A
unpow1N/A
sqr-powN/A
fabs-sqrN/A
sqr-powN/A
unpow187.7
Applied rewrites87.7%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6487.9
Applied rewrites87.9%
(FPCore (x y) :precision binary64 (if (<= x -1.22e-58) (* (- x y) 0.5) (if (<= x 2.5e-26) (fma (fabs (- y)) 0.5 x) (fma (- x y) 0.5 x))))
double code(double x, double y) {
double tmp;
if (x <= -1.22e-58) {
tmp = (x - y) * 0.5;
} else if (x <= 2.5e-26) {
tmp = fma(fabs(-y), 0.5, x);
} else {
tmp = fma((x - y), 0.5, x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -1.22e-58) tmp = Float64(Float64(x - y) * 0.5); elseif (x <= 2.5e-26) tmp = fma(abs(Float64(-y)), 0.5, x); else tmp = fma(Float64(x - y), 0.5, x); end return tmp end
code[x_, y_] := If[LessEqual[x, -1.22e-58], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2.5e-26], N[(N[Abs[(-y)], $MachinePrecision] * 0.5 + x), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * 0.5 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.22 \cdot 10^{-58}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-26}:\\
\;\;\;\;\mathsf{fma}\left(\left|-y\right|, 0.5, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x - y, 0.5, x\right)\\
\end{array}
\end{array}
if x < -1.2199999999999999e-58Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
sub-negN/A
mul-1-negN/A
lower-*.f64N/A
+-commutativeN/A
remove-double-negN/A
mul-1-negN/A
neg-mul-1N/A
distribute-lft-inN/A
neg-mul-1N/A
lower-fabs.f64N/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
lower--.f6434.3
Applied rewrites34.3%
Applied rewrites83.8%
if -1.2199999999999999e-58 < x < 2.5000000000000001e-26Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
div-invN/A
lower-fma.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6485.0
Applied rewrites85.0%
if 2.5000000000000001e-26 < x Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
div-invN/A
lower-fma.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
metadata-eval99.7
Applied rewrites99.7%
lift-fabs.f64N/A
unpow1N/A
sqr-powN/A
fabs-sqrN/A
sqr-powN/A
unpow187.7
Applied rewrites87.7%
(FPCore (x y) :precision binary64 (if (<= x -1.22e-58) (* (- x y) 0.5) (if (<= x 2.5e-26) (* (fabs (- y x)) 0.5) (fma (- x y) 0.5 x))))
double code(double x, double y) {
double tmp;
if (x <= -1.22e-58) {
tmp = (x - y) * 0.5;
} else if (x <= 2.5e-26) {
tmp = fabs((y - x)) * 0.5;
} else {
tmp = fma((x - y), 0.5, x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -1.22e-58) tmp = Float64(Float64(x - y) * 0.5); elseif (x <= 2.5e-26) tmp = Float64(abs(Float64(y - x)) * 0.5); else tmp = fma(Float64(x - y), 0.5, x); end return tmp end
code[x_, y_] := If[LessEqual[x, -1.22e-58], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2.5e-26], N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * 0.5 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.22 \cdot 10^{-58}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-26}:\\
\;\;\;\;\left|y - x\right| \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x - y, 0.5, x\right)\\
\end{array}
\end{array}
if x < -1.2199999999999999e-58Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
sub-negN/A
mul-1-negN/A
lower-*.f64N/A
+-commutativeN/A
remove-double-negN/A
mul-1-negN/A
neg-mul-1N/A
distribute-lft-inN/A
neg-mul-1N/A
lower-fabs.f64N/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
lower--.f6434.3
Applied rewrites34.3%
Applied rewrites83.8%
if -1.2199999999999999e-58 < x < 2.5000000000000001e-26Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
sub-negN/A
mul-1-negN/A
lower-*.f64N/A
+-commutativeN/A
remove-double-negN/A
mul-1-negN/A
neg-mul-1N/A
distribute-lft-inN/A
neg-mul-1N/A
lower-fabs.f64N/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
lower--.f6483.7
Applied rewrites83.7%
if 2.5000000000000001e-26 < x Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
div-invN/A
lower-fma.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
metadata-eval99.7
Applied rewrites99.7%
lift-fabs.f64N/A
unpow1N/A
sqr-powN/A
fabs-sqrN/A
sqr-powN/A
unpow187.7
Applied rewrites87.7%
(FPCore (x y) :precision binary64 (if (<= x -3e-15) (* 0.5 x) (if (<= x 1.05e-161) (* -0.5 y) (* 1.5 x))))
double code(double x, double y) {
double tmp;
if (x <= -3e-15) {
tmp = 0.5 * x;
} else if (x <= 1.05e-161) {
tmp = -0.5 * y;
} else {
tmp = 1.5 * x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-3d-15)) then
tmp = 0.5d0 * x
else if (x <= 1.05d-161) then
tmp = (-0.5d0) * y
else
tmp = 1.5d0 * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -3e-15) {
tmp = 0.5 * x;
} else if (x <= 1.05e-161) {
tmp = -0.5 * y;
} else {
tmp = 1.5 * x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3e-15: tmp = 0.5 * x elif x <= 1.05e-161: tmp = -0.5 * y else: tmp = 1.5 * x return tmp
function code(x, y) tmp = 0.0 if (x <= -3e-15) tmp = Float64(0.5 * x); elseif (x <= 1.05e-161) tmp = Float64(-0.5 * y); else tmp = Float64(1.5 * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3e-15) tmp = 0.5 * x; elseif (x <= 1.05e-161) tmp = -0.5 * y; else tmp = 1.5 * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3e-15], N[(0.5 * x), $MachinePrecision], If[LessEqual[x, 1.05e-161], N[(-0.5 * y), $MachinePrecision], N[(1.5 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3 \cdot 10^{-15}:\\
\;\;\;\;0.5 \cdot x\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{-161}:\\
\;\;\;\;-0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;1.5 \cdot x\\
\end{array}
\end{array}
if x < -3e-15Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
sub-negN/A
mul-1-negN/A
lower-*.f64N/A
+-commutativeN/A
remove-double-negN/A
mul-1-negN/A
neg-mul-1N/A
distribute-lft-inN/A
neg-mul-1N/A
lower-fabs.f64N/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
lower--.f6428.6
Applied rewrites28.6%
Applied rewrites83.6%
Taylor expanded in x around inf
Applied rewrites71.3%
if -3e-15 < x < 1.05e-161Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
div-invN/A
lower-fma.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
metadata-eval100.0
Applied rewrites100.0%
lift-fabs.f64N/A
unpow1N/A
sqr-powN/A
fabs-sqrN/A
sqr-powN/A
unpow150.3
Applied rewrites50.3%
Taylor expanded in x around 0
lower-*.f6443.9
Applied rewrites43.9%
if 1.05e-161 < x Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
div-invN/A
lower-fma.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-fabs.f64N/A
unpow1N/A
sqr-powN/A
fabs-sqrN/A
sqr-powN/A
unpow180.6
Applied rewrites80.6%
Taylor expanded in x around inf
lower-*.f6465.9
Applied rewrites65.9%
(FPCore (x y) :precision binary64 (if (<= x 1.95e-113) (* (- x y) 0.5) (* 1.5 x)))
double code(double x, double y) {
double tmp;
if (x <= 1.95e-113) {
tmp = (x - y) * 0.5;
} else {
tmp = 1.5 * x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 1.95d-113) then
tmp = (x - y) * 0.5d0
else
tmp = 1.5d0 * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 1.95e-113) {
tmp = (x - y) * 0.5;
} else {
tmp = 1.5 * x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.95e-113: tmp = (x - y) * 0.5 else: tmp = 1.5 * x return tmp
function code(x, y) tmp = 0.0 if (x <= 1.95e-113) tmp = Float64(Float64(x - y) * 0.5); else tmp = Float64(1.5 * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.95e-113) tmp = (x - y) * 0.5; else tmp = 1.5 * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.95e-113], N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision], N[(1.5 * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.95 \cdot 10^{-113}:\\
\;\;\;\;\left(x - y\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;1.5 \cdot x\\
\end{array}
\end{array}
if x < 1.9499999999999999e-113Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
sub-negN/A
mul-1-negN/A
lower-*.f64N/A
+-commutativeN/A
remove-double-negN/A
mul-1-negN/A
neg-mul-1N/A
distribute-lft-inN/A
neg-mul-1N/A
lower-fabs.f64N/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
lower--.f6462.7
Applied rewrites62.7%
Applied rewrites65.2%
if 1.9499999999999999e-113 < x Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
div-invN/A
lower-fma.f64N/A
lift-fabs.f64N/A
lift--.f64N/A
fabs-subN/A
lower-fabs.f64N/A
lower--.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-fabs.f64N/A
unpow1N/A
sqr-powN/A
fabs-sqrN/A
sqr-powN/A
unpow181.6
Applied rewrites81.6%
Taylor expanded in x around inf
lower-*.f6469.3
Applied rewrites69.3%
(FPCore (x y) :precision binary64 (* 0.5 x))
double code(double x, double y) {
return 0.5 * x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.5d0 * x
end function
public static double code(double x, double y) {
return 0.5 * x;
}
def code(x, y): return 0.5 * x
function code(x, y) return Float64(0.5 * x) end
function tmp = code(x, y) tmp = 0.5 * x; end
code[x_, y_] := N[(0.5 * x), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot x
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
sub-negN/A
mul-1-negN/A
lower-*.f64N/A
+-commutativeN/A
remove-double-negN/A
mul-1-negN/A
neg-mul-1N/A
distribute-lft-inN/A
neg-mul-1N/A
lower-fabs.f64N/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
lower--.f6456.2
Applied rewrites56.2%
Applied rewrites52.5%
Taylor expanded in x around inf
Applied rewrites28.7%
herbie shell --seed 2024318
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
:precision binary64
(+ x (/ (fabs (- y x)) 2.0)))