
(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 10 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
(let* ((t_1 (* (- t) (/ z a))) (t_2 (- (* x y) (* z t))))
(if (<= t_2 (- INFINITY))
(fma (/ y a) x t_1)
(if (<= t_2 2e+185) (/ t_2 a) (fma (/ x a) y 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 = -t * (z / a);
double t_2 = (x * y) - (z * t);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = fma((y / a), x, t_1);
} else if (t_2 <= 2e+185) {
tmp = t_2 / a;
} else {
tmp = fma((x / a), y, 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(-t) * Float64(z / a)) t_2 = Float64(Float64(x * y) - Float64(z * t)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = fma(Float64(y / a), x, t_1); elseif (t_2 <= 2e+185) tmp = Float64(t_2 / a); else tmp = fma(Float64(x / a), y, t_1); 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_] := Block[{t$95$1 = N[((-t) * N[(z / a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(y / a), $MachinePrecision] * x + t$95$1), $MachinePrecision], If[LessEqual[t$95$2, 2e+185], N[(t$95$2 / a), $MachinePrecision], N[(N[(x / a), $MachinePrecision] * y + t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := \left(-t\right) \cdot \frac{z}{a}\\
t_2 := x \cdot y - z \cdot t\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, x, t\_1\right)\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+185}:\\
\;\;\;\;\frac{t\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{a}, y, t\_1\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -inf.0Initial program 72.6%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-negN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-/.f6495.6
Applied rewrites95.6%
if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z t)) < 2e185Initial program 98.5%
if 2e185 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 85.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
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-/.f6496.0
Applied rewrites96.0%
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) (* z t))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 2e+185)))
(fma (/ x a) y (* (- t) (/ z a)))
(/ t_1 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 = (x * y) - (z * t);
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 2e+185)) {
tmp = fma((x / a), y, (-t * (z / a)));
} else {
tmp = t_1 / a;
}
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) - Float64(z * t)) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 2e+185)) tmp = fma(Float64(x / a), y, Float64(Float64(-t) * Float64(z / a))); else tmp = Float64(t_1 / 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_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 2e+185]], $MachinePrecision]], N[(N[(x / a), $MachinePrecision] * y + N[((-t) * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / a), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
\mathbf{if}\;t\_1 \leq -\infty \lor \neg \left(t\_1 \leq 2 \cdot 10^{+185}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{a}, y, \left(-t\right) \cdot \frac{z}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{a}\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -inf.0 or 2e185 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 81.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
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-/.f6495.9
Applied rewrites95.9%
if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z t)) < 2e185Initial program 98.5%
Final simplification97.7%
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) -2e+246)
(/ y (/ a x))
(if (<= (* x y) 1e+238)
(/ (- (* x y) (* z t)) a)
(fma (/ (- t) a) z (* (/ 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) <= -2e+246) {
tmp = y / (a / x);
} else if ((x * y) <= 1e+238) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = fma((-t / a), z, ((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(x * y) <= -2e+246) tmp = Float64(y / Float64(a / x)); elseif (Float64(x * y) <= 1e+238) tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); else tmp = fma(Float64(Float64(-t) / a), z, Float64(Float64(y / 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[(x * y), $MachinePrecision], -2e+246], N[(y / N[(a / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e+238], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[((-t) / a), $MachinePrecision] * z + N[(N[(y / a), $MachinePrecision] * x), $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 \leq -2 \cdot 10^{+246}:\\
\;\;\;\;\frac{y}{\frac{a}{x}}\\
\mathbf{elif}\;x \cdot y \leq 10^{+238}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-t}{a}, z, \frac{y}{a} \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -2.00000000000000014e246Initial program 61.8%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6468.5
Applied rewrites68.5%
Applied rewrites93.7%
if -2.00000000000000014e246 < (*.f64 x y) < 1e238Initial program 97.5%
if 1e238 < (*.f64 x y) Initial program 75.5%
lift-/.f64N/A
frac-2negN/A
div-invN/A
lower-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-neg-inN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
remove-double-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
neg-mul-1N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6475.8
Applied rewrites75.8%
lift-*.f64N/A
*-commutativeN/A
lift-fma.f64N/A
distribute-rgt-inN/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
div-invN/A
*-commutativeN/A
associate-/l*N/A
lift-neg.f64N/A
frac-2negN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6491.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6491.7
Applied rewrites91.7%
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
un-div-invN/A
lower-/.f64N/A
lower-neg.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Final simplification97.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 (if (or (<= (* z t) -2e+40) (not (<= (* z t) 1e+14))) (* z (/ (- t) a)) (/ (* y x) 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+40) || !((z * t) <= 1e+14)) {
tmp = z * (-t / 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.
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+40)) .or. (.not. ((z * t) <= 1d+14))) then
tmp = z * (-t / a)
else
tmp = (y * x) / a
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 tmp;
if (((z * t) <= -2e+40) || !((z * t) <= 1e+14)) {
tmp = z * (-t / a);
} else {
tmp = (y * x) / a;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if ((z * t) <= -2e+40) or not ((z * t) <= 1e+14): tmp = z * (-t / a) else: tmp = (y * x) / 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) <= -2e+40) || !(Float64(z * t) <= 1e+14)) tmp = Float64(z * Float64(Float64(-t) / a)); else tmp = Float64(Float64(y * x) / a); 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)
tmp = 0.0;
if (((z * t) <= -2e+40) || ~(((z * t) <= 1e+14)))
tmp = z * (-t / 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. code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], -2e+40], N[Not[LessEqual[N[(z * t), $MachinePrecision], 1e+14]], $MachinePrecision]], N[(z * N[((-t) / a), $MachinePrecision]), $MachinePrecision], N[(N[(y * x), $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 -2 \cdot 10^{+40} \lor \neg \left(z \cdot t \leq 10^{+14}\right):\\
\;\;\;\;z \cdot \frac{-t}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{a}\\
\end{array}
\end{array}
if (*.f64 z t) < -2.00000000000000006e40 or 1e14 < (*.f64 z t) Initial program 90.8%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r/N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6482.8
Applied rewrites82.8%
if -2.00000000000000006e40 < (*.f64 z t) < 1e14Initial program 95.5%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6477.4
Applied rewrites77.4%
Final simplification79.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 (or (<= (* z t) -2e+40) (not (<= (* z t) 2e-22))) (* (/ (- z) a) t) (/ (* y x) 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+40) || !((z * t) <= 2e-22)) {
tmp = (-z / a) * t;
} else {
tmp = (y * x) / a;
}
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) :: tmp
if (((z * t) <= (-2d+40)) .or. (.not. ((z * t) <= 2d-22))) then
tmp = (-z / a) * t
else
tmp = (y * x) / a
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 tmp;
if (((z * t) <= -2e+40) || !((z * t) <= 2e-22)) {
tmp = (-z / a) * t;
} else {
tmp = (y * x) / a;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if ((z * t) <= -2e+40) or not ((z * t) <= 2e-22): tmp = (-z / a) * t else: tmp = (y * x) / 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) <= -2e+40) || !(Float64(z * t) <= 2e-22)) tmp = Float64(Float64(Float64(-z) / a) * t); else tmp = Float64(Float64(y * x) / a); 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)
tmp = 0.0;
if (((z * t) <= -2e+40) || ~(((z * t) <= 2e-22)))
tmp = (-z / a) * t;
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. code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], -2e+40], N[Not[LessEqual[N[(z * t), $MachinePrecision], 2e-22]], $MachinePrecision]], N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision], N[(N[(y * x), $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 -2 \cdot 10^{+40} \lor \neg \left(z \cdot t \leq 2 \cdot 10^{-22}\right):\\
\;\;\;\;\frac{-z}{a} \cdot t\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{a}\\
\end{array}
\end{array}
if (*.f64 z t) < -2.00000000000000006e40 or 2.0000000000000001e-22 < (*.f64 z t) Initial program 91.4%
lift-/.f64N/A
frac-2negN/A
div-invN/A
lower-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-neg-inN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
remove-double-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
neg-mul-1N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6491.3
Applied rewrites91.3%
Taylor expanded in x around 0
*-commutativeN/A
associate-*l/N/A
associate-*l*N/A
lower-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6477.1
Applied rewrites77.1%
if -2.00000000000000006e40 < (*.f64 z t) < 2.0000000000000001e-22Initial program 95.3%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6480.1
Applied rewrites80.1%
Final simplification78.7%
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) -5e-8) (/ (* (- z) t) a) (if (<= (* z t) 1e+14) (/ (* y x) a) (* z (/ (- 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) <= -5e-8) {
tmp = (-z * t) / a;
} else if ((z * t) <= 1e+14) {
tmp = (y * x) / 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.
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) <= (-5d-8)) then
tmp = (-z * t) / a
else if ((z * t) <= 1d+14) then
tmp = (y * x) / a
else
tmp = z * (-t / a)
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 tmp;
if ((z * t) <= -5e-8) {
tmp = (-z * t) / a;
} else if ((z * t) <= 1e+14) {
tmp = (y * x) / a;
} else {
tmp = z * (-t / a);
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (z * t) <= -5e-8: tmp = (-z * t) / a elif (z * t) <= 1e+14: tmp = (y * x) / a else: tmp = z * (-t / 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) <= -5e-8) tmp = Float64(Float64(Float64(-z) * t) / a); elseif (Float64(z * t) <= 1e+14) tmp = Float64(Float64(y * x) / a); else tmp = Float64(z * Float64(Float64(-t) / a)); 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)
tmp = 0.0;
if ((z * t) <= -5e-8)
tmp = (-z * t) / a;
elseif ((z * t) <= 1e+14)
tmp = (y * x) / 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. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(z * t), $MachinePrecision], -5e-8], N[(N[((-z) * t), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1e+14], N[(N[(y * x), $MachinePrecision] / a), $MachinePrecision], N[(z * N[((-t) / a), $MachinePrecision]), $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 -5 \cdot 10^{-8}:\\
\;\;\;\;\frac{\left(-z\right) \cdot t}{a}\\
\mathbf{elif}\;z \cdot t \leq 10^{+14}:\\
\;\;\;\;\frac{y \cdot x}{a}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{-t}{a}\\
\end{array}
\end{array}
if (*.f64 z t) < -4.9999999999999998e-8Initial program 90.6%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6479.3
Applied rewrites79.3%
if -4.9999999999999998e-8 < (*.f64 z t) < 1e14Initial program 96.7%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6480.3
Applied rewrites80.3%
if 1e14 < (*.f64 z t) Initial program 89.1%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r/N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6480.5
Applied rewrites80.5%
Final simplification80.1%
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) -2e+246) (/ y (/ a x)) (/ (- (* 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) {
double tmp;
if ((x * y) <= -2e+246) {
tmp = y / (a / x);
} else {
tmp = ((x * y) - (z * t)) / a;
}
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) :: tmp
if ((x * y) <= (-2d+246)) then
tmp = y / (a / x)
else
tmp = ((x * y) - (z * t)) / a
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 tmp;
if ((x * y) <= -2e+246) {
tmp = y / (a / x);
} else {
tmp = ((x * y) - (z * t)) / a;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= -2e+246: tmp = y / (a / x) else: tmp = ((x * y) - (z * t)) / 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(x * y) <= -2e+246) tmp = Float64(y / Float64(a / x)); else tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); 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)
tmp = 0.0;
if ((x * y) <= -2e+246)
tmp = y / (a / x);
else
tmp = ((x * y) - (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. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], -2e+246], N[(y / N[(a / x), $MachinePrecision]), $MachinePrecision], 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])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+246}:\\
\;\;\;\;\frac{y}{\frac{a}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < -2.00000000000000014e246Initial program 61.8%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6468.5
Applied rewrites68.5%
Applied rewrites93.7%
if -2.00000000000000014e246 < (*.f64 x y) Initial program 95.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 (<= (* x y) 2e+49) (* x (/ y a)) (* (/ x a) y)))
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) <= 2e+49) {
tmp = x * (y / a);
} else {
tmp = (x / a) * y;
}
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) :: tmp
if ((x * y) <= 2d+49) then
tmp = x * (y / a)
else
tmp = (x / a) * y
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 tmp;
if ((x * y) <= 2e+49) {
tmp = x * (y / a);
} else {
tmp = (x / a) * y;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= 2e+49: tmp = x * (y / a) else: tmp = (x / a) * y 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(x * y) <= 2e+49) tmp = Float64(x * Float64(y / a)); else tmp = Float64(Float64(x / a) * y); 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)
tmp = 0.0;
if ((x * y) <= 2e+49)
tmp = x * (y / a);
else
tmp = (x / a) * y;
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_] := If[LessEqual[N[(x * y), $MachinePrecision], 2e+49], N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq 2 \cdot 10^{+49}:\\
\;\;\;\;x \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < 1.99999999999999989e49Initial program 94.9%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6446.0
Applied rewrites46.0%
Applied rewrites46.5%
if 1.99999999999999989e49 < (*.f64 x y) Initial program 88.5%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.3
Applied rewrites69.3%
Applied rewrites69.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 (<= t 1.9e-7) (/ (* y x) a) (* (/ x a) y)))
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.9e-7) {
tmp = (y * x) / a;
} else {
tmp = (x / a) * y;
}
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) :: tmp
if (t <= 1.9d-7) then
tmp = (y * x) / a
else
tmp = (x / a) * y
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 tmp;
if (t <= 1.9e-7) {
tmp = (y * x) / a;
} else {
tmp = (x / a) * y;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if t <= 1.9e-7: tmp = (y * x) / a else: tmp = (x / a) * y return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (t <= 1.9e-7) tmp = Float64(Float64(y * x) / a); else tmp = Float64(Float64(x / a) * y); 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)
tmp = 0.0;
if (t <= 1.9e-7)
tmp = (y * x) / a;
else
tmp = (x / a) * y;
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_] := If[LessEqual[t, 1.9e-7], N[(N[(y * x), $MachinePrecision] / a), $MachinePrecision], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.9 \cdot 10^{-7}:\\
\;\;\;\;\frac{y \cdot x}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\end{array}
\end{array}
if t < 1.90000000000000007e-7Initial program 93.4%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6459.1
Applied rewrites59.1%
if 1.90000000000000007e-7 < t Initial program 93.3%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6431.4
Applied rewrites31.4%
Applied rewrites35.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 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(x * Float64(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[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
x \cdot \frac{y}{a}
\end{array}
Initial program 93.4%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.3
Applied rewrites51.3%
Applied rewrites51.3%
(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 2024313
(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))