
(FPCore (x y z t) :precision binary64 :pre TRUE (+ (* (+ (* 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)
use fmin_fmax_functions
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]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = (((x * y) + z) * y) + t END code
\left(x \cdot y + z\right) \cdot y + t
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 :pre TRUE (+ (* (+ (* 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)
use fmin_fmax_functions
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]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = (((x * y) + z) * y) + t END code
\left(x \cdot y + z\right) \cdot y + t
(FPCore (x y z t) :precision binary64 :pre TRUE (fma y (fma y x z) t))
double code(double x, double y, double z, double t) {
return fma(y, fma(y, x, z), t);
}
function code(x, y, z, t) return fma(y, fma(y, x, z), t) end
code[x_, y_, z_, t_] := N[(y * N[(y * x + z), $MachinePrecision] + t), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = (y * ((y * x) + z)) + t END code
\mathsf{fma}\left(y, \mathsf{fma}\left(y, x, z\right), t\right)
Initial program 99.9%
Applied rewrites99.9%
(FPCore (x y z t)
:precision binary64
:pre TRUE
(let* ((t_1 (* (fma y x z) y)))
(if (<= y -362737.36445094895)
t_1
(if (<= y 27842210377009184.0) (fma y z t) t_1))))double code(double x, double y, double z, double t) {
double t_1 = fma(y, x, z) * y;
double tmp;
if (y <= -362737.36445094895) {
tmp = t_1;
} else if (y <= 27842210377009184.0) {
tmp = fma(y, z, t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(fma(y, x, z) * y) tmp = 0.0 if (y <= -362737.36445094895) tmp = t_1; elseif (y <= 27842210377009184.0) tmp = fma(y, z, t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y * x + z), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -362737.36445094895], t$95$1, If[LessEqual[y, 27842210377009184.0], N[(y * z + t), $MachinePrecision], t$95$1]]]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = LET t_1 = (((y * x) + z) * y) IN LET tmp_1 = IF (y <= (27842210377009184)) THEN ((y * z) + t) ELSE t_1 ENDIF IN LET tmp = IF (y <= (-3627373644509489531628787517547607421875e-34)) THEN t_1 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, x, z\right) \cdot y\\
\mathbf{if}\;y \leq -362737.36445094895:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 27842210377009184:\\
\;\;\;\;\mathsf{fma}\left(y, z, t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -362737.36445094895 or 27842210377009184 < y Initial program 99.9%
Taylor expanded in t around inf
Applied rewrites92.3%
Applied rewrites92.2%
Taylor expanded in t around 0
Applied rewrites55.4%
Applied rewrites63.2%
if -362737.36445094895 < y < 27842210377009184Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites65.7%
Applied rewrites65.7%
(FPCore (x y z t) :precision binary64 :pre TRUE (fma y z t))
double code(double x, double y, double z, double t) {
return fma(y, z, t);
}
function code(x, y, z, t) return fma(y, z, t) end
code[x_, y_, z_, t_] := N[(y * z + t), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = (y * z) + t END code
\mathsf{fma}\left(y, z, t\right)
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites65.7%
Applied rewrites65.7%
(FPCore (x y z t) :precision binary64 :pre TRUE t)
double code(double x, double y, double z, double t) {
return t;
}
real(8) function code(x, y, z, t)
use fmin_fmax_functions
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
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = t END code
t
Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites38.6%
herbie shell --seed 2026092
(FPCore (x y z t)
:name "Language.Haskell.HsColour.ColourHighlight:unbase from hscolour-1.23"
:precision binary64
(+ (* (+ (* x y) z) y) t))