
(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 (let* ((t_1 (- (* y x) (* t z))) (t_2 (fma (/ y a) x (* (/ (- z) a) t)))) (if (<= t_1 -2e+256) t_2 (if (<= t_1 5e+264) (/ t_1 a) t_2))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * x) - (t * z);
double t_2 = fma((y / a), x, ((-z / a) * t));
double tmp;
if (t_1 <= -2e+256) {
tmp = t_2;
} else if (t_1 <= 5e+264) {
tmp = t_1 / a;
} else {
tmp = t_2;
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) t_1 = Float64(Float64(y * x) - Float64(t * z)) t_2 = fma(Float64(y / a), x, Float64(Float64(Float64(-z) / a) * t)) tmp = 0.0 if (t_1 <= -2e+256) tmp = t_2; elseif (t_1 <= 5e+264) tmp = Float64(t_1 / a); else tmp = t_2; 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[(y * x), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y / a), $MachinePrecision] * x + N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+256], t$95$2, If[LessEqual[t$95$1, 5e+264], N[(t$95$1 / a), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := y \cdot x - t \cdot z\\
t_2 := \mathsf{fma}\left(\frac{y}{a}, x, \frac{-z}{a} \cdot t\right)\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+256}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+264}:\\
\;\;\;\;\frac{t\_1}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -2.0000000000000001e256 or 5.00000000000000033e264 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 76.1%
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.2
Applied rewrites95.2%
if -2.0000000000000001e256 < (-.f64 (*.f64 x y) (*.f64 z t)) < 5.00000000000000033e264Initial program 99.2%
Final simplification97.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 (let* ((t_1 (* (/ x a) y)) (t_2 (/ (- (* y x) (* t z)) a))) (if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 2e+307) (/ (* y x) 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 / a) * y;
double t_2 = ((y * x) - (t * z)) / a;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 2e+307) {
tmp = (y * x) / a;
} else {
tmp = t_1;
}
return tmp;
}
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 / a) * y;
double t_2 = ((y * x) - (t * z)) / a;
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_2 <= 2e+307) {
tmp = (y * x) / 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 / a) * y t_2 = ((y * x) - (t * z)) / a tmp = 0 if t_2 <= -math.inf: tmp = t_1 elif t_2 <= 2e+307: tmp = (y * x) / 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 / a) * y) t_2 = Float64(Float64(Float64(y * x) - Float64(t * z)) / a) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 2e+307) tmp = Float64(Float64(y * x) / 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 / a) * y;
t_2 = ((y * x) - (t * z)) / a;
tmp = 0.0;
if (t_2 <= -Inf)
tmp = t_1;
elseif (t_2 <= 2e+307)
tmp = (y * x) / 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 / a), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(y * x), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 2e+307], N[(N[(y * x), $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}{a} \cdot y\\
t_2 := \frac{y \cdot x - t \cdot z}{a}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+307}:\\
\;\;\;\;\frac{y \cdot x}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 x y) (*.f64 z t)) a) < -inf.0 or 1.99999999999999997e307 < (/.f64 (-.f64 (*.f64 x y) (*.f64 z t)) a) Initial program 79.7%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6448.8
Applied rewrites48.8%
Applied rewrites63.4%
if -inf.0 < (/.f64 (-.f64 (*.f64 x y) (*.f64 z t)) a) < 1.99999999999999997e307Initial program 99.0%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6455.6
Applied rewrites55.6%
Final simplification58.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 (let* ((t_1 (fma (/ x a) y (* (/ (- z) a) t))) (t_2 (- (* y x) (* t z)))) (if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 5e+264) (/ t_2 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 = fma((x / a), y, ((-z / a) * t));
double t_2 = (y * x) - (t * z);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 5e+264) {
tmp = t_2 / 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 = fma(Float64(x / a), y, Float64(Float64(Float64(-z) / a) * t)) t_2 = Float64(Float64(y * x) - Float64(t * z)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 5e+264) 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.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x / a), $MachinePrecision] * y + N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y * x), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 5e+264], N[(t$95$2 / 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 := \mathsf{fma}\left(\frac{x}{a}, y, \frac{-z}{a} \cdot t\right)\\
t_2 := y \cdot x - t \cdot z\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+264}:\\
\;\;\;\;\frac{t\_2}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -inf.0 or 5.00000000000000033e264 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial 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
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)) < 5.00000000000000033e264Initial program 99.2%
Final simplification98.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
(if (<= (* y x) -1e-10)
(/ (* y x) a)
(if (<= (* y x) 5e-291)
(* (/ (- z) a) t)
(if (<= (* y x) 1e+28) (* (/ (- 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 ((y * x) <= -1e-10) {
tmp = (y * x) / a;
} else if ((y * x) <= 5e-291) {
tmp = (-z / a) * t;
} else if ((y * x) <= 1e+28) {
tmp = (-t / a) * z;
} else {
tmp = (y / a) * x;
}
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 ((y * x) <= (-1d-10)) then
tmp = (y * x) / a
else if ((y * x) <= 5d-291) then
tmp = (-z / a) * t
else if ((y * x) <= 1d+28) then
tmp = (-t / a) * z
else
tmp = (y / a) * x
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 ((y * x) <= -1e-10) {
tmp = (y * x) / a;
} else if ((y * x) <= 5e-291) {
tmp = (-z / a) * t;
} else if ((y * x) <= 1e+28) {
tmp = (-t / a) * z;
} else {
tmp = (y / a) * x;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (y * x) <= -1e-10: tmp = (y * x) / a elif (y * x) <= 5e-291: tmp = (-z / a) * t elif (y * x) <= 1e+28: tmp = (-t / a) * z else: tmp = (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(y * x) <= -1e-10) tmp = Float64(Float64(y * x) / a); elseif (Float64(y * x) <= 5e-291) tmp = Float64(Float64(Float64(-z) / a) * t); elseif (Float64(y * x) <= 1e+28) tmp = Float64(Float64(Float64(-t) / a) * z); else tmp = Float64(Float64(y / a) * x); 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 ((y * x) <= -1e-10)
tmp = (y * x) / a;
elseif ((y * x) <= 5e-291)
tmp = (-z / a) * t;
elseif ((y * x) <= 1e+28)
tmp = (-t / a) * z;
else
tmp = (y / a) * x;
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[(y * x), $MachinePrecision], -1e-10], N[(N[(y * x), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[N[(y * x), $MachinePrecision], 5e-291], N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[N[(y * x), $MachinePrecision], 1e+28], N[(N[((-t) / a), $MachinePrecision] * z), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot x \leq -1 \cdot 10^{-10}:\\
\;\;\;\;\frac{y \cdot x}{a}\\
\mathbf{elif}\;y \cdot x \leq 5 \cdot 10^{-291}:\\
\;\;\;\;\frac{-z}{a} \cdot t\\
\mathbf{elif}\;y \cdot x \leq 10^{+28}:\\
\;\;\;\;\frac{-t}{a} \cdot z\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\end{array}
\end{array}
if (*.f64 x y) < -1.00000000000000004e-10Initial program 90.6%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6478.4
Applied rewrites78.4%
if -1.00000000000000004e-10 < (*.f64 x y) < 5.0000000000000003e-291Initial program 93.9%
Applied rewrites93.8%
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.f6483.2
Applied rewrites83.2%
if 5.0000000000000003e-291 < (*.f64 x y) < 9.99999999999999958e27Initial program 98.0%
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-/.f6470.0
Applied rewrites70.0%
if 9.99999999999999958e27 < (*.f64 x y) Initial program 82.6%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6471.8
Applied rewrites71.8%
Applied rewrites83.9%
Final simplification79.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 (<= (* y x) -5e-86) (/ (* y x) a) (if (<= (* y x) 1e+28) (/ (* (- z) t) 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 ((y * x) <= -5e-86) {
tmp = (y * x) / a;
} else if ((y * x) <= 1e+28) {
tmp = (-z * t) / a;
} else {
tmp = (y / a) * x;
}
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 ((y * x) <= (-5d-86)) then
tmp = (y * x) / a
else if ((y * x) <= 1d+28) then
tmp = (-z * t) / a
else
tmp = (y / a) * x
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 ((y * x) <= -5e-86) {
tmp = (y * x) / a;
} else if ((y * x) <= 1e+28) {
tmp = (-z * t) / a;
} else {
tmp = (y / a) * x;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (y * x) <= -5e-86: tmp = (y * x) / a elif (y * x) <= 1e+28: tmp = (-z * t) / a else: tmp = (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(y * x) <= -5e-86) tmp = Float64(Float64(y * x) / a); elseif (Float64(y * x) <= 1e+28) tmp = Float64(Float64(Float64(-z) * t) / a); else tmp = Float64(Float64(y / a) * x); 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 ((y * x) <= -5e-86)
tmp = (y * x) / a;
elseif ((y * x) <= 1e+28)
tmp = (-z * t) / a;
else
tmp = (y / a) * x;
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[(y * x), $MachinePrecision], -5e-86], N[(N[(y * x), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[N[(y * x), $MachinePrecision], 1e+28], N[(N[((-z) * t), $MachinePrecision] / a), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot x \leq -5 \cdot 10^{-86}:\\
\;\;\;\;\frac{y \cdot x}{a}\\
\mathbf{elif}\;y \cdot x \leq 10^{+28}:\\
\;\;\;\;\frac{\left(-z\right) \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\end{array}
\end{array}
if (*.f64 x y) < -4.9999999999999999e-86Initial program 89.7%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6473.4
Applied rewrites73.4%
if -4.9999999999999999e-86 < (*.f64 x y) < 9.99999999999999958e27Initial program 96.6%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6483.1
Applied rewrites83.1%
if 9.99999999999999958e27 < (*.f64 x y) Initial program 82.6%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6471.8
Applied rewrites71.8%
Applied rewrites83.9%
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 (<= (* y x) -1e-10) (/ (* y x) a) (if (<= (* y x) 1e+28) (* (/ (- z) a) t) (* (/ 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 ((y * x) <= -1e-10) {
tmp = (y * x) / a;
} else if ((y * x) <= 1e+28) {
tmp = (-z / a) * t;
} else {
tmp = (y / a) * x;
}
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 ((y * x) <= (-1d-10)) then
tmp = (y * x) / a
else if ((y * x) <= 1d+28) then
tmp = (-z / a) * t
else
tmp = (y / a) * x
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 ((y * x) <= -1e-10) {
tmp = (y * x) / a;
} else if ((y * x) <= 1e+28) {
tmp = (-z / a) * t;
} else {
tmp = (y / a) * x;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (y * x) <= -1e-10: tmp = (y * x) / a elif (y * x) <= 1e+28: tmp = (-z / a) * t else: tmp = (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(y * x) <= -1e-10) tmp = Float64(Float64(y * x) / a); elseif (Float64(y * x) <= 1e+28) tmp = Float64(Float64(Float64(-z) / a) * t); else tmp = Float64(Float64(y / a) * x); 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 ((y * x) <= -1e-10)
tmp = (y * x) / a;
elseif ((y * x) <= 1e+28)
tmp = (-z / a) * t;
else
tmp = (y / a) * x;
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[(y * x), $MachinePrecision], -1e-10], N[(N[(y * x), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[N[(y * x), $MachinePrecision], 1e+28], N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot x \leq -1 \cdot 10^{-10}:\\
\;\;\;\;\frac{y \cdot x}{a}\\
\mathbf{elif}\;y \cdot x \leq 10^{+28}:\\
\;\;\;\;\frac{-z}{a} \cdot t\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\end{array}
\end{array}
if (*.f64 x y) < -1.00000000000000004e-10Initial program 90.6%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6478.4
Applied rewrites78.4%
if -1.00000000000000004e-10 < (*.f64 x y) < 9.99999999999999958e27Initial program 95.5%
Applied rewrites95.4%
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.f6478.5
Applied rewrites78.5%
if 9.99999999999999958e27 < (*.f64 x y) Initial program 82.6%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6471.8
Applied rewrites71.8%
Applied rewrites83.9%
Final simplification79.6%
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 (<= (* y x) 2e+276) (/ (- (* y x) (* 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 ((y * x) <= 2e+276) {
tmp = ((y * x) - (t * z)) / a;
} else {
tmp = (y / a) * x;
}
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 ((y * x) <= 2d+276) then
tmp = ((y * x) - (t * z)) / a
else
tmp = (y / a) * x
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 ((y * x) <= 2e+276) {
tmp = ((y * x) - (t * z)) / a;
} else {
tmp = (y / a) * x;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (y * x) <= 2e+276: tmp = ((y * x) - (t * z)) / a else: tmp = (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(y * x) <= 2e+276) tmp = Float64(Float64(Float64(y * x) - Float64(t * z)) / a); else tmp = Float64(Float64(y / a) * x); 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 ((y * x) <= 2e+276)
tmp = ((y * x) - (t * z)) / a;
else
tmp = (y / a) * x;
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[(y * x), $MachinePrecision], 2e+276], N[(N[(N[(y * x), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot x \leq 2 \cdot 10^{+276}:\\
\;\;\;\;\frac{y \cdot x - t \cdot z}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\end{array}
\end{array}
if (*.f64 x y) < 2.0000000000000001e276Initial program 94.2%
if 2.0000000000000001e276 < (*.f64 x y) Initial program 61.8%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6461.8
Applied rewrites61.8%
Applied rewrites99.9%
Final simplification94.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 (<= t 5.8e-258) (* (/ y a) x) (* (/ 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 <= 5.8e-258) {
tmp = (y / a) * x;
} 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 <= 5.8d-258) then
tmp = (y / a) * x
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 <= 5.8e-258) {
tmp = (y / a) * x;
} 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 <= 5.8e-258: tmp = (y / a) * x 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 <= 5.8e-258) tmp = Float64(Float64(y / a) * x); 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 <= 5.8e-258)
tmp = (y / a) * x;
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, 5.8e-258], N[(N[(y / a), $MachinePrecision] * x), $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 5.8 \cdot 10^{-258}:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\end{array}
\end{array}
if t < 5.7999999999999999e-258Initial program 92.1%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6458.6
Applied rewrites58.6%
Applied rewrites58.9%
if 5.7999999999999999e-258 < t Initial program 90.4%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6445.2
Applied rewrites45.2%
Applied rewrites46.7%
Final simplification53.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 (* (/ y a) x))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
return (y / a) * x;
}
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 / a) * x
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 (y / a) * x;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): return (y / a) * x
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(Float64(y / a) * x) end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
tmp = (y / a) * x;
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[(y / a), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\frac{y}{a} \cdot x
\end{array}
Initial program 91.4%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6452.9
Applied rewrites52.9%
Applied rewrites53.4%
Final simplification53.4%
(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 2024298
(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))