
(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}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (- (* x y) (* z t)) 4e+191) (/ (fma (- z) t (* x y)) a) (fma (- t) (/ z a) (/ y (/ a x)))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) - (z * t)) <= 4e+191) {
tmp = fma(-z, t, (x * y)) / a;
} else {
tmp = fma(-t, (z / a), (y / (a / x)));
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(Float64(x * y) - Float64(z * t)) <= 4e+191) tmp = Float64(fma(Float64(-z), t, Float64(x * y)) / a); else tmp = fma(Float64(-t), Float64(z / a), Float64(y / Float64(a / x))); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision], 4e+191], N[(N[((-z) * t + N[(x * y), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[((-t) * N[(z / a), $MachinePrecision] + N[(y / N[(a / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \leq 4 \cdot 10^{+191}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, t, x \cdot y\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-t, \frac{z}{a}, \frac{y}{\frac{a}{x}}\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < 4.00000000000000029e191Initial program 96.5%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6496.5
Applied rewrites96.5%
if 4.00000000000000029e191 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 77.1%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-/.f6490.7
Applied rewrites90.7%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/r*N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6492.4
Applied rewrites92.4%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* z t) -4e+161) (fma (/ x a) y (* z (* t (/ -1.0 a)))) (/ (fma (- z) t (* x y)) a)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z * t) <= -4e+161) {
tmp = fma((x / a), y, (z * (t * (-1.0 / a))));
} else {
tmp = fma(-z, t, (x * y)) / a;
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(z * t) <= -4e+161) tmp = fma(Float64(x / a), y, Float64(z * Float64(t * Float64(-1.0 / a)))); else tmp = Float64(fma(Float64(-z), t, Float64(x * y)) / a); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(z * t), $MachinePrecision], -4e+161], N[(N[(x / a), $MachinePrecision] * y + N[(z * N[(t * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-z) * t + N[(x * y), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -4 \cdot 10^{+161}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{a}, y, z \cdot \left(t \cdot \frac{-1}{a}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, t, x \cdot y\right)}{a}\\
\end{array}
\end{array}
if (*.f64 z t) < -4.0000000000000002e161Initial program 72.9%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-/.f6469.9
Applied rewrites69.9%
lift-neg.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
div-invN/A
lift-/.f64N/A
distribute-rgt-neg-inN/A
neg-mul-1N/A
lift-/.f64N/A
div-invN/A
frac-2negN/A
metadata-evalN/A
div-invN/A
lower-*.f64N/A
lower-/.f64N/A
lower-neg.f6486.7
Applied rewrites86.7%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
metadata-evalN/A
lift-neg.f64N/A
frac-2negN/A
lower-/.f6486.7
Applied rewrites86.7%
if -4.0000000000000002e161 < (*.f64 z t) Initial program 95.8%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6496.3
Applied rewrites96.3%
Final simplification94.8%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* z t) -4e+161) (fma (/ x a) y (- (* z (/ t a)))) (/ (fma (- z) t (* x y)) a)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z * t) <= -4e+161) {
tmp = fma((x / a), y, -(z * (t / a)));
} else {
tmp = fma(-z, t, (x * y)) / a;
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(z * t) <= -4e+161) tmp = fma(Float64(x / a), y, Float64(-Float64(z * Float64(t / a)))); else tmp = Float64(fma(Float64(-z), t, Float64(x * y)) / a); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(z * t), $MachinePrecision], -4e+161], N[(N[(x / a), $MachinePrecision] * y + (-N[(z * N[(t / a), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], N[(N[((-z) * t + N[(x * y), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -4 \cdot 10^{+161}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{a}, y, -z \cdot \frac{t}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, t, x \cdot y\right)}{a}\\
\end{array}
\end{array}
if (*.f64 z t) < -4.0000000000000002e161Initial program 72.9%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-/.f6469.9
Applied rewrites69.9%
lift-neg.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
div-invN/A
lift-/.f64N/A
distribute-rgt-neg-inN/A
neg-mul-1N/A
lift-/.f64N/A
div-invN/A
frac-2negN/A
metadata-evalN/A
div-invN/A
lower-*.f64N/A
lower-/.f64N/A
lower-neg.f6486.7
Applied rewrites86.7%
if -4.0000000000000002e161 < (*.f64 z t) Initial program 95.8%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6496.3
Applied rewrites96.3%
Final simplification94.8%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* z t) (- INFINITY)) (fma (- t) (/ z a) (/ (* x y) a)) (/ (fma (- z) t (* x y)) a)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z * t) <= -((double) INFINITY)) {
tmp = fma(-t, (z / a), ((x * y) / a));
} else {
tmp = fma(-z, t, (x * y)) / a;
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(z * t) <= Float64(-Inf)) tmp = fma(Float64(-t), Float64(z / a), Float64(Float64(x * y) / a)); else tmp = Float64(fma(Float64(-z), t, Float64(x * y)) / a); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(z * t), $MachinePrecision], (-Infinity)], N[((-t) * N[(z / a), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[((-z) * t + N[(x * y), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(-t, \frac{z}{a}, \frac{x \cdot y}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, t, x \cdot y\right)}{a}\\
\end{array}
\end{array}
if (*.f64 z t) < -inf.0Initial program 55.7%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-/.f6494.4
Applied rewrites94.4%
if -inf.0 < (*.f64 z t) Initial program 95.3%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6495.8
Applied rewrites95.8%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= a 8.2e-111) (/ 1.0 (/ a (fma (- z) t (* x y)))) (fma (- z) (/ t a) (/ (* x y) a))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= 8.2e-111) {
tmp = 1.0 / (a / fma(-z, t, (x * y)));
} else {
tmp = fma(-z, (t / a), ((x * y) / a));
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (a <= 8.2e-111) tmp = Float64(1.0 / Float64(a / fma(Float64(-z), t, Float64(x * y)))); else tmp = fma(Float64(-z), Float64(t / a), Float64(Float64(x * y) / a)); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[a, 8.2e-111], N[(1.0 / N[(a / N[((-z) * t + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-z) * N[(t / a), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq 8.2 \cdot 10^{-111}:\\
\;\;\;\;\frac{1}{\frac{a}{\mathsf{fma}\left(-z, t, x \cdot y\right)}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-z, \frac{t}{a}, \frac{x \cdot y}{a}\right)\\
\end{array}
\end{array}
if a < 8.19999999999999936e-111Initial program 93.3%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6494.6
Applied rewrites94.6%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6494.6
Applied rewrites94.6%
if 8.19999999999999936e-111 < a Initial program 91.1%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-/.f6492.5
Applied rewrites92.5%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (* x y) a)))
(if (<= (* x y) -8.8e-13)
t_1
(if (<= (* x y) 0.0019) (/ (* z (- t)) a) t_1))))assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double t_1 = (x * y) / a;
double tmp;
if ((x * y) <= -8.8e-13) {
tmp = t_1;
} else if ((x * y) <= 0.0019) {
tmp = (z * -t) / a;
} else {
tmp = t_1;
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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) / a
if ((x * y) <= (-8.8d-13)) then
tmp = t_1
else if ((x * y) <= 0.0019d0) then
tmp = (z * -t) / a
else
tmp = t_1
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (x * y) / a;
double tmp;
if ((x * y) <= -8.8e-13) {
tmp = t_1;
} else if ((x * y) <= 0.0019) {
tmp = (z * -t) / a;
} else {
tmp = t_1;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): t_1 = (x * y) / a tmp = 0 if (x * y) <= -8.8e-13: tmp = t_1 elif (x * y) <= 0.0019: tmp = (z * -t) / a else: tmp = t_1 return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) t_1 = Float64(Float64(x * y) / a) tmp = 0.0 if (Float64(x * y) <= -8.8e-13) tmp = t_1; elseif (Float64(x * y) <= 0.0019) tmp = Float64(Float64(z * Float64(-t)) / a); else tmp = t_1; end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
t_1 = (x * y) / a;
tmp = 0.0;
if ((x * y) <= -8.8e-13)
tmp = t_1;
elseif ((x * y) <= 0.0019)
tmp = (z * -t) / a;
else
tmp = t_1;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -8.8e-13], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 0.0019], N[(N[(z * (-t)), $MachinePrecision] / a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := \frac{x \cdot y}{a}\\
\mathbf{if}\;x \cdot y \leq -8.8 \cdot 10^{-13}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot y \leq 0.0019:\\
\;\;\;\;\frac{z \cdot \left(-t\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 x y) < -8.79999999999999986e-13 or 0.0019 < (*.f64 x y) Initial program 90.5%
Taylor expanded in x around inf
lower-*.f6479.8
Applied rewrites79.8%
if -8.79999999999999986e-13 < (*.f64 x y) < 0.0019Initial program 94.4%
Taylor expanded in x around 0
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6477.9
Applied rewrites77.9%
Final simplification78.9%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (/ (fma (- z) t (* x y)) a))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
return fma(-z, t, (x * y)) / a;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(fma(Float64(-z), t, Float64(x * y)) / a) end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(N[((-z) * t + N[(x * y), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\frac{\mathsf{fma}\left(-z, t, x \cdot y\right)}{a}
\end{array}
Initial program 92.4%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6493.2
Applied rewrites93.2%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): return ((x * y) - (z * t)) / a
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(z * t)) / a) end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
tmp = ((x * y) - (z * t)) / a;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\frac{x \cdot y - z \cdot t}{a}
\end{array}
Initial program 92.4%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (/ (* x y) a))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
return (x * y) / a;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
return (x * y) / a;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): return (x * y) / a
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(Float64(x * y) / a) end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
tmp = (x * y) / a;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\frac{x \cdot y}{a}
\end{array}
Initial program 92.4%
Taylor expanded in x around inf
lower-*.f6458.0
Applied rewrites58.0%
(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 2024233
(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))