
(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 11 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 (<= y -7e-81) (+ x (/ (fabs y) 2.0)) (if (<= y 3.3e-147) (+ x (/ (fabs x) 2.0)) (* 0.5 (+ x y)))))
double code(double x, double y) {
double tmp;
if (y <= -7e-81) {
tmp = x + (fabs(y) / 2.0);
} else if (y <= 3.3e-147) {
tmp = x + (fabs(x) / 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 <= (-7d-81)) then
tmp = x + (abs(y) / 2.0d0)
else if (y <= 3.3d-147) then
tmp = x + (abs(x) / 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 <= -7e-81) {
tmp = x + (Math.abs(y) / 2.0);
} else if (y <= 3.3e-147) {
tmp = x + (Math.abs(x) / 2.0);
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -7e-81: tmp = x + (math.fabs(y) / 2.0) elif y <= 3.3e-147: tmp = x + (math.fabs(x) / 2.0) else: tmp = 0.5 * (x + y) return tmp
function code(x, y) tmp = 0.0 if (y <= -7e-81) tmp = Float64(x + Float64(abs(y) / 2.0)); elseif (y <= 3.3e-147) tmp = Float64(x + Float64(abs(x) / 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 <= -7e-81) tmp = x + (abs(y) / 2.0); elseif (y <= 3.3e-147) tmp = x + (abs(x) / 2.0); else tmp = 0.5 * (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -7e-81], N[(x + N[(N[Abs[y], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.3e-147], N[(x + N[(N[Abs[x], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{-81}:\\
\;\;\;\;x + \frac{\left|y\right|}{2}\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{-147}:\\
\;\;\;\;x + \frac{\left|x\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < -6.99999999999999973e-81Initial program 100.0%
Taylor expanded in y around inf 78.2%
if -6.99999999999999973e-81 < y < 3.29999999999999987e-147Initial program 99.9%
Taylor expanded in y around 0 85.6%
neg-mul-185.6%
Simplified85.6%
if 3.29999999999999987e-147 < y Initial program 99.9%
Taylor expanded in x around inf 88.9%
+-commutative88.9%
sub-neg88.9%
neg-mul-188.9%
fma-define88.9%
neg-mul-188.9%
sub-neg88.9%
rem-square-sqrt68.6%
fabs-sqr68.6%
rem-square-sqrt72.5%
Simplified72.5%
Taylor expanded in x around 0 83.5%
distribute-lft-out83.5%
+-commutative83.5%
Simplified83.5%
Final simplification82.7%
(FPCore (x y) :precision binary64 (if (<= x -2.4e-100) (* 0.5 (+ x y)) (if (<= x 2.3e+103) (+ x (/ (fabs y) 2.0)) (+ x (/ 1.0 (/ 2.0 x))))))
double code(double x, double y) {
double tmp;
if (x <= -2.4e-100) {
tmp = 0.5 * (x + y);
} else if (x <= 2.3e+103) {
tmp = x + (fabs(y) / 2.0);
} else {
tmp = x + (1.0 / (2.0 / x));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-2.4d-100)) then
tmp = 0.5d0 * (x + y)
else if (x <= 2.3d+103) then
tmp = x + (abs(y) / 2.0d0)
else
tmp = x + (1.0d0 / (2.0d0 / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -2.4e-100) {
tmp = 0.5 * (x + y);
} else if (x <= 2.3e+103) {
tmp = x + (Math.abs(y) / 2.0);
} else {
tmp = x + (1.0 / (2.0 / x));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.4e-100: tmp = 0.5 * (x + y) elif x <= 2.3e+103: tmp = x + (math.fabs(y) / 2.0) else: tmp = x + (1.0 / (2.0 / x)) return tmp
function code(x, y) tmp = 0.0 if (x <= -2.4e-100) tmp = Float64(0.5 * Float64(x + y)); elseif (x <= 2.3e+103) tmp = Float64(x + Float64(abs(y) / 2.0)); else tmp = Float64(x + Float64(1.0 / Float64(2.0 / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.4e-100) tmp = 0.5 * (x + y); elseif (x <= 2.3e+103) tmp = x + (abs(y) / 2.0); else tmp = x + (1.0 / (2.0 / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.4e-100], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.3e+103], N[(x + N[(N[Abs[y], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(1.0 / N[(2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.4 \cdot 10^{-100}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{+103}:\\
\;\;\;\;x + \frac{\left|y\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{\frac{2}{x}}\\
\end{array}
\end{array}
if x < -2.4000000000000003e-100Initial program 99.9%
Taylor expanded in x around inf 98.7%
+-commutative98.7%
sub-neg98.7%
neg-mul-198.7%
fma-define98.7%
neg-mul-198.7%
sub-neg98.7%
rem-square-sqrt82.9%
fabs-sqr82.9%
rem-square-sqrt83.4%
Simplified83.4%
Taylor expanded in x around 0 83.4%
distribute-lft-out83.4%
+-commutative83.4%
Simplified83.4%
if -2.4000000000000003e-100 < x < 2.30000000000000008e103Initial program 100.0%
Taylor expanded in y around inf 77.4%
if 2.30000000000000008e103 < x Initial program 99.8%
Taylor expanded in y around 0 73.8%
neg-mul-173.8%
Simplified73.8%
clear-num73.9%
inv-pow73.9%
fabs-neg73.9%
add-sqr-sqrt73.8%
fabs-sqr73.8%
add-sqr-sqrt73.9%
Applied egg-rr73.9%
unpow-173.9%
Simplified73.9%
Final simplification78.6%
(FPCore (x y) :precision binary64 (if (<= x -3.45e-99) (* 0.5 (+ x y)) (if (<= x 5.5e-67) (* (fabs y) 0.5) (+ x (/ 1.0 (/ 2.0 x))))))
double code(double x, double y) {
double tmp;
if (x <= -3.45e-99) {
tmp = 0.5 * (x + y);
} else if (x <= 5.5e-67) {
tmp = fabs(y) * 0.5;
} else {
tmp = x + (1.0 / (2.0 / 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.45d-99)) then
tmp = 0.5d0 * (x + y)
else if (x <= 5.5d-67) then
tmp = abs(y) * 0.5d0
else
tmp = x + (1.0d0 / (2.0d0 / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -3.45e-99) {
tmp = 0.5 * (x + y);
} else if (x <= 5.5e-67) {
tmp = Math.abs(y) * 0.5;
} else {
tmp = x + (1.0 / (2.0 / x));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3.45e-99: tmp = 0.5 * (x + y) elif x <= 5.5e-67: tmp = math.fabs(y) * 0.5 else: tmp = x + (1.0 / (2.0 / x)) return tmp
function code(x, y) tmp = 0.0 if (x <= -3.45e-99) tmp = Float64(0.5 * Float64(x + y)); elseif (x <= 5.5e-67) tmp = Float64(abs(y) * 0.5); else tmp = Float64(x + Float64(1.0 / Float64(2.0 / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3.45e-99) tmp = 0.5 * (x + y); elseif (x <= 5.5e-67) tmp = abs(y) * 0.5; else tmp = x + (1.0 / (2.0 / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3.45e-99], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.5e-67], N[(N[Abs[y], $MachinePrecision] * 0.5), $MachinePrecision], N[(x + N[(1.0 / N[(2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.45 \cdot 10^{-99}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-67}:\\
\;\;\;\;\left|y\right| \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{\frac{2}{x}}\\
\end{array}
\end{array}
if x < -3.4500000000000002e-99Initial program 99.9%
Taylor expanded in x around inf 98.7%
+-commutative98.7%
sub-neg98.7%
neg-mul-198.7%
fma-define98.7%
neg-mul-198.7%
sub-neg98.7%
rem-square-sqrt82.9%
fabs-sqr82.9%
rem-square-sqrt83.4%
Simplified83.4%
Taylor expanded in x around 0 83.4%
distribute-lft-out83.4%
+-commutative83.4%
Simplified83.4%
if -3.4500000000000002e-99 < x < 5.5000000000000003e-67Initial program 100.0%
Taylor expanded in y around inf 85.1%
Taylor expanded in x around 0 82.8%
if 5.5000000000000003e-67 < x Initial program 99.8%
Taylor expanded in y around 0 65.0%
neg-mul-165.0%
Simplified65.0%
clear-num65.0%
inv-pow65.0%
fabs-neg65.0%
add-sqr-sqrt64.9%
fabs-sqr64.9%
add-sqr-sqrt65.0%
Applied egg-rr65.0%
unpow-165.0%
Simplified65.0%
Final simplification77.0%
(FPCore (x y) :precision binary64 (if (<= y -2.2e-82) (* x (- 1.0 (* 0.5 (/ y x)))) (* 0.5 (+ x y))))
double code(double x, double y) {
double tmp;
if (y <= -2.2e-82) {
tmp = x * (1.0 - (0.5 * (y / 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 <= (-2.2d-82)) then
tmp = x * (1.0d0 - (0.5d0 * (y / 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 <= -2.2e-82) {
tmp = x * (1.0 - (0.5 * (y / x)));
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.2e-82: tmp = x * (1.0 - (0.5 * (y / x))) else: tmp = 0.5 * (x + y) return tmp
function code(x, y) tmp = 0.0 if (y <= -2.2e-82) tmp = Float64(x * Float64(1.0 - Float64(0.5 * Float64(y / x)))); else tmp = Float64(0.5 * Float64(x + y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.2e-82) tmp = x * (1.0 - (0.5 * (y / x))); else tmp = 0.5 * (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.2e-82], N[(x * N[(1.0 - N[(0.5 * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.2 \cdot 10^{-82}:\\
\;\;\;\;x \cdot \left(1 - 0.5 \cdot \frac{y}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < -2.19999999999999986e-82Initial program 100.0%
Taylor expanded in y around inf 78.2%
Taylor expanded in x around inf 63.2%
associate-*r/63.2%
rem-square-sqrt0.0%
fabs-sqr0.0%
rem-square-sqrt5.2%
Simplified5.2%
frac-2neg5.2%
add-sqr-sqrt2.8%
sqrt-unprod26.9%
sqr-neg26.9%
sqrt-unprod31.9%
add-sqr-sqrt63.2%
distribute-frac-neg63.2%
sub-neg63.2%
associate-/l*63.2%
Applied egg-rr63.2%
if -2.19999999999999986e-82 < y Initial program 99.9%
Taylor expanded in x around inf 94.1%
+-commutative94.1%
sub-neg94.1%
neg-mul-194.1%
fma-define94.1%
neg-mul-194.1%
sub-neg94.1%
rem-square-sqrt59.1%
fabs-sqr59.1%
rem-square-sqrt64.9%
Simplified64.9%
Taylor expanded in x around 0 70.7%
distribute-lft-out70.7%
+-commutative70.7%
Simplified70.7%
Final simplification68.5%
(FPCore (x y) :precision binary64 (if (<= x -3.5e-150) (* x 0.5) (if (<= x 5e-68) (* y 0.5) (* x 1.5))))
double code(double x, double y) {
double tmp;
if (x <= -3.5e-150) {
tmp = x * 0.5;
} else if (x <= 5e-68) {
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 <= (-3.5d-150)) then
tmp = x * 0.5d0
else if (x <= 5d-68) 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 <= -3.5e-150) {
tmp = x * 0.5;
} else if (x <= 5e-68) {
tmp = y * 0.5;
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3.5e-150: tmp = x * 0.5 elif x <= 5e-68: tmp = y * 0.5 else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -3.5e-150) tmp = Float64(x * 0.5); elseif (x <= 5e-68) 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 <= -3.5e-150) tmp = x * 0.5; elseif (x <= 5e-68) tmp = y * 0.5; else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3.5e-150], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 5e-68], N[(y * 0.5), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{-150}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-68}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -3.4999999999999998e-150Initial program 99.9%
Taylor expanded in x around inf 97.9%
+-commutative97.9%
sub-neg97.9%
neg-mul-197.9%
fma-define97.9%
neg-mul-197.9%
sub-neg97.9%
rem-square-sqrt79.3%
fabs-sqr79.3%
rem-square-sqrt79.9%
Simplified79.9%
Taylor expanded in y around 0 63.9%
if -3.4999999999999998e-150 < x < 4.99999999999999971e-68Initial program 100.0%
Taylor expanded in y around inf 87.1%
Taylor expanded in x around 0 85.2%
rem-square-sqrt45.9%
fabs-sqr45.9%
rem-square-sqrt47.4%
Simplified47.4%
if 4.99999999999999971e-68 < x Initial program 99.8%
Taylor expanded in y around 0 65.0%
neg-mul-165.0%
Simplified65.0%
Taylor expanded in x around 0 65.0%
fabs-neg65.0%
rem-square-sqrt64.9%
fabs-sqr64.9%
rem-square-sqrt65.0%
*-commutative65.0%
*-rgt-identity65.0%
distribute-lft-out65.0%
metadata-eval65.0%
Simplified65.0%
Final simplification59.0%
(FPCore (x y) :precision binary64 (if (<= x 2.9e-67) (* 0.5 (+ x y)) (+ x (/ 1.0 (/ 2.0 x)))))
double code(double x, double y) {
double tmp;
if (x <= 2.9e-67) {
tmp = 0.5 * (x + y);
} else {
tmp = x + (1.0 / (2.0 / x));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 2.9d-67) then
tmp = 0.5d0 * (x + y)
else
tmp = x + (1.0d0 / (2.0d0 / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 2.9e-67) {
tmp = 0.5 * (x + y);
} else {
tmp = x + (1.0 / (2.0 / x));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 2.9e-67: tmp = 0.5 * (x + y) else: tmp = x + (1.0 / (2.0 / x)) return tmp
function code(x, y) tmp = 0.0 if (x <= 2.9e-67) tmp = Float64(0.5 * Float64(x + y)); else tmp = Float64(x + Float64(1.0 / Float64(2.0 / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 2.9e-67) tmp = 0.5 * (x + y); else tmp = x + (1.0 / (2.0 / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 2.9e-67], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x + N[(1.0 / N[(2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.9 \cdot 10^{-67}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{1}{\frac{2}{x}}\\
\end{array}
\end{array}
if x < 2.90000000000000005e-67Initial program 100.0%
Taylor expanded in x around inf 87.2%
+-commutative87.2%
sub-neg87.2%
neg-mul-187.2%
fma-define87.2%
neg-mul-187.2%
sub-neg87.2%
rem-square-sqrt60.0%
fabs-sqr60.0%
rem-square-sqrt61.5%
Simplified61.5%
Taylor expanded in x around 0 67.7%
distribute-lft-out67.7%
+-commutative67.7%
Simplified67.7%
if 2.90000000000000005e-67 < x Initial program 99.8%
Taylor expanded in y around 0 65.0%
neg-mul-165.0%
Simplified65.0%
clear-num65.0%
inv-pow65.0%
fabs-neg65.0%
add-sqr-sqrt64.9%
fabs-sqr64.9%
add-sqr-sqrt65.0%
Applied egg-rr65.0%
unpow-165.0%
Simplified65.0%
Final simplification66.8%
(FPCore (x y) :precision binary64 (if (<= x 9e-68) (* 0.5 (+ x y)) (* x 1.5)))
double code(double x, double y) {
double tmp;
if (x <= 9e-68) {
tmp = 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 <= 9d-68) then
tmp = 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 <= 9e-68) {
tmp = 0.5 * (x + y);
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 9e-68: tmp = 0.5 * (x + y) else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= 9e-68) tmp = 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 <= 9e-68) tmp = 0.5 * (x + y); else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 9e-68], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9 \cdot 10^{-68}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < 8.99999999999999998e-68Initial program 100.0%
Taylor expanded in x around inf 87.2%
+-commutative87.2%
sub-neg87.2%
neg-mul-187.2%
fma-define87.2%
neg-mul-187.2%
sub-neg87.2%
rem-square-sqrt60.0%
fabs-sqr60.0%
rem-square-sqrt61.5%
Simplified61.5%
Taylor expanded in x around 0 67.7%
distribute-lft-out67.7%
+-commutative67.7%
Simplified67.7%
if 8.99999999999999998e-68 < x Initial program 99.8%
Taylor expanded in y around 0 65.0%
neg-mul-165.0%
Simplified65.0%
Taylor expanded in x around 0 65.0%
fabs-neg65.0%
rem-square-sqrt64.9%
fabs-sqr64.9%
rem-square-sqrt65.0%
*-commutative65.0%
*-rgt-identity65.0%
distribute-lft-out65.0%
metadata-eval65.0%
Simplified65.0%
Final simplification66.8%
(FPCore (x y) :precision binary64 (if (<= y 6.5e-60) (* x 0.5) (* y 0.5)))
double code(double x, double y) {
double tmp;
if (y <= 6.5e-60) {
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 <= 6.5d-60) 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 <= 6.5e-60) {
tmp = x * 0.5;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 6.5e-60: tmp = x * 0.5 else: tmp = y * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= 6.5e-60) 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 <= 6.5e-60) tmp = x * 0.5; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 6.5e-60], N[(x * 0.5), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.5 \cdot 10^{-60}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < 6.49999999999999995e-60Initial program 99.9%
Taylor expanded in x around inf 93.7%
+-commutative93.7%
sub-neg93.7%
neg-mul-193.7%
fma-define93.7%
neg-mul-193.7%
sub-neg93.7%
rem-square-sqrt37.0%
fabs-sqr37.0%
rem-square-sqrt42.4%
Simplified42.4%
Taylor expanded in y around 0 37.6%
if 6.49999999999999995e-60 < y Initial program 99.9%
Taylor expanded in y around inf 78.6%
Taylor expanded in x around 0 75.3%
rem-square-sqrt74.8%
fabs-sqr74.8%
rem-square-sqrt75.3%
Simplified75.3%
Final simplification48.3%
(FPCore (x y) :precision binary64 (if (<= y 8.5e-182) x (* y 0.5)))
double code(double x, double y) {
double tmp;
if (y <= 8.5e-182) {
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 <= 8.5d-182) 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 <= 8.5e-182) {
tmp = x;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 8.5e-182: tmp = x else: tmp = y * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= 8.5e-182) tmp = x; else tmp = Float64(y * 0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 8.5e-182) tmp = x; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 8.5e-182], x, N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.5 \cdot 10^{-182}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < 8.5000000000000001e-182Initial program 99.9%
Taylor expanded in x around inf 12.7%
if 8.5000000000000001e-182 < y Initial program 99.9%
Taylor expanded in y around inf 68.4%
Taylor expanded in x around 0 62.7%
rem-square-sqrt62.3%
fabs-sqr62.3%
rem-square-sqrt62.7%
Simplified62.7%
Final simplification32.8%
(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 2024157
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
:precision binary64
(+ x (/ (fabs (- y x)) 2.0)))