
(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 6 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) 1e+255) (/ (- (* x y) (* z t)) a) (* x (/ y a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= 1e+255) {
tmp = ((x * y) - (z * t)) / a;
} 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 ((x * y) <= 1d+255) then
tmp = ((x * y) - (z * t)) / a
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 ((x * y) <= 1e+255) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = x * (y / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (x * y) <= 1e+255: tmp = ((x * y) - (z * t)) / a else: tmp = x * (y / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= 1e+255) tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); else tmp = Float64(x * Float64(y / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((x * y) <= 1e+255) tmp = ((x * y) - (z * t)) / a; else tmp = x * (y / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], 1e+255], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq 10^{+255}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < 9.99999999999999988e254Initial program 94.5%
if 9.99999999999999988e254 < (*.f64 x y) Initial program 65.5%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6465.5%
Simplified65.5%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64100.0%
Applied egg-rr100.0%
Final simplification94.9%
(FPCore (x y z t a) :precision binary64 (if (<= (* x y) -1e+89) (* x (/ y a)) (if (<= (* x y) 6e+116) (- 0.0 (* z (/ t a))) (* y (/ x a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e+89) {
tmp = x * (y / a);
} else if ((x * y) <= 6e+116) {
tmp = 0.0 - (z * (t / 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 ((x * y) <= (-1d+89)) then
tmp = x * (y / a)
else if ((x * y) <= 6d+116) then
tmp = 0.0d0 - (z * (t / 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 ((x * y) <= -1e+89) {
tmp = x * (y / a);
} else if ((x * y) <= 6e+116) {
tmp = 0.0 - (z * (t / a));
} else {
tmp = y * (x / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (x * y) <= -1e+89: tmp = x * (y / a) elif (x * y) <= 6e+116: tmp = 0.0 - (z * (t / a)) else: tmp = y * (x / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -1e+89) tmp = Float64(x * Float64(y / a)); elseif (Float64(x * y) <= 6e+116) tmp = Float64(0.0 - Float64(z * Float64(t / 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 ((x * y) <= -1e+89) tmp = x * (y / a); elseif ((x * y) <= 6e+116) tmp = 0.0 - (z * (t / a)); else tmp = y * (x / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], -1e+89], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 6e+116], N[(0.0 - N[(z * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+89}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\mathbf{elif}\;x \cdot y \leq 6 \cdot 10^{+116}:\\
\;\;\;\;0 - z \cdot \frac{t}{a}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < -9.99999999999999995e88Initial program 93.0%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6485.6%
Simplified85.6%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f6488.0%
Applied egg-rr88.0%
if -9.99999999999999995e88 < (*.f64 x y) < 5.9999999999999997e116Initial program 93.8%
div-invN/A
flip--N/A
frac-2negN/A
metadata-evalN/A
clear-numN/A
frac-timesN/A
metadata-evalN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
Applied egg-rr92.5%
Taylor expanded in x around 0
/-lowering-/.f64N/A
*-lowering-*.f6472.1%
Simplified72.1%
associate-/r/N/A
associate-*l/N/A
neg-mul-1N/A
distribute-rgt-neg-inN/A
sub0-negN/A
associate-*l/N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
--lowering--.f6471.3%
Applied egg-rr71.3%
sub0-negN/A
neg-lowering-neg.f6471.3%
Applied egg-rr71.3%
if 5.9999999999999997e116 < (*.f64 x y) Initial program 85.4%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6477.8%
Simplified77.8%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6490.3%
Applied egg-rr90.3%
Final simplification77.8%
(FPCore (x y z t a) :precision binary64 (if (<= (* x y) -1e+89) (* x (/ y a)) (if (<= (* x y) 6e+116) (- 0.0 (/ z (/ a t))) (* y (/ x a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e+89) {
tmp = x * (y / a);
} else if ((x * y) <= 6e+116) {
tmp = 0.0 - (z / (a / t));
} 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 ((x * y) <= (-1d+89)) then
tmp = x * (y / a)
else if ((x * y) <= 6d+116) then
tmp = 0.0d0 - (z / (a / t))
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 ((x * y) <= -1e+89) {
tmp = x * (y / a);
} else if ((x * y) <= 6e+116) {
tmp = 0.0 - (z / (a / t));
} else {
tmp = y * (x / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (x * y) <= -1e+89: tmp = x * (y / a) elif (x * y) <= 6e+116: tmp = 0.0 - (z / (a / t)) else: tmp = y * (x / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -1e+89) tmp = Float64(x * Float64(y / a)); elseif (Float64(x * y) <= 6e+116) tmp = Float64(0.0 - Float64(z / Float64(a / t))); else tmp = Float64(y * Float64(x / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((x * y) <= -1e+89) tmp = x * (y / a); elseif ((x * y) <= 6e+116) tmp = 0.0 - (z / (a / t)); else tmp = y * (x / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], -1e+89], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 6e+116], N[(0.0 - N[(z / N[(a / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+89}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\mathbf{elif}\;x \cdot y \leq 6 \cdot 10^{+116}:\\
\;\;\;\;0 - \frac{z}{\frac{a}{t}}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < -9.99999999999999995e88Initial program 93.0%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6485.6%
Simplified85.6%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f6488.0%
Applied egg-rr88.0%
if -9.99999999999999995e88 < (*.f64 x y) < 5.9999999999999997e116Initial program 93.8%
div-invN/A
flip--N/A
frac-2negN/A
metadata-evalN/A
clear-numN/A
frac-timesN/A
metadata-evalN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
Applied egg-rr92.5%
Taylor expanded in x around 0
/-lowering-/.f64N/A
*-lowering-*.f6472.1%
Simplified72.1%
div-invN/A
clear-numN/A
mul-1-negN/A
neg-lowering-neg.f64N/A
clear-numN/A
associate-/r*N/A
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f6469.8%
Applied egg-rr69.8%
if 5.9999999999999997e116 < (*.f64 x y) Initial program 85.4%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6477.8%
Simplified77.8%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6490.3%
Applied egg-rr90.3%
Final simplification76.8%
(FPCore (x y z t a) :precision binary64 (if (<= (* x y) 2e+211) (/ (* x y) a) (* x (/ y a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= 2e+211) {
tmp = (x * y) / a;
} 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 ((x * y) <= 2d+211) then
tmp = (x * y) / a
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 ((x * y) <= 2e+211) {
tmp = (x * y) / a;
} else {
tmp = x * (y / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (x * y) <= 2e+211: tmp = (x * y) / a else: tmp = x * (y / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= 2e+211) tmp = Float64(Float64(x * y) / a); else tmp = Float64(x * Float64(y / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((x * y) <= 2e+211) tmp = (x * y) / a; else tmp = x * (y / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], 2e+211], N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq 2 \cdot 10^{+211}:\\
\;\;\;\;\frac{x \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < 1.9999999999999999e211Initial program 94.2%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6447.1%
Simplified47.1%
if 1.9999999999999999e211 < (*.f64 x y) Initial program 75.5%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6472.4%
Simplified72.4%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f6496.8%
Applied egg-rr96.8%
Final simplification53.1%
(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}
Initial program 92.0%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6450.1%
Simplified50.1%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f6451.3%
Applied egg-rr51.3%
Final simplification51.3%
(FPCore (x y z t a) :precision binary64 (* y (/ x a)))
double code(double x, double y, double z, double t, double a) {
return y * (x / 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 = y * (x / a)
end function
public static double code(double x, double y, double z, double t, double a) {
return y * (x / a);
}
def code(x, y, z, t, a): return y * (x / a)
function code(x, y, z, t, a) return Float64(y * Float64(x / a)) end
function tmp = code(x, y, z, t, a) tmp = y * (x / a); end
code[x_, y_, z_, t_, a_] := N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \frac{x}{a}
\end{array}
Initial program 92.0%
Taylor expanded in x around inf
/-lowering-/.f64N/A
*-lowering-*.f6450.1%
Simplified50.1%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6450.6%
Applied egg-rr50.6%
(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 2024152
(FPCore (x y z t a)
:name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
:precision binary64
:alt
(! :herbie-platform default (if (< z -246868496869954800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6309831121978371/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z)))))
(/ (- (* x y) (* z t)) a))