
(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 -5.8e+41) (+ x (/ (fabs y) 2.0)) (if (<= y 6e-150) (+ x (/ (fabs x) 2.0)) (* 0.5 (+ x y)))))
double code(double x, double y) {
double tmp;
if (y <= -5.8e+41) {
tmp = x + (fabs(y) / 2.0);
} else if (y <= 6e-150) {
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 <= (-5.8d+41)) then
tmp = x + (abs(y) / 2.0d0)
else if (y <= 6d-150) 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 <= -5.8e+41) {
tmp = x + (Math.abs(y) / 2.0);
} else if (y <= 6e-150) {
tmp = x + (Math.abs(x) / 2.0);
} else {
tmp = 0.5 * (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -5.8e+41: tmp = x + (math.fabs(y) / 2.0) elif y <= 6e-150: tmp = x + (math.fabs(x) / 2.0) else: tmp = 0.5 * (x + y) return tmp
function code(x, y) tmp = 0.0 if (y <= -5.8e+41) tmp = Float64(x + Float64(abs(y) / 2.0)); elseif (y <= 6e-150) 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 <= -5.8e+41) tmp = x + (abs(y) / 2.0); elseif (y <= 6e-150) tmp = x + (abs(x) / 2.0); else tmp = 0.5 * (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -5.8e+41], N[(x + N[(N[Abs[y], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6e-150], 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 -5.8 \cdot 10^{+41}:\\
\;\;\;\;x + \frac{\left|y\right|}{2}\\
\mathbf{elif}\;y \leq 6 \cdot 10^{-150}:\\
\;\;\;\;x + \frac{\left|x\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\end{array}
\end{array}
if y < -5.79999999999999977e41Initial program 100.0%
Taylor expanded in y around inf 83.1%
if -5.79999999999999977e41 < y < 6.0000000000000003e-150Initial program 99.9%
Taylor expanded in y around 0 83.8%
neg-mul-183.8%
Simplified83.8%
if 6.0000000000000003e-150 < y Initial program 99.9%
clear-num99.6%
inv-pow99.6%
add-sqr-sqrt79.4%
fabs-sqr79.4%
add-sqr-sqrt83.4%
Applied egg-rr83.4%
Taylor expanded in x around 0 83.7%
distribute-lft-out83.7%
+-commutative83.7%
Simplified83.7%
Final simplification83.6%
(FPCore (x y)
:precision binary64
(if (<= x -62000000000000.0)
(* 0.5 (+ x y))
(if (<= x 5.5e-174)
(+ x (/ (fabs y) 2.0))
(if (<= x 2.05e+37) (* y (+ 0.5 (/ (* x 1.5) y))) (* x 1.5)))))
double code(double x, double y) {
double tmp;
if (x <= -62000000000000.0) {
tmp = 0.5 * (x + y);
} else if (x <= 5.5e-174) {
tmp = x + (fabs(y) / 2.0);
} else if (x <= 2.05e+37) {
tmp = y * (0.5 + ((x * 1.5) / 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 <= (-62000000000000.0d0)) then
tmp = 0.5d0 * (x + y)
else if (x <= 5.5d-174) then
tmp = x + (abs(y) / 2.0d0)
else if (x <= 2.05d+37) then
tmp = y * (0.5d0 + ((x * 1.5d0) / y))
else
tmp = x * 1.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -62000000000000.0) {
tmp = 0.5 * (x + y);
} else if (x <= 5.5e-174) {
tmp = x + (Math.abs(y) / 2.0);
} else if (x <= 2.05e+37) {
tmp = y * (0.5 + ((x * 1.5) / y));
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -62000000000000.0: tmp = 0.5 * (x + y) elif x <= 5.5e-174: tmp = x + (math.fabs(y) / 2.0) elif x <= 2.05e+37: tmp = y * (0.5 + ((x * 1.5) / y)) else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -62000000000000.0) tmp = Float64(0.5 * Float64(x + y)); elseif (x <= 5.5e-174) tmp = Float64(x + Float64(abs(y) / 2.0)); elseif (x <= 2.05e+37) tmp = Float64(y * Float64(0.5 + Float64(Float64(x * 1.5) / y))); else tmp = Float64(x * 1.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -62000000000000.0) tmp = 0.5 * (x + y); elseif (x <= 5.5e-174) tmp = x + (abs(y) / 2.0); elseif (x <= 2.05e+37) tmp = y * (0.5 + ((x * 1.5) / y)); else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -62000000000000.0], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.5e-174], N[(x + N[(N[Abs[y], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.05e+37], N[(y * N[(0.5 + N[(N[(x * 1.5), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -62000000000000:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-174}:\\
\;\;\;\;x + \frac{\left|y\right|}{2}\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{+37}:\\
\;\;\;\;y \cdot \left(0.5 + \frac{x \cdot 1.5}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -6.2e13Initial program 100.0%
clear-num99.8%
inv-pow99.8%
add-sqr-sqrt88.3%
fabs-sqr88.3%
add-sqr-sqrt89.1%
Applied egg-rr89.1%
Taylor expanded in x around 0 89.3%
distribute-lft-out89.3%
+-commutative89.3%
Simplified89.3%
if -6.2e13 < x < 5.4999999999999999e-174Initial program 100.0%
Taylor expanded in y around inf 82.4%
if 5.4999999999999999e-174 < x < 2.0499999999999999e37Initial program 99.8%
add-sqr-sqrt99.4%
pow299.4%
div-inv99.4%
add-sqr-sqrt44.5%
fabs-sqr44.5%
add-sqr-sqrt44.6%
metadata-eval44.6%
Applied egg-rr44.6%
add-sqr-sqrt44.5%
fabs-sqr44.5%
add-sqr-sqrt99.4%
fabs-sub99.4%
Applied egg-rr99.4%
sqrt-prod98.8%
unpow-prod-down98.6%
pow298.6%
add-sqr-sqrt98.6%
fabs-sub98.6%
add-sqr-sqrt44.0%
fabs-sqr44.0%
add-sqr-sqrt51.8%
sub-neg51.8%
add-sqr-sqrt0.0%
sqrt-unprod81.3%
sqr-neg81.3%
sqrt-unprod83.2%
add-sqr-sqrt83.2%
+-commutative83.2%
Applied egg-rr83.2%
Taylor expanded in y around -inf 83.2%
mul-1-neg83.2%
distribute-rgt-neg-in83.2%
distribute-lft-out83.2%
mul-1-neg83.2%
remove-double-neg83.2%
unpow283.2%
rem-square-sqrt83.9%
+-commutative83.9%
*-lft-identity83.9%
*-commutative83.9%
unpow283.9%
rem-square-sqrt84.1%
distribute-rgt-in84.1%
metadata-eval84.1%
Simplified84.1%
if 2.0499999999999999e37 < x Initial program 99.7%
Taylor expanded in y around 0 76.9%
neg-mul-176.9%
Simplified76.9%
Taylor expanded in x around 0 76.9%
*-commutative76.9%
fabs-neg76.9%
rem-square-sqrt77.0%
fabs-sqr77.0%
rem-square-sqrt76.9%
*-rgt-identity76.9%
distribute-lft-out76.9%
metadata-eval76.9%
Simplified76.9%
Final simplification83.5%
(FPCore (x y)
:precision binary64
(if (<= x -48000000000000.0)
(* 0.5 (+ x y))
(if (<= x 5e-174)
(* (fabs y) 0.5)
(if (<= x 2.05e+37) (* y (+ 0.5 (/ (* x 1.5) y))) (* x 1.5)))))
double code(double x, double y) {
double tmp;
if (x <= -48000000000000.0) {
tmp = 0.5 * (x + y);
} else if (x <= 5e-174) {
tmp = fabs(y) * 0.5;
} else if (x <= 2.05e+37) {
tmp = y * (0.5 + ((x * 1.5) / 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 <= (-48000000000000.0d0)) then
tmp = 0.5d0 * (x + y)
else if (x <= 5d-174) then
tmp = abs(y) * 0.5d0
else if (x <= 2.05d+37) then
tmp = y * (0.5d0 + ((x * 1.5d0) / y))
else
tmp = x * 1.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -48000000000000.0) {
tmp = 0.5 * (x + y);
} else if (x <= 5e-174) {
tmp = Math.abs(y) * 0.5;
} else if (x <= 2.05e+37) {
tmp = y * (0.5 + ((x * 1.5) / y));
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -48000000000000.0: tmp = 0.5 * (x + y) elif x <= 5e-174: tmp = math.fabs(y) * 0.5 elif x <= 2.05e+37: tmp = y * (0.5 + ((x * 1.5) / y)) else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -48000000000000.0) tmp = Float64(0.5 * Float64(x + y)); elseif (x <= 5e-174) tmp = Float64(abs(y) * 0.5); elseif (x <= 2.05e+37) tmp = Float64(y * Float64(0.5 + Float64(Float64(x * 1.5) / y))); else tmp = Float64(x * 1.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -48000000000000.0) tmp = 0.5 * (x + y); elseif (x <= 5e-174) tmp = abs(y) * 0.5; elseif (x <= 2.05e+37) tmp = y * (0.5 + ((x * 1.5) / y)); else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -48000000000000.0], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5e-174], N[(N[Abs[y], $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2.05e+37], N[(y * N[(0.5 + N[(N[(x * 1.5), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -48000000000000:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-174}:\\
\;\;\;\;\left|y\right| \cdot 0.5\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{+37}:\\
\;\;\;\;y \cdot \left(0.5 + \frac{x \cdot 1.5}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -4.8e13Initial program 100.0%
clear-num99.8%
inv-pow99.8%
add-sqr-sqrt88.3%
fabs-sqr88.3%
add-sqr-sqrt89.1%
Applied egg-rr89.1%
Taylor expanded in x around 0 89.3%
distribute-lft-out89.3%
+-commutative89.3%
Simplified89.3%
if -4.8e13 < x < 5.0000000000000002e-174Initial program 100.0%
Taylor expanded in y around inf 82.4%
Taylor expanded in x around 0 79.8%
if 5.0000000000000002e-174 < x < 2.0499999999999999e37Initial program 99.8%
add-sqr-sqrt99.4%
pow299.4%
div-inv99.4%
add-sqr-sqrt44.5%
fabs-sqr44.5%
add-sqr-sqrt44.6%
metadata-eval44.6%
Applied egg-rr44.6%
add-sqr-sqrt44.5%
fabs-sqr44.5%
add-sqr-sqrt99.4%
fabs-sub99.4%
Applied egg-rr99.4%
sqrt-prod98.8%
unpow-prod-down98.6%
pow298.6%
add-sqr-sqrt98.6%
fabs-sub98.6%
add-sqr-sqrt44.0%
fabs-sqr44.0%
add-sqr-sqrt51.8%
sub-neg51.8%
add-sqr-sqrt0.0%
sqrt-unprod81.3%
sqr-neg81.3%
sqrt-unprod83.2%
add-sqr-sqrt83.2%
+-commutative83.2%
Applied egg-rr83.2%
Taylor expanded in y around -inf 83.2%
mul-1-neg83.2%
distribute-rgt-neg-in83.2%
distribute-lft-out83.2%
mul-1-neg83.2%
remove-double-neg83.2%
unpow283.2%
rem-square-sqrt83.9%
+-commutative83.9%
*-lft-identity83.9%
*-commutative83.9%
unpow283.9%
rem-square-sqrt84.1%
distribute-rgt-in84.1%
metadata-eval84.1%
Simplified84.1%
if 2.0499999999999999e37 < x Initial program 99.7%
Taylor expanded in y around 0 76.9%
neg-mul-176.9%
Simplified76.9%
Taylor expanded in x around 0 76.9%
*-commutative76.9%
fabs-neg76.9%
rem-square-sqrt77.0%
fabs-sqr77.0%
rem-square-sqrt76.9%
*-rgt-identity76.9%
distribute-lft-out76.9%
metadata-eval76.9%
Simplified76.9%
Final simplification82.6%
(FPCore (x y) :precision binary64 (if (<= x 1e-227) (* 0.5 (+ x y)) (if (<= x 1.55e+37) (* y (+ 0.5 (/ (* x 1.5) y))) (* x 1.5))))
double code(double x, double y) {
double tmp;
if (x <= 1e-227) {
tmp = 0.5 * (x + y);
} else if (x <= 1.55e+37) {
tmp = y * (0.5 + ((x * 1.5) / 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 <= 1d-227) then
tmp = 0.5d0 * (x + y)
else if (x <= 1.55d+37) then
tmp = y * (0.5d0 + ((x * 1.5d0) / y))
else
tmp = x * 1.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 1e-227) {
tmp = 0.5 * (x + y);
} else if (x <= 1.55e+37) {
tmp = y * (0.5 + ((x * 1.5) / y));
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1e-227: tmp = 0.5 * (x + y) elif x <= 1.55e+37: tmp = y * (0.5 + ((x * 1.5) / y)) else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= 1e-227) tmp = Float64(0.5 * Float64(x + y)); elseif (x <= 1.55e+37) tmp = Float64(y * Float64(0.5 + Float64(Float64(x * 1.5) / y))); else tmp = Float64(x * 1.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1e-227) tmp = 0.5 * (x + y); elseif (x <= 1.55e+37) tmp = y * (0.5 + ((x * 1.5) / y)); else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1e-227], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.55e+37], N[(y * N[(0.5 + N[(N[(x * 1.5), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{-227}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{+37}:\\
\;\;\;\;y \cdot \left(0.5 + \frac{x \cdot 1.5}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < 9.99999999999999945e-228Initial program 100.0%
clear-num99.7%
inv-pow99.7%
add-sqr-sqrt73.6%
fabs-sqr73.6%
add-sqr-sqrt74.5%
Applied egg-rr74.5%
Taylor expanded in x around 0 74.8%
distribute-lft-out74.8%
+-commutative74.8%
Simplified74.8%
if 9.99999999999999945e-228 < x < 1.5500000000000001e37Initial program 99.8%
add-sqr-sqrt99.4%
pow299.4%
div-inv99.4%
add-sqr-sqrt34.8%
fabs-sqr34.8%
add-sqr-sqrt34.8%
metadata-eval34.8%
Applied egg-rr34.8%
add-sqr-sqrt34.8%
fabs-sqr34.8%
add-sqr-sqrt99.4%
fabs-sub99.4%
Applied egg-rr99.4%
sqrt-prod98.8%
unpow-prod-down98.6%
pow298.6%
add-sqr-sqrt98.6%
fabs-sub98.6%
add-sqr-sqrt34.4%
fabs-sqr34.4%
add-sqr-sqrt41.4%
sub-neg41.4%
add-sqr-sqrt0.0%
sqrt-unprod63.4%
sqr-neg63.4%
sqrt-unprod68.5%
add-sqr-sqrt68.5%
+-commutative68.5%
Applied egg-rr68.5%
Taylor expanded in y around -inf 68.5%
mul-1-neg68.5%
distribute-rgt-neg-in68.5%
distribute-lft-out68.5%
mul-1-neg68.5%
remove-double-neg68.5%
unpow268.5%
rem-square-sqrt69.1%
+-commutative69.1%
*-lft-identity69.1%
*-commutative69.1%
unpow269.1%
rem-square-sqrt69.2%
distribute-rgt-in69.2%
metadata-eval69.2%
Simplified69.2%
if 1.5500000000000001e37 < x Initial program 99.7%
Taylor expanded in y around 0 76.9%
neg-mul-176.9%
Simplified76.9%
Taylor expanded in x around 0 76.9%
*-commutative76.9%
fabs-neg76.9%
rem-square-sqrt77.0%
fabs-sqr77.0%
rem-square-sqrt76.9%
*-rgt-identity76.9%
distribute-lft-out76.9%
metadata-eval76.9%
Simplified76.9%
Final simplification74.0%
(FPCore (x y) :precision binary64 (if (<= x -1.35e-78) (* x 0.5) (if (<= x 8.8e-103) (* y 0.5) (* x 1.5))))
double code(double x, double y) {
double tmp;
if (x <= -1.35e-78) {
tmp = x * 0.5;
} else if (x <= 8.8e-103) {
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.35d-78)) then
tmp = x * 0.5d0
else if (x <= 8.8d-103) 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.35e-78) {
tmp = x * 0.5;
} else if (x <= 8.8e-103) {
tmp = y * 0.5;
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.35e-78: tmp = x * 0.5 elif x <= 8.8e-103: tmp = y * 0.5 else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -1.35e-78) tmp = Float64(x * 0.5); elseif (x <= 8.8e-103) 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.35e-78) tmp = x * 0.5; elseif (x <= 8.8e-103) tmp = y * 0.5; else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.35e-78], N[(x * 0.5), $MachinePrecision], If[LessEqual[x, 8.8e-103], N[(y * 0.5), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{-78}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;x \leq 8.8 \cdot 10^{-103}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -1.34999999999999997e-78Initial program 100.0%
clear-num99.7%
inv-pow99.7%
add-sqr-sqrt81.8%
fabs-sqr81.8%
add-sqr-sqrt82.6%
Applied egg-rr82.6%
Taylor expanded in x around inf 68.1%
if -1.34999999999999997e-78 < x < 8.7999999999999997e-103Initial program 100.0%
Taylor expanded in y around inf 83.5%
Taylor expanded in x around 0 81.4%
rem-square-sqrt44.1%
fabs-sqr44.1%
rem-square-sqrt45.7%
Simplified45.7%
if 8.7999999999999997e-103 < x Initial program 99.7%
Taylor expanded in y around 0 71.4%
neg-mul-171.4%
Simplified71.4%
Taylor expanded in x around 0 71.4%
*-commutative71.4%
fabs-neg71.4%
rem-square-sqrt71.5%
fabs-sqr71.5%
rem-square-sqrt71.4%
*-rgt-identity71.4%
distribute-lft-out71.4%
metadata-eval71.4%
Simplified71.4%
Final simplification61.3%
(FPCore (x y) :precision binary64 (if (<= x 3.6e-104) (* 0.5 (+ x y)) (* x 1.5)))
double code(double x, double y) {
double tmp;
if (x <= 3.6e-104) {
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 <= 3.6d-104) 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 <= 3.6e-104) {
tmp = 0.5 * (x + y);
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 3.6e-104: tmp = 0.5 * (x + y) else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= 3.6e-104) 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 <= 3.6e-104) tmp = 0.5 * (x + y); else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 3.6e-104], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.6 \cdot 10^{-104}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < 3.5999999999999998e-104Initial program 100.0%
clear-num99.7%
inv-pow99.7%
add-sqr-sqrt68.7%
fabs-sqr68.7%
add-sqr-sqrt70.0%
Applied egg-rr70.0%
Taylor expanded in x around 0 70.3%
distribute-lft-out70.3%
+-commutative70.3%
Simplified70.3%
if 3.5999999999999998e-104 < x Initial program 99.7%
Taylor expanded in y around 0 71.4%
neg-mul-171.4%
Simplified71.4%
Taylor expanded in x around 0 71.4%
*-commutative71.4%
fabs-neg71.4%
rem-square-sqrt71.5%
fabs-sqr71.5%
rem-square-sqrt71.4%
*-rgt-identity71.4%
distribute-lft-out71.4%
metadata-eval71.4%
Simplified71.4%
Final simplification70.6%
(FPCore (x y) :precision binary64 (if (<= y 5.3e-137) (* x 0.5) (* y 0.5)))
double code(double x, double y) {
double tmp;
if (y <= 5.3e-137) {
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 <= 5.3d-137) 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 <= 5.3e-137) {
tmp = x * 0.5;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 5.3e-137: tmp = x * 0.5 else: tmp = y * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= 5.3e-137) 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 <= 5.3e-137) tmp = x * 0.5; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 5.3e-137], N[(x * 0.5), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.3 \cdot 10^{-137}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < 5.30000000000000037e-137Initial program 99.9%
clear-num99.7%
inv-pow99.7%
add-sqr-sqrt33.9%
fabs-sqr33.9%
add-sqr-sqrt39.3%
Applied egg-rr39.3%
Taylor expanded in x around inf 37.3%
if 5.30000000000000037e-137 < y Initial program 99.9%
Taylor expanded in y around inf 68.1%
Taylor expanded in x around 0 62.1%
rem-square-sqrt61.7%
fabs-sqr61.7%
rem-square-sqrt62.1%
Simplified62.1%
Final simplification46.8%
(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%
clear-num99.7%
inv-pow99.7%
add-sqr-sqrt51.5%
fabs-sqr51.5%
add-sqr-sqrt56.3%
Applied egg-rr56.3%
Taylor expanded in x around inf 31.9%
Final simplification31.9%
(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.6%
herbie shell --seed 2024138
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
:precision binary64
(+ x (/ (fabs (- y x)) 2.0)))