
(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 5 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 (+ t (* y (+ (* x y) z))))
double code(double x, double y, double z, double t) {
return t + (y * ((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 = t + (y * ((x * y) + z))
end function
public static double code(double x, double y, double z, double t) {
return t + (y * ((x * y) + z));
}
def code(x, y, z, t): return t + (y * ((x * y) + z))
function code(x, y, z, t) return Float64(t + Float64(y * Float64(Float64(x * y) + z))) end
function tmp = code(x, y, z, t) tmp = t + (y * ((x * y) + z)); end
code[x_, y_, z_, t_] := N[(t + N[(y * N[(N[(x * y), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
t + y \cdot \left(x \cdot y + z\right)
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.3e-56) (not (<= y 0.00014))) (* y (+ (* x y) z)) (+ t (* y z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.3e-56) || !(y <= 0.00014)) {
tmp = y * ((x * y) + z);
} else {
tmp = t + (y * z);
}
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) :: tmp
if ((y <= (-1.3d-56)) .or. (.not. (y <= 0.00014d0))) then
tmp = y * ((x * y) + z)
else
tmp = t + (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.3e-56) || !(y <= 0.00014)) {
tmp = y * ((x * y) + z);
} else {
tmp = t + (y * z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.3e-56) or not (y <= 0.00014): tmp = y * ((x * y) + z) else: tmp = t + (y * z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.3e-56) || !(y <= 0.00014)) tmp = Float64(y * Float64(Float64(x * y) + z)); else tmp = Float64(t + Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -1.3e-56) || ~((y <= 0.00014))) tmp = y * ((x * y) + z); else tmp = t + (y * z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.3e-56], N[Not[LessEqual[y, 0.00014]], $MachinePrecision]], N[(y * N[(N[(x * y), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], N[(t + N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.3 \cdot 10^{-56} \lor \neg \left(y \leq 0.00014\right):\\
\;\;\;\;y \cdot \left(x \cdot y + z\right)\\
\mathbf{else}:\\
\;\;\;\;t + y \cdot z\\
\end{array}
\end{array}
if y < -1.29999999999999998e-56 or 1.3999999999999999e-4 < y Initial program 99.9%
Taylor expanded in t around 0 93.0%
if -1.29999999999999998e-56 < y < 1.3999999999999999e-4Initial program 100.0%
Taylor expanded in x around 0 92.2%
Final simplification92.6%
(FPCore (x y z t) :precision binary64 (if (or (<= z -6.6e+107) (not (<= z 5.8e+199))) (* y z) t))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -6.6e+107) || !(z <= 5.8e+199)) {
tmp = y * z;
} else {
tmp = t;
}
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) :: tmp
if ((z <= (-6.6d+107)) .or. (.not. (z <= 5.8d+199))) then
tmp = y * z
else
tmp = t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -6.6e+107) || !(z <= 5.8e+199)) {
tmp = y * z;
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -6.6e+107) or not (z <= 5.8e+199): tmp = y * z else: tmp = t return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -6.6e+107) || !(z <= 5.8e+199)) tmp = Float64(y * z); else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -6.6e+107) || ~((z <= 5.8e+199))) tmp = y * z; else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -6.6e+107], N[Not[LessEqual[z, 5.8e+199]], $MachinePrecision]], N[(y * z), $MachinePrecision], t]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.6 \cdot 10^{+107} \lor \neg \left(z \leq 5.8 \cdot 10^{+199}\right):\\
\;\;\;\;y \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -6.60000000000000064e107 or 5.7999999999999998e199 < z Initial program 100.0%
Taylor expanded in t around 0 85.8%
Taylor expanded in y around 0 74.2%
if -6.60000000000000064e107 < z < 5.7999999999999998e199Initial program 99.9%
Taylor expanded in y around 0 46.7%
Final simplification55.5%
(FPCore (x y z t) :precision binary64 (+ t (* y z)))
double code(double x, double y, double z, double t) {
return t + (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 = t + (y * z)
end function
public static double code(double x, double y, double z, double t) {
return t + (y * z);
}
def code(x, y, z, t): return t + (y * z)
function code(x, y, z, t) return Float64(t + Float64(y * z)) end
function tmp = code(x, y, z, t) tmp = t + (y * z); end
code[x_, y_, z_, t_] := N[(t + N[(y * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
t + y \cdot z
\end{array}
Initial program 99.9%
Taylor expanded in x around 0 67.5%
Final simplification67.5%
(FPCore (x y z t) :precision binary64 t)
double code(double x, double y, double z, double t) {
return 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 = t
end function
public static double code(double x, double y, double z, double t) {
return t;
}
def code(x, y, z, t): return t
function code(x, y, z, t) return t end
function tmp = code(x, y, z, t) tmp = t; end
code[x_, y_, z_, t_] := t
\begin{array}{l}
\\
t
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 37.1%
Final simplification37.1%
herbie shell --seed 2023308
(FPCore (x y z t)
:name "Language.Haskell.HsColour.ColourHighlight:unbase from hscolour-1.23"
:precision binary64
(+ (* (+ (* x y) z) y) t))