
(FPCore (x y z t) :precision binary64 (- (* 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)
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]
\begin{array}{l}
\\
x \cdot y - z \cdot t
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- (* 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)
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]
\begin{array}{l}
\\
x \cdot y - z \cdot t
\end{array}
(FPCore (x y z t) :precision binary64 (- (* 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)
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]
\begin{array}{l}
\\
x \cdot y - z \cdot t
\end{array}
Initial program 98.8%
(FPCore (x y z t) :precision binary64 (if (or (<= (* z t) -5e-17) (not (<= (* z t) 4e-6))) (* (- z) t) (* y x)))
double code(double x, double y, double z, double t) {
double tmp;
if (((z * t) <= -5e-17) || !((z * t) <= 4e-6)) {
tmp = -z * t;
} else {
tmp = y * x;
}
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 * t) <= (-5d-17)) .or. (.not. ((z * t) <= 4d-6))) then
tmp = -z * t
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((z * t) <= -5e-17) || !((z * t) <= 4e-6)) {
tmp = -z * t;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((z * t) <= -5e-17) or not ((z * t) <= 4e-6): tmp = -z * t else: tmp = y * x return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(z * t) <= -5e-17) || !(Float64(z * t) <= 4e-6)) tmp = Float64(Float64(-z) * t); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((z * t) <= -5e-17) || ~(((z * t) <= 4e-6))) tmp = -z * t; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], -5e-17], N[Not[LessEqual[N[(z * t), $MachinePrecision], 4e-6]], $MachinePrecision]], N[((-z) * t), $MachinePrecision], N[(y * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{-17} \lor \neg \left(z \cdot t \leq 4 \cdot 10^{-6}\right):\\
\;\;\;\;\left(-z\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if (*.f64 z t) < -4.9999999999999999e-17 or 3.99999999999999982e-6 < (*.f64 z t) Initial program 98.1%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6485.8
Applied rewrites85.8%
if -4.9999999999999999e-17 < (*.f64 z t) < 3.99999999999999982e-6Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6430.0
Applied rewrites30.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6479.3
Applied rewrites79.3%
Final simplification83.2%
(FPCore (x y z t) :precision binary64 (* y x))
double code(double x, double y, double z, double t) {
return y * x;
}
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 = y * x
end function
public static double code(double x, double y, double z, double t) {
return y * x;
}
def code(x, y, z, t): return y * x
function code(x, y, z, t) return Float64(y * x) end
function tmp = code(x, y, z, t) tmp = y * x; end
code[x_, y_, z_, t_] := N[(y * x), $MachinePrecision]
\begin{array}{l}
\\
y \cdot x
\end{array}
Initial program 98.8%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6463.8
Applied rewrites63.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6441.4
Applied rewrites41.4%
herbie shell --seed 2024326
(FPCore (x y z t)
:name "Linear.V3:cross from linear-1.19.1.3"
:precision binary64
(- (* x y) (* z t)))