
(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 (- 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 (if (<= y -2.8e-22) (+ x (/ (fabs y) 2.0)) (if (<= y 5.5e-30) (+ x (/ (fabs x) 2.0)) (* 0.5 (+ x y)))))
double code(double x, double y) {
double tmp;
if (y <= -2.8e-22) {
tmp = x + (fabs(y) / 2.0);
} else if (y <= 5.5e-30) {
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 <= (-2.8d-22)) then
tmp = x + (abs(y) / 2.0d0)
else if (y <= 5.5d-30) 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 <= -2.8e-22) {
tmp = x + (Math.abs(y) / 2.0);
} else if (y <= 5.5e-30) {
tmp = x + (Math.abs(x) / 2.0);
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.8e-22: tmp = x + (math.fabs(y) / 2.0) elif y <= 5.5e-30: tmp = x + (math.fabs(x) / 2.0) else: tmp = 0.5 * (x + y) return tmp
function code(x, y) tmp = 0.0 if (y <= -2.8e-22) tmp = Float64(x + Float64(abs(y) / 2.0)); elseif (y <= 5.5e-30) 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 <= -2.8e-22) tmp = x + (abs(y) / 2.0); elseif (y <= 5.5e-30) tmp = x + (abs(x) / 2.0); else tmp = 0.5 * (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.8e-22], N[(x + N[(N[Abs[y], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.5e-30], 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 -2.8 \cdot 10^{-22}:\\
\;\;\;\;x + \frac{\left|y\right|}{2}\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{-30}:\\
\;\;\;\;x + \frac{\left|x\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < -2.79999999999999995e-22Initial program 99.9%
Taylor expanded in y around inf 77.4%
if -2.79999999999999995e-22 < y < 5.49999999999999976e-30Initial program 99.9%
Taylor expanded in y around 0 87.7%
neg-mul-187.7%
Simplified87.7%
if 5.49999999999999976e-30 < y Initial program 99.9%
Taylor expanded in x around inf 82.4%
add-cube-cbrt81.1%
unpow281.1%
mul-fabs81.1%
clear-num81.1%
un-div-inv81.1%
unpow281.1%
fabs-sqr81.1%
add-sqr-sqrt69.5%
fabs-sqr69.5%
add-sqr-sqrt71.8%
add-cube-cbrt72.9%
Applied egg-rr72.9%
associate-/r/72.9%
Simplified72.9%
Taylor expanded in x around 0 90.6%
distribute-lft-out90.6%
+-commutative90.6%
Simplified90.6%
Final simplification86.0%
(FPCore (x y)
:precision binary64
(if (<= x -3e-21)
(* 0.5 (+ x y))
(if (<= x 1.18e-120)
(+ x (/ (fabs y) 2.0))
(- x (/ -1.0 (/ 2.0 (+ x y)))))))
double code(double x, double y) {
double tmp;
if (x <= -3e-21) {
tmp = 0.5 * (x + y);
} else if (x <= 1.18e-120) {
tmp = x + (fabs(y) / 2.0);
} else {
tmp = x - (-1.0 / (2.0 / (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 <= (-3d-21)) then
tmp = 0.5d0 * (x + y)
else if (x <= 1.18d-120) then
tmp = x + (abs(y) / 2.0d0)
else
tmp = x - ((-1.0d0) / (2.0d0 / (x + y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -3e-21) {
tmp = 0.5 * (x + y);
} else if (x <= 1.18e-120) {
tmp = x + (Math.abs(y) / 2.0);
} else {
tmp = x - (-1.0 / (2.0 / (x + y)));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3e-21: tmp = 0.5 * (x + y) elif x <= 1.18e-120: tmp = x + (math.fabs(y) / 2.0) else: tmp = x - (-1.0 / (2.0 / (x + y))) return tmp
function code(x, y) tmp = 0.0 if (x <= -3e-21) tmp = Float64(0.5 * Float64(x + y)); elseif (x <= 1.18e-120) tmp = Float64(x + Float64(abs(y) / 2.0)); else tmp = Float64(x - Float64(-1.0 / Float64(2.0 / Float64(x + y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3e-21) tmp = 0.5 * (x + y); elseif (x <= 1.18e-120) tmp = x + (abs(y) / 2.0); else tmp = x - (-1.0 / (2.0 / (x + y))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3e-21], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.18e-120], N[(x + N[(N[Abs[y], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], N[(x - N[(-1.0 / N[(2.0 / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3 \cdot 10^{-21}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\mathbf{elif}\;x \leq 1.18 \cdot 10^{-120}:\\
\;\;\;\;x + \frac{\left|y\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{-1}{\frac{2}{x + y}}\\
\end{array}
\end{array}
if x < -2.99999999999999991e-21Initial program 100.0%
Taylor expanded in x around inf 99.9%
add-cube-cbrt98.0%
unpow298.0%
mul-fabs98.0%
clear-num97.7%
un-div-inv97.7%
unpow297.7%
fabs-sqr97.7%
add-sqr-sqrt81.5%
fabs-sqr81.5%
add-sqr-sqrt81.7%
add-cube-cbrt83.6%
Applied egg-rr83.6%
associate-/r/83.6%
Simplified83.6%
Taylor expanded in x around 0 83.6%
distribute-lft-out83.6%
+-commutative83.6%
Simplified83.6%
if -2.99999999999999991e-21 < x < 1.17999999999999999e-120Initial program 100.0%
Taylor expanded in y around inf 81.1%
if 1.17999999999999999e-120 < x Initial program 99.8%
add-cube-cbrt98.7%
fabs-mul98.7%
pow298.7%
Applied egg-rr98.7%
add-sqr-sqrt20.4%
fabs-sqr20.4%
add-sqr-sqrt98.7%
flip--51.3%
unpow251.3%
unpow251.3%
div-fabs51.3%
clear-num51.3%
cbrt-div51.4%
metadata-eval51.4%
add-sqr-sqrt48.9%
fabs-sqr48.9%
add-sqr-sqrt51.4%
add-sqr-sqrt10.0%
fabs-sqr10.0%
add-sqr-sqrt51.4%
Applied egg-rr98.9%
clear-num98.9%
inv-pow98.9%
mul-fabs98.9%
cbrt-div98.7%
metadata-eval98.7%
Applied egg-rr98.7%
fabs-mul98.7%
unpow298.7%
fabs-sqr98.7%
unpow298.7%
remove-double-div98.7%
unpow-198.7%
unpow298.7%
fabs-sqr98.7%
unpow298.7%
Simplified99.7%
*-un-lft-identity99.7%
add-sqr-sqrt20.8%
fabs-sqr20.8%
add-sqr-sqrt33.7%
sub-neg33.7%
add-sqr-sqrt0.0%
sqrt-unprod60.2%
sqr-neg60.2%
sqrt-prod92.1%
add-sqr-sqrt92.2%
Applied egg-rr92.2%
*-lft-identity92.2%
Simplified92.2%
Final simplification85.6%
(FPCore (x y) :precision binary64 (if (<= x -3.3e-190) (* 0.5 (+ x y)) (if (<= x 6e-114) (* (fabs y) 0.5) (- x (/ -1.0 (/ 2.0 (+ x y)))))))
double code(double x, double y) {
double tmp;
if (x <= -3.3e-190) {
tmp = 0.5 * (x + y);
} else if (x <= 6e-114) {
tmp = fabs(y) * 0.5;
} else {
tmp = x - (-1.0 / (2.0 / (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 <= (-3.3d-190)) then
tmp = 0.5d0 * (x + y)
else if (x <= 6d-114) then
tmp = abs(y) * 0.5d0
else
tmp = x - ((-1.0d0) / (2.0d0 / (x + y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -3.3e-190) {
tmp = 0.5 * (x + y);
} else if (x <= 6e-114) {
tmp = Math.abs(y) * 0.5;
} else {
tmp = x - (-1.0 / (2.0 / (x + y)));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3.3e-190: tmp = 0.5 * (x + y) elif x <= 6e-114: tmp = math.fabs(y) * 0.5 else: tmp = x - (-1.0 / (2.0 / (x + y))) return tmp
function code(x, y) tmp = 0.0 if (x <= -3.3e-190) tmp = Float64(0.5 * Float64(x + y)); elseif (x <= 6e-114) tmp = Float64(abs(y) * 0.5); else tmp = Float64(x - Float64(-1.0 / Float64(2.0 / Float64(x + y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3.3e-190) tmp = 0.5 * (x + y); elseif (x <= 6e-114) tmp = abs(y) * 0.5; else tmp = x - (-1.0 / (2.0 / (x + y))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3.3e-190], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6e-114], N[(N[Abs[y], $MachinePrecision] * 0.5), $MachinePrecision], N[(x - N[(-1.0 / N[(2.0 / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.3 \cdot 10^{-190}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\mathbf{elif}\;x \leq 6 \cdot 10^{-114}:\\
\;\;\;\;\left|y\right| \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x - \frac{-1}{\frac{2}{x + y}}\\
\end{array}
\end{array}
if x < -3.30000000000000019e-190Initial program 100.0%
Taylor expanded in x around inf 98.4%
add-cube-cbrt96.5%
unpow296.5%
mul-fabs96.5%
clear-num96.3%
un-div-inv96.3%
unpow296.3%
fabs-sqr96.3%
add-sqr-sqrt76.2%
fabs-sqr76.2%
add-sqr-sqrt76.5%
add-cube-cbrt78.2%
Applied egg-rr78.2%
associate-/r/78.2%
Simplified78.2%
Taylor expanded in x around 0 78.2%
distribute-lft-out78.2%
+-commutative78.2%
Simplified78.2%
if -3.30000000000000019e-190 < x < 6.0000000000000003e-114Initial program 99.9%
Taylor expanded in y around inf 88.1%
Taylor expanded in x around 0 86.3%
if 6.0000000000000003e-114 < x Initial program 99.8%
add-cube-cbrt98.7%
fabs-mul98.7%
pow298.7%
Applied egg-rr98.7%
add-sqr-sqrt20.4%
fabs-sqr20.4%
add-sqr-sqrt98.7%
flip--51.3%
unpow251.3%
unpow251.3%
div-fabs51.3%
clear-num51.3%
cbrt-div51.4%
metadata-eval51.4%
add-sqr-sqrt48.9%
fabs-sqr48.9%
add-sqr-sqrt51.4%
add-sqr-sqrt10.0%
fabs-sqr10.0%
add-sqr-sqrt51.4%
Applied egg-rr98.9%
clear-num98.9%
inv-pow98.9%
mul-fabs98.9%
cbrt-div98.7%
metadata-eval98.7%
Applied egg-rr98.7%
fabs-mul98.7%
unpow298.7%
fabs-sqr98.7%
unpow298.7%
remove-double-div98.7%
unpow-198.7%
unpow298.7%
fabs-sqr98.7%
unpow298.7%
Simplified99.7%
*-un-lft-identity99.7%
add-sqr-sqrt20.8%
fabs-sqr20.8%
add-sqr-sqrt33.7%
sub-neg33.7%
add-sqr-sqrt0.0%
sqrt-unprod60.2%
sqr-neg60.2%
sqrt-prod92.1%
add-sqr-sqrt92.2%
Applied egg-rr92.2%
*-lft-identity92.2%
Simplified92.2%
Final simplification84.7%
(FPCore (x y) :precision binary64 (if (<= x -1.18e-268) (* 0.5 (+ x y)) (- x (/ -1.0 (/ 2.0 (+ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -1.18e-268) {
tmp = 0.5 * (x + y);
} else {
tmp = x - (-1.0 / (2.0 / (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.18d-268)) then
tmp = 0.5d0 * (x + y)
else
tmp = x - ((-1.0d0) / (2.0d0 / (x + y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.18e-268) {
tmp = 0.5 * (x + y);
} else {
tmp = x - (-1.0 / (2.0 / (x + y)));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.18e-268: tmp = 0.5 * (x + y) else: tmp = x - (-1.0 / (2.0 / (x + y))) return tmp
function code(x, y) tmp = 0.0 if (x <= -1.18e-268) tmp = Float64(0.5 * Float64(x + y)); else tmp = Float64(x - Float64(-1.0 / Float64(2.0 / Float64(x + y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.18e-268) tmp = 0.5 * (x + y); else tmp = x - (-1.0 / (2.0 / (x + y))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.18e-268], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x - N[(-1.0 / N[(2.0 / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.18 \cdot 10^{-268}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{-1}{\frac{2}{x + y}}\\
\end{array}
\end{array}
if x < -1.18e-268Initial program 100.0%
Taylor expanded in x around inf 94.3%
add-cube-cbrt92.4%
unpow292.4%
mul-fabs92.4%
clear-num92.2%
un-div-inv92.2%
unpow292.2%
fabs-sqr92.2%
add-sqr-sqrt70.8%
fabs-sqr70.8%
add-sqr-sqrt71.2%
add-cube-cbrt72.7%
Applied egg-rr72.7%
associate-/r/72.7%
Simplified72.7%
Taylor expanded in x around 0 76.4%
distribute-lft-out76.4%
+-commutative76.4%
Simplified76.4%
if -1.18e-268 < x Initial program 99.8%
add-cube-cbrt98.4%
fabs-mul98.4%
pow298.4%
Applied egg-rr98.4%
add-sqr-sqrt24.9%
fabs-sqr24.9%
add-sqr-sqrt98.4%
flip--55.5%
unpow255.5%
unpow255.5%
div-fabs55.5%
clear-num55.5%
cbrt-div55.7%
metadata-eval55.7%
add-sqr-sqrt42.0%
fabs-sqr42.0%
add-sqr-sqrt55.7%
add-sqr-sqrt25.9%
fabs-sqr25.9%
add-sqr-sqrt55.7%
Applied egg-rr98.6%
clear-num98.6%
inv-pow98.6%
mul-fabs98.6%
cbrt-div98.4%
metadata-eval98.4%
Applied egg-rr98.4%
fabs-mul98.4%
unpow298.4%
fabs-sqr98.4%
unpow298.4%
remove-double-div98.4%
unpow-198.4%
unpow298.4%
fabs-sqr98.4%
unpow298.4%
Simplified99.7%
*-un-lft-identity99.7%
add-sqr-sqrt25.2%
fabs-sqr25.2%
add-sqr-sqrt35.1%
sub-neg35.1%
add-sqr-sqrt3.2%
sqrt-unprod54.5%
sqr-neg54.5%
sqrt-prod74.9%
add-sqr-sqrt78.2%
Applied egg-rr78.2%
*-lft-identity78.2%
Simplified78.2%
Final simplification77.3%
(FPCore (x y) :precision binary64 (if (<= x -6.8e-192) (* x 0.5) (if (<= x 1.25e-129) (* y 0.5) (* x 1.5))))
double code(double x, double y) {
double tmp;
if (x <= -6.8e-192) {
tmp = x * 0.5;
} else if (x <= 1.25e-129) {
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 <= (-6.8d-192)) then
tmp = x * 0.5d0
else if (x <= 1.25d-129) 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 <= -6.8e-192) {
tmp = x * 0.5;
} else if (x <= 1.25e-129) {
tmp = y * 0.5;
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -6.8e-192: tmp = x * 0.5 elif x <= 1.25e-129: tmp = y * 0.5 else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -6.8e-192) tmp = Float64(x * 0.5); elseif (x <= 1.25e-129) 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 <= -6.8e-192) tmp = x * 0.5; elseif (x <= 1.25e-129) tmp = y * 0.5; else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -6.8e-192], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 1.25e-129], N[(y * 0.5), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.8 \cdot 10^{-192}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{-129}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -6.80000000000000003e-192Initial program 100.0%
Taylor expanded in x around inf 98.4%
add-cube-cbrt96.5%
unpow296.5%
mul-fabs96.5%
clear-num96.3%
un-div-inv96.3%
unpow296.3%
fabs-sqr96.3%
add-sqr-sqrt75.5%
fabs-sqr75.5%
add-sqr-sqrt75.9%
add-cube-cbrt77.5%
Applied egg-rr77.5%
associate-/r/77.5%
Simplified77.5%
Taylor expanded in x around inf 61.5%
if -6.80000000000000003e-192 < x < 1.25000000000000007e-129Initial program 99.9%
Taylor expanded in y around inf 87.2%
Taylor expanded in x around 0 85.2%
rem-square-sqrt40.0%
fabs-sqr40.0%
rem-square-sqrt41.8%
Simplified41.8%
if 1.25000000000000007e-129 < x Initial program 99.8%
Taylor expanded in y around 0 71.1%
neg-mul-171.1%
Simplified71.1%
Taylor expanded in x around 0 71.1%
fabs-neg71.1%
rem-square-sqrt71.0%
fabs-sqr71.0%
rem-square-sqrt71.1%
*-commutative71.1%
*-rgt-identity71.1%
distribute-lft-out71.1%
metadata-eval71.1%
Simplified71.1%
Final simplification60.8%
(FPCore (x y) :precision binary64 (if (<= x 1.25e-129) (* 0.5 (+ x y)) (* x 1.5)))
double code(double x, double y) {
double tmp;
if (x <= 1.25e-129) {
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 <= 1.25d-129) 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 <= 1.25e-129) {
tmp = 0.5 * (x + y);
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.25e-129: tmp = 0.5 * (x + y) else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= 1.25e-129) 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 <= 1.25e-129) tmp = 0.5 * (x + y); else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.25e-129], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.25 \cdot 10^{-129}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < 1.25000000000000007e-129Initial program 100.0%
Taylor expanded in x around inf 87.6%
add-cube-cbrt86.0%
unpow286.0%
mul-fabs86.0%
clear-num85.8%
un-div-inv85.8%
unpow285.8%
fabs-sqr85.8%
add-sqr-sqrt59.0%
fabs-sqr59.0%
add-sqr-sqrt60.0%
add-cube-cbrt61.2%
Applied egg-rr61.2%
associate-/r/61.2%
Simplified61.2%
Taylor expanded in x around 0 68.6%
distribute-lft-out68.6%
+-commutative68.6%
Simplified68.6%
if 1.25000000000000007e-129 < x Initial program 99.8%
Taylor expanded in y around 0 71.1%
neg-mul-171.1%
Simplified71.1%
Taylor expanded in x around 0 71.1%
fabs-neg71.1%
rem-square-sqrt71.0%
fabs-sqr71.0%
rem-square-sqrt71.1%
*-commutative71.1%
*-rgt-identity71.1%
distribute-lft-out71.1%
metadata-eval71.1%
Simplified71.1%
Final simplification69.5%
(FPCore (x y) :precision binary64 (if (<= y 2.7e-10) (* x 0.5) (* y 0.5)))
double code(double x, double y) {
double tmp;
if (y <= 2.7e-10) {
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 <= 2.7d-10) 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 <= 2.7e-10) {
tmp = x * 0.5;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 2.7e-10: tmp = x * 0.5 else: tmp = y * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= 2.7e-10) 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 <= 2.7e-10) tmp = x * 0.5; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 2.7e-10], N[(x * 0.5), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.7 \cdot 10^{-10}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < 2.7e-10Initial program 99.9%
Taylor expanded in x around inf 94.9%
add-cube-cbrt93.5%
unpow293.5%
mul-fabs93.5%
clear-num93.3%
un-div-inv93.3%
unpow293.3%
fabs-sqr93.3%
add-sqr-sqrt37.2%
fabs-sqr37.2%
add-sqr-sqrt43.1%
add-cube-cbrt44.0%
Applied egg-rr44.0%
associate-/r/44.0%
Simplified44.0%
Taylor expanded in x around inf 42.1%
if 2.7e-10 < y Initial program 99.9%
Taylor expanded in y around inf 82.1%
Taylor expanded in x around 0 78.7%
rem-square-sqrt78.1%
fabs-sqr78.1%
rem-square-sqrt78.7%
Simplified78.7%
Final simplification51.6%
(FPCore (x y) :precision binary64 (if (<= y 5.5e-30) x (* y 0.5)))
double code(double x, double y) {
double tmp;
if (y <= 5.5e-30) {
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 <= 5.5d-30) 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 <= 5.5e-30) {
tmp = x;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 5.5e-30: tmp = x else: tmp = y * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= 5.5e-30) tmp = x; else tmp = Float64(y * 0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 5.5e-30) tmp = x; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 5.5e-30], x, N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.5 \cdot 10^{-30}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < 5.49999999999999976e-30Initial program 99.9%
Taylor expanded in x around inf 14.0%
if 5.49999999999999976e-30 < y Initial program 99.9%
Taylor expanded in y around inf 80.5%
Taylor expanded in x around 0 76.8%
rem-square-sqrt76.2%
fabs-sqr76.2%
rem-square-sqrt76.8%
Simplified76.8%
Final simplification31.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 2024137
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
:precision binary64
(+ x (/ (fabs (- y x)) 2.0)))