
(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 3 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) (* x y)) z))
double code(double x, double y, double z) {
return ((x / 2.0) + (x * y)) + 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) + (x * y)) + z
end function
public static double code(double x, double y, double z) {
return ((x / 2.0) + (x * y)) + z;
}
def code(x, y, z): return ((x / 2.0) + (x * y)) + z
function code(x, y, z) return Float64(Float64(Float64(x / 2.0) + Float64(x * y)) + z) end
function tmp = code(x, y, z) tmp = ((x / 2.0) + (x * y)) + z; end
code[x_, y_, z_] := N[(N[(N[(x / 2.0), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{x}{2} + x \cdot y\right) + z
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (/ x 2.0) (* x y)))) (if (or (<= t_0 -1e+64) (not (<= t_0 1e+158))) t_0 (+ (/ x 2.0) z))))
double code(double x, double y, double z) {
double t_0 = (x / 2.0) + (x * y);
double tmp;
if ((t_0 <= -1e+64) || !(t_0 <= 1e+158)) {
tmp = t_0;
} else {
tmp = (x / 2.0) + z;
}
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 = (x / 2.0d0) + (x * y)
if ((t_0 <= (-1d+64)) .or. (.not. (t_0 <= 1d+158))) then
tmp = t_0
else
tmp = (x / 2.0d0) + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x / 2.0) + (x * y);
double tmp;
if ((t_0 <= -1e+64) || !(t_0 <= 1e+158)) {
tmp = t_0;
} else {
tmp = (x / 2.0) + z;
}
return tmp;
}
def code(x, y, z): t_0 = (x / 2.0) + (x * y) tmp = 0 if (t_0 <= -1e+64) or not (t_0 <= 1e+158): tmp = t_0 else: tmp = (x / 2.0) + z return tmp
function code(x, y, z) t_0 = Float64(Float64(x / 2.0) + Float64(x * y)) tmp = 0.0 if ((t_0 <= -1e+64) || !(t_0 <= 1e+158)) tmp = t_0; else tmp = Float64(Float64(x / 2.0) + z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x / 2.0) + (x * y); tmp = 0.0; if ((t_0 <= -1e+64) || ~((t_0 <= 1e+158))) tmp = t_0; else tmp = (x / 2.0) + z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / 2.0), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -1e+64], N[Not[LessEqual[t$95$0, 1e+158]], $MachinePrecision]], t$95$0, N[(N[(x / 2.0), $MachinePrecision] + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2} + x \cdot y\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{+64} \lor \neg \left(t_0 \leq 10^{+158}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{2} + z\\
\end{array}
\end{array}
if (+.f64 (/.f64 x 2) (*.f64 y x)) < -1.00000000000000002e64 or 9.99999999999999953e157 < (+.f64 (/.f64 x 2) (*.f64 y x)) Initial program 100.0%
associate-+l+100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 94.3%
if -1.00000000000000002e64 < (+.f64 (/.f64 x 2) (*.f64 y x)) < 9.99999999999999953e157Initial program 100.0%
associate-+l+100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 88.1%
Final simplification90.6%
(FPCore (x y z) :precision binary64 (+ (/ x 2.0) z))
double code(double x, double y, double z) {
return (x / 2.0) + 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) + z
end function
public static double code(double x, double y, double z) {
return (x / 2.0) + z;
}
def code(x, y, z): return (x / 2.0) + z
function code(x, y, z) return Float64(Float64(x / 2.0) + z) end
function tmp = code(x, y, z) tmp = (x / 2.0) + z; end
code[x_, y_, z_] := N[(N[(x / 2.0), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{2} + z
\end{array}
Initial program 100.0%
associate-+l+100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 68.4%
Final simplification68.4%
herbie shell --seed 2023257
(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))