
(FPCore (x y z t a b c i j k) :precision binary64 (- (- (+ (- (* (* (* (* x 18.0) y) z) t) (* (* a 4.0) t)) (* b c)) (* (* x 4.0) i)) (* (* j 27.0) k)))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
return (((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i, j, k)
use fmin_fmax_functions
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), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
real(8), intent (in) :: j
real(8), intent (in) :: k
code = (((((((x * 18.0d0) * y) * z) * t) - ((a * 4.0d0) * t)) + (b * c)) - ((x * 4.0d0) * i)) - ((j * 27.0d0) * k)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
return (((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k);
}
def code(x, y, z, t, a, b, c, i, j, k): return (((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k)
function code(x, y, z, t, a, b, c, i, j, k) return Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(x * 18.0) * y) * z) * t) - Float64(Float64(a * 4.0) * t)) + Float64(b * c)) - Float64(Float64(x * 4.0) * i)) - Float64(Float64(j * 27.0) * k)) end
function tmp = code(x, y, z, t, a, b, c, i, j, k) tmp = (((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k); end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := N[(N[(N[(N[(N[(N[(N[(N[(x * 18.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(b * c), $MachinePrecision]), $MachinePrecision] - N[(N[(x * 4.0), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision] - N[(N[(j * 27.0), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\right) - \left(j \cdot 27\right) \cdot k
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c i j k) :precision binary64 (- (- (+ (- (* (* (* (* x 18.0) y) z) t) (* (* a 4.0) t)) (* b c)) (* (* x 4.0) i)) (* (* j 27.0) k)))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
return (((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i, j, k)
use fmin_fmax_functions
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), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
real(8), intent (in) :: j
real(8), intent (in) :: k
code = (((((((x * 18.0d0) * y) * z) * t) - ((a * 4.0d0) * t)) + (b * c)) - ((x * 4.0d0) * i)) - ((j * 27.0d0) * k)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
return (((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k);
}
def code(x, y, z, t, a, b, c, i, j, k): return (((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k)
function code(x, y, z, t, a, b, c, i, j, k) return Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(x * 18.0) * y) * z) * t) - Float64(Float64(a * 4.0) * t)) + Float64(b * c)) - Float64(Float64(x * 4.0) * i)) - Float64(Float64(j * 27.0) * k)) end
function tmp = code(x, y, z, t, a, b, c, i, j, k) tmp = (((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k); end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := N[(N[(N[(N[(N[(N[(N[(N[(x * 18.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(b * c), $MachinePrecision]), $MachinePrecision] - N[(N[(x * 4.0), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision] - N[(N[(j * 27.0), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\right) - \left(j \cdot 27\right) \cdot k
\end{array}
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i j k)
:precision binary64
(if (<=
(-
(-
(+ (- (* (* (* (* x 18.0) y) z) t) (* (* a 4.0) t)) (* b c))
(* (* x 4.0) i))
(* (* j 27.0) k))
INFINITY)
(-
(fma (fma z (* y (* 18.0 x)) (* -4.0 a)) t (fma c b (* (* -4.0 x) i)))
(* (* k 27.0) j))
(fma c b (* (fma -4.0 i (* (* (* y z) t) 18.0)) x))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k);
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double tmp;
if (((((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k)) <= ((double) INFINITY)) {
tmp = fma(fma(z, (y * (18.0 * x)), (-4.0 * a)), t, fma(c, b, ((-4.0 * x) * i))) - ((k * 27.0) * j);
} else {
tmp = fma(c, b, (fma(-4.0, i, (((y * z) * t) * 18.0)) * x));
}
return tmp;
}
x, y, z, t, a, b, c, i, j, k = sort([x, y, z, t, a, b, c, i, j, k]) function code(x, y, z, t, a, b, c, i, j, k) tmp = 0.0 if (Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(x * 18.0) * y) * z) * t) - Float64(Float64(a * 4.0) * t)) + Float64(b * c)) - Float64(Float64(x * 4.0) * i)) - Float64(Float64(j * 27.0) * k)) <= Inf) tmp = Float64(fma(fma(z, Float64(y * Float64(18.0 * x)), Float64(-4.0 * a)), t, fma(c, b, Float64(Float64(-4.0 * x) * i))) - Float64(Float64(k * 27.0) * j)); else tmp = fma(c, b, Float64(fma(-4.0, i, Float64(Float64(Float64(y * z) * t) * 18.0)) * x)); end return tmp end
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := If[LessEqual[N[(N[(N[(N[(N[(N[(N[(N[(x * 18.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(b * c), $MachinePrecision]), $MachinePrecision] - N[(N[(x * 4.0), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision] - N[(N[(j * 27.0), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(z * N[(y * N[(18.0 * x), $MachinePrecision]), $MachinePrecision] + N[(-4.0 * a), $MachinePrecision]), $MachinePrecision] * t + N[(c * b + N[(N[(-4.0 * x), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(k * 27.0), $MachinePrecision] * j), $MachinePrecision]), $MachinePrecision], N[(c * b + N[(N[(-4.0 * i + N[(N[(N[(y * z), $MachinePrecision] * t), $MachinePrecision] * 18.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i, j, k] = \mathsf{sort}([x, y, z, t, a, b, c, i, j, k])\\
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\right) - \left(j \cdot 27\right) \cdot k \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z, y \cdot \left(18 \cdot x\right), -4 \cdot a\right), t, \mathsf{fma}\left(c, b, \left(-4 \cdot x\right) \cdot i\right)\right) - \left(k \cdot 27\right) \cdot j\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(c, b, \mathsf{fma}\left(-4, i, \left(\left(y \cdot z\right) \cdot t\right) \cdot 18\right) \cdot x\right)\\
\end{array}
\end{array}
if (-.f64 (-.f64 (+.f64 (-.f64 (*.f64 (*.f64 (*.f64 (*.f64 x #s(literal 18 binary64)) y) z) t) (*.f64 (*.f64 a #s(literal 4 binary64)) t)) (*.f64 b c)) (*.f64 (*.f64 x #s(literal 4 binary64)) i)) (*.f64 (*.f64 j #s(literal 27 binary64)) k)) < +inf.0Initial program 97.8%
Applied rewrites97.9%
if +inf.0 < (-.f64 (-.f64 (+.f64 (-.f64 (*.f64 (*.f64 (*.f64 (*.f64 x #s(literal 18 binary64)) y) z) t) (*.f64 (*.f64 a #s(literal 4 binary64)) t)) (*.f64 b c)) (*.f64 (*.f64 x #s(literal 4 binary64)) i)) (*.f64 (*.f64 j #s(literal 27 binary64)) k)) Initial program 0.0%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
Applied rewrites37.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6477.8
Applied rewrites77.8%
Final simplification95.7%
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i j k)
:precision binary64
(let* ((t_1
(-
(+ (- (* (* (* (* x 18.0) y) z) t) (* (* a 4.0) t)) (* b c))
(* (* x 4.0) i))))
(if (or (<= t_1 -2e+230) (not (<= t_1 1e+255)))
(fma c b (* (* -4.0 i) x))
(fma -27.0 (* j k) (* b c)))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k);
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double t_1 = ((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i);
double tmp;
if ((t_1 <= -2e+230) || !(t_1 <= 1e+255)) {
tmp = fma(c, b, ((-4.0 * i) * x));
} else {
tmp = fma(-27.0, (j * k), (b * c));
}
return tmp;
}
x, y, z, t, a, b, c, i, j, k = sort([x, y, z, t, a, b, c, i, j, k]) function code(x, y, z, t, a, b, c, i, j, k) t_1 = Float64(Float64(Float64(Float64(Float64(Float64(Float64(x * 18.0) * y) * z) * t) - Float64(Float64(a * 4.0) * t)) + Float64(b * c)) - Float64(Float64(x * 4.0) * i)) tmp = 0.0 if ((t_1 <= -2e+230) || !(t_1 <= 1e+255)) tmp = fma(c, b, Float64(Float64(-4.0 * i) * x)); else tmp = fma(-27.0, Float64(j * k), Float64(b * c)); end return tmp end
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := Block[{t$95$1 = N[(N[(N[(N[(N[(N[(N[(x * 18.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(b * c), $MachinePrecision]), $MachinePrecision] - N[(N[(x * 4.0), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+230], N[Not[LessEqual[t$95$1, 1e+255]], $MachinePrecision]], N[(c * b + N[(N[(-4.0 * i), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(-27.0 * N[(j * k), $MachinePrecision] + N[(b * c), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i, j, k] = \mathsf{sort}([x, y, z, t, a, b, c, i, j, k])\\
\\
\begin{array}{l}
t_1 := \left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+230} \lor \neg \left(t\_1 \leq 10^{+255}\right):\\
\;\;\;\;\mathsf{fma}\left(c, b, \left(-4 \cdot i\right) \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-27, j \cdot k, b \cdot c\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (-.f64 (*.f64 (*.f64 (*.f64 (*.f64 x #s(literal 18 binary64)) y) z) t) (*.f64 (*.f64 a #s(literal 4 binary64)) t)) (*.f64 b c)) (*.f64 (*.f64 x #s(literal 4 binary64)) i)) < -2.0000000000000002e230 or 9.99999999999999988e254 < (-.f64 (+.f64 (-.f64 (*.f64 (*.f64 (*.f64 (*.f64 x #s(literal 18 binary64)) y) z) t) (*.f64 (*.f64 a #s(literal 4 binary64)) t)) (*.f64 b c)) (*.f64 (*.f64 x #s(literal 4 binary64)) i)) Initial program 79.1%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
Applied rewrites85.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6482.5
Applied rewrites82.5%
Taylor expanded in y around 0
Applied rewrites57.6%
if -2.0000000000000002e230 < (-.f64 (+.f64 (-.f64 (*.f64 (*.f64 (*.f64 (*.f64 x #s(literal 18 binary64)) y) z) t) (*.f64 (*.f64 a #s(literal 4 binary64)) t)) (*.f64 b c)) (*.f64 (*.f64 x #s(literal 4 binary64)) i)) < 9.99999999999999988e254Initial program 99.7%
Taylor expanded in i around 0
+-commutativeN/A
associate--r+N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
associate--l+N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate--l+N/A
+-commutativeN/A
Applied rewrites83.1%
Taylor expanded in t around 0
Applied rewrites62.4%
Final simplification59.5%
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i j k)
:precision binary64
(if (<=
(-
(-
(+ (- (* (* (* (* x 18.0) y) z) t) (* (* a 4.0) t)) (* b c))
(* (* x 4.0) i))
(* (* j 27.0) k))
INFINITY)
(fma
c
b
(-
(* (fma z (* y (* 18.0 x)) (* -4.0 a)) t)
(fma k (* 27.0 j) (* i (* 4.0 x)))))
(fma c b (* (fma -4.0 i (* (* (* y z) t) 18.0)) x))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k);
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double tmp;
if (((((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k)) <= ((double) INFINITY)) {
tmp = fma(c, b, ((fma(z, (y * (18.0 * x)), (-4.0 * a)) * t) - fma(k, (27.0 * j), (i * (4.0 * x)))));
} else {
tmp = fma(c, b, (fma(-4.0, i, (((y * z) * t) * 18.0)) * x));
}
return tmp;
}
x, y, z, t, a, b, c, i, j, k = sort([x, y, z, t, a, b, c, i, j, k]) function code(x, y, z, t, a, b, c, i, j, k) tmp = 0.0 if (Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(x * 18.0) * y) * z) * t) - Float64(Float64(a * 4.0) * t)) + Float64(b * c)) - Float64(Float64(x * 4.0) * i)) - Float64(Float64(j * 27.0) * k)) <= Inf) tmp = fma(c, b, Float64(Float64(fma(z, Float64(y * Float64(18.0 * x)), Float64(-4.0 * a)) * t) - fma(k, Float64(27.0 * j), Float64(i * Float64(4.0 * x))))); else tmp = fma(c, b, Float64(fma(-4.0, i, Float64(Float64(Float64(y * z) * t) * 18.0)) * x)); end return tmp end
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := If[LessEqual[N[(N[(N[(N[(N[(N[(N[(N[(x * 18.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(b * c), $MachinePrecision]), $MachinePrecision] - N[(N[(x * 4.0), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision] - N[(N[(j * 27.0), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision], Infinity], N[(c * b + N[(N[(N[(z * N[(y * N[(18.0 * x), $MachinePrecision]), $MachinePrecision] + N[(-4.0 * a), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision] - N[(k * N[(27.0 * j), $MachinePrecision] + N[(i * N[(4.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c * b + N[(N[(-4.0 * i + N[(N[(N[(y * z), $MachinePrecision] * t), $MachinePrecision] * 18.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i, j, k] = \mathsf{sort}([x, y, z, t, a, b, c, i, j, k])\\
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\right) - \left(j \cdot 27\right) \cdot k \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(c, b, \mathsf{fma}\left(z, y \cdot \left(18 \cdot x\right), -4 \cdot a\right) \cdot t - \mathsf{fma}\left(k, 27 \cdot j, i \cdot \left(4 \cdot x\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(c, b, \mathsf{fma}\left(-4, i, \left(\left(y \cdot z\right) \cdot t\right) \cdot 18\right) \cdot x\right)\\
\end{array}
\end{array}
if (-.f64 (-.f64 (+.f64 (-.f64 (*.f64 (*.f64 (*.f64 (*.f64 x #s(literal 18 binary64)) y) z) t) (*.f64 (*.f64 a #s(literal 4 binary64)) t)) (*.f64 b c)) (*.f64 (*.f64 x #s(literal 4 binary64)) i)) (*.f64 (*.f64 j #s(literal 27 binary64)) k)) < +inf.0Initial program 97.8%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
Applied rewrites97.8%
if +inf.0 < (-.f64 (-.f64 (+.f64 (-.f64 (*.f64 (*.f64 (*.f64 (*.f64 x #s(literal 18 binary64)) y) z) t) (*.f64 (*.f64 a #s(literal 4 binary64)) t)) (*.f64 b c)) (*.f64 (*.f64 x #s(literal 4 binary64)) i)) (*.f64 (*.f64 j #s(literal 27 binary64)) k)) Initial program 0.0%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
Applied rewrites37.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6477.8
Applied rewrites77.8%
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i j k)
:precision binary64
(if (<=
(-
(-
(+ (- (* (* (* (* x 18.0) y) z) t) (* (* a 4.0) t)) (* b c))
(* (* x 4.0) i))
(* (* j 27.0) k))
INFINITY)
(fma
(* -27.0 j)
k
(fma (fma z (* y (* 18.0 x)) (* -4.0 a)) t (fma c b (* (* -4.0 x) i))))
(fma c b (* (fma -4.0 i (* (* (* y z) t) 18.0)) x))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k);
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double tmp;
if (((((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k)) <= ((double) INFINITY)) {
tmp = fma((-27.0 * j), k, fma(fma(z, (y * (18.0 * x)), (-4.0 * a)), t, fma(c, b, ((-4.0 * x) * i))));
} else {
tmp = fma(c, b, (fma(-4.0, i, (((y * z) * t) * 18.0)) * x));
}
return tmp;
}
x, y, z, t, a, b, c, i, j, k = sort([x, y, z, t, a, b, c, i, j, k]) function code(x, y, z, t, a, b, c, i, j, k) tmp = 0.0 if (Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(x * 18.0) * y) * z) * t) - Float64(Float64(a * 4.0) * t)) + Float64(b * c)) - Float64(Float64(x * 4.0) * i)) - Float64(Float64(j * 27.0) * k)) <= Inf) tmp = fma(Float64(-27.0 * j), k, fma(fma(z, Float64(y * Float64(18.0 * x)), Float64(-4.0 * a)), t, fma(c, b, Float64(Float64(-4.0 * x) * i)))); else tmp = fma(c, b, Float64(fma(-4.0, i, Float64(Float64(Float64(y * z) * t) * 18.0)) * x)); end return tmp end
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := If[LessEqual[N[(N[(N[(N[(N[(N[(N[(N[(x * 18.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(b * c), $MachinePrecision]), $MachinePrecision] - N[(N[(x * 4.0), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision] - N[(N[(j * 27.0), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(-27.0 * j), $MachinePrecision] * k + N[(N[(z * N[(y * N[(18.0 * x), $MachinePrecision]), $MachinePrecision] + N[(-4.0 * a), $MachinePrecision]), $MachinePrecision] * t + N[(c * b + N[(N[(-4.0 * x), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c * b + N[(N[(-4.0 * i + N[(N[(N[(y * z), $MachinePrecision] * t), $MachinePrecision] * 18.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i, j, k] = \mathsf{sort}([x, y, z, t, a, b, c, i, j, k])\\
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\right) - \left(j \cdot 27\right) \cdot k \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(-27 \cdot j, k, \mathsf{fma}\left(\mathsf{fma}\left(z, y \cdot \left(18 \cdot x\right), -4 \cdot a\right), t, \mathsf{fma}\left(c, b, \left(-4 \cdot x\right) \cdot i\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(c, b, \mathsf{fma}\left(-4, i, \left(\left(y \cdot z\right) \cdot t\right) \cdot 18\right) \cdot x\right)\\
\end{array}
\end{array}
if (-.f64 (-.f64 (+.f64 (-.f64 (*.f64 (*.f64 (*.f64 (*.f64 x #s(literal 18 binary64)) y) z) t) (*.f64 (*.f64 a #s(literal 4 binary64)) t)) (*.f64 b c)) (*.f64 (*.f64 x #s(literal 4 binary64)) i)) (*.f64 (*.f64 j #s(literal 27 binary64)) k)) < +inf.0Initial program 97.8%
Applied rewrites97.8%
if +inf.0 < (-.f64 (-.f64 (+.f64 (-.f64 (*.f64 (*.f64 (*.f64 (*.f64 x #s(literal 18 binary64)) y) z) t) (*.f64 (*.f64 a #s(literal 4 binary64)) t)) (*.f64 b c)) (*.f64 (*.f64 x #s(literal 4 binary64)) i)) (*.f64 (*.f64 j #s(literal 27 binary64)) k)) Initial program 0.0%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
Applied rewrites37.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6477.8
Applied rewrites77.8%
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i j k)
:precision binary64
(let* ((t_1 (* (* j 27.0) k)))
(if (<= t_1 -5e-6)
(* (* k -27.0) j)
(if (<= t_1 2e-298)
(* (* -4.0 a) t)
(if (<= t_1 2e+83) (* (* -4.0 x) i) (* (* j k) -27.0))))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k);
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double t_1 = (j * 27.0) * k;
double tmp;
if (t_1 <= -5e-6) {
tmp = (k * -27.0) * j;
} else if (t_1 <= 2e-298) {
tmp = (-4.0 * a) * t;
} else if (t_1 <= 2e+83) {
tmp = (-4.0 * x) * i;
} else {
tmp = (j * k) * -27.0;
}
return tmp;
}
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i, j, k)
use fmin_fmax_functions
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), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8) :: t_1
real(8) :: tmp
t_1 = (j * 27.0d0) * k
if (t_1 <= (-5d-6)) then
tmp = (k * (-27.0d0)) * j
else if (t_1 <= 2d-298) then
tmp = ((-4.0d0) * a) * t
else if (t_1 <= 2d+83) then
tmp = ((-4.0d0) * x) * i
else
tmp = (j * k) * (-27.0d0)
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double t_1 = (j * 27.0) * k;
double tmp;
if (t_1 <= -5e-6) {
tmp = (k * -27.0) * j;
} else if (t_1 <= 2e-298) {
tmp = (-4.0 * a) * t;
} else if (t_1 <= 2e+83) {
tmp = (-4.0 * x) * i;
} else {
tmp = (j * k) * -27.0;
}
return tmp;
}
[x, y, z, t, a, b, c, i, j, k] = sort([x, y, z, t, a, b, c, i, j, k]) def code(x, y, z, t, a, b, c, i, j, k): t_1 = (j * 27.0) * k tmp = 0 if t_1 <= -5e-6: tmp = (k * -27.0) * j elif t_1 <= 2e-298: tmp = (-4.0 * a) * t elif t_1 <= 2e+83: tmp = (-4.0 * x) * i else: tmp = (j * k) * -27.0 return tmp
x, y, z, t, a, b, c, i, j, k = sort([x, y, z, t, a, b, c, i, j, k]) function code(x, y, z, t, a, b, c, i, j, k) t_1 = Float64(Float64(j * 27.0) * k) tmp = 0.0 if (t_1 <= -5e-6) tmp = Float64(Float64(k * -27.0) * j); elseif (t_1 <= 2e-298) tmp = Float64(Float64(-4.0 * a) * t); elseif (t_1 <= 2e+83) tmp = Float64(Float64(-4.0 * x) * i); else tmp = Float64(Float64(j * k) * -27.0); end return tmp end
x, y, z, t, a, b, c, i, j, k = num2cell(sort([x, y, z, t, a, b, c, i, j, k])){:}
function tmp_2 = code(x, y, z, t, a, b, c, i, j, k)
t_1 = (j * 27.0) * k;
tmp = 0.0;
if (t_1 <= -5e-6)
tmp = (k * -27.0) * j;
elseif (t_1 <= 2e-298)
tmp = (-4.0 * a) * t;
elseif (t_1 <= 2e+83)
tmp = (-4.0 * x) * i;
else
tmp = (j * k) * -27.0;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := Block[{t$95$1 = N[(N[(j * 27.0), $MachinePrecision] * k), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-6], N[(N[(k * -27.0), $MachinePrecision] * j), $MachinePrecision], If[LessEqual[t$95$1, 2e-298], N[(N[(-4.0 * a), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[t$95$1, 2e+83], N[(N[(-4.0 * x), $MachinePrecision] * i), $MachinePrecision], N[(N[(j * k), $MachinePrecision] * -27.0), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i, j, k] = \mathsf{sort}([x, y, z, t, a, b, c, i, j, k])\\
\\
\begin{array}{l}
t_1 := \left(j \cdot 27\right) \cdot k\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-6}:\\
\;\;\;\;\left(k \cdot -27\right) \cdot j\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-298}:\\
\;\;\;\;\left(-4 \cdot a\right) \cdot t\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+83}:\\
\;\;\;\;\left(-4 \cdot x\right) \cdot i\\
\mathbf{else}:\\
\;\;\;\;\left(j \cdot k\right) \cdot -27\\
\end{array}
\end{array}
if (*.f64 (*.f64 j #s(literal 27 binary64)) k) < -5.00000000000000041e-6Initial program 88.1%
Taylor expanded in j around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f6446.1
Applied rewrites46.1%
Applied rewrites46.3%
if -5.00000000000000041e-6 < (*.f64 (*.f64 j #s(literal 27 binary64)) k) < 1.99999999999999982e-298Initial program 90.0%
Taylor expanded in j around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f641.9
Applied rewrites1.9%
Taylor expanded in t around inf
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6452.5
Applied rewrites52.5%
Taylor expanded in x around 0
Applied rewrites28.9%
if 1.99999999999999982e-298 < (*.f64 (*.f64 j #s(literal 27 binary64)) k) < 2.00000000000000006e83Initial program 86.3%
Taylor expanded in i around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6447.3
Applied rewrites47.3%
if 2.00000000000000006e83 < (*.f64 (*.f64 j #s(literal 27 binary64)) k) Initial program 84.7%
Taylor expanded in j around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f6452.1
Applied rewrites52.1%
Applied rewrites52.3%
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i j k)
:precision binary64
(let* ((t_1 (* (* j k) -27.0)) (t_2 (* (* j 27.0) k)))
(if (<= t_2 -5e-6)
t_1
(if (<= t_2 2e-298)
(* (* -4.0 a) t)
(if (<= t_2 2e+83) (* (* -4.0 x) i) t_1)))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k);
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double t_1 = (j * k) * -27.0;
double t_2 = (j * 27.0) * k;
double tmp;
if (t_2 <= -5e-6) {
tmp = t_1;
} else if (t_2 <= 2e-298) {
tmp = (-4.0 * a) * t;
} else if (t_2 <= 2e+83) {
tmp = (-4.0 * x) * i;
} else {
tmp = t_1;
}
return tmp;
}
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i, j, k)
use fmin_fmax_functions
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), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (j * k) * (-27.0d0)
t_2 = (j * 27.0d0) * k
if (t_2 <= (-5d-6)) then
tmp = t_1
else if (t_2 <= 2d-298) then
tmp = ((-4.0d0) * a) * t
else if (t_2 <= 2d+83) then
tmp = ((-4.0d0) * x) * i
else
tmp = t_1
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double t_1 = (j * k) * -27.0;
double t_2 = (j * 27.0) * k;
double tmp;
if (t_2 <= -5e-6) {
tmp = t_1;
} else if (t_2 <= 2e-298) {
tmp = (-4.0 * a) * t;
} else if (t_2 <= 2e+83) {
tmp = (-4.0 * x) * i;
} else {
tmp = t_1;
}
return tmp;
}
[x, y, z, t, a, b, c, i, j, k] = sort([x, y, z, t, a, b, c, i, j, k]) def code(x, y, z, t, a, b, c, i, j, k): t_1 = (j * k) * -27.0 t_2 = (j * 27.0) * k tmp = 0 if t_2 <= -5e-6: tmp = t_1 elif t_2 <= 2e-298: tmp = (-4.0 * a) * t elif t_2 <= 2e+83: tmp = (-4.0 * x) * i else: tmp = t_1 return tmp
x, y, z, t, a, b, c, i, j, k = sort([x, y, z, t, a, b, c, i, j, k]) function code(x, y, z, t, a, b, c, i, j, k) t_1 = Float64(Float64(j * k) * -27.0) t_2 = Float64(Float64(j * 27.0) * k) tmp = 0.0 if (t_2 <= -5e-6) tmp = t_1; elseif (t_2 <= 2e-298) tmp = Float64(Float64(-4.0 * a) * t); elseif (t_2 <= 2e+83) tmp = Float64(Float64(-4.0 * x) * i); else tmp = t_1; end return tmp end
x, y, z, t, a, b, c, i, j, k = num2cell(sort([x, y, z, t, a, b, c, i, j, k])){:}
function tmp_2 = code(x, y, z, t, a, b, c, i, j, k)
t_1 = (j * k) * -27.0;
t_2 = (j * 27.0) * k;
tmp = 0.0;
if (t_2 <= -5e-6)
tmp = t_1;
elseif (t_2 <= 2e-298)
tmp = (-4.0 * a) * t;
elseif (t_2 <= 2e+83)
tmp = (-4.0 * x) * i;
else
tmp = t_1;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := Block[{t$95$1 = N[(N[(j * k), $MachinePrecision] * -27.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(j * 27.0), $MachinePrecision] * k), $MachinePrecision]}, If[LessEqual[t$95$2, -5e-6], t$95$1, If[LessEqual[t$95$2, 2e-298], N[(N[(-4.0 * a), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[t$95$2, 2e+83], N[(N[(-4.0 * x), $MachinePrecision] * i), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i, j, k] = \mathsf{sort}([x, y, z, t, a, b, c, i, j, k])\\
\\
\begin{array}{l}
t_1 := \left(j \cdot k\right) \cdot -27\\
t_2 := \left(j \cdot 27\right) \cdot k\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-298}:\\
\;\;\;\;\left(-4 \cdot a\right) \cdot t\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+83}:\\
\;\;\;\;\left(-4 \cdot x\right) \cdot i\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 j #s(literal 27 binary64)) k) < -5.00000000000000041e-6 or 2.00000000000000006e83 < (*.f64 (*.f64 j #s(literal 27 binary64)) k) Initial program 86.7%
Taylor expanded in j around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f6448.5
Applied rewrites48.5%
Applied rewrites48.6%
if -5.00000000000000041e-6 < (*.f64 (*.f64 j #s(literal 27 binary64)) k) < 1.99999999999999982e-298Initial program 90.0%
Taylor expanded in j around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f641.9
Applied rewrites1.9%
Taylor expanded in t around inf
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6452.5
Applied rewrites52.5%
Taylor expanded in x around 0
Applied rewrites28.9%
if 1.99999999999999982e-298 < (*.f64 (*.f64 j #s(literal 27 binary64)) k) < 2.00000000000000006e83Initial program 86.3%
Taylor expanded in i around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6447.3
Applied rewrites47.3%
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i j k)
:precision binary64
(let* ((t_1 (* (* -27.0 j) k)) (t_2 (* (* j 27.0) k)))
(if (<= t_2 -5e-6)
t_1
(if (<= t_2 2e-298)
(* (* -4.0 a) t)
(if (<= t_2 2e+83) (* (* -4.0 x) i) t_1)))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k);
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double t_1 = (-27.0 * j) * k;
double t_2 = (j * 27.0) * k;
double tmp;
if (t_2 <= -5e-6) {
tmp = t_1;
} else if (t_2 <= 2e-298) {
tmp = (-4.0 * a) * t;
} else if (t_2 <= 2e+83) {
tmp = (-4.0 * x) * i;
} else {
tmp = t_1;
}
return tmp;
}
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i, j, k)
use fmin_fmax_functions
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), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = ((-27.0d0) * j) * k
t_2 = (j * 27.0d0) * k
if (t_2 <= (-5d-6)) then
tmp = t_1
else if (t_2 <= 2d-298) then
tmp = ((-4.0d0) * a) * t
else if (t_2 <= 2d+83) then
tmp = ((-4.0d0) * x) * i
else
tmp = t_1
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double t_1 = (-27.0 * j) * k;
double t_2 = (j * 27.0) * k;
double tmp;
if (t_2 <= -5e-6) {
tmp = t_1;
} else if (t_2 <= 2e-298) {
tmp = (-4.0 * a) * t;
} else if (t_2 <= 2e+83) {
tmp = (-4.0 * x) * i;
} else {
tmp = t_1;
}
return tmp;
}
[x, y, z, t, a, b, c, i, j, k] = sort([x, y, z, t, a, b, c, i, j, k]) def code(x, y, z, t, a, b, c, i, j, k): t_1 = (-27.0 * j) * k t_2 = (j * 27.0) * k tmp = 0 if t_2 <= -5e-6: tmp = t_1 elif t_2 <= 2e-298: tmp = (-4.0 * a) * t elif t_2 <= 2e+83: tmp = (-4.0 * x) * i else: tmp = t_1 return tmp
x, y, z, t, a, b, c, i, j, k = sort([x, y, z, t, a, b, c, i, j, k]) function code(x, y, z, t, a, b, c, i, j, k) t_1 = Float64(Float64(-27.0 * j) * k) t_2 = Float64(Float64(j * 27.0) * k) tmp = 0.0 if (t_2 <= -5e-6) tmp = t_1; elseif (t_2 <= 2e-298) tmp = Float64(Float64(-4.0 * a) * t); elseif (t_2 <= 2e+83) tmp = Float64(Float64(-4.0 * x) * i); else tmp = t_1; end return tmp end
x, y, z, t, a, b, c, i, j, k = num2cell(sort([x, y, z, t, a, b, c, i, j, k])){:}
function tmp_2 = code(x, y, z, t, a, b, c, i, j, k)
t_1 = (-27.0 * j) * k;
t_2 = (j * 27.0) * k;
tmp = 0.0;
if (t_2 <= -5e-6)
tmp = t_1;
elseif (t_2 <= 2e-298)
tmp = (-4.0 * a) * t;
elseif (t_2 <= 2e+83)
tmp = (-4.0 * x) * i;
else
tmp = t_1;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := Block[{t$95$1 = N[(N[(-27.0 * j), $MachinePrecision] * k), $MachinePrecision]}, Block[{t$95$2 = N[(N[(j * 27.0), $MachinePrecision] * k), $MachinePrecision]}, If[LessEqual[t$95$2, -5e-6], t$95$1, If[LessEqual[t$95$2, 2e-298], N[(N[(-4.0 * a), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[t$95$2, 2e+83], N[(N[(-4.0 * x), $MachinePrecision] * i), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i, j, k] = \mathsf{sort}([x, y, z, t, a, b, c, i, j, k])\\
\\
\begin{array}{l}
t_1 := \left(-27 \cdot j\right) \cdot k\\
t_2 := \left(j \cdot 27\right) \cdot k\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-298}:\\
\;\;\;\;\left(-4 \cdot a\right) \cdot t\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+83}:\\
\;\;\;\;\left(-4 \cdot x\right) \cdot i\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 j #s(literal 27 binary64)) k) < -5.00000000000000041e-6 or 2.00000000000000006e83 < (*.f64 (*.f64 j #s(literal 27 binary64)) k) Initial program 86.7%
Taylor expanded in j around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f6448.5
Applied rewrites48.5%
if -5.00000000000000041e-6 < (*.f64 (*.f64 j #s(literal 27 binary64)) k) < 1.99999999999999982e-298Initial program 90.0%
Taylor expanded in j around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f641.9
Applied rewrites1.9%
Taylor expanded in t around inf
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6452.5
Applied rewrites52.5%
Taylor expanded in x around 0
Applied rewrites28.9%
if 1.99999999999999982e-298 < (*.f64 (*.f64 j #s(literal 27 binary64)) k) < 2.00000000000000006e83Initial program 86.3%
Taylor expanded in i around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6447.3
Applied rewrites47.3%
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i j k) :precision binary64 (if (or (<= x -2.1e+109) (not (<= x 1.5e+94))) (fma c b (* (fma -4.0 i (* (* (* y z) t) 18.0)) x)) (fma (* -27.0 j) k (fma (fma -4.0 a (* (* (* x z) y) 18.0)) t (* c b)))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k);
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double tmp;
if ((x <= -2.1e+109) || !(x <= 1.5e+94)) {
tmp = fma(c, b, (fma(-4.0, i, (((y * z) * t) * 18.0)) * x));
} else {
tmp = fma((-27.0 * j), k, fma(fma(-4.0, a, (((x * z) * y) * 18.0)), t, (c * b)));
}
return tmp;
}
x, y, z, t, a, b, c, i, j, k = sort([x, y, z, t, a, b, c, i, j, k]) function code(x, y, z, t, a, b, c, i, j, k) tmp = 0.0 if ((x <= -2.1e+109) || !(x <= 1.5e+94)) tmp = fma(c, b, Float64(fma(-4.0, i, Float64(Float64(Float64(y * z) * t) * 18.0)) * x)); else tmp = fma(Float64(-27.0 * j), k, fma(fma(-4.0, a, Float64(Float64(Float64(x * z) * y) * 18.0)), t, Float64(c * b))); end return tmp end
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := If[Or[LessEqual[x, -2.1e+109], N[Not[LessEqual[x, 1.5e+94]], $MachinePrecision]], N[(c * b + N[(N[(-4.0 * i + N[(N[(N[(y * z), $MachinePrecision] * t), $MachinePrecision] * 18.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(-27.0 * j), $MachinePrecision] * k + N[(N[(-4.0 * a + N[(N[(N[(x * z), $MachinePrecision] * y), $MachinePrecision] * 18.0), $MachinePrecision]), $MachinePrecision] * t + N[(c * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i, j, k] = \mathsf{sort}([x, y, z, t, a, b, c, i, j, k])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{+109} \lor \neg \left(x \leq 1.5 \cdot 10^{+94}\right):\\
\;\;\;\;\mathsf{fma}\left(c, b, \mathsf{fma}\left(-4, i, \left(\left(y \cdot z\right) \cdot t\right) \cdot 18\right) \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-27 \cdot j, k, \mathsf{fma}\left(\mathsf{fma}\left(-4, a, \left(\left(x \cdot z\right) \cdot y\right) \cdot 18\right), t, c \cdot b\right)\right)\\
\end{array}
\end{array}
if x < -2.1000000000000001e109 or 1.5e94 < x Initial program 75.7%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
Applied rewrites81.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6490.8
Applied rewrites90.8%
if -2.1000000000000001e109 < x < 1.5e94Initial program 94.8%
Taylor expanded in i around 0
+-commutativeN/A
associate--r+N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
associate--l+N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate--l+N/A
+-commutativeN/A
Applied rewrites88.6%
Applied rewrites91.6%
Final simplification91.3%
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i j k)
:precision binary64
(if (<= (* b c) -5e+148)
(fma c b (* (* (* (* z y) t) 18.0) x))
(if (<= (* b c) 5e+191)
(fma (* j k) -27.0 (* (fma i x (* a t)) -4.0))
(fma c b (* (* -4.0 i) x)))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k);
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double tmp;
if ((b * c) <= -5e+148) {
tmp = fma(c, b, ((((z * y) * t) * 18.0) * x));
} else if ((b * c) <= 5e+191) {
tmp = fma((j * k), -27.0, (fma(i, x, (a * t)) * -4.0));
} else {
tmp = fma(c, b, ((-4.0 * i) * x));
}
return tmp;
}
x, y, z, t, a, b, c, i, j, k = sort([x, y, z, t, a, b, c, i, j, k]) function code(x, y, z, t, a, b, c, i, j, k) tmp = 0.0 if (Float64(b * c) <= -5e+148) tmp = fma(c, b, Float64(Float64(Float64(Float64(z * y) * t) * 18.0) * x)); elseif (Float64(b * c) <= 5e+191) tmp = fma(Float64(j * k), -27.0, Float64(fma(i, x, Float64(a * t)) * -4.0)); else tmp = fma(c, b, Float64(Float64(-4.0 * i) * x)); end return tmp end
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := If[LessEqual[N[(b * c), $MachinePrecision], -5e+148], N[(c * b + N[(N[(N[(N[(z * y), $MachinePrecision] * t), $MachinePrecision] * 18.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(b * c), $MachinePrecision], 5e+191], N[(N[(j * k), $MachinePrecision] * -27.0 + N[(N[(i * x + N[(a * t), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], N[(c * b + N[(N[(-4.0 * i), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i, j, k] = \mathsf{sort}([x, y, z, t, a, b, c, i, j, k])\\
\\
\begin{array}{l}
\mathbf{if}\;b \cdot c \leq -5 \cdot 10^{+148}:\\
\;\;\;\;\mathsf{fma}\left(c, b, \left(\left(\left(z \cdot y\right) \cdot t\right) \cdot 18\right) \cdot x\right)\\
\mathbf{elif}\;b \cdot c \leq 5 \cdot 10^{+191}:\\
\;\;\;\;\mathsf{fma}\left(j \cdot k, -27, \mathsf{fma}\left(i, x, a \cdot t\right) \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(c, b, \left(-4 \cdot i\right) \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 b c) < -5.00000000000000024e148Initial program 76.9%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
Applied rewrites86.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6490.8
Applied rewrites90.8%
Taylor expanded in y around inf
Applied rewrites82.5%
if -5.00000000000000024e148 < (*.f64 b c) < 5.0000000000000002e191Initial program 92.2%
Taylor expanded in y around 0
distribute-lft-outN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6480.4
Applied rewrites80.4%
Taylor expanded in b around 0
Applied rewrites76.2%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
Applied rewrites76.2%
if 5.0000000000000002e191 < (*.f64 b c) Initial program 75.0%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
Applied rewrites81.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6481.7
Applied rewrites81.7%
Taylor expanded in y around 0
Applied rewrites78.8%
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i j k) :precision binary64 (if (or (<= x -3.35e+128) (not (<= x 0.0011))) (fma c b (* (fma -4.0 i (* (* (* y z) t) 18.0)) x)) (- (fma c b (* -4.0 (fma i x (* a t)))) (* (* j 27.0) k))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k);
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double tmp;
if ((x <= -3.35e+128) || !(x <= 0.0011)) {
tmp = fma(c, b, (fma(-4.0, i, (((y * z) * t) * 18.0)) * x));
} else {
tmp = fma(c, b, (-4.0 * fma(i, x, (a * t)))) - ((j * 27.0) * k);
}
return tmp;
}
x, y, z, t, a, b, c, i, j, k = sort([x, y, z, t, a, b, c, i, j, k]) function code(x, y, z, t, a, b, c, i, j, k) tmp = 0.0 if ((x <= -3.35e+128) || !(x <= 0.0011)) tmp = fma(c, b, Float64(fma(-4.0, i, Float64(Float64(Float64(y * z) * t) * 18.0)) * x)); else tmp = Float64(fma(c, b, Float64(-4.0 * fma(i, x, Float64(a * t)))) - Float64(Float64(j * 27.0) * k)); end return tmp end
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := If[Or[LessEqual[x, -3.35e+128], N[Not[LessEqual[x, 0.0011]], $MachinePrecision]], N[(c * b + N[(N[(-4.0 * i + N[(N[(N[(y * z), $MachinePrecision] * t), $MachinePrecision] * 18.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(c * b + N[(-4.0 * N[(i * x + N[(a * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(j * 27.0), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i, j, k] = \mathsf{sort}([x, y, z, t, a, b, c, i, j, k])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.35 \cdot 10^{+128} \lor \neg \left(x \leq 0.0011\right):\\
\;\;\;\;\mathsf{fma}\left(c, b, \mathsf{fma}\left(-4, i, \left(\left(y \cdot z\right) \cdot t\right) \cdot 18\right) \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(c, b, -4 \cdot \mathsf{fma}\left(i, x, a \cdot t\right)\right) - \left(j \cdot 27\right) \cdot k\\
\end{array}
\end{array}
if x < -3.34999999999999996e128 or 0.00110000000000000007 < x Initial program 76.1%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
Applied rewrites84.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6489.4
Applied rewrites89.4%
if -3.34999999999999996e128 < x < 0.00110000000000000007Initial program 96.3%
Taylor expanded in y around 0
distribute-lft-outN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6488.9
Applied rewrites88.9%
Final simplification89.1%
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i j k) :precision binary64 (if (or (<= (* b c) -1e+72) (not (<= (* b c) 2e+125))) (fma c b (* (* -4.0 i) x)) (- (* (* a t) -4.0) (* (* j 27.0) k))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k);
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double tmp;
if (((b * c) <= -1e+72) || !((b * c) <= 2e+125)) {
tmp = fma(c, b, ((-4.0 * i) * x));
} else {
tmp = ((a * t) * -4.0) - ((j * 27.0) * k);
}
return tmp;
}
x, y, z, t, a, b, c, i, j, k = sort([x, y, z, t, a, b, c, i, j, k]) function code(x, y, z, t, a, b, c, i, j, k) tmp = 0.0 if ((Float64(b * c) <= -1e+72) || !(Float64(b * c) <= 2e+125)) tmp = fma(c, b, Float64(Float64(-4.0 * i) * x)); else tmp = Float64(Float64(Float64(a * t) * -4.0) - Float64(Float64(j * 27.0) * k)); end return tmp end
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := If[Or[LessEqual[N[(b * c), $MachinePrecision], -1e+72], N[Not[LessEqual[N[(b * c), $MachinePrecision], 2e+125]], $MachinePrecision]], N[(c * b + N[(N[(-4.0 * i), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * t), $MachinePrecision] * -4.0), $MachinePrecision] - N[(N[(j * 27.0), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i, j, k] = \mathsf{sort}([x, y, z, t, a, b, c, i, j, k])\\
\\
\begin{array}{l}
\mathbf{if}\;b \cdot c \leq -1 \cdot 10^{+72} \lor \neg \left(b \cdot c \leq 2 \cdot 10^{+125}\right):\\
\;\;\;\;\mathsf{fma}\left(c, b, \left(-4 \cdot i\right) \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot t\right) \cdot -4 - \left(j \cdot 27\right) \cdot k\\
\end{array}
\end{array}
if (*.f64 b c) < -9.99999999999999944e71 or 1.9999999999999998e125 < (*.f64 b c) Initial program 82.2%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
Applied rewrites87.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6481.5
Applied rewrites81.5%
Taylor expanded in y around 0
Applied rewrites74.2%
if -9.99999999999999944e71 < (*.f64 b c) < 1.9999999999999998e125Initial program 91.2%
Taylor expanded in y around 0
distribute-lft-outN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6479.1
Applied rewrites79.1%
Taylor expanded in b around 0
Applied rewrites78.3%
Taylor expanded in x around 0
Applied rewrites54.7%
Final simplification62.8%
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i j k) :precision binary64 (if (or (<= x -6.5e+126) (not (<= x 0.00021))) (fma c b (* (fma -4.0 i (* (* (* y z) t) 18.0)) x)) (fma (* k -27.0) j (fma (* t a) -4.0 (* b c)))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k);
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double tmp;
if ((x <= -6.5e+126) || !(x <= 0.00021)) {
tmp = fma(c, b, (fma(-4.0, i, (((y * z) * t) * 18.0)) * x));
} else {
tmp = fma((k * -27.0), j, fma((t * a), -4.0, (b * c)));
}
return tmp;
}
x, y, z, t, a, b, c, i, j, k = sort([x, y, z, t, a, b, c, i, j, k]) function code(x, y, z, t, a, b, c, i, j, k) tmp = 0.0 if ((x <= -6.5e+126) || !(x <= 0.00021)) tmp = fma(c, b, Float64(fma(-4.0, i, Float64(Float64(Float64(y * z) * t) * 18.0)) * x)); else tmp = fma(Float64(k * -27.0), j, fma(Float64(t * a), -4.0, Float64(b * c))); end return tmp end
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := If[Or[LessEqual[x, -6.5e+126], N[Not[LessEqual[x, 0.00021]], $MachinePrecision]], N[(c * b + N[(N[(-4.0 * i + N[(N[(N[(y * z), $MachinePrecision] * t), $MachinePrecision] * 18.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(k * -27.0), $MachinePrecision] * j + N[(N[(t * a), $MachinePrecision] * -4.0 + N[(b * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i, j, k] = \mathsf{sort}([x, y, z, t, a, b, c, i, j, k])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.5 \cdot 10^{+126} \lor \neg \left(x \leq 0.00021\right):\\
\;\;\;\;\mathsf{fma}\left(c, b, \mathsf{fma}\left(-4, i, \left(\left(y \cdot z\right) \cdot t\right) \cdot 18\right) \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(k \cdot -27, j, \mathsf{fma}\left(t \cdot a, -4, b \cdot c\right)\right)\\
\end{array}
\end{array}
if x < -6.5000000000000005e126 or 2.1000000000000001e-4 < x Initial program 76.1%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
Applied rewrites84.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6489.4
Applied rewrites89.4%
if -6.5000000000000005e126 < x < 2.1000000000000001e-4Initial program 96.3%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6483.5
Applied rewrites83.5%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites84.3%
Final simplification86.5%
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i j k)
:precision binary64
(let* ((t_1 (* (* j 27.0) k)))
(if (or (<= t_1 -5e-6) (not (<= t_1 5e+61)))
(* (* -27.0 j) k)
(* (* -4.0 a) t))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k);
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double t_1 = (j * 27.0) * k;
double tmp;
if ((t_1 <= -5e-6) || !(t_1 <= 5e+61)) {
tmp = (-27.0 * j) * k;
} else {
tmp = (-4.0 * a) * t;
}
return tmp;
}
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i, j, k)
use fmin_fmax_functions
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), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8) :: t_1
real(8) :: tmp
t_1 = (j * 27.0d0) * k
if ((t_1 <= (-5d-6)) .or. (.not. (t_1 <= 5d+61))) then
tmp = ((-27.0d0) * j) * k
else
tmp = ((-4.0d0) * a) * t
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double t_1 = (j * 27.0) * k;
double tmp;
if ((t_1 <= -5e-6) || !(t_1 <= 5e+61)) {
tmp = (-27.0 * j) * k;
} else {
tmp = (-4.0 * a) * t;
}
return tmp;
}
[x, y, z, t, a, b, c, i, j, k] = sort([x, y, z, t, a, b, c, i, j, k]) def code(x, y, z, t, a, b, c, i, j, k): t_1 = (j * 27.0) * k tmp = 0 if (t_1 <= -5e-6) or not (t_1 <= 5e+61): tmp = (-27.0 * j) * k else: tmp = (-4.0 * a) * t return tmp
x, y, z, t, a, b, c, i, j, k = sort([x, y, z, t, a, b, c, i, j, k]) function code(x, y, z, t, a, b, c, i, j, k) t_1 = Float64(Float64(j * 27.0) * k) tmp = 0.0 if ((t_1 <= -5e-6) || !(t_1 <= 5e+61)) tmp = Float64(Float64(-27.0 * j) * k); else tmp = Float64(Float64(-4.0 * a) * t); end return tmp end
x, y, z, t, a, b, c, i, j, k = num2cell(sort([x, y, z, t, a, b, c, i, j, k])){:}
function tmp_2 = code(x, y, z, t, a, b, c, i, j, k)
t_1 = (j * 27.0) * k;
tmp = 0.0;
if ((t_1 <= -5e-6) || ~((t_1 <= 5e+61)))
tmp = (-27.0 * j) * k;
else
tmp = (-4.0 * a) * t;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := Block[{t$95$1 = N[(N[(j * 27.0), $MachinePrecision] * k), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -5e-6], N[Not[LessEqual[t$95$1, 5e+61]], $MachinePrecision]], N[(N[(-27.0 * j), $MachinePrecision] * k), $MachinePrecision], N[(N[(-4.0 * a), $MachinePrecision] * t), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i, j, k] = \mathsf{sort}([x, y, z, t, a, b, c, i, j, k])\\
\\
\begin{array}{l}
t_1 := \left(j \cdot 27\right) \cdot k\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-6} \lor \neg \left(t\_1 \leq 5 \cdot 10^{+61}\right):\\
\;\;\;\;\left(-27 \cdot j\right) \cdot k\\
\mathbf{else}:\\
\;\;\;\;\left(-4 \cdot a\right) \cdot t\\
\end{array}
\end{array}
if (*.f64 (*.f64 j #s(literal 27 binary64)) k) < -5.00000000000000041e-6 or 5.00000000000000018e61 < (*.f64 (*.f64 j #s(literal 27 binary64)) k) Initial program 87.4%
Taylor expanded in j around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f6447.9
Applied rewrites47.9%
if -5.00000000000000041e-6 < (*.f64 (*.f64 j #s(literal 27 binary64)) k) < 5.00000000000000018e61Initial program 87.6%
Taylor expanded in j around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f642.2
Applied rewrites2.2%
Taylor expanded in t around inf
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6450.7
Applied rewrites50.7%
Taylor expanded in x around 0
Applied rewrites24.3%
Final simplification35.4%
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i j k) :precision binary64 (if (or (<= x -6.2e+127) (not (<= x 9.2e+51))) (* (fma -4.0 i (* (* (* z y) t) 18.0)) x) (fma (* k -27.0) j (fma (* t a) -4.0 (* b c)))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k);
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double tmp;
if ((x <= -6.2e+127) || !(x <= 9.2e+51)) {
tmp = fma(-4.0, i, (((z * y) * t) * 18.0)) * x;
} else {
tmp = fma((k * -27.0), j, fma((t * a), -4.0, (b * c)));
}
return tmp;
}
x, y, z, t, a, b, c, i, j, k = sort([x, y, z, t, a, b, c, i, j, k]) function code(x, y, z, t, a, b, c, i, j, k) tmp = 0.0 if ((x <= -6.2e+127) || !(x <= 9.2e+51)) tmp = Float64(fma(-4.0, i, Float64(Float64(Float64(z * y) * t) * 18.0)) * x); else tmp = fma(Float64(k * -27.0), j, fma(Float64(t * a), -4.0, Float64(b * c))); end return tmp end
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := If[Or[LessEqual[x, -6.2e+127], N[Not[LessEqual[x, 9.2e+51]], $MachinePrecision]], N[(N[(-4.0 * i + N[(N[(N[(z * y), $MachinePrecision] * t), $MachinePrecision] * 18.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(k * -27.0), $MachinePrecision] * j + N[(N[(t * a), $MachinePrecision] * -4.0 + N[(b * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i, j, k] = \mathsf{sort}([x, y, z, t, a, b, c, i, j, k])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.2 \cdot 10^{+127} \lor \neg \left(x \leq 9.2 \cdot 10^{+51}\right):\\
\;\;\;\;\mathsf{fma}\left(-4, i, \left(\left(z \cdot y\right) \cdot t\right) \cdot 18\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(k \cdot -27, j, \mathsf{fma}\left(t \cdot a, -4, b \cdot c\right)\right)\\
\end{array}
\end{array}
if x < -6.2000000000000005e127 or 9.2000000000000002e51 < x Initial program 75.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6484.2
Applied rewrites84.2%
if -6.2000000000000005e127 < x < 9.2000000000000002e51Initial program 95.3%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6482.0
Applied rewrites82.0%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites82.7%
Final simplification83.3%
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i j k) :precision binary64 (if (or (<= x -1.96e+77) (not (<= x 0.00105))) (* (fma -4.0 i (* (* 18.0 z) (* t y))) x) (- (* (* a t) -4.0) (* (* j 27.0) k))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k);
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double tmp;
if ((x <= -1.96e+77) || !(x <= 0.00105)) {
tmp = fma(-4.0, i, ((18.0 * z) * (t * y))) * x;
} else {
tmp = ((a * t) * -4.0) - ((j * 27.0) * k);
}
return tmp;
}
x, y, z, t, a, b, c, i, j, k = sort([x, y, z, t, a, b, c, i, j, k]) function code(x, y, z, t, a, b, c, i, j, k) tmp = 0.0 if ((x <= -1.96e+77) || !(x <= 0.00105)) tmp = Float64(fma(-4.0, i, Float64(Float64(18.0 * z) * Float64(t * y))) * x); else tmp = Float64(Float64(Float64(a * t) * -4.0) - Float64(Float64(j * 27.0) * k)); end return tmp end
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := If[Or[LessEqual[x, -1.96e+77], N[Not[LessEqual[x, 0.00105]], $MachinePrecision]], N[(N[(-4.0 * i + N[(N[(18.0 * z), $MachinePrecision] * N[(t * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(a * t), $MachinePrecision] * -4.0), $MachinePrecision] - N[(N[(j * 27.0), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i, j, k] = \mathsf{sort}([x, y, z, t, a, b, c, i, j, k])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.96 \cdot 10^{+77} \lor \neg \left(x \leq 0.00105\right):\\
\;\;\;\;\mathsf{fma}\left(-4, i, \left(18 \cdot z\right) \cdot \left(t \cdot y\right)\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot t\right) \cdot -4 - \left(j \cdot 27\right) \cdot k\\
\end{array}
\end{array}
if x < -1.96000000000000011e77 or 0.00104999999999999994 < x Initial program 75.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6478.8
Applied rewrites78.8%
Applied rewrites80.4%
if -1.96000000000000011e77 < x < 0.00104999999999999994Initial program 97.6%
Taylor expanded in y around 0
distribute-lft-outN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6489.2
Applied rewrites89.2%
Taylor expanded in b around 0
Applied rewrites64.5%
Taylor expanded in x around 0
Applied rewrites59.1%
Final simplification68.9%
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i j k)
:precision binary64
(if (<= x -1.96e+77)
(* (fma -4.0 i (* (* (* z y) t) 18.0)) x)
(if (<= x 0.00105)
(- (* (* a t) -4.0) (* (* j 27.0) k))
(* (fma -4.0 i (* (* 18.0 z) (* t y))) x))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k);
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double tmp;
if (x <= -1.96e+77) {
tmp = fma(-4.0, i, (((z * y) * t) * 18.0)) * x;
} else if (x <= 0.00105) {
tmp = ((a * t) * -4.0) - ((j * 27.0) * k);
} else {
tmp = fma(-4.0, i, ((18.0 * z) * (t * y))) * x;
}
return tmp;
}
x, y, z, t, a, b, c, i, j, k = sort([x, y, z, t, a, b, c, i, j, k]) function code(x, y, z, t, a, b, c, i, j, k) tmp = 0.0 if (x <= -1.96e+77) tmp = Float64(fma(-4.0, i, Float64(Float64(Float64(z * y) * t) * 18.0)) * x); elseif (x <= 0.00105) tmp = Float64(Float64(Float64(a * t) * -4.0) - Float64(Float64(j * 27.0) * k)); else tmp = Float64(fma(-4.0, i, Float64(Float64(18.0 * z) * Float64(t * y))) * x); end return tmp end
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := If[LessEqual[x, -1.96e+77], N[(N[(-4.0 * i + N[(N[(N[(z * y), $MachinePrecision] * t), $MachinePrecision] * 18.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 0.00105], N[(N[(N[(a * t), $MachinePrecision] * -4.0), $MachinePrecision] - N[(N[(j * 27.0), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * i + N[(N[(18.0 * z), $MachinePrecision] * N[(t * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i, j, k] = \mathsf{sort}([x, y, z, t, a, b, c, i, j, k])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.96 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{fma}\left(-4, i, \left(\left(z \cdot y\right) \cdot t\right) \cdot 18\right) \cdot x\\
\mathbf{elif}\;x \leq 0.00105:\\
\;\;\;\;\left(a \cdot t\right) \cdot -4 - \left(j \cdot 27\right) \cdot k\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-4, i, \left(18 \cdot z\right) \cdot \left(t \cdot y\right)\right) \cdot x\\
\end{array}
\end{array}
if x < -1.96000000000000011e77Initial program 73.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6483.9
Applied rewrites83.9%
if -1.96000000000000011e77 < x < 0.00104999999999999994Initial program 97.6%
Taylor expanded in y around 0
distribute-lft-outN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
metadata-evalN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6489.2
Applied rewrites89.2%
Taylor expanded in b around 0
Applied rewrites64.5%
Taylor expanded in x around 0
Applied rewrites59.1%
if 0.00104999999999999994 < x Initial program 77.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6474.8
Applied rewrites74.8%
Applied rewrites77.6%
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i j k) :precision binary64 (if (or (<= x -2.65e+146) (not (<= x 9.2e+51))) (* (* -4.0 x) i) (fma -27.0 (* j k) (* b c))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k);
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double tmp;
if ((x <= -2.65e+146) || !(x <= 9.2e+51)) {
tmp = (-4.0 * x) * i;
} else {
tmp = fma(-27.0, (j * k), (b * c));
}
return tmp;
}
x, y, z, t, a, b, c, i, j, k = sort([x, y, z, t, a, b, c, i, j, k]) function code(x, y, z, t, a, b, c, i, j, k) tmp = 0.0 if ((x <= -2.65e+146) || !(x <= 9.2e+51)) tmp = Float64(Float64(-4.0 * x) * i); else tmp = fma(-27.0, Float64(j * k), Float64(b * c)); end return tmp end
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := If[Or[LessEqual[x, -2.65e+146], N[Not[LessEqual[x, 9.2e+51]], $MachinePrecision]], N[(N[(-4.0 * x), $MachinePrecision] * i), $MachinePrecision], N[(-27.0 * N[(j * k), $MachinePrecision] + N[(b * c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i, j, k] = \mathsf{sort}([x, y, z, t, a, b, c, i, j, k])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.65 \cdot 10^{+146} \lor \neg \left(x \leq 9.2 \cdot 10^{+51}\right):\\
\;\;\;\;\left(-4 \cdot x\right) \cdot i\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-27, j \cdot k, b \cdot c\right)\\
\end{array}
\end{array}
if x < -2.65000000000000001e146 or 9.2000000000000002e51 < x Initial program 76.3%
Taylor expanded in i around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6458.0
Applied rewrites58.0%
if -2.65000000000000001e146 < x < 9.2000000000000002e51Initial program 94.3%
Taylor expanded in i around 0
+-commutativeN/A
associate--r+N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
associate--l+N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate--l+N/A
+-commutativeN/A
Applied rewrites89.3%
Taylor expanded in t around 0
Applied rewrites56.2%
Final simplification56.9%
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i j k) :precision binary64 (* (* -4.0 a) t))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k);
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
return (-4.0 * a) * t;
}
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i, j, k)
use fmin_fmax_functions
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), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
real(8), intent (in) :: j
real(8), intent (in) :: k
code = ((-4.0d0) * a) * t
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i && i < j && j < k;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
return (-4.0 * a) * t;
}
[x, y, z, t, a, b, c, i, j, k] = sort([x, y, z, t, a, b, c, i, j, k]) def code(x, y, z, t, a, b, c, i, j, k): return (-4.0 * a) * t
x, y, z, t, a, b, c, i, j, k = sort([x, y, z, t, a, b, c, i, j, k]) function code(x, y, z, t, a, b, c, i, j, k) return Float64(Float64(-4.0 * a) * t) end
x, y, z, t, a, b, c, i, j, k = num2cell(sort([x, y, z, t, a, b, c, i, j, k])){:}
function tmp = code(x, y, z, t, a, b, c, i, j, k)
tmp = (-4.0 * a) * t;
end
NOTE: x, y, z, t, a, b, c, i, j, and k should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := N[(N[(-4.0 * a), $MachinePrecision] * t), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b, c, i, j, k] = \mathsf{sort}([x, y, z, t, a, b, c, i, j, k])\\
\\
\left(-4 \cdot a\right) \cdot t
\end{array}
Initial program 87.5%
Taylor expanded in j around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f6423.6
Applied rewrites23.6%
Taylor expanded in t around inf
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6442.4
Applied rewrites42.4%
Taylor expanded in x around 0
Applied rewrites19.8%
(FPCore (x y z t a b c i j k)
:precision binary64
(let* ((t_1 (* (+ (* a t) (* i x)) 4.0))
(t_2
(-
(- (* (* 18.0 t) (* (* x y) z)) t_1)
(- (* (* k j) 27.0) (* c b)))))
(if (< t -1.6210815397541398e-69)
t_2
(if (< t 165.68027943805222)
(+ (- (* (* 18.0 y) (* x (* z t))) t_1) (- (* c b) (* 27.0 (* k j))))
t_2))))
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double t_1 = ((a * t) + (i * x)) * 4.0;
double t_2 = (((18.0 * t) * ((x * y) * z)) - t_1) - (((k * j) * 27.0) - (c * b));
double tmp;
if (t < -1.6210815397541398e-69) {
tmp = t_2;
} else if (t < 165.68027943805222) {
tmp = (((18.0 * y) * (x * (z * t))) - t_1) + ((c * b) - (27.0 * (k * j)));
} else {
tmp = t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i, j, k)
use fmin_fmax_functions
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), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = ((a * t) + (i * x)) * 4.0d0
t_2 = (((18.0d0 * t) * ((x * y) * z)) - t_1) - (((k * j) * 27.0d0) - (c * b))
if (t < (-1.6210815397541398d-69)) then
tmp = t_2
else if (t < 165.68027943805222d0) then
tmp = (((18.0d0 * y) * (x * (z * t))) - t_1) + ((c * b) - (27.0d0 * (k * j)))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double t_1 = ((a * t) + (i * x)) * 4.0;
double t_2 = (((18.0 * t) * ((x * y) * z)) - t_1) - (((k * j) * 27.0) - (c * b));
double tmp;
if (t < -1.6210815397541398e-69) {
tmp = t_2;
} else if (t < 165.68027943805222) {
tmp = (((18.0 * y) * (x * (z * t))) - t_1) + ((c * b) - (27.0 * (k * j)));
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i, j, k): t_1 = ((a * t) + (i * x)) * 4.0 t_2 = (((18.0 * t) * ((x * y) * z)) - t_1) - (((k * j) * 27.0) - (c * b)) tmp = 0 if t < -1.6210815397541398e-69: tmp = t_2 elif t < 165.68027943805222: tmp = (((18.0 * y) * (x * (z * t))) - t_1) + ((c * b) - (27.0 * (k * j))) else: tmp = t_2 return tmp
function code(x, y, z, t, a, b, c, i, j, k) t_1 = Float64(Float64(Float64(a * t) + Float64(i * x)) * 4.0) t_2 = Float64(Float64(Float64(Float64(18.0 * t) * Float64(Float64(x * y) * z)) - t_1) - Float64(Float64(Float64(k * j) * 27.0) - Float64(c * b))) tmp = 0.0 if (t < -1.6210815397541398e-69) tmp = t_2; elseif (t < 165.68027943805222) tmp = Float64(Float64(Float64(Float64(18.0 * y) * Float64(x * Float64(z * t))) - t_1) + Float64(Float64(c * b) - Float64(27.0 * Float64(k * j)))); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i, j, k) t_1 = ((a * t) + (i * x)) * 4.0; t_2 = (((18.0 * t) * ((x * y) * z)) - t_1) - (((k * j) * 27.0) - (c * b)); tmp = 0.0; if (t < -1.6210815397541398e-69) tmp = t_2; elseif (t < 165.68027943805222) tmp = (((18.0 * y) * (x * (z * t))) - t_1) + ((c * b) - (27.0 * (k * j))); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := Block[{t$95$1 = N[(N[(N[(a * t), $MachinePrecision] + N[(i * x), $MachinePrecision]), $MachinePrecision] * 4.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(18.0 * t), $MachinePrecision] * N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision] - N[(N[(N[(k * j), $MachinePrecision] * 27.0), $MachinePrecision] - N[(c * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[t, -1.6210815397541398e-69], t$95$2, If[Less[t, 165.68027943805222], N[(N[(N[(N[(18.0 * y), $MachinePrecision] * N[(x * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision] + N[(N[(c * b), $MachinePrecision] - N[(27.0 * N[(k * j), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a \cdot t + i \cdot x\right) \cdot 4\\
t_2 := \left(\left(18 \cdot t\right) \cdot \left(\left(x \cdot y\right) \cdot z\right) - t\_1\right) - \left(\left(k \cdot j\right) \cdot 27 - c \cdot b\right)\\
\mathbf{if}\;t < -1.6210815397541398 \cdot 10^{-69}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t < 165.68027943805222:\\
\;\;\;\;\left(\left(18 \cdot y\right) \cdot \left(x \cdot \left(z \cdot t\right)\right) - t\_1\right) + \left(c \cdot b - 27 \cdot \left(k \cdot j\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
herbie shell --seed 2024360
(FPCore (x y z t a b c i j k)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, E"
:precision binary64
:alt
(! :herbie-platform default (if (< t -8105407698770699/5000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (- (* (* 18 t) (* (* x y) z)) (* (+ (* a t) (* i x)) 4)) (- (* (* k j) 27) (* c b))) (if (< t 8284013971902611/50000000000000) (+ (- (* (* 18 y) (* x (* z t))) (* (+ (* a t) (* i x)) 4)) (- (* c b) (* 27 (* k j)))) (- (- (* (* 18 t) (* (* x y) z)) (* (+ (* a t) (* i x)) 4)) (- (* (* k j) 27) (* c b))))))
(- (- (+ (- (* (* (* (* x 18.0) y) z) t) (* (* a 4.0) t)) (* b c)) (* (* x 4.0) i)) (* (* j 27.0) k)))