
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = ((x * y) - (z * t)) / a
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
def code(x, y, z, t, a): return ((x * y) - (z * t)) / a
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(z * t)) / a) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - (z * t)) / a; end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - z \cdot t}{a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = ((x * y) - (z * t)) / a
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
def code(x, y, z, t, a): return ((x * y) - (z * t)) / a
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(z * t)) / a) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - (z * t)) / a; end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - z \cdot t}{a}
\end{array}
(FPCore (x y z t a) :precision binary64 (if (<= (- (* x y) (* z t)) 5e+273) (/ (fma x y (* z (- t))) a) (- (* x (/ y a)) (* t (/ z a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) - (z * t)) <= 5e+273) {
tmp = fma(x, y, (z * -t)) / a;
} else {
tmp = (x * (y / a)) - (t * (z / a));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (Float64(Float64(x * y) - Float64(z * t)) <= 5e+273) tmp = Float64(fma(x, y, Float64(z * Float64(-t))) / a); else tmp = Float64(Float64(x * Float64(y / a)) - Float64(t * Float64(z / a))); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision], 5e+273], N[(N[(x * y + N[(z * (-t)), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision] - N[(t * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \leq 5 \cdot 10^{+273}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y, z \cdot \left(-t\right)\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a} - t \cdot \frac{z}{a}\\
\end{array}
\end{array}
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (- (* x y) (* z t)))) (if (<= t_1 5e+273) (/ t_1 a) (- (* x (/ y a)) (* t (/ z a))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (x * y) - (z * t);
double tmp;
if (t_1 <= 5e+273) {
tmp = t_1 / a;
} else {
tmp = (x * (y / a)) - (t * (z / a));
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: tmp
t_1 = (x * y) - (z * t)
if (t_1 <= 5d+273) then
tmp = t_1 / a
else
tmp = (x * (y / a)) - (t * (z / a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (x * y) - (z * t);
double tmp;
if (t_1 <= 5e+273) {
tmp = t_1 / a;
} else {
tmp = (x * (y / a)) - (t * (z / a));
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (x * y) - (z * t) tmp = 0 if t_1 <= 5e+273: tmp = t_1 / a else: tmp = (x * (y / a)) - (t * (z / a)) return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(x * y) - Float64(z * t)) tmp = 0.0 if (t_1 <= 5e+273) tmp = Float64(t_1 / a); else tmp = Float64(Float64(x * Float64(y / a)) - Float64(t * Float64(z / a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (x * y) - (z * t); tmp = 0.0; if (t_1 <= 5e+273) tmp = t_1 / a; else tmp = (x * (y / a)) - (t * (z / a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e+273], N[(t$95$1 / a), $MachinePrecision], N[(N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision] - N[(t * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t_1 \leq 5 \cdot 10^{+273}:\\
\;\;\;\;\frac{t_1}{a}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a} - t \cdot \frac{z}{a}\\
\end{array}
\end{array}
(FPCore (x y z t a) :precision binary64 (if (or (<= (* z t) -2e-7) (not (<= (* z t) 2e-15))) (/ (- t) (/ a z)) (/ (* x y) a)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((z * t) <= -2e-7) || !((z * t) <= 2e-15)) {
tmp = -t / (a / z);
} else {
tmp = (x * y) / a;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (((z * t) <= (-2d-7)) .or. (.not. ((z * t) <= 2d-15))) then
tmp = -t / (a / z)
else
tmp = (x * y) / a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (((z * t) <= -2e-7) || !((z * t) <= 2e-15)) {
tmp = -t / (a / z);
} else {
tmp = (x * y) / a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if ((z * t) <= -2e-7) or not ((z * t) <= 2e-15): tmp = -t / (a / z) else: tmp = (x * y) / a return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((Float64(z * t) <= -2e-7) || !(Float64(z * t) <= 2e-15)) tmp = Float64(Float64(-t) / Float64(a / z)); else tmp = Float64(Float64(x * y) / a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (((z * t) <= -2e-7) || ~(((z * t) <= 2e-15))) tmp = -t / (a / z); else tmp = (x * y) / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], -2e-7], N[Not[LessEqual[N[(z * t), $MachinePrecision], 2e-15]], $MachinePrecision]], N[((-t) / N[(a / z), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{-7} \lor \neg \left(z \cdot t \leq 2 \cdot 10^{-15}\right):\\
\;\;\;\;\frac{-t}{\frac{a}{z}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{a}\\
\end{array}
\end{array}
(FPCore (x y z t a) :precision binary64 (if (<= (* x y) -20000.0) (* y (/ x a)) (if (<= (* x y) 1e+38) (/ (* z (- t)) a) (/ x (/ a y)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -20000.0) {
tmp = y * (x / a);
} else if ((x * y) <= 1e+38) {
tmp = (z * -t) / a;
} else {
tmp = x / (a / y);
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((x * y) <= (-20000.0d0)) then
tmp = y * (x / a)
else if ((x * y) <= 1d+38) then
tmp = (z * -t) / a
else
tmp = x / (a / y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -20000.0) {
tmp = y * (x / a);
} else if ((x * y) <= 1e+38) {
tmp = (z * -t) / a;
} else {
tmp = x / (a / y);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (x * y) <= -20000.0: tmp = y * (x / a) elif (x * y) <= 1e+38: tmp = (z * -t) / a else: tmp = x / (a / y) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -20000.0) tmp = Float64(y * Float64(x / a)); elseif (Float64(x * y) <= 1e+38) tmp = Float64(Float64(z * Float64(-t)) / a); else tmp = Float64(x / Float64(a / y)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((x * y) <= -20000.0) tmp = y * (x / a); elseif ((x * y) <= 1e+38) tmp = (z * -t) / a; else tmp = x / (a / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], -20000.0], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e+38], N[(N[(z * (-t)), $MachinePrecision] / a), $MachinePrecision], N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -20000:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\mathbf{elif}\;x \cdot y \leq 10^{+38}:\\
\;\;\;\;\frac{z \cdot \left(-t\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{a}{y}}\\
\end{array}
\end{array}
(FPCore (x y z t a) :precision binary64 (if (<= (* z t) 1e-158) (/ (* x y) a) (* y (/ x a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z * t) <= 1e-158) {
tmp = (x * y) / a;
} else {
tmp = y * (x / a);
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((z * t) <= 1d-158) then
tmp = (x * y) / a
else
tmp = y * (x / a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z * t) <= 1e-158) {
tmp = (x * y) / a;
} else {
tmp = y * (x / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z * t) <= 1e-158: tmp = (x * y) / a else: tmp = y * (x / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(z * t) <= 1e-158) tmp = Float64(Float64(x * y) / a); else tmp = Float64(y * Float64(x / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z * t) <= 1e-158) tmp = (x * y) / a; else tmp = y * (x / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(z * t), $MachinePrecision], 1e-158], N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq 10^{-158}:\\
\;\;\;\;\frac{x \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\end{array}
\end{array}
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = ((x * y) - (z * t)) / a
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
def code(x, y, z, t, a): return ((x * y) - (z * t)) / a
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(z * t)) / a) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - (z * t)) / a; end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - z \cdot t}{a}
\end{array}
(FPCore (x y z t a) :precision binary64 (if (<= a 2.6e-158) (* x (/ y a)) (* y (/ x a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= 2.6e-158) {
tmp = x * (y / a);
} else {
tmp = y * (x / a);
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (a <= 2.6d-158) then
tmp = x * (y / a)
else
tmp = y * (x / a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= 2.6e-158) {
tmp = x * (y / a);
} else {
tmp = y * (x / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= 2.6e-158: tmp = x * (y / a) else: tmp = y * (x / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= 2.6e-158) tmp = Float64(x * Float64(y / a)); else tmp = Float64(y * Float64(x / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= 2.6e-158) tmp = x * (y / a); else tmp = y * (x / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, 2.6e-158], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.6 \cdot 10^{-158}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\end{array}
\end{array}
(FPCore (x y z t a) :precision binary64 (if (<= a 2.05e-157) (/ x (/ a y)) (* y (/ x a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= 2.05e-157) {
tmp = x / (a / y);
} else {
tmp = y * (x / a);
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (a <= 2.05d-157) then
tmp = x / (a / y)
else
tmp = y * (x / a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= 2.05e-157) {
tmp = x / (a / y);
} else {
tmp = y * (x / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= 2.05e-157: tmp = x / (a / y) else: tmp = y * (x / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= 2.05e-157) tmp = Float64(x / Float64(a / y)); else tmp = Float64(y * Float64(x / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= 2.05e-157) tmp = x / (a / y); else tmp = y * (x / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, 2.05e-157], N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.05 \cdot 10^{-157}:\\
\;\;\;\;\frac{x}{\frac{a}{y}}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\end{array}
\end{array}
(FPCore (x y z t a) :precision binary64 (* x (/ y a)))
double code(double x, double y, double z, double t, double a) {
return x * (y / a);
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x * (y / a)
end function
public static double code(double x, double y, double z, double t, double a) {
return x * (y / a);
}
def code(x, y, z, t, a): return x * (y / a)
function code(x, y, z, t, a) return Float64(x * Float64(y / a)) end
function tmp = code(x, y, z, t, a) tmp = x * (y / a); end
code[x_, y_, z_, t_, a_] := N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{y}{a}
\end{array}
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- (* (/ y a) x) (* (/ t a) z))))
(if (< z -2.468684968699548e+170)
t_1
(if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = ((y / a) * x) - ((t / a) * z);
double tmp;
if (z < -2.468684968699548e+170) {
tmp = t_1;
} else if (z < 6.309831121978371e-71) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: tmp
t_1 = ((y / a) * x) - ((t / a) * z)
if (z < (-2.468684968699548d+170)) then
tmp = t_1
else if (z < 6.309831121978371d-71) then
tmp = ((x * y) - (z * t)) / a
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = ((y / a) * x) - ((t / a) * z);
double tmp;
if (z < -2.468684968699548e+170) {
tmp = t_1;
} else if (z < 6.309831121978371e-71) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = ((y / a) * x) - ((t / a) * z) tmp = 0 if z < -2.468684968699548e+170: tmp = t_1 elif z < 6.309831121978371e-71: tmp = ((x * y) - (z * t)) / a else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(y / a) * x) - Float64(Float64(t / a) * z)) tmp = 0.0 if (z < -2.468684968699548e+170) tmp = t_1; elseif (z < 6.309831121978371e-71) tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = ((y / a) * x) - ((t / a) * z); tmp = 0.0; if (z < -2.468684968699548e+170) tmp = t_1; elseif (z < 6.309831121978371e-71) tmp = ((x * y) - (z * t)) / a; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision] - N[(N[(t / a), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -2.468684968699548e+170], t$95$1, If[Less[z, 6.309831121978371e-71], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\
\mathbf{if}\;z < -2.468684968699548 \cdot 10^{+170}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z < 6.309831121978371 \cdot 10^{-71}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
herbie shell --seed 2024008
(FPCore (x y z t a)
:name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
:precision binary64
:herbie-target
(if (< z -2.468684968699548e+170) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z))))
(/ (- (* x y) (* z t)) a))