
(FPCore (x y) :precision binary64 (- (* x 2.0) y))
double code(double x, double y) {
return (x * 2.0) - y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * 2.0d0) - y
end function
public static double code(double x, double y) {
return (x * 2.0) - y;
}
def code(x, y): return (x * 2.0) - y
function code(x, y) return Float64(Float64(x * 2.0) - y) end
function tmp = code(x, y) tmp = (x * 2.0) - y; end
code[x_, y_] := N[(N[(x * 2.0), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 2 - y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- (* x 2.0) y))
double code(double x, double y) {
return (x * 2.0) - y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * 2.0d0) - y
end function
public static double code(double x, double y) {
return (x * 2.0) - y;
}
def code(x, y): return (x * 2.0) - y
function code(x, y) return Float64(Float64(x * 2.0) - y) end
function tmp = code(x, y) tmp = (x * 2.0) - y; end
code[x_, y_] := N[(N[(x * 2.0), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 2 - y
\end{array}
(FPCore (x y) :precision binary64 (- (* x 2.0) y))
double code(double x, double y) {
return (x * 2.0) - y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * 2.0d0) - y
end function
public static double code(double x, double y) {
return (x * 2.0) - y;
}
def code(x, y): return (x * 2.0) - y
function code(x, y) return Float64(Float64(x * 2.0) - y) end
function tmp = code(x, y) tmp = (x * 2.0) - y; end
code[x_, y_] := N[(N[(x * 2.0), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 2 - y
\end{array}
Initial program 100.0%
(FPCore (x y) :precision binary64 (- y))
double code(double x, double y) {
return -y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -y
end function
public static double code(double x, double y) {
return -y;
}
def code(x, y): return -y
function code(x, y) return Float64(-y) end
function tmp = code(x, y) tmp = -y; end
code[x_, y_] := (-y)
\begin{array}{l}
\\
-y
\end{array}
Initial program 100.0%
Taylor expanded in x around 0 51.2%
neg-mul-151.2%
Simplified51.2%
(FPCore (x y) :precision binary64 0.0)
double code(double x, double y) {
return 0.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.0d0
end function
public static double code(double x, double y) {
return 0.0;
}
def code(x, y): return 0.0
function code(x, y) return 0.0 end
function tmp = code(x, y) tmp = 0.0; end
code[x_, y_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 100.0%
Taylor expanded in x around 0 51.2%
neg-mul-151.2%
Simplified51.2%
add-sqr-sqrt27.1%
sqrt-unprod14.2%
sqr-neg14.2%
sqrt-unprod1.1%
add-log-exp1.0%
add-sqr-sqrt2.1%
add-sqr-sqrt2.1%
sqrt-unprod2.1%
add-sqr-sqrt1.0%
sqrt-unprod1.7%
sqr-neg1.7%
sqrt-unprod0.7%
add-sqr-sqrt1.6%
exp-neg1.6%
rgt-mult-inverse2.7%
metadata-eval2.7%
metadata-eval2.7%
Applied egg-rr2.7%
herbie shell --seed 2024179
(FPCore (x y)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, C"
:precision binary64
(- (* x 2.0) y))