
(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 8 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. 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 (fma (/ x a) y (- (/ z (/ a t))))) (t_2 (- (* x y) (* z t)))) (if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 5e+235) (/ t_2 a) t_1))))
assert(x < y && y < z && z < t && t < a);
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((x / a), y, -(z / (a / t)));
double t_2 = (x * y) - (z * t);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 5e+235) {
tmp = t_2 / a;
} else {
tmp = t_1;
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) t_1 = fma(Float64(x / a), y, Float64(-Float64(z / Float64(a / t)))) t_2 = Float64(Float64(x * y) - Float64(z * t)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 5e+235) tmp = Float64(t_2 / a); else tmp = t_1; end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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 / a), $MachinePrecision] * y + (-N[(z / N[(a / t), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 5e+235], N[(t$95$2 / a), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{x}{a}, y, -\frac{z}{\frac{a}{t}}\right)\\
t_2 := x \cdot y - z \cdot t\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+235}:\\
\;\;\;\;\frac{t\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -inf.0 or 5.00000000000000027e235 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 59.1%
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-/.f6467.8
Applied rewrites67.8%
associate-/l*N/A
lift-/.f64N/A
distribute-lft-neg-outN/A
lift-/.f64N/A
lift-neg.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6490.4
Applied rewrites90.4%
if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z t)) < 5.00000000000000027e235Initial program 98.8%
Final simplification96.3%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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)) (* z (/ t (- a))) (if (<= (* z t) 5e+246) (/ (- (* x y) (* z t)) a) (* t (* z (/ -1.0 a))))))
assert(x < y && y < z && z < t && t < 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 = z * (t / -a);
} else if ((z * t) <= 5e+246) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = t * (z * (-1.0 / a));
}
return tmp;
}
assert x < y && y < z && z < t && t < a;
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z * t) <= -Double.POSITIVE_INFINITY) {
tmp = z * (t / -a);
} else if ((z * t) <= 5e+246) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = t * (z * (-1.0 / a));
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (z * t) <= -math.inf: tmp = z * (t / -a) elif (z * t) <= 5e+246: tmp = ((x * y) - (z * t)) / a else: tmp = t * (z * (-1.0 / a)) return tmp
x, y, z, t, a = sort([x, y, z, t, a]) 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 = Float64(z * Float64(t / Float64(-a))); elseif (Float64(z * t) <= 5e+246) tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); else tmp = Float64(t * Float64(z * Float64(-1.0 / a))); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((z * t) <= -Inf)
tmp = z * (t / -a);
elseif ((z * t) <= 5e+246)
tmp = ((x * y) - (z * t)) / a;
else
tmp = t * (z * (-1.0 / a));
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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[(z * N[(t / (-a)), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+246], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(t * N[(z * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -\infty:\\
\;\;\;\;z \cdot \frac{t}{-a}\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+246}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;t \cdot \left(z \cdot \frac{-1}{a}\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -inf.0Initial program 42.8%
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-/.f6482.8
Applied rewrites82.8%
Taylor expanded in z around inf
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
distribute-neg-frac2N/A
neg-mul-1N/A
lower-/.f64N/A
neg-mul-1N/A
lower-neg.f6495.7
Applied rewrites95.7%
lift-neg.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
lift-*.f6495.7
Applied rewrites95.7%
if -inf.0 < (*.f64 z t) < 4.99999999999999976e246Initial program 94.5%
if 4.99999999999999976e246 < (*.f64 z t) Initial program 59.7%
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-/.f6479.9
Applied rewrites79.9%
Taylor expanded in z around inf
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
distribute-neg-frac2N/A
neg-mul-1N/A
lower-/.f64N/A
neg-mul-1N/A
lower-neg.f6486.9
Applied rewrites86.9%
lift-neg.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-neg.f64N/A
metadata-evalN/A
frac-2negN/A
lower-/.f6486.9
Applied rewrites86.9%
Final simplification94.1%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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) -2e-63) (- (* t (/ z a))) (if (<= (* z t) 2e+50) (/ x (/ a y)) (* z (/ t (- a))))))
assert(x < y && y < z && z < t && t < 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) <= -2e-63) {
tmp = -(t * (z / a));
} else if ((z * t) <= 2e+50) {
tmp = x / (a / y);
} else {
tmp = z * (t / -a);
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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) :: tmp
if ((z * t) <= (-2d-63)) then
tmp = -(t * (z / a))
else if ((z * t) <= 2d+50) then
tmp = x / (a / y)
else
tmp = z * (t / -a)
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z * t) <= -2e-63) {
tmp = -(t * (z / a));
} else if ((z * t) <= 2e+50) {
tmp = x / (a / y);
} else {
tmp = z * (t / -a);
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (z * t) <= -2e-63: tmp = -(t * (z / a)) elif (z * t) <= 2e+50: tmp = x / (a / y) else: tmp = z * (t / -a) return tmp
x, y, z, t, a = sort([x, y, z, t, a]) 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) <= -2e-63) tmp = Float64(-Float64(t * Float64(z / a))); elseif (Float64(z * t) <= 2e+50) tmp = Float64(x / Float64(a / y)); else tmp = Float64(z * Float64(t / Float64(-a))); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((z * t) <= -2e-63)
tmp = -(t * (z / a));
elseif ((z * t) <= 2e+50)
tmp = x / (a / y);
else
tmp = z * (t / -a);
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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], -2e-63], (-N[(t * N[(z / a), $MachinePrecision]), $MachinePrecision]), If[LessEqual[N[(z * t), $MachinePrecision], 2e+50], N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision], N[(z * N[(t / (-a)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{-63}:\\
\;\;\;\;-t \cdot \frac{z}{a}\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+50}:\\
\;\;\;\;\frac{x}{\frac{a}{y}}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{t}{-a}\\
\end{array}
\end{array}
if (*.f64 z t) < -2.00000000000000013e-63Initial program 78.8%
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-/.f6483.8
Applied rewrites83.8%
Taylor expanded in z around inf
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
distribute-neg-frac2N/A
neg-mul-1N/A
lower-/.f64N/A
neg-mul-1N/A
lower-neg.f6478.1
Applied rewrites78.1%
if -2.00000000000000013e-63 < (*.f64 z t) < 2.0000000000000002e50Initial program 93.6%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f6476.0
Applied rewrites76.0%
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6475.3
Applied rewrites75.3%
if 2.0000000000000002e50 < (*.f64 z t) Initial program 83.2%
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-/.f6488.8
Applied rewrites88.8%
Taylor expanded in z around inf
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
distribute-neg-frac2N/A
neg-mul-1N/A
lower-/.f64N/A
neg-mul-1N/A
lower-neg.f6486.1
Applied rewrites86.1%
lift-neg.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
lift-*.f6487.6
Applied rewrites87.6%
Final simplification78.3%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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 1.3e-73) (/ (- (* x y) (* z t)) a) (fma (/ y a) x (* z (/ t (- a))))))
assert(x < y && y < z && z < t && t < 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 <= 1.3e-73) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = fma((y / a), x, (z * (t / -a)));
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (a <= 1.3e-73) tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); else tmp = fma(Float64(y / a), x, Float64(z * Float64(t / Float64(-a)))); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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, 1.3e-73], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * x + N[(z * N[(t / (-a)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.3 \cdot 10^{-73}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, x, z \cdot \frac{t}{-a}\right)\\
\end{array}
\end{array}
if a < 1.3e-73Initial program 90.0%
if 1.3e-73 < a Initial program 81.6%
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-/.f6487.9
Applied rewrites87.9%
lift-neg.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
+-commutativeN/A
lift-neg.f64N/A
cancel-sign-sub-invN/A
*-commutativeN/A
lift-/.f64N/A
frac-2negN/A
distribute-frac-negN/A
cancel-sign-subN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-neg.f6494.6
Applied rewrites94.6%
Final simplification91.5%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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) -2e-63) (- (* t (/ z a))) (if (<= (* z t) 2e+50) (* x (/ y a)) (* z (/ t (- a))))))
assert(x < y && y < z && z < t && t < 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) <= -2e-63) {
tmp = -(t * (z / a));
} else if ((z * t) <= 2e+50) {
tmp = x * (y / a);
} else {
tmp = z * (t / -a);
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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) :: tmp
if ((z * t) <= (-2d-63)) then
tmp = -(t * (z / a))
else if ((z * t) <= 2d+50) then
tmp = x * (y / a)
else
tmp = z * (t / -a)
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z * t) <= -2e-63) {
tmp = -(t * (z / a));
} else if ((z * t) <= 2e+50) {
tmp = x * (y / a);
} else {
tmp = z * (t / -a);
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (z * t) <= -2e-63: tmp = -(t * (z / a)) elif (z * t) <= 2e+50: tmp = x * (y / a) else: tmp = z * (t / -a) return tmp
x, y, z, t, a = sort([x, y, z, t, a]) 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) <= -2e-63) tmp = Float64(-Float64(t * Float64(z / a))); elseif (Float64(z * t) <= 2e+50) tmp = Float64(x * Float64(y / a)); else tmp = Float64(z * Float64(t / Float64(-a))); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((z * t) <= -2e-63)
tmp = -(t * (z / a));
elseif ((z * t) <= 2e+50)
tmp = x * (y / a);
else
tmp = z * (t / -a);
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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], -2e-63], (-N[(t * N[(z / a), $MachinePrecision]), $MachinePrecision]), If[LessEqual[N[(z * t), $MachinePrecision], 2e+50], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision], N[(z * N[(t / (-a)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{-63}:\\
\;\;\;\;-t \cdot \frac{z}{a}\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+50}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{t}{-a}\\
\end{array}
\end{array}
if (*.f64 z t) < -2.00000000000000013e-63Initial program 78.8%
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-/.f6483.8
Applied rewrites83.8%
Taylor expanded in z around inf
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
distribute-neg-frac2N/A
neg-mul-1N/A
lower-/.f64N/A
neg-mul-1N/A
lower-neg.f6478.1
Applied rewrites78.1%
if -2.00000000000000013e-63 < (*.f64 z t) < 2.0000000000000002e50Initial program 93.6%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f6476.0
Applied rewrites76.0%
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6475.2
Applied rewrites75.2%
if 2.0000000000000002e50 < (*.f64 z t) Initial program 83.2%
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-/.f6488.8
Applied rewrites88.8%
Taylor expanded in z around inf
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
distribute-neg-frac2N/A
neg-mul-1N/A
lower-/.f64N/A
neg-mul-1N/A
lower-neg.f6486.1
Applied rewrites86.1%
lift-neg.f64N/A
associate-*r/N/A
associate-*l/N/A
lift-/.f64N/A
lift-*.f6487.6
Applied rewrites87.6%
Final simplification78.3%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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 (- (* t (/ z a))))) (if (<= (* z t) -2e-63) t_1 (if (<= (* z t) 2e+50) (* x (/ y a)) t_1))))
assert(x < y && y < z && z < t && t < a);
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double t_1 = -(t * (z / a));
double tmp;
if ((z * t) <= -2e-63) {
tmp = t_1;
} else if ((z * t) <= 2e+50) {
tmp = x * (y / a);
} else {
tmp = t_1;
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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 = -(t * (z / a))
if ((z * t) <= (-2d-63)) then
tmp = t_1
else if ((z * t) <= 2d+50) then
tmp = x * (y / a)
else
tmp = t_1
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
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 = -(t * (z / a));
double tmp;
if ((z * t) <= -2e-63) {
tmp = t_1;
} else if ((z * t) <= 2e+50) {
tmp = x * (y / a);
} else {
tmp = t_1;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): t_1 = -(t * (z / a)) tmp = 0 if (z * t) <= -2e-63: tmp = t_1 elif (z * t) <= 2e+50: tmp = x * (y / a) else: tmp = t_1 return tmp
x, y, z, t, a = sort([x, y, z, t, a]) x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) t_1 = Float64(-Float64(t * Float64(z / a))) tmp = 0.0 if (Float64(z * t) <= -2e-63) tmp = t_1; elseif (Float64(z * t) <= 2e+50) tmp = Float64(x * Float64(y / a)); else tmp = t_1; end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
t_1 = -(t * (z / a));
tmp = 0.0;
if ((z * t) <= -2e-63)
tmp = t_1;
elseif ((z * t) <= 2e+50)
tmp = x * (y / 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.
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[(t * N[(z / a), $MachinePrecision]), $MachinePrecision])}, If[LessEqual[N[(z * t), $MachinePrecision], -2e-63], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 2e+50], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := -t \cdot \frac{z}{a}\\
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{-63}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+50}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -2.00000000000000013e-63 or 2.0000000000000002e50 < (*.f64 z t) Initial program 80.4%
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-/.f6485.7
Applied rewrites85.7%
Taylor expanded in z around inf
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
distribute-neg-frac2N/A
neg-mul-1N/A
lower-/.f64N/A
neg-mul-1N/A
lower-neg.f6481.1
Applied rewrites81.1%
if -2.00000000000000013e-63 < (*.f64 z t) < 2.0000000000000002e50Initial program 93.6%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f6476.0
Applied rewrites76.0%
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6475.2
Applied rewrites75.2%
Final simplification78.0%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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 (<= t 1.02e-69) (* x (/ y a)) (* y (/ x a))))
assert(x < y && y < z && z < t && t < 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 (t <= 1.02e-69) {
tmp = x * (y / a);
} else {
tmp = y * (x / a);
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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) :: tmp
if (t <= 1.02d-69) then
tmp = x * (y / a)
else
tmp = y * (x / a)
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 1.02e-69) {
tmp = x * (y / a);
} else {
tmp = y * (x / a);
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if t <= 1.02e-69: tmp = x * (y / a) else: tmp = y * (x / a) return tmp
x, y, z, t, a = sort([x, y, z, t, a]) x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (t <= 1.02e-69) tmp = Float64(x * Float64(y / a)); else tmp = Float64(y * Float64(x / a)); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if (t <= 1.02e-69)
tmp = x * (y / a);
else
tmp = y * (x / a);
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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[t, 1.02e-69], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.02 \cdot 10^{-69}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{a}\\
\end{array}
\end{array}
if t < 1.02000000000000005e-69Initial program 90.1%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f6457.9
Applied rewrites57.9%
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6460.1
Applied rewrites60.1%
if 1.02000000000000005e-69 < t Initial program 81.5%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f6430.2
Applied rewrites30.2%
associate-*l/N/A
lift-/.f64N/A
lower-*.f6436.9
Applied rewrites36.9%
Final simplification52.6%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. 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 (* y (/ x a)))
assert(x < y && y < z && z < t && t < a);
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
return y * (x / a);
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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 = y * (x / a)
end function
assert x < y && y < z && z < t && t < a;
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
return y * (x / a);
}
[x, y, z, t, a] = sort([x, y, z, t, a]) [x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): return y * (x / a)
x, y, z, t, a = sort([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(y * Float64(x / a)) end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
tmp = y * (x / a);
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\\\
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
y \cdot \frac{x}{a}
\end{array}
Initial program 87.3%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f6449.0
Applied rewrites49.0%
associate-*l/N/A
lift-/.f64N/A
lower-*.f6451.7
Applied rewrites51.7%
Final simplification51.7%
(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 2024216
(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))