
(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 8 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%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-lft-identityN/A
metadata-evalN/A
fabs-subN/A
fp-cancel-sign-sub-invN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6499.9
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (+ x (/ (fabs (- y x)) 2.0)) 5e-252) (* 0.5 x) (* 0.5 y)))
double code(double x, double y) {
double tmp;
if ((x + (fabs((y - x)) / 2.0)) <= 5e-252) {
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)) <= 5d-252) 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)) <= 5e-252) {
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)) <= 5e-252: 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)) <= 5e-252) 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)) <= 5e-252) 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], 5e-252], 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 5 \cdot 10^{-252}:\\
\;\;\;\;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))) < 5.00000000000000008e-252Initial program 100.0%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift--.f64N/A
flip--N/A
lift--.f64N/A
flip3--N/A
frac-timesN/A
sqrt-divN/A
lower-/.f64N/A
Applied rewrites0.0%
Taylor expanded in x around 0
lower-*.f643.8
Applied rewrites3.8%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
div-subN/A
associate-/l*N/A
*-inversesN/A
metadata-evalN/A
*-inversesN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6493.9
Applied rewrites93.9%
Taylor expanded in x around inf
Applied rewrites92.8%
if 5.00000000000000008e-252 < (+.f64 x (/.f64 (fabs.f64 (-.f64 y x)) #s(literal 2 binary64))) Initial program 99.9%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift--.f64N/A
flip--N/A
lift--.f64N/A
flip3--N/A
frac-timesN/A
sqrt-divN/A
lower-/.f64N/A
Applied rewrites14.9%
Taylor expanded in x around 0
lower-*.f6433.5
Applied rewrites33.5%
(FPCore (x y) :precision binary64 (if (<= x -1.35e-91) (* (+ y x) 0.5) (if (<= x 5.1e-10) (fma (fabs (- y)) 0.5 x) (* x 1.5))))
double code(double x, double y) {
double tmp;
if (x <= -1.35e-91) {
tmp = (y + x) * 0.5;
} else if (x <= 5.1e-10) {
tmp = fma(fabs(-y), 0.5, x);
} else {
tmp = x * 1.5;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -1.35e-91) tmp = Float64(Float64(y + x) * 0.5); elseif (x <= 5.1e-10) tmp = fma(abs(Float64(-y)), 0.5, x); else tmp = Float64(x * 1.5); end return tmp end
code[x_, y_] := If[LessEqual[x, -1.35e-91], N[(N[(y + x), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 5.1e-10], N[(N[Abs[(-y)], $MachinePrecision] * 0.5 + x), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{-91}:\\
\;\;\;\;\left(y + x\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 5.1 \cdot 10^{-10}:\\
\;\;\;\;\mathsf{fma}\left(\left|-y\right|, 0.5, x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -1.3499999999999999e-91Initial program 100.0%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift--.f64N/A
flip--N/A
lift--.f64N/A
flip3--N/A
frac-timesN/A
sqrt-divN/A
lower-/.f64N/A
Applied rewrites1.4%
Taylor expanded in x around 0
lower-*.f6418.1
Applied rewrites18.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
div-subN/A
associate-/l*N/A
*-inversesN/A
metadata-evalN/A
*-inversesN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6485.6
Applied rewrites85.6%
Taylor expanded in x around 0
*-commutativeN/A
div-subN/A
*-inversesN/A
associate-/l*N/A
*-inversesN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6485.6
Applied rewrites85.6%
if -1.3499999999999999e-91 < x < 5.09999999999999997e-10Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-lft-identityN/A
metadata-evalN/A
fabs-subN/A
fp-cancel-sign-sub-invN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites77.5%
if 5.09999999999999997e-10 < x Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
Applied rewrites84.4%
Taylor expanded in x around inf
+-commutativeN/A
mul-1-negN/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f6472.9
Applied rewrites72.9%
(FPCore (x y) :precision binary64 (if (<= x -4.8e-94) (* (+ y x) 0.5) (if (<= x 5.1e-10) (* (fabs (- y x)) 0.5) (* x 1.5))))
double code(double x, double y) {
double tmp;
if (x <= -4.8e-94) {
tmp = (y + x) * 0.5;
} else if (x <= 5.1e-10) {
tmp = fabs((y - x)) * 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 <= (-4.8d-94)) then
tmp = (y + x) * 0.5d0
else if (x <= 5.1d-10) then
tmp = abs((y - x)) * 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 <= -4.8e-94) {
tmp = (y + x) * 0.5;
} else if (x <= 5.1e-10) {
tmp = Math.abs((y - x)) * 0.5;
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -4.8e-94: tmp = (y + x) * 0.5 elif x <= 5.1e-10: tmp = math.fabs((y - x)) * 0.5 else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -4.8e-94) tmp = Float64(Float64(y + x) * 0.5); elseif (x <= 5.1e-10) tmp = Float64(abs(Float64(y - x)) * 0.5); else tmp = Float64(x * 1.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -4.8e-94) tmp = (y + x) * 0.5; elseif (x <= 5.1e-10) tmp = abs((y - x)) * 0.5; else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -4.8e-94], N[(N[(y + x), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 5.1e-10], N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{-94}:\\
\;\;\;\;\left(y + x\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 5.1 \cdot 10^{-10}:\\
\;\;\;\;\left|y - x\right| \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -4.8e-94Initial program 100.0%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift--.f64N/A
flip--N/A
lift--.f64N/A
flip3--N/A
frac-timesN/A
sqrt-divN/A
lower-/.f64N/A
Applied rewrites1.4%
Taylor expanded in x around 0
lower-*.f6418.1
Applied rewrites18.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
div-subN/A
associate-/l*N/A
*-inversesN/A
metadata-evalN/A
*-inversesN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6485.6
Applied rewrites85.6%
Taylor expanded in x around 0
*-commutativeN/A
div-subN/A
*-inversesN/A
associate-/l*N/A
*-inversesN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6485.6
Applied rewrites85.6%
if -4.8e-94 < x < 5.09999999999999997e-10Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
*-lft-identityN/A
metadata-evalN/A
fabs-subN/A
fp-cancel-sign-sub-invN/A
lower-fabs.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6476.5
Applied rewrites76.5%
if 5.09999999999999997e-10 < x Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
Applied rewrites84.4%
Taylor expanded in x around inf
+-commutativeN/A
mul-1-negN/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f6472.9
Applied rewrites72.9%
Final simplification78.0%
(FPCore (x y) :precision binary64 (if (<= y -2.4e-124) (* y -0.5) (if (<= y 3.9e-252) (* x 1.5) (* (+ y x) 0.5))))
double code(double x, double y) {
double tmp;
if (y <= -2.4e-124) {
tmp = y * -0.5;
} else if (y <= 3.9e-252) {
tmp = x * 1.5;
} else {
tmp = (y + x) * 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.4d-124)) then
tmp = y * (-0.5d0)
else if (y <= 3.9d-252) then
tmp = x * 1.5d0
else
tmp = (y + x) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2.4e-124) {
tmp = y * -0.5;
} else if (y <= 3.9e-252) {
tmp = x * 1.5;
} else {
tmp = (y + x) * 0.5;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.4e-124: tmp = y * -0.5 elif y <= 3.9e-252: tmp = x * 1.5 else: tmp = (y + x) * 0.5 return tmp
function code(x, y) tmp = 0.0 if (y <= -2.4e-124) tmp = Float64(y * -0.5); elseif (y <= 3.9e-252) tmp = Float64(x * 1.5); else tmp = Float64(Float64(y + x) * 0.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.4e-124) tmp = y * -0.5; elseif (y <= 3.9e-252) tmp = x * 1.5; else tmp = (y + x) * 0.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.4e-124], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 3.9e-252], N[(x * 1.5), $MachinePrecision], N[(N[(y + x), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{-124}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 3.9 \cdot 10^{-252}:\\
\;\;\;\;x \cdot 1.5\\
\mathbf{else}:\\
\;\;\;\;\left(y + x\right) \cdot 0.5\\
\end{array}
\end{array}
if y < -2.39999999999999992e-124Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
Applied rewrites80.9%
Taylor expanded in x around 0
unpow2N/A
rem-square-sqrtN/A
lower-*.f6465.1
Applied rewrites65.1%
if -2.39999999999999992e-124 < y < 3.8999999999999999e-252Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
Applied rewrites68.1%
Taylor expanded in x around inf
+-commutativeN/A
mul-1-negN/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f6466.5
Applied rewrites66.5%
if 3.8999999999999999e-252 < y Initial program 99.9%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift--.f64N/A
flip--N/A
lift--.f64N/A
flip3--N/A
frac-timesN/A
sqrt-divN/A
lower-/.f64N/A
Applied rewrites17.9%
Taylor expanded in x around 0
lower-*.f6464.7
Applied rewrites64.7%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
div-subN/A
associate-/l*N/A
*-inversesN/A
metadata-evalN/A
*-inversesN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6483.7
Applied rewrites83.7%
Taylor expanded in x around 0
*-commutativeN/A
div-subN/A
*-inversesN/A
associate-/l*N/A
*-inversesN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
distribute-lft-outN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6483.7
Applied rewrites83.7%
(FPCore (x y) :precision binary64 (if (<= y -2.4e-124) (* y -0.5) (if (<= y 1.7e-18) (* x 1.5) (* 0.5 y))))
double code(double x, double y) {
double tmp;
if (y <= -2.4e-124) {
tmp = y * -0.5;
} else if (y <= 1.7e-18) {
tmp = x * 1.5;
} 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 (y <= (-2.4d-124)) then
tmp = y * (-0.5d0)
else if (y <= 1.7d-18) then
tmp = x * 1.5d0
else
tmp = 0.5d0 * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2.4e-124) {
tmp = y * -0.5;
} else if (y <= 1.7e-18) {
tmp = x * 1.5;
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.4e-124: tmp = y * -0.5 elif y <= 1.7e-18: tmp = x * 1.5 else: tmp = 0.5 * y return tmp
function code(x, y) tmp = 0.0 if (y <= -2.4e-124) tmp = Float64(y * -0.5); elseif (y <= 1.7e-18) tmp = Float64(x * 1.5); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.4e-124) tmp = y * -0.5; elseif (y <= 1.7e-18) tmp = x * 1.5; else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.4e-124], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.7e-18], N[(x * 1.5), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{-124}:\\
\;\;\;\;y \cdot -0.5\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{-18}:\\
\;\;\;\;x \cdot 1.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < -2.39999999999999992e-124Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
Applied rewrites80.9%
Taylor expanded in x around 0
unpow2N/A
rem-square-sqrtN/A
lower-*.f6465.1
Applied rewrites65.1%
if -2.39999999999999992e-124 < y < 1.70000000000000001e-18Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
Applied rewrites57.6%
Taylor expanded in x around inf
+-commutativeN/A
mul-1-negN/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f6458.0
Applied rewrites58.0%
if 1.70000000000000001e-18 < y Initial program 100.0%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift--.f64N/A
flip--N/A
lift--.f64N/A
flip3--N/A
frac-timesN/A
sqrt-divN/A
lower-/.f64N/A
Applied rewrites13.5%
Taylor expanded in x around 0
lower-*.f6477.6
Applied rewrites77.6%
(FPCore (x y) :precision binary64 (if (<= x -7.2e-73) (* 0.5 x) (if (<= x 9.2e-160) (* 0.5 y) (* x 1.5))))
double code(double x, double y) {
double tmp;
if (x <= -7.2e-73) {
tmp = 0.5 * x;
} else if (x <= 9.2e-160) {
tmp = 0.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 <= (-7.2d-73)) then
tmp = 0.5d0 * x
else if (x <= 9.2d-160) then
tmp = 0.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 <= -7.2e-73) {
tmp = 0.5 * x;
} else if (x <= 9.2e-160) {
tmp = 0.5 * y;
} else {
tmp = x * 1.5;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -7.2e-73: tmp = 0.5 * x elif x <= 9.2e-160: tmp = 0.5 * y else: tmp = x * 1.5 return tmp
function code(x, y) tmp = 0.0 if (x <= -7.2e-73) tmp = Float64(0.5 * x); elseif (x <= 9.2e-160) tmp = Float64(0.5 * y); else tmp = Float64(x * 1.5); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -7.2e-73) tmp = 0.5 * x; elseif (x <= 9.2e-160) tmp = 0.5 * y; else tmp = x * 1.5; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -7.2e-73], N[(0.5 * x), $MachinePrecision], If[LessEqual[x, 9.2e-160], N[(0.5 * y), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.2 \cdot 10^{-73}:\\
\;\;\;\;0.5 \cdot x\\
\mathbf{elif}\;x \leq 9.2 \cdot 10^{-160}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\
\end{array}
\end{array}
if x < -7.1999999999999999e-73Initial program 100.0%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift--.f64N/A
flip--N/A
lift--.f64N/A
flip3--N/A
frac-timesN/A
sqrt-divN/A
lower-/.f64N/A
Applied rewrites1.5%
Taylor expanded in x around 0
lower-*.f6416.1
Applied rewrites16.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
div-subN/A
associate-/l*N/A
*-inversesN/A
metadata-evalN/A
*-inversesN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6484.7
Applied rewrites84.7%
Taylor expanded in x around inf
Applied rewrites70.2%
if -7.1999999999999999e-73 < x < 9.19999999999999939e-160Initial program 100.0%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift--.f64N/A
flip--N/A
lift--.f64N/A
flip3--N/A
frac-timesN/A
sqrt-divN/A
lower-/.f64N/A
Applied rewrites8.3%
Taylor expanded in x around 0
lower-*.f6441.9
Applied rewrites41.9%
if 9.19999999999999939e-160 < x Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-fma.f64N/A
Applied rewrites79.0%
Taylor expanded in x around inf
+-commutativeN/A
mul-1-negN/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f6463.2
Applied rewrites63.2%
(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%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift--.f64N/A
flip--N/A
lift--.f64N/A
flip3--N/A
frac-timesN/A
sqrt-divN/A
lower-/.f64N/A
Applied rewrites11.7%
Taylor expanded in x around 0
lower-*.f6427.0
Applied rewrites27.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
div-subN/A
associate-/l*N/A
*-inversesN/A
metadata-evalN/A
*-inversesN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6451.6
Applied rewrites51.6%
Taylor expanded in x around inf
Applied rewrites27.0%
herbie shell --seed 2024329
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
:precision binary64
(+ x (/ (fabs (- y x)) 2.0)))