
(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 -6.2e-10)
t_0
(if (<= y -7.2e-139)
(/ x 2.0)
(if (<= y -6.2e-195) t_0 (if (<= y 5.5e-210) (/ x 2.0) t_0))))))
double code(double x, double y, double z) {
double t_0 = (y * x) + z;
double tmp;
if (y <= -6.2e-10) {
tmp = t_0;
} else if (y <= -7.2e-139) {
tmp = x / 2.0;
} else if (y <= -6.2e-195) {
tmp = t_0;
} else if (y <= 5.5e-210) {
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 <= (-6.2d-10)) then
tmp = t_0
else if (y <= (-7.2d-139)) then
tmp = x / 2.0d0
else if (y <= (-6.2d-195)) then
tmp = t_0
else if (y <= 5.5d-210) 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 <= -6.2e-10) {
tmp = t_0;
} else if (y <= -7.2e-139) {
tmp = x / 2.0;
} else if (y <= -6.2e-195) {
tmp = t_0;
} else if (y <= 5.5e-210) {
tmp = x / 2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (y * x) + z tmp = 0 if y <= -6.2e-10: tmp = t_0 elif y <= -7.2e-139: tmp = x / 2.0 elif y <= -6.2e-195: tmp = t_0 elif y <= 5.5e-210: 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 <= -6.2e-10) tmp = t_0; elseif (y <= -7.2e-139) tmp = Float64(x / 2.0); elseif (y <= -6.2e-195) tmp = t_0; elseif (y <= 5.5e-210) 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 <= -6.2e-10) tmp = t_0; elseif (y <= -7.2e-139) tmp = x / 2.0; elseif (y <= -6.2e-195) tmp = t_0; elseif (y <= 5.5e-210) 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, -6.2e-10], t$95$0, If[LessEqual[y, -7.2e-139], N[(x / 2.0), $MachinePrecision], If[LessEqual[y, -6.2e-195], t$95$0, If[LessEqual[y, 5.5e-210], N[(x / 2.0), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot x + z\\
\mathbf{if}\;y \leq -6.2 \cdot 10^{-10}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -7.2 \cdot 10^{-139}:\\
\;\;\;\;\frac{x}{2}\\
\mathbf{elif}\;y \leq -6.2 \cdot 10^{-195}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{-210}:\\
\;\;\;\;\frac{x}{2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -6.2000000000000003e-10 or -7.20000000000000007e-139 < y < -6.20000000000000005e-195 or 5.50000000000000024e-210 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites47.7%
Taylor expanded in x around 0
Applied rewrites91.2%
if -6.2000000000000003e-10 < y < -7.20000000000000007e-139 or -6.20000000000000005e-195 < y < 5.50000000000000024e-210Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites68.8%
Taylor expanded in x around 0
Applied rewrites68.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 rewrites30.1%
Taylor expanded in x around 0
Applied rewrites97.5%
if -0.5 < y < 0.5Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites99.1%
(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 rewrites62.2%
Taylor expanded in x around 0
Applied rewrites74.5%
(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 rewrites63.6%
Taylor expanded in y around 0
Applied rewrites38.9%
herbie shell --seed 2024313
(FPCore (x y z)
:name "Data.Histogram.Bin.BinF:$cfromIndex from histogram-fill-0.8.4.1"
:precision binary64
(+ (+ (/ x 2.0) (* y x)) z))