
(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 4 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) (* y x)))
double code(double x, double y, double z, double t) {
return fma(t, -z, (y * x));
}
function code(x, y, z, t) return fma(t, Float64(-z), Float64(y * x)) end
code[x_, y_, z_, t_] := N[(t * (-z) + N[(y * x), $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)) + (y * x) END code
\mathsf{fma}\left(t, -z, y \cdot x\right)
Initial program 99.2%
Applied rewrites99.6%
(FPCore (x y z t)
:precision binary64
:pre TRUE
(let* ((t_1 (* (- z) t)))
(if (<= (* z t) -2e-20)
t_1
(if (<= (* z t) 50000000000000.0) (* x y) t_1))))double code(double x, double y, double z, double t) {
double t_1 = -z * t;
double tmp;
if ((z * t) <= -2e-20) {
tmp = t_1;
} else if ((z * t) <= 50000000000000.0) {
tmp = x * y;
} else {
tmp = t_1;
}
return tmp;
}
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
real(8) :: t_1
real(8) :: tmp
t_1 = -z * t
if ((z * t) <= (-2d-20)) then
tmp = t_1
else if ((z * t) <= 50000000000000.0d0) then
tmp = x * y
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 = -z * t;
double tmp;
if ((z * t) <= -2e-20) {
tmp = t_1;
} else if ((z * t) <= 50000000000000.0) {
tmp = x * y;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = -z * t tmp = 0 if (z * t) <= -2e-20: tmp = t_1 elif (z * t) <= 50000000000000.0: tmp = x * y else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(-z) * t) tmp = 0.0 if (Float64(z * t) <= -2e-20) tmp = t_1; elseif (Float64(z * t) <= 50000000000000.0) tmp = Float64(x * y); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = -z * t; tmp = 0.0; if ((z * t) <= -2e-20) tmp = t_1; elseif ((z * t) <= 50000000000000.0) tmp = x * y; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[((-z) * t), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -2e-20], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 50000000000000.0], N[(x * y), $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 = ((- z) * t) IN LET tmp_1 = IF ((z * t) <= (5e13)) THEN (x * y) ELSE t_1 ENDIF IN LET tmp = IF ((z * t) <= (-199999999999999989030654290841914330345900740557478489421543155213356612875941209495067596435546875e-118)) THEN t_1 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_1 := \left(-z\right) \cdot t\\
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{-20}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 50000000000000:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (*.f64 z t) < -1.9999999999999999e-20 or 5e13 < (*.f64 z t) Initial program 99.2%
Taylor expanded in x around 0
Applied rewrites51.9%
Applied rewrites51.9%
if -1.9999999999999999e-20 < (*.f64 z t) < 5e13Initial program 99.2%
Taylor expanded in x around 0
Applied rewrites51.9%
Applied rewrites51.9%
Taylor expanded in x around inf
Applied rewrites52.0%
(FPCore (x y z t) :precision binary64 :pre TRUE (* x y))
double code(double x, double y, double z, double t) {
return x * y;
}
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
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]
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 END code
x \cdot y
Initial program 99.2%
Taylor expanded in x around 0
Applied rewrites51.9%
Applied rewrites51.9%
Taylor expanded in x around inf
Applied rewrites52.0%
herbie shell --seed 2026092
(FPCore (x y z t)
:name "Linear.V3:cross from linear-1.19.1.3"
:precision binary64
(- (* x y) (* z t)))