
(FPCore (x y) :precision binary64 (+ x (/ y 500.0)))
double code(double x, double y) {
return x + (y / 500.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (y / 500.0d0)
end function
public static double code(double x, double y) {
return x + (y / 500.0);
}
def code(x, y): return x + (y / 500.0)
function code(x, y) return Float64(x + Float64(y / 500.0)) end
function tmp = code(x, y) tmp = x + (y / 500.0); end
code[x_, y_] := N[(x + N[(y / 500.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{500}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (+ x (/ y 500.0)))
double code(double x, double y) {
return x + (y / 500.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (y / 500.0d0)
end function
public static double code(double x, double y) {
return x + (y / 500.0);
}
def code(x, y): return x + (y / 500.0)
function code(x, y) return Float64(x + Float64(y / 500.0)) end
function tmp = code(x, y) tmp = x + (y / 500.0); end
code[x_, y_] := N[(x + N[(y / 500.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{500}
\end{array}
(FPCore (x y) :precision binary64 (+ x (/ y 500.0)))
double code(double x, double y) {
return x + (y / 500.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (y / 500.0d0)
end function
public static double code(double x, double y) {
return x + (y / 500.0);
}
def code(x, y): return x + (y / 500.0)
function code(x, y) return Float64(x + Float64(y / 500.0)) end
function tmp = code(x, y) tmp = x + (y / 500.0); end
code[x_, y_] := N[(x + N[(y / 500.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{500}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= (/ y 500.0) -2e+54)
(/ y 500.0)
(if (<= (/ y 500.0) 2.5e-27)
x
(if (<= (/ y 500.0) 20.0)
(/ y 500.0)
(if (<= (/ y 500.0) 1e+28) x (/ y 500.0))))))
double code(double x, double y) {
double tmp;
if ((y / 500.0) <= -2e+54) {
tmp = y / 500.0;
} else if ((y / 500.0) <= 2.5e-27) {
tmp = x;
} else if ((y / 500.0) <= 20.0) {
tmp = y / 500.0;
} else if ((y / 500.0) <= 1e+28) {
tmp = x;
} else {
tmp = y / 500.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y / 500.0d0) <= (-2d+54)) then
tmp = y / 500.0d0
else if ((y / 500.0d0) <= 2.5d-27) then
tmp = x
else if ((y / 500.0d0) <= 20.0d0) then
tmp = y / 500.0d0
else if ((y / 500.0d0) <= 1d+28) then
tmp = x
else
tmp = y / 500.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y / 500.0) <= -2e+54) {
tmp = y / 500.0;
} else if ((y / 500.0) <= 2.5e-27) {
tmp = x;
} else if ((y / 500.0) <= 20.0) {
tmp = y / 500.0;
} else if ((y / 500.0) <= 1e+28) {
tmp = x;
} else {
tmp = y / 500.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y / 500.0) <= -2e+54: tmp = y / 500.0 elif (y / 500.0) <= 2.5e-27: tmp = x elif (y / 500.0) <= 20.0: tmp = y / 500.0 elif (y / 500.0) <= 1e+28: tmp = x else: tmp = y / 500.0 return tmp
function code(x, y) tmp = 0.0 if (Float64(y / 500.0) <= -2e+54) tmp = Float64(y / 500.0); elseif (Float64(y / 500.0) <= 2.5e-27) tmp = x; elseif (Float64(y / 500.0) <= 20.0) tmp = Float64(y / 500.0); elseif (Float64(y / 500.0) <= 1e+28) tmp = x; else tmp = Float64(y / 500.0); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y / 500.0) <= -2e+54) tmp = y / 500.0; elseif ((y / 500.0) <= 2.5e-27) tmp = x; elseif ((y / 500.0) <= 20.0) tmp = y / 500.0; elseif ((y / 500.0) <= 1e+28) tmp = x; else tmp = y / 500.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(y / 500.0), $MachinePrecision], -2e+54], N[(y / 500.0), $MachinePrecision], If[LessEqual[N[(y / 500.0), $MachinePrecision], 2.5e-27], x, If[LessEqual[N[(y / 500.0), $MachinePrecision], 20.0], N[(y / 500.0), $MachinePrecision], If[LessEqual[N[(y / 500.0), $MachinePrecision], 1e+28], x, N[(y / 500.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{y}{500} \leq -2 \cdot 10^{+54}:\\
\;\;\;\;\frac{y}{500}\\
\mathbf{elif}\;\frac{y}{500} \leq 2.5 \cdot 10^{-27}:\\
\;\;\;\;x\\
\mathbf{elif}\;\frac{y}{500} \leq 20:\\
\;\;\;\;\frac{y}{500}\\
\mathbf{elif}\;\frac{y}{500} \leq 10^{+28}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{500}\\
\end{array}
\end{array}
if (/.f64 y 500) < -2.0000000000000002e54 or 2.5000000000000001e-27 < (/.f64 y 500) < 20 or 9.99999999999999958e27 < (/.f64 y 500) Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.7%
distribute-neg-frac99.7%
associate-/r/99.8%
distribute-lft-neg-in99.8%
*-commutative99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
+-commutative99.8%
flip-+42.4%
swap-sqr42.1%
metadata-eval42.1%
Applied egg-rr42.1%
Taylor expanded in y around inf 39.8%
unpow239.8%
*-commutative39.8%
associate-*r*39.9%
Simplified39.9%
Taylor expanded in y around inf 86.1%
*-commutative86.1%
Simplified86.1%
metadata-eval86.1%
div-inv86.2%
Applied egg-rr86.2%
if -2.0000000000000002e54 < (/.f64 y 500) < 2.5000000000000001e-27 or 20 < (/.f64 y 500) < 9.99999999999999958e27Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.8%
distribute-neg-frac99.8%
associate-/r/100.0%
distribute-lft-neg-in100.0%
*-commutative100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 78.4%
Final simplification82.3%
(FPCore (x y)
:precision binary64
(if (<= y -9.2e+56)
(* y 0.002)
(if (<= y 1.3e-24)
x
(if (<= y 4100000000.0) (* y 0.002) (if (<= y 4.5e+30) x (* y 0.002))))))
double code(double x, double y) {
double tmp;
if (y <= -9.2e+56) {
tmp = y * 0.002;
} else if (y <= 1.3e-24) {
tmp = x;
} else if (y <= 4100000000.0) {
tmp = y * 0.002;
} else if (y <= 4.5e+30) {
tmp = x;
} else {
tmp = y * 0.002;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-9.2d+56)) then
tmp = y * 0.002d0
else if (y <= 1.3d-24) then
tmp = x
else if (y <= 4100000000.0d0) then
tmp = y * 0.002d0
else if (y <= 4.5d+30) then
tmp = x
else
tmp = y * 0.002d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -9.2e+56) {
tmp = y * 0.002;
} else if (y <= 1.3e-24) {
tmp = x;
} else if (y <= 4100000000.0) {
tmp = y * 0.002;
} else if (y <= 4.5e+30) {
tmp = x;
} else {
tmp = y * 0.002;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -9.2e+56: tmp = y * 0.002 elif y <= 1.3e-24: tmp = x elif y <= 4100000000.0: tmp = y * 0.002 elif y <= 4.5e+30: tmp = x else: tmp = y * 0.002 return tmp
function code(x, y) tmp = 0.0 if (y <= -9.2e+56) tmp = Float64(y * 0.002); elseif (y <= 1.3e-24) tmp = x; elseif (y <= 4100000000.0) tmp = Float64(y * 0.002); elseif (y <= 4.5e+30) tmp = x; else tmp = Float64(y * 0.002); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -9.2e+56) tmp = y * 0.002; elseif (y <= 1.3e-24) tmp = x; elseif (y <= 4100000000.0) tmp = y * 0.002; elseif (y <= 4.5e+30) tmp = x; else tmp = y * 0.002; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -9.2e+56], N[(y * 0.002), $MachinePrecision], If[LessEqual[y, 1.3e-24], x, If[LessEqual[y, 4100000000.0], N[(y * 0.002), $MachinePrecision], If[LessEqual[y, 4.5e+30], x, N[(y * 0.002), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{+56}:\\
\;\;\;\;y \cdot 0.002\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-24}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 4100000000:\\
\;\;\;\;y \cdot 0.002\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{+30}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.002\\
\end{array}
\end{array}
if y < -9.20000000000000058e56 or 1.3e-24 < y < 4.1e9 or 4.49999999999999995e30 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.7%
distribute-neg-frac99.7%
associate-/r/99.8%
distribute-lft-neg-in99.8%
*-commutative99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
+-commutative99.8%
flip-+42.4%
swap-sqr42.1%
metadata-eval42.1%
Applied egg-rr42.1%
Taylor expanded in y around inf 39.8%
unpow239.8%
*-commutative39.8%
associate-*r*39.9%
Simplified39.9%
Taylor expanded in y around inf 86.1%
*-commutative86.1%
Simplified86.1%
if -9.20000000000000058e56 < y < 1.3e-24 or 4.1e9 < y < 4.49999999999999995e30Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.8%
distribute-neg-frac99.8%
associate-/r/100.0%
distribute-lft-neg-in100.0%
*-commutative100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 78.4%
Final simplification82.2%
(FPCore (x y) :precision binary64 (+ x (* y 0.002)))
double code(double x, double y) {
return x + (y * 0.002);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (y * 0.002d0)
end function
public static double code(double x, double y) {
return x + (y * 0.002);
}
def code(x, y): return x + (y * 0.002)
function code(x, y) return Float64(x + Float64(y * 0.002)) end
function tmp = code(x, y) tmp = x + (y * 0.002); end
code[x_, y_] := N[(x + N[(y * 0.002), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot 0.002
\end{array}
Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.8%
distribute-neg-frac99.8%
associate-/r/99.9%
distribute-lft-neg-in99.9%
*-commutative99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.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 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.8%
distribute-neg-frac99.8%
associate-/r/99.9%
distribute-lft-neg-in99.9%
*-commutative99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 48.0%
Final simplification48.0%
herbie shell --seed 2023293
(FPCore (x y)
:name "Data.Colour.CIE:cieLAB from colour-2.3.3, C"
:precision binary64
(+ x (/ y 500.0)))