
(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 5 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 (/ (- (* 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}
Initial program 93.0%
(FPCore (x y z t a) :precision binary64 (if (<= (* z t) -1.85e+292) (* z t) (if (<= (* z t) 2.15e+304) (/ (* x y) a) (- (* x y) (* z t)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z * t) <= -1.85e+292) {
tmp = z * t;
} else if ((z * t) <= 2.15e+304) {
tmp = (x * y) / a;
} else {
tmp = (x * y) - (z * t);
}
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) <= (-1.85d+292)) then
tmp = z * t
else if ((z * t) <= 2.15d+304) then
tmp = (x * y) / a
else
tmp = (x * y) - (z * t)
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) <= -1.85e+292) {
tmp = z * t;
} else if ((z * t) <= 2.15e+304) {
tmp = (x * y) / a;
} else {
tmp = (x * y) - (z * t);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z * t) <= -1.85e+292: tmp = z * t elif (z * t) <= 2.15e+304: tmp = (x * y) / a else: tmp = (x * y) - (z * t) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(z * t) <= -1.85e+292) tmp = Float64(z * t); elseif (Float64(z * t) <= 2.15e+304) tmp = Float64(Float64(x * y) / a); else tmp = Float64(Float64(x * y) - Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z * t) <= -1.85e+292) tmp = z * t; elseif ((z * t) <= 2.15e+304) tmp = (x * y) / a; else tmp = (x * y) - (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(z * t), $MachinePrecision], -1.85e+292], N[(z * t), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2.15e+304], N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision], N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1.85 \cdot 10^{+292}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;z \cdot t \leq 2.15 \cdot 10^{+304}:\\
\;\;\;\;\frac{x \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;x \cdot y - z \cdot t\\
\end{array}
\end{array}
if (*.f64 z t) < -1.85000000000000005e292Initial program 72.6%
Taylor expanded in x around 0
Applied rewrites25.5%
Taylor expanded in x around 0
Applied rewrites34.4%
if -1.85000000000000005e292 < (*.f64 z t) < 2.15000000000000002e304Initial program 96.2%
Taylor expanded in x around 0
Applied rewrites58.4%
if 2.15000000000000002e304 < (*.f64 z t) Initial program 74.7%
Taylor expanded in x around 0
Applied rewrites46.7%
(FPCore (x y z t a) :precision binary64 (if (<= a -5e-310) (* z t) (- (* x y) (* z t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -5e-310) {
tmp = z * t;
} else {
tmp = (x * y) - (z * t);
}
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 <= (-5d-310)) then
tmp = z * t
else
tmp = (x * y) - (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -5e-310) {
tmp = z * t;
} else {
tmp = (x * y) - (z * t);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -5e-310: tmp = z * t else: tmp = (x * y) - (z * t) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -5e-310) tmp = Float64(z * t); else tmp = Float64(Float64(x * y) - Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -5e-310) tmp = z * t; else tmp = (x * y) - (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -5e-310], N[(z * t), $MachinePrecision], N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5 \cdot 10^{-310}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot y - z \cdot t\\
\end{array}
\end{array}
if a < -4.999999999999985e-310Initial program 89.5%
Taylor expanded in x around 0
Applied rewrites2.0%
Taylor expanded in x around 0
Applied rewrites16.4%
if -4.999999999999985e-310 < a Initial program 95.7%
Taylor expanded in x around 0
Applied rewrites22.0%
(FPCore (x y z t a) :precision binary64 (if (<= a -5e-310) (* z t) (* x y)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -5e-310) {
tmp = z * t;
} else {
tmp = x * 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 (a <= (-5d-310)) then
tmp = z * t
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -5e-310) {
tmp = z * t;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -5e-310: tmp = z * t else: tmp = x * y return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -5e-310) tmp = Float64(z * t); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -5e-310) tmp = z * t; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -5e-310], N[(z * t), $MachinePrecision], N[(x * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5 \cdot 10^{-310}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if a < -4.999999999999985e-310Initial program 89.5%
Taylor expanded in x around 0
Applied rewrites2.0%
Taylor expanded in x around 0
Applied rewrites16.4%
if -4.999999999999985e-310 < a Initial program 95.7%
Taylor expanded in x around 0
Applied rewrites22.0%
Taylor expanded in x around 0
Applied rewrites16.2%
(FPCore (x y z t a) :precision binary64 (* x y))
double code(double x, double y, double z, double t, double a) {
return x * y;
}
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
end function
public static double code(double x, double y, double z, double t, double a) {
return x * y;
}
def code(x, y, z, t, a): return x * y
function code(x, y, z, t, a) return Float64(x * y) end
function tmp = code(x, y, z, t, a) tmp = x * y; end
code[x_, y_, z_, t_, a_] := N[(x * y), $MachinePrecision]
\begin{array}{l}
\\
x \cdot y
\end{array}
Initial program 93.0%
Taylor expanded in x around 0
Applied rewrites13.3%
Taylor expanded in x around 0
Applied rewrites11.9%
(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 2024321
(FPCore (x y z t a)
:name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
:precision binary64
:pre (TRUE)
: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))