
(FPCore (x y z t) :precision binary64 :pre TRUE (+ (* x y) (* z t)))
double code(double x, double y, double z, double t) {
return (x * y) + (z * 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 * t)
end function
public static double code(double x, double y, double z, double t) {
return (x * y) + (z * t);
}
def code(x, y, z, t): return (x * y) + (z * t)
function code(x, y, z, t) return Float64(Float64(x * y) + Float64(z * t)) end
function tmp = code(x, y, z, t) tmp = (x * y) + (z * t); end
code[x_, y_, z_, t_] := N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $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 * t) END code
x \cdot y + z \cdot t
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 :pre TRUE (+ (* x y) (* z t)))
double code(double x, double y, double z, double t) {
return (x * y) + (z * 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 * t)
end function
public static double code(double x, double y, double z, double t) {
return (x * y) + (z * t);
}
def code(x, y, z, t): return (x * y) + (z * t)
function code(x, y, z, t) return Float64(Float64(x * y) + Float64(z * t)) end
function tmp = code(x, y, z, t) tmp = (x * y) + (z * t); end
code[x_, y_, z_, t_] := N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $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 * t) END code
x \cdot y + z \cdot t
(FPCore (x y z t) :precision binary64 :pre TRUE (fma t z (* x y)))
double code(double x, double y, double z, double t) {
return fma(t, z, (x * y));
}
function code(x, y, z, t) return fma(t, z, Float64(x * y)) end
code[x_, y_, z_, t_] := N[(t * z + N[(x * y), $MachinePrecision]), $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 = (t * z) + (x * y) END code
\mathsf{fma}\left(t, z, x \cdot y\right)
Initial program 99.2%
Taylor expanded in x around 0
Applied rewrites99.6%
(FPCore (x y z t) :precision binary64 :pre TRUE (* t z))
double code(double x, double y, double z, double t) {
return t * z;
}
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 * z
end function
public static double code(double x, double y, double z, double t) {
return t * z;
}
def code(x, y, z, t): return t * z
function code(x, y, z, t) return Float64(t * z) end
function tmp = code(x, y, z, t) tmp = t * z; end
code[x_, y_, z_, t_] := N[(t * z), $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 = t * z END code
t \cdot z
Initial program 99.2%
Taylor expanded in x around 0
Applied rewrites51.8%
herbie shell --seed 2026092
(FPCore (x y z t)
:name "Linear.V2:$cdot from linear-1.19.1.3, A"
:precision binary64
(+ (* x y) (* z t)))