
(FPCore (x y z) :precision binary64 (+ (+ (/ x 2.0) (* y x)) z))
double code(double x, double y, double z) {
return ((x / 2.0) + (y * x)) + z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x / 2.0d0) + (y * x)) + z
end function
public static double code(double x, double y, double z) {
return ((x / 2.0) + (y * x)) + z;
}
def code(x, y, z): return ((x / 2.0) + (y * x)) + z
function code(x, y, z) return Float64(Float64(Float64(x / 2.0) + Float64(y * x)) + z) end
function tmp = code(x, y, z) tmp = ((x / 2.0) + (y * x)) + z; end
code[x_, y_, z_] := N[(N[(N[(x / 2.0), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{x}{2} + y \cdot x\right) + z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ (/ x 2.0) (* y x)) z))
double code(double x, double y, double z) {
return ((x / 2.0) + (y * x)) + z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x / 2.0d0) + (y * x)) + z
end function
public static double code(double x, double y, double z) {
return ((x / 2.0) + (y * x)) + z;
}
def code(x, y, z): return ((x / 2.0) + (y * x)) + z
function code(x, y, z) return Float64(Float64(Float64(x / 2.0) + Float64(y * x)) + z) end
function tmp = code(x, y, z) tmp = ((x / 2.0) + (y * x)) + z; end
code[x_, y_, z_] := N[(N[(N[(x / 2.0), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{x}{2} + y \cdot x\right) + z
\end{array}
(FPCore (x y z) :precision binary64 (+ (+ (/ x 2.0) (* y x)) z))
double code(double x, double y, double z) {
return ((x / 2.0) + (y * x)) + z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x / 2.0d0) + (y * x)) + z
end function
public static double code(double x, double y, double z) {
return ((x / 2.0) + (y * x)) + z;
}
def code(x, y, z): return ((x / 2.0) + (y * x)) + z
function code(x, y, z) return Float64(Float64(Float64(x / 2.0) + Float64(y * x)) + z) end
function tmp = code(x, y, z) tmp = ((x / 2.0) + (y * x)) + z; end
code[x_, y_, z_] := N[(N[(N[(x / 2.0), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{x}{2} + y \cdot x\right) + z
\end{array}
Initial program 100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (* y x) z)))
(if (<= y -3.6e-17)
t_0
(if (<= y -1.95e-125)
(/ x 2.0)
(if (<= y 5.1e-299) t_0 (if (<= y 1.9e-11) (/ x 2.0) t_0))))))
double code(double x, double y, double z) {
double t_0 = (y * x) + z;
double tmp;
if (y <= -3.6e-17) {
tmp = t_0;
} else if (y <= -1.95e-125) {
tmp = x / 2.0;
} else if (y <= 5.1e-299) {
tmp = t_0;
} else if (y <= 1.9e-11) {
tmp = x / 2.0;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (y * x) + z
if (y <= (-3.6d-17)) then
tmp = t_0
else if (y <= (-1.95d-125)) then
tmp = x / 2.0d0
else if (y <= 5.1d-299) then
tmp = t_0
else if (y <= 1.9d-11) then
tmp = x / 2.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y * x) + z;
double tmp;
if (y <= -3.6e-17) {
tmp = t_0;
} else if (y <= -1.95e-125) {
tmp = x / 2.0;
} else if (y <= 5.1e-299) {
tmp = t_0;
} else if (y <= 1.9e-11) {
tmp = x / 2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (y * x) + z tmp = 0 if y <= -3.6e-17: tmp = t_0 elif y <= -1.95e-125: tmp = x / 2.0 elif y <= 5.1e-299: tmp = t_0 elif y <= 1.9e-11: tmp = x / 2.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(y * x) + z) tmp = 0.0 if (y <= -3.6e-17) tmp = t_0; elseif (y <= -1.95e-125) tmp = Float64(x / 2.0); elseif (y <= 5.1e-299) tmp = t_0; elseif (y <= 1.9e-11) tmp = Float64(x / 2.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y * x) + z; tmp = 0.0; if (y <= -3.6e-17) tmp = t_0; elseif (y <= -1.95e-125) tmp = x / 2.0; elseif (y <= 5.1e-299) tmp = t_0; elseif (y <= 1.9e-11) tmp = x / 2.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y * x), $MachinePrecision] + z), $MachinePrecision]}, If[LessEqual[y, -3.6e-17], t$95$0, If[LessEqual[y, -1.95e-125], N[(x / 2.0), $MachinePrecision], If[LessEqual[y, 5.1e-299], t$95$0, If[LessEqual[y, 1.9e-11], N[(x / 2.0), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot x + z\\
\mathbf{if}\;y \leq -3.6 \cdot 10^{-17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -1.95 \cdot 10^{-125}:\\
\;\;\;\;\frac{x}{2}\\
\mathbf{elif}\;y \leq 5.1 \cdot 10^{-299}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{-11}:\\
\;\;\;\;\frac{x}{2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.59999999999999995e-17 or -1.94999999999999991e-125 < y < 5.10000000000000021e-299 or 1.8999999999999999e-11 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites48.1%
Taylor expanded in x around 0
Applied rewrites89.4%
if -3.59999999999999995e-17 < y < -1.94999999999999991e-125 or 5.10000000000000021e-299 < y < 1.8999999999999999e-11Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites63.9%
Taylor expanded in x around 0
Applied rewrites63.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (* y x) z))) (if (<= y -0.5) t_0 (if (<= y 0.5) (+ (/ x 2.0) z) t_0))))
double code(double x, double y, double z) {
double t_0 = (y * x) + z;
double tmp;
if (y <= -0.5) {
tmp = t_0;
} else if (y <= 0.5) {
tmp = (x / 2.0) + z;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (y * x) + z
if (y <= (-0.5d0)) then
tmp = t_0
else if (y <= 0.5d0) then
tmp = (x / 2.0d0) + z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y * x) + z;
double tmp;
if (y <= -0.5) {
tmp = t_0;
} else if (y <= 0.5) {
tmp = (x / 2.0) + z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (y * x) + z tmp = 0 if y <= -0.5: tmp = t_0 elif y <= 0.5: tmp = (x / 2.0) + z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(y * x) + z) tmp = 0.0 if (y <= -0.5) tmp = t_0; elseif (y <= 0.5) tmp = Float64(Float64(x / 2.0) + z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y * x) + z; tmp = 0.0; if (y <= -0.5) tmp = t_0; elseif (y <= 0.5) tmp = (x / 2.0) + z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y * x), $MachinePrecision] + z), $MachinePrecision]}, If[LessEqual[y, -0.5], t$95$0, If[LessEqual[y, 0.5], N[(N[(x / 2.0), $MachinePrecision] + z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot x + z\\
\mathbf{if}\;y \leq -0.5:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 0.5:\\
\;\;\;\;\frac{x}{2} + z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -0.5 or 0.5 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites31.2%
Taylor expanded in x around 0
Applied rewrites97.9%
if -0.5 < y < 0.5Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites98.8%
(FPCore (x y z) :precision binary64 (+ (* y x) z))
double code(double x, double y, double z) {
return (y * x) + z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y * x) + z
end function
public static double code(double x, double y, double z) {
return (y * x) + z;
}
def code(x, y, z): return (y * x) + z
function code(x, y, z) return Float64(Float64(y * x) + z) end
function tmp = code(x, y, z) tmp = (y * x) + z; end
code[x_, y_, z_] := N[(N[(y * x), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}
\\
y \cdot x + z
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites64.5%
Taylor expanded in x around 0
Applied rewrites73.4%
(FPCore (x y z) :precision binary64 (* y x))
double code(double x, double y, double z) {
return y * x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y * x
end function
public static double code(double x, double y, double z) {
return y * x;
}
def code(x, y, z): return y * x
function code(x, y, z) return Float64(y * x) end
function tmp = code(x, y, z) tmp = y * x; end
code[x_, y_, z_] := N[(y * x), $MachinePrecision]
\begin{array}{l}
\\
y \cdot x
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites62.6%
Taylor expanded in y around 0
Applied rewrites36.5%
herbie shell --seed 2024321
(FPCore (x y z)
:name "Data.Histogram.Bin.BinF:$cfromIndex from histogram-fill-0.8.4.1"
:precision binary64
:pre (TRUE)
(+ (+ (/ x 2.0) (* y x)) z))