
(FPCore (x y z t) :precision binary64 (+ (* (+ (* x y) z) y) t))
double code(double x, double y, double z, double t) {
return (((x * y) + z) * y) + t;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((x * y) + z) * y) + t
end function
public static double code(double x, double y, double z, double t) {
return (((x * y) + z) * y) + t;
}
def code(x, y, z, t): return (((x * y) + z) * y) + t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * y) + z) * y) + t) end
function tmp = code(x, y, z, t) tmp = (((x * y) + z) * y) + t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * y), $MachinePrecision] + z), $MachinePrecision] * y), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y + z\right) \cdot y + t
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ (* (+ (* x y) z) y) t))
double code(double x, double y, double z, double t) {
return (((x * y) + z) * y) + t;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((x * y) + z) * y) + t
end function
public static double code(double x, double y, double z, double t) {
return (((x * y) + z) * y) + t;
}
def code(x, y, z, t): return (((x * y) + z) * y) + t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * y) + z) * y) + t) end
function tmp = code(x, y, z, t) tmp = (((x * y) + z) * y) + t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * y), $MachinePrecision] + z), $MachinePrecision] * y), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y + z\right) \cdot y + t
\end{array}
(FPCore (x y z t) :precision binary64 (+ (* (+ (* x y) z) y) t))
double code(double x, double y, double z, double t) {
return (((x * y) + z) * y) + t;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((x * y) + z) * y) + t
end function
public static double code(double x, double y, double z, double t) {
return (((x * y) + z) * y) + t;
}
def code(x, y, z, t): return (((x * y) + z) * y) + t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * y) + z) * y) + t) end
function tmp = code(x, y, z, t) tmp = (((x * y) + z) * y) + t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * y), $MachinePrecision] + z), $MachinePrecision] * y), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y + z\right) \cdot y + t
\end{array}
Initial program 100.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (+ (* x y) z) y))) (if (<= t_1 -5e-127) t_1 (if (<= t_1 2e+42) (+ (* x y) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = ((x * y) + z) * y;
double tmp;
if (t_1 <= -5e-127) {
tmp = t_1;
} else if (t_1 <= 2e+42) {
tmp = (x * y) + t;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = ((x * y) + z) * y
if (t_1 <= (-5d-127)) then
tmp = t_1
else if (t_1 <= 2d+42) then
tmp = (x * y) + t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = ((x * y) + z) * y;
double tmp;
if (t_1 <= -5e-127) {
tmp = t_1;
} else if (t_1 <= 2e+42) {
tmp = (x * y) + t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = ((x * y) + z) * y tmp = 0 if t_1 <= -5e-127: tmp = t_1 elif t_1 <= 2e+42: tmp = (x * y) + t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(Float64(x * y) + z) * y) tmp = 0.0 if (t_1 <= -5e-127) tmp = t_1; elseif (t_1 <= 2e+42) tmp = Float64(Float64(x * y) + t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = ((x * y) + z) * y; tmp = 0.0; if (t_1 <= -5e-127) tmp = t_1; elseif (t_1 <= 2e+42) tmp = (x * y) + t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(x * y), $MachinePrecision] + z), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-127], t$95$1, If[LessEqual[t$95$1, 2e+42], N[(N[(x * y), $MachinePrecision] + t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot y + z\right) \cdot y\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-127}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+42}:\\
\;\;\;\;x \cdot y + t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (+.f64 (*.f64 x y) z) y) < -4.9999999999999997e-127 or 2.00000000000000009e42 < (*.f64 (+.f64 (*.f64 x y) z) y) Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites86.9%
if -4.9999999999999997e-127 < (*.f64 (+.f64 (*.f64 x y) z) y) < 2.00000000000000009e42Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites73.6%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (* x y) y))) (if (<= y -3.9e-43) t_1 (if (<= y 1.2) (+ (* x y) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (x * y) * y;
double tmp;
if (y <= -3.9e-43) {
tmp = t_1;
} else if (y <= 1.2) {
tmp = (x * y) + t;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (x * y) * y
if (y <= (-3.9d-43)) then
tmp = t_1
else if (y <= 1.2d0) then
tmp = (x * y) + t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (x * y) * y;
double tmp;
if (y <= -3.9e-43) {
tmp = t_1;
} else if (y <= 1.2) {
tmp = (x * y) + t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * y) * y tmp = 0 if y <= -3.9e-43: tmp = t_1 elif y <= 1.2: tmp = (x * y) + t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * y) * y) tmp = 0.0 if (y <= -3.9e-43) tmp = t_1; elseif (y <= 1.2) tmp = Float64(Float64(x * y) + t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * y) * y; tmp = 0.0; if (y <= -3.9e-43) tmp = t_1; elseif (y <= 1.2) tmp = (x * y) + t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -3.9e-43], t$95$1, If[LessEqual[y, 1.2], N[(N[(x * y), $MachinePrecision] + t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x \cdot y\right) \cdot y\\
\mathbf{if}\;y \leq -3.9 \cdot 10^{-43}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.2:\\
\;\;\;\;x \cdot y + t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -3.9e-43 or 1.19999999999999996 < y Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites92.4%
Taylor expanded in x around 0
Applied rewrites74.3%
if -3.9e-43 < y < 1.19999999999999996Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites58.6%
(FPCore (x y z t) :precision binary64 (+ (* x y) t))
double code(double x, double y, double z, double t) {
return (x * y) + t;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * y) + t
end function
public static double code(double x, double y, double z, double t) {
return (x * y) + t;
}
def code(x, y, z, t): return (x * y) + t
function code(x, y, z, t) return Float64(Float64(x * y) + t) end
function tmp = code(x, y, z, t) tmp = (x * y) + t; end
code[x_, y_, z_, t_] := N[(N[(x * y), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}
\\
x \cdot y + t
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites40.4%
(FPCore (x y z t) :precision binary64 (+ (* x y) z))
double code(double x, double y, double z, double t) {
return (x * y) + z;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * y) + z
end function
public static double code(double x, double y, double z, double t) {
return (x * y) + z;
}
def code(x, y, z, t): return (x * y) + z
function code(x, y, z, t) return Float64(Float64(x * y) + z) end
function tmp = code(x, y, z, t) tmp = (x * y) + z; end
code[x_, y_, z_, t_] := N[(N[(x * y), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot y + z
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites65.7%
Taylor expanded in x around 0
Applied rewrites10.8%
(FPCore (x y z t) :precision binary64 (* x y))
double code(double x, double y, double z, double t) {
return x * y;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x * y
end function
public static double code(double x, double y, double z, double t) {
return x * y;
}
def code(x, y, z, t): return x * y
function code(x, y, z, t) return Float64(x * y) end
function tmp = code(x, y, z, t) tmp = x * y; end
code[x_, y_, z_, t_] := N[(x * y), $MachinePrecision]
\begin{array}{l}
\\
x \cdot y
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites65.7%
Taylor expanded in x around 0
Applied rewrites10.6%
herbie shell --seed 2024321
(FPCore (x y z t)
:name "Language.Haskell.HsColour.ColourHighlight:unbase from hscolour-1.23"
:precision binary64
:pre (TRUE)
(+ (* (+ (* x y) z) y) t))