
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = ((x * y) - (z * t)) / a
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
def code(x, y, z, t, a): return ((x * y) - (z * t)) / a
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(z * t)) / a) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - (z * t)) / a; end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - z \cdot t}{a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = ((x * y) - (z * t)) / a
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
def code(x, y, z, t, a): return ((x * y) - (z * t)) / a
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(z * t)) / a) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - (z * t)) / a; end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - z \cdot t}{a}
\end{array}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* t z) (- INFINITY)) (* (/ (- z) a) t) (if (<= (* t z) 2e+302) (/ (fma (- z) t (* x y)) a) (/ (- z) (/ a t)))))
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 * z) <= -((double) INFINITY)) {
tmp = (-z / a) * t;
} else if ((t * z) <= 2e+302) {
tmp = fma(-z, t, (x * y)) / a;
} else {
tmp = -z / (a / t);
}
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(t * z) <= Float64(-Inf)) tmp = Float64(Float64(Float64(-z) / a) * t); elseif (Float64(t * z) <= 2e+302) tmp = Float64(fma(Float64(-z), t, Float64(x * y)) / a); else tmp = Float64(Float64(-z) / Float64(a / t)); 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[(t * z), $MachinePrecision], (-Infinity)], N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[N[(t * z), $MachinePrecision], 2e+302], N[(N[((-z) * t + N[(x * y), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[((-z) / N[(a / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;t \cdot z \leq -\infty:\\
\;\;\;\;\frac{-z}{a} \cdot t\\
\mathbf{elif}\;t \cdot z \leq 2 \cdot 10^{+302}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, t, x \cdot y\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-z}{\frac{a}{t}}\\
\end{array}
\end{array}
if (*.f64 z t) < -inf.0Initial program 57.2%
Taylor expanded in t around inf
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
if -inf.0 < (*.f64 z t) < 2.0000000000000002e302Initial program 97.3%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6497.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6497.3
Applied rewrites97.3%
if 2.0000000000000002e302 < (*.f64 z t) Initial program 61.4%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f6419.6
Applied rewrites19.6%
Taylor expanded in t around inf
associate-*l/N/A
associate-*l*N/A
lower-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6499.8
Applied rewrites99.8%
Applied rewrites99.7%
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 (<= (* t z) (- INFINITY)) (* (/ (- z) a) t) (if (<= (* t z) 2e+302) (/ (- (* x y) (* t z)) a) (/ (- z) (/ a t)))))
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 * z) <= -((double) INFINITY)) {
tmp = (-z / a) * t;
} else if ((t * z) <= 2e+302) {
tmp = ((x * y) - (t * z)) / a;
} else {
tmp = -z / (a / t);
}
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 tmp;
if ((t * z) <= -Double.POSITIVE_INFINITY) {
tmp = (-z / a) * t;
} else if ((t * z) <= 2e+302) {
tmp = ((x * y) - (t * z)) / a;
} else {
tmp = -z / (a / t);
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (t * z) <= -math.inf: tmp = (-z / a) * t elif (t * z) <= 2e+302: tmp = ((x * y) - (t * z)) / a else: tmp = -z / (a / t) 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(t * z) <= Float64(-Inf)) tmp = Float64(Float64(Float64(-z) / a) * t); elseif (Float64(t * z) <= 2e+302) tmp = Float64(Float64(Float64(x * y) - Float64(t * z)) / a); else tmp = Float64(Float64(-z) / Float64(a / t)); 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 * z) <= -Inf)
tmp = (-z / a) * t;
elseif ((t * z) <= 2e+302)
tmp = ((x * y) - (t * z)) / a;
else
tmp = -z / (a / t);
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[(t * z), $MachinePrecision], (-Infinity)], N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[N[(t * z), $MachinePrecision], 2e+302], N[(N[(N[(x * y), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[((-z) / N[(a / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;t \cdot z \leq -\infty:\\
\;\;\;\;\frac{-z}{a} \cdot t\\
\mathbf{elif}\;t \cdot z \leq 2 \cdot 10^{+302}:\\
\;\;\;\;\frac{x \cdot y - t \cdot z}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-z}{\frac{a}{t}}\\
\end{array}
\end{array}
if (*.f64 z t) < -inf.0Initial program 57.2%
Taylor expanded in t around inf
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
if -inf.0 < (*.f64 z t) < 2.0000000000000002e302Initial program 97.3%
if 2.0000000000000002e302 < (*.f64 z t) Initial program 61.4%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f6419.6
Applied rewrites19.6%
Taylor expanded in t around inf
associate-*l/N/A
associate-*l*N/A
lower-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6499.8
Applied rewrites99.8%
Applied rewrites99.7%
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
(let* ((t_1 (/ (- t) (/ a z))))
(if (<= (* t z) -5e-24)
t_1
(if (<= (* t z) 500000000000.0) (/ (* x y) 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 = -t / (a / z);
double tmp;
if ((t * z) <= -5e-24) {
tmp = t_1;
} else if ((t * z) <= 500000000000.0) {
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.
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 / (a / z)
if ((t * z) <= (-5d-24)) then
tmp = t_1
else if ((t * z) <= 500000000000.0d0) then
tmp = (x * y) / a
else
tmp = t_1
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double t_1 = -t / (a / z);
double tmp;
if ((t * z) <= -5e-24) {
tmp = t_1;
} else if ((t * z) <= 500000000000.0) {
tmp = (x * y) / 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 = -t / (a / z) tmp = 0 if (t * z) <= -5e-24: tmp = t_1 elif (t * z) <= 500000000000.0: tmp = (x * y) / 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(-t) / Float64(a / z)) tmp = 0.0 if (Float64(t * z) <= -5e-24) tmp = t_1; elseif (Float64(t * z) <= 500000000000.0) tmp = Float64(Float64(x * y) / 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 = -t / (a / z);
tmp = 0.0;
if ((t * z) <= -5e-24)
tmp = t_1;
elseif ((t * z) <= 500000000000.0)
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.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[((-t) / N[(a / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t * z), $MachinePrecision], -5e-24], t$95$1, If[LessEqual[N[(t * z), $MachinePrecision], 500000000000.0], N[(N[(x * y), $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{-t}{\frac{a}{z}}\\
\mathbf{if}\;t \cdot z \leq -5 \cdot 10^{-24}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \cdot z \leq 500000000000:\\
\;\;\;\;\frac{x \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -4.9999999999999998e-24 or 5e11 < (*.f64 z t) Initial program 89.9%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f6426.7
Applied rewrites26.7%
Taylor expanded in t around inf
associate-*l/N/A
associate-*l*N/A
lower-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6474.6
Applied rewrites74.6%
Applied rewrites76.7%
if -4.9999999999999998e-24 < (*.f64 z t) < 5e11Initial program 96.7%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f6486.8
Applied rewrites86.8%
Final simplification81.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 (<= a 6e-75) (/ (fma (- z) t (* x y)) a) (fma (/ y a) x (* (/ (- z) a) t))))
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 <= 6e-75) {
tmp = fma(-z, t, (x * y)) / a;
} else {
tmp = fma((y / a), x, ((-z / a) * t));
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (a <= 6e-75) tmp = Float64(fma(Float64(-z), t, Float64(x * y)) / a); else tmp = fma(Float64(y / a), x, Float64(Float64(Float64(-z) / a) * t)); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[a, 6e-75], N[(N[((-z) * t + N[(x * y), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * x + N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq 6 \cdot 10^{-75}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, t, x \cdot y\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, x, \frac{-z}{a} \cdot t\right)\\
\end{array}
\end{array}
if a < 5.9999999999999997e-75Initial program 95.6%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6495.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6495.6
Applied rewrites95.6%
if 5.9999999999999997e-75 < a Initial program 87.5%
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-/.f6496.9
Applied rewrites96.9%
Final simplification96.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 (if (<= a 4e-75) (/ (fma (- z) t (* x y)) a) (fma (/ x a) y (* (/ (- z) a) t))))
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 <= 4e-75) {
tmp = fma(-z, t, (x * y)) / a;
} else {
tmp = fma((x / a), y, ((-z / a) * t));
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (a <= 4e-75) tmp = Float64(fma(Float64(-z), t, Float64(x * y)) / a); else tmp = fma(Float64(x / a), y, Float64(Float64(Float64(-z) / a) * t)); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[a, 4e-75], N[(N[((-z) * t + N[(x * y), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(x / a), $MachinePrecision] * y + N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq 4 \cdot 10^{-75}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, t, x \cdot y\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{a}, y, \frac{-z}{a} \cdot t\right)\\
\end{array}
\end{array}
if a < 3.9999999999999998e-75Initial program 95.6%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6495.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6495.6
Applied rewrites95.6%
if 3.9999999999999998e-75 < a Initial program 87.5%
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-/.f6490.5
Applied rewrites90.5%
Final simplification94.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
(let* ((t_1 (* (/ (- z) a) t)))
(if (<= (* t z) -5e-24)
t_1
(if (<= (* t z) 500000000000.0) (/ (* x y) 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 = (-z / a) * t;
double tmp;
if ((t * z) <= -5e-24) {
tmp = t_1;
} else if ((t * z) <= 500000000000.0) {
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.
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 = (-z / a) * t
if ((t * z) <= (-5d-24)) then
tmp = t_1
else if ((t * z) <= 500000000000.0d0) then
tmp = (x * y) / a
else
tmp = t_1
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (-z / a) * t;
double tmp;
if ((t * z) <= -5e-24) {
tmp = t_1;
} else if ((t * z) <= 500000000000.0) {
tmp = (x * y) / 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 = (-z / a) * t tmp = 0 if (t * z) <= -5e-24: tmp = t_1 elif (t * z) <= 500000000000.0: tmp = (x * y) / 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(Float64(-z) / a) * t) tmp = 0.0 if (Float64(t * z) <= -5e-24) tmp = t_1; elseif (Float64(t * z) <= 500000000000.0) tmp = Float64(Float64(x * y) / 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 = (-z / a) * t;
tmp = 0.0;
if ((t * z) <= -5e-24)
tmp = t_1;
elseif ((t * z) <= 500000000000.0)
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.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[N[(t * z), $MachinePrecision], -5e-24], t$95$1, If[LessEqual[N[(t * z), $MachinePrecision], 500000000000.0], N[(N[(x * y), $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{-z}{a} \cdot t\\
\mathbf{if}\;t \cdot z \leq -5 \cdot 10^{-24}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \cdot z \leq 500000000000:\\
\;\;\;\;\frac{x \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -4.9999999999999998e-24 or 5e11 < (*.f64 z t) Initial program 89.9%
Taylor expanded in t around inf
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6477.2
Applied rewrites77.2%
if -4.9999999999999998e-24 < (*.f64 z t) < 5e11Initial program 96.7%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f6486.8
Applied rewrites86.8%
Final simplification81.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 (<= (- (* x y) (* t z)) -1e+303) (* (/ x a) y) (/ (* x y) a)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) - (t * z)) <= -1e+303) {
tmp = (x / a) * y;
} else {
tmp = (x * y) / 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) - (t * z)) <= (-1d+303)) then
tmp = (x / a) * y
else
tmp = (x * y) / 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) - (t * z)) <= -1e+303) {
tmp = (x / a) * y;
} else {
tmp = (x * y) / 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) - (t * z)) <= -1e+303: tmp = (x / a) * y else: tmp = (x * y) / a return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(Float64(x * y) - Float64(t * z)) <= -1e+303) tmp = Float64(Float64(x / a) * y); else tmp = Float64(Float64(x * y) / 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) - (t * z)) <= -1e+303)
tmp = (x / a) * y;
else
tmp = (x * y) / 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[(N[(x * y), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision], -1e+303], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision], N[(N[(x * y), $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 - t \cdot z \leq -1 \cdot 10^{+303}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{a}\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -1e303Initial program 66.6%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f6441.2
Applied rewrites41.2%
Taylor expanded in t around 0
associate-*l/N/A
lower-*.f64N/A
lower-/.f6454.4
Applied rewrites54.4%
if -1e303 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 96.4%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f6457.3
Applied rewrites57.3%
Final simplification57.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 (if (<= (* x y) 2e+31) (* (/ 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 ((x * y) <= 2e+31) {
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 ((x * y) <= 2d+31) 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 ((x * y) <= 2e+31) {
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 (x * y) <= 2e+31: 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 (Float64(x * y) <= 2e+31) 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 ((x * y) <= 2e+31)
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[N[(x * y), $MachinePrecision], 2e+31], 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}\;x \cdot y \leq 2 \cdot 10^{+31}:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < 1.9999999999999999e31Initial program 92.1%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f6446.4
Applied rewrites46.4%
Taylor expanded in t around 0
associate-*l/N/A
lower-*.f64N/A
lower-/.f6444.7
Applied rewrites44.7%
Taylor expanded in t around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6446.4
Applied rewrites46.4%
if 1.9999999999999999e31 < (*.f64 x y) Initial program 95.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f6478.9
Applied rewrites78.9%
Taylor expanded in t around 0
associate-*l/N/A
lower-*.f64N/A
lower-/.f6476.2
Applied rewrites76.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 a) y))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
return (x / a) * y;
}
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 / a) * y
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 / a) * y;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): return (x / a) * y
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(Float64(x / a) * y) end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
tmp = (x / a) * y;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\frac{x}{a} \cdot y
\end{array}
Initial program 93.2%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f6455.6
Applied rewrites55.6%
Taylor expanded in t around 0
associate-*l/N/A
lower-*.f64N/A
lower-/.f6453.6
Applied rewrites53.6%
(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 2024235
(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))