
(FPCore (x y z t a b) :precision binary64 (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
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)
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
code = ((x * 2.0d0) - (((y * 9.0d0) * z) * t)) + ((a * 27.0d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
def code(x, y, z, t, a, b): return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * 2.0) - Float64(Float64(Float64(y * 9.0) * z) * t)) + Float64(Float64(a * 27.0) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * 2.0), $MachinePrecision] - N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\end{array}
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
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)
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
code = ((x * 2.0d0) - (((y * 9.0d0) * z) * t)) + ((a * 27.0d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
def code(x, y, z, t, a, b): return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * 2.0) - Float64(Float64(Float64(y * 9.0) * z) * t)) + Float64(Float64(a * 27.0) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * 2.0), $MachinePrecision] - N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\end{array}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (if (<= t 3.6e+81) (fma (* t y) (* -9.0 z) (fma (* b a) 27.0 (+ x x))) (fma (* b 27.0) a (fma (* t -9.0) (* z y) (+ x x)))))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= 3.6e+81) {
tmp = fma((t * y), (-9.0 * z), fma((b * a), 27.0, (x + x)));
} else {
tmp = fma((b * 27.0), a, fma((t * -9.0), (z * y), (x + x)));
}
return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b]) x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) tmp = 0.0 if (t <= 3.6e+81) tmp = fma(Float64(t * y), Float64(-9.0 * z), fma(Float64(b * a), 27.0, Float64(x + x))); else tmp = fma(Float64(b * 27.0), a, fma(Float64(t * -9.0), Float64(z * y), Float64(x + x))); end return tmp end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, 3.6e+81], N[(N[(t * y), $MachinePrecision] * N[(-9.0 * z), $MachinePrecision] + N[(N[(b * a), $MachinePrecision] * 27.0 + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * 27.0), $MachinePrecision] * a + N[(N[(t * -9.0), $MachinePrecision] * N[(z * y), $MachinePrecision] + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 3.6 \cdot 10^{+81}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot y, -9 \cdot z, \mathsf{fma}\left(b \cdot a, 27, x + x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot 27, a, \mathsf{fma}\left(t \cdot -9, z \cdot y, x + x\right)\right)\\
\end{array}
\end{array}
if t < 3.60000000000000005e81Initial program 95.5%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
fp-cancel-sign-sub-invN/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift-*.f64N/A
associate--l+N/A
Applied rewrites93.5%
if 3.60000000000000005e81 < t Initial program 95.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6496.1
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
fp-cancel-sub-sign-invN/A
Applied rewrites96.1%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (if (<= t 3.6e+81) (fma (* -9.0 (* t y)) z (fma (* b a) 27.0 (+ x x))) (fma (* b 27.0) a (fma (* t -9.0) (* z y) (+ x x)))))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= 3.6e+81) {
tmp = fma((-9.0 * (t * y)), z, fma((b * a), 27.0, (x + x)));
} else {
tmp = fma((b * 27.0), a, fma((t * -9.0), (z * y), (x + x)));
}
return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b]) x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) tmp = 0.0 if (t <= 3.6e+81) tmp = fma(Float64(-9.0 * Float64(t * y)), z, fma(Float64(b * a), 27.0, Float64(x + x))); else tmp = fma(Float64(b * 27.0), a, fma(Float64(t * -9.0), Float64(z * y), Float64(x + x))); end return tmp end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, 3.6e+81], N[(N[(-9.0 * N[(t * y), $MachinePrecision]), $MachinePrecision] * z + N[(N[(b * a), $MachinePrecision] * 27.0 + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * 27.0), $MachinePrecision] * a + N[(N[(t * -9.0), $MachinePrecision] * N[(z * y), $MachinePrecision] + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 3.6 \cdot 10^{+81}:\\
\;\;\;\;\mathsf{fma}\left(-9 \cdot \left(t \cdot y\right), z, \mathsf{fma}\left(b \cdot a, 27, x + x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot 27, a, \mathsf{fma}\left(t \cdot -9, z \cdot y, x + x\right)\right)\\
\end{array}
\end{array}
if t < 3.60000000000000005e81Initial program 95.5%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
fp-cancel-sign-sub-invN/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift-*.f64N/A
associate--l+N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
associate-*r*N/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
Applied rewrites93.5%
if 3.60000000000000005e81 < t Initial program 95.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6496.1
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
fp-cancel-sub-sign-invN/A
Applied rewrites96.1%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (if (<= t 3.2e-48) (fma (* -9.0 (* t y)) z (fma (* b a) 27.0 (+ x x))) (+ (fma (* b 27.0) a (fma (* (* z -9.0) y) t x)) x)))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= 3.2e-48) {
tmp = fma((-9.0 * (t * y)), z, fma((b * a), 27.0, (x + x)));
} else {
tmp = fma((b * 27.0), a, fma(((z * -9.0) * y), t, x)) + x;
}
return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b]) x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) tmp = 0.0 if (t <= 3.2e-48) tmp = fma(Float64(-9.0 * Float64(t * y)), z, fma(Float64(b * a), 27.0, Float64(x + x))); else tmp = Float64(fma(Float64(b * 27.0), a, fma(Float64(Float64(z * -9.0) * y), t, x)) + x); end return tmp end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, 3.2e-48], N[(N[(-9.0 * N[(t * y), $MachinePrecision]), $MachinePrecision] * z + N[(N[(b * a), $MachinePrecision] * 27.0 + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b * 27.0), $MachinePrecision] * a + N[(N[(N[(z * -9.0), $MachinePrecision] * y), $MachinePrecision] * t + x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 3.2 \cdot 10^{-48}:\\
\;\;\;\;\mathsf{fma}\left(-9 \cdot \left(t \cdot y\right), z, \mathsf{fma}\left(b \cdot a, 27, x + x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot 27, a, \mathsf{fma}\left(\left(z \cdot -9\right) \cdot y, t, x\right)\right) + x\\
\end{array}
\end{array}
if t < 3.1999999999999998e-48Initial program 95.5%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
fp-cancel-sign-sub-invN/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift-*.f64N/A
associate--l+N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
associate-*r*N/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
Applied rewrites93.5%
if 3.1999999999999998e-48 < t Initial program 95.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6496.1
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
fp-cancel-sub-sign-invN/A
Applied rewrites96.1%
Applied rewrites95.9%
lift-fma.f64N/A
lift-fma.f64N/A
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
associate-*r*N/A
+-commutativeN/A
count-2-revN/A
Applied rewrites96.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6496.2
Applied rewrites96.2%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (if (<= t 1e-48) (+ (fma (* b a) 27.0 (fma (* -9.0 (* t z)) y x)) x) (+ (fma (* b 27.0) a (fma (* (* z -9.0) y) t x)) x)))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= 1e-48) {
tmp = fma((b * a), 27.0, fma((-9.0 * (t * z)), y, x)) + x;
} else {
tmp = fma((b * 27.0), a, fma(((z * -9.0) * y), t, x)) + x;
}
return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b]) x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) tmp = 0.0 if (t <= 1e-48) tmp = Float64(fma(Float64(b * a), 27.0, fma(Float64(-9.0 * Float64(t * z)), y, x)) + x); else tmp = Float64(fma(Float64(b * 27.0), a, fma(Float64(Float64(z * -9.0) * y), t, x)) + x); end return tmp end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, 1e-48], N[(N[(N[(b * a), $MachinePrecision] * 27.0 + N[(N[(-9.0 * N[(t * z), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(b * 27.0), $MachinePrecision] * a + N[(N[(N[(z * -9.0), $MachinePrecision] * y), $MachinePrecision] * t + x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 10^{-48}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot a, 27, \mathsf{fma}\left(-9 \cdot \left(t \cdot z\right), y, x\right)\right) + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot 27, a, \mathsf{fma}\left(\left(z \cdot -9\right) \cdot y, t, x\right)\right) + x\\
\end{array}
\end{array}
if t < 9.9999999999999997e-49Initial program 95.5%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
associate-+r+N/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites95.7%
if 9.9999999999999997e-49 < t Initial program 95.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6496.1
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
fp-cancel-sub-sign-invN/A
Applied rewrites96.1%
Applied rewrites95.9%
lift-fma.f64N/A
lift-fma.f64N/A
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
associate-*r*N/A
+-commutativeN/A
count-2-revN/A
Applied rewrites96.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6496.2
Applied rewrites96.2%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (if (<= (* (* y 9.0) z) 1e+289) (+ (fma (* b 27.0) a (fma (* (* z -9.0) y) t x)) x) (fma (* 27.0 a) b (* y (* -9.0 (* t z))))))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((y * 9.0) * z) <= 1e+289) {
tmp = fma((b * 27.0), a, fma(((z * -9.0) * y), t, x)) + x;
} else {
tmp = fma((27.0 * a), b, (y * (-9.0 * (t * z))));
}
return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b]) x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(y * 9.0) * z) <= 1e+289) tmp = Float64(fma(Float64(b * 27.0), a, fma(Float64(Float64(z * -9.0) * y), t, x)) + x); else tmp = fma(Float64(27.0 * a), b, Float64(y * Float64(-9.0 * Float64(t * z)))); end return tmp end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision], 1e+289], N[(N[(N[(b * 27.0), $MachinePrecision] * a + N[(N[(N[(z * -9.0), $MachinePrecision] * y), $MachinePrecision] * t + x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(27.0 * a), $MachinePrecision] * b + N[(y * N[(-9.0 * N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;\left(y \cdot 9\right) \cdot z \leq 10^{+289}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot 27, a, \mathsf{fma}\left(\left(z \cdot -9\right) \cdot y, t, x\right)\right) + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(27 \cdot a, b, y \cdot \left(-9 \cdot \left(t \cdot z\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 y #s(literal 9 binary64)) z) < 1.0000000000000001e289Initial program 95.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6496.1
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
fp-cancel-sub-sign-invN/A
Applied rewrites96.1%
Applied rewrites95.9%
lift-fma.f64N/A
lift-fma.f64N/A
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
associate-*r*N/A
+-commutativeN/A
count-2-revN/A
Applied rewrites96.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6496.2
Applied rewrites96.2%
if 1.0000000000000001e289 < (*.f64 (*.f64 y #s(literal 9 binary64)) z) Initial program 95.5%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6466.8
Applied rewrites66.8%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6466.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.8
Applied rewrites66.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6467.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
Applied rewrites67.4%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (if (<= (* (* y 9.0) z) 1e+289) (+ (fma (* b 27.0) a (fma (* (* y -9.0) z) t x)) x) (fma (* 27.0 a) b (* y (* -9.0 (* t z))))))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((y * 9.0) * z) <= 1e+289) {
tmp = fma((b * 27.0), a, fma(((y * -9.0) * z), t, x)) + x;
} else {
tmp = fma((27.0 * a), b, (y * (-9.0 * (t * z))));
}
return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b]) x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(y * 9.0) * z) <= 1e+289) tmp = Float64(fma(Float64(b * 27.0), a, fma(Float64(Float64(y * -9.0) * z), t, x)) + x); else tmp = fma(Float64(27.0 * a), b, Float64(y * Float64(-9.0 * Float64(t * z)))); end return tmp end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision], 1e+289], N[(N[(N[(b * 27.0), $MachinePrecision] * a + N[(N[(N[(y * -9.0), $MachinePrecision] * z), $MachinePrecision] * t + x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(27.0 * a), $MachinePrecision] * b + N[(y * N[(-9.0 * N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;\left(y \cdot 9\right) \cdot z \leq 10^{+289}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot 27, a, \mathsf{fma}\left(\left(y \cdot -9\right) \cdot z, t, x\right)\right) + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(27 \cdot a, b, y \cdot \left(-9 \cdot \left(t \cdot z\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 y #s(literal 9 binary64)) z) < 1.0000000000000001e289Initial program 95.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6496.1
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
fp-cancel-sub-sign-invN/A
Applied rewrites96.1%
Applied rewrites95.9%
lift-fma.f64N/A
lift-fma.f64N/A
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
associate-*r*N/A
+-commutativeN/A
count-2-revN/A
Applied rewrites96.1%
if 1.0000000000000001e289 < (*.f64 (*.f64 y #s(literal 9 binary64)) z) Initial program 95.5%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6466.8
Applied rewrites66.8%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6466.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.8
Applied rewrites66.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6467.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
Applied rewrites67.4%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma (* 27.0 a) b (* y (* -9.0 (* t z)))))
(t_2 (* (* (* y 9.0) z) t))
(t_3 (* 27.0 (* a b))))
(if (<= t_2 -4e+57)
t_1
(if (<= t_2 4e+55)
(fma 2.0 x t_3)
(if (<= t_2 1e+290) (fma -9.0 (* t (* y z)) t_3) t_1)))))assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma((27.0 * a), b, (y * (-9.0 * (t * z))));
double t_2 = ((y * 9.0) * z) * t;
double t_3 = 27.0 * (a * b);
double tmp;
if (t_2 <= -4e+57) {
tmp = t_1;
} else if (t_2 <= 4e+55) {
tmp = fma(2.0, x, t_3);
} else if (t_2 <= 1e+290) {
tmp = fma(-9.0, (t * (y * z)), t_3);
} else {
tmp = t_1;
}
return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b]) x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) t_1 = fma(Float64(27.0 * a), b, Float64(y * Float64(-9.0 * Float64(t * z)))) t_2 = Float64(Float64(Float64(y * 9.0) * z) * t) t_3 = Float64(27.0 * Float64(a * b)) tmp = 0.0 if (t_2 <= -4e+57) tmp = t_1; elseif (t_2 <= 4e+55) tmp = fma(2.0, x, t_3); elseif (t_2 <= 1e+290) tmp = fma(-9.0, Float64(t * Float64(y * z)), t_3); else tmp = t_1; end return tmp end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(27.0 * a), $MachinePrecision] * b + N[(y * N[(-9.0 * N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]}, Block[{t$95$3 = N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -4e+57], t$95$1, If[LessEqual[t$95$2, 4e+55], N[(2.0 * x + t$95$3), $MachinePrecision], If[LessEqual[t$95$2, 1e+290], N[(-9.0 * N[(t * N[(y * z), $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(27 \cdot a, b, y \cdot \left(-9 \cdot \left(t \cdot z\right)\right)\right)\\
t_2 := \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\\
t_3 := 27 \cdot \left(a \cdot b\right)\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{+57}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+55}:\\
\;\;\;\;\mathsf{fma}\left(2, x, t\_3\right)\\
\mathbf{elif}\;t\_2 \leq 10^{+290}:\\
\;\;\;\;\mathsf{fma}\left(-9, t \cdot \left(y \cdot z\right), t\_3\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < -4.00000000000000019e57 or 1.00000000000000006e290 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) Initial program 95.5%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6466.8
Applied rewrites66.8%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6466.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.8
Applied rewrites66.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6467.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
Applied rewrites67.4%
if -4.00000000000000019e57 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < 4.00000000000000004e55Initial program 95.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6463.7
Applied rewrites63.7%
if 4.00000000000000004e55 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < 1.00000000000000006e290Initial program 95.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6496.1
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
fp-cancel-sub-sign-invN/A
Applied rewrites96.1%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6466.9
Applied rewrites66.9%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (* (* y 9.0) z) t)))
(if (<= t_1 -4e+57)
(fma (* 27.0 a) b (* y (* -9.0 (* t z))))
(if (<= t_1 2e+35)
(fma 2.0 x (* 27.0 (* a b)))
(+ (fma (* b 27.0) a (* -9.0 (* t (* y z)))) x)))))assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((y * 9.0) * z) * t;
double tmp;
if (t_1 <= -4e+57) {
tmp = fma((27.0 * a), b, (y * (-9.0 * (t * z))));
} else if (t_1 <= 2e+35) {
tmp = fma(2.0, x, (27.0 * (a * b)));
} else {
tmp = fma((b * 27.0), a, (-9.0 * (t * (y * z)))) + x;
}
return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b]) x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(y * 9.0) * z) * t) tmp = 0.0 if (t_1 <= -4e+57) tmp = fma(Float64(27.0 * a), b, Float64(y * Float64(-9.0 * Float64(t * z)))); elseif (t_1 <= 2e+35) tmp = fma(2.0, x, Float64(27.0 * Float64(a * b))); else tmp = Float64(fma(Float64(b * 27.0), a, Float64(-9.0 * Float64(t * Float64(y * z)))) + x); end return tmp end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+57], N[(N[(27.0 * a), $MachinePrecision] * b + N[(y * N[(-9.0 * N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+35], N[(2.0 * x + N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b * 27.0), $MachinePrecision] * a + N[(-9.0 * N[(t * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+57}:\\
\;\;\;\;\mathsf{fma}\left(27 \cdot a, b, y \cdot \left(-9 \cdot \left(t \cdot z\right)\right)\right)\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+35}:\\
\;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot 27, a, -9 \cdot \left(t \cdot \left(y \cdot z\right)\right)\right) + x\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < -4.00000000000000019e57Initial program 95.5%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6466.8
Applied rewrites66.8%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6466.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.8
Applied rewrites66.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6467.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
Applied rewrites67.4%
if -4.00000000000000019e57 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < 1.9999999999999999e35Initial program 95.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6463.7
Applied rewrites63.7%
if 1.9999999999999999e35 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) Initial program 95.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6496.1
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
fp-cancel-sub-sign-invN/A
Applied rewrites96.1%
Applied rewrites95.9%
lift-fma.f64N/A
lift-fma.f64N/A
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
associate-*r*N/A
+-commutativeN/A
count-2-revN/A
Applied rewrites96.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6471.9
Applied rewrites71.9%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (* (* y 9.0) z) t)))
(if (<= t_1 -4e+57)
(fma (* 27.0 a) b (* y (* -9.0 (* t z))))
(if (<= t_1 4e+55)
(fma 2.0 x (* 27.0 (* a b)))
(fma (* 27.0 a) b (* (* y z) (* t -9.0)))))))assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((y * 9.0) * z) * t;
double tmp;
if (t_1 <= -4e+57) {
tmp = fma((27.0 * a), b, (y * (-9.0 * (t * z))));
} else if (t_1 <= 4e+55) {
tmp = fma(2.0, x, (27.0 * (a * b)));
} else {
tmp = fma((27.0 * a), b, ((y * z) * (t * -9.0)));
}
return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b]) x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(y * 9.0) * z) * t) tmp = 0.0 if (t_1 <= -4e+57) tmp = fma(Float64(27.0 * a), b, Float64(y * Float64(-9.0 * Float64(t * z)))); elseif (t_1 <= 4e+55) tmp = fma(2.0, x, Float64(27.0 * Float64(a * b))); else tmp = fma(Float64(27.0 * a), b, Float64(Float64(y * z) * Float64(t * -9.0))); end return tmp end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+57], N[(N[(27.0 * a), $MachinePrecision] * b + N[(y * N[(-9.0 * N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+55], N[(2.0 * x + N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(27.0 * a), $MachinePrecision] * b + N[(N[(y * z), $MachinePrecision] * N[(t * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+57}:\\
\;\;\;\;\mathsf{fma}\left(27 \cdot a, b, y \cdot \left(-9 \cdot \left(t \cdot z\right)\right)\right)\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+55}:\\
\;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(27 \cdot a, b, \left(y \cdot z\right) \cdot \left(t \cdot -9\right)\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < -4.00000000000000019e57Initial program 95.5%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6466.8
Applied rewrites66.8%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6466.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.8
Applied rewrites66.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6467.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
Applied rewrites67.4%
if -4.00000000000000019e57 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < 4.00000000000000004e55Initial program 95.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6463.7
Applied rewrites63.7%
if 4.00000000000000004e55 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) Initial program 95.5%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6466.8
Applied rewrites66.8%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6466.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.8
Applied rewrites66.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6467.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
Applied rewrites67.4%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6467.3
Applied rewrites67.3%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* 27.0 (* a b))) (t_2 (* (* (* y 9.0) z) t)))
(if (<= t_2 -4e+57)
(fma -9.0 (* (* t z) y) t_1)
(if (<= t_2 4e+55) (fma 2.0 x t_1) (fma -9.0 (* t (* y z)) t_1)))))assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 27.0 * (a * b);
double t_2 = ((y * 9.0) * z) * t;
double tmp;
if (t_2 <= -4e+57) {
tmp = fma(-9.0, ((t * z) * y), t_1);
} else if (t_2 <= 4e+55) {
tmp = fma(2.0, x, t_1);
} else {
tmp = fma(-9.0, (t * (y * z)), t_1);
}
return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b]) x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) t_1 = Float64(27.0 * Float64(a * b)) t_2 = Float64(Float64(Float64(y * 9.0) * z) * t) tmp = 0.0 if (t_2 <= -4e+57) tmp = fma(-9.0, Float64(Float64(t * z) * y), t_1); elseif (t_2 <= 4e+55) tmp = fma(2.0, x, t_1); else tmp = fma(-9.0, Float64(t * Float64(y * z)), t_1); end return tmp end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[t$95$2, -4e+57], N[(-9.0 * N[(N[(t * z), $MachinePrecision] * y), $MachinePrecision] + t$95$1), $MachinePrecision], If[LessEqual[t$95$2, 4e+55], N[(2.0 * x + t$95$1), $MachinePrecision], N[(-9.0 * N[(t * N[(y * z), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := 27 \cdot \left(a \cdot b\right)\\
t_2 := \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{+57}:\\
\;\;\;\;\mathsf{fma}\left(-9, \left(t \cdot z\right) \cdot y, t\_1\right)\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+55}:\\
\;\;\;\;\mathsf{fma}\left(2, x, t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-9, t \cdot \left(y \cdot z\right), t\_1\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < -4.00000000000000019e57Initial program 95.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6496.1
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
fp-cancel-sub-sign-invN/A
Applied rewrites96.1%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6466.9
Applied rewrites66.9%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6466.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.9
Applied rewrites66.9%
if -4.00000000000000019e57 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < 4.00000000000000004e55Initial program 95.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6463.7
Applied rewrites63.7%
if 4.00000000000000004e55 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) Initial program 95.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6496.1
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
fp-cancel-sub-sign-invN/A
Applied rewrites96.1%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6466.9
Applied rewrites66.9%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* 27.0 (* a b)))
(t_2 (fma -9.0 (* t (* y z)) t_1))
(t_3 (* (* (* y 9.0) z) t)))
(if (<= t_3 -1e+18) t_2 (if (<= t_3 4e+55) (fma 2.0 x t_1) t_2))))assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 27.0 * (a * b);
double t_2 = fma(-9.0, (t * (y * z)), t_1);
double t_3 = ((y * 9.0) * z) * t;
double tmp;
if (t_3 <= -1e+18) {
tmp = t_2;
} else if (t_3 <= 4e+55) {
tmp = fma(2.0, x, t_1);
} else {
tmp = t_2;
}
return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b]) x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) t_1 = Float64(27.0 * Float64(a * b)) t_2 = fma(-9.0, Float64(t * Float64(y * z)), t_1) t_3 = Float64(Float64(Float64(y * 9.0) * z) * t) tmp = 0.0 if (t_3 <= -1e+18) tmp = t_2; elseif (t_3 <= 4e+55) tmp = fma(2.0, x, t_1); else tmp = t_2; end return tmp end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(-9.0 * N[(t * N[(y * z), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[t$95$3, -1e+18], t$95$2, If[LessEqual[t$95$3, 4e+55], N[(2.0 * x + t$95$1), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := 27 \cdot \left(a \cdot b\right)\\
t_2 := \mathsf{fma}\left(-9, t \cdot \left(y \cdot z\right), t\_1\right)\\
t_3 := \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\\
\mathbf{if}\;t\_3 \leq -1 \cdot 10^{+18}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 4 \cdot 10^{+55}:\\
\;\;\;\;\mathsf{fma}\left(2, x, t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < -1e18 or 4.00000000000000004e55 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) Initial program 95.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6496.1
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
fp-cancel-sub-sign-invN/A
Applied rewrites96.1%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6466.9
Applied rewrites66.9%
if -1e18 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < 4.00000000000000004e55Initial program 95.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6463.7
Applied rewrites63.7%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (fma (* a b) 27.0 (+ x x)))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
return fma((a * b), 27.0, (x + x));
}
x, y, z, t, a, b = sort([x, y, z, t, a, b]) x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) return fma(Float64(a * b), 27.0, Float64(x + x)) end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := N[(N[(a * b), $MachinePrecision] * 27.0 + N[(x + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\mathsf{fma}\left(a \cdot b, 27, x + x\right)
\end{array}
Initial program 95.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6463.7
Applied rewrites63.7%
lift-fma.f64N/A
count-2-revN/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-+.f64N/A
associate-+r+N/A
lower-+.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6463.6
Applied rewrites63.6%
lift-+.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+l+N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
count-2-revN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6463.7
Applied rewrites63.7%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (fma (* 27.0 b) a (+ x x)))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
return fma((27.0 * b), a, (x + x));
}
x, y, z, t, a, b = sort([x, y, z, t, a, b]) x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) return fma(Float64(27.0 * b), a, Float64(x + x)) end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := N[(N[(27.0 * b), $MachinePrecision] * a + N[(x + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\mathsf{fma}\left(27 \cdot b, a, x + x\right)
\end{array}
Initial program 95.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6463.7
Applied rewrites63.7%
lift-fma.f64N/A
count-2-revN/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-fma.f6463.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6463.6
Applied rewrites63.6%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (+ (fma (* a 27.0) b x) x))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
return fma((a * 27.0), b, x) + x;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b]) x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) return Float64(fma(Float64(a * 27.0), b, x) + x) end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(a * 27.0), $MachinePrecision] * b + x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\mathsf{fma}\left(a \cdot 27, b, x\right) + x
\end{array}
Initial program 95.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6463.7
Applied rewrites63.7%
lift-fma.f64N/A
count-2-revN/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-+.f64N/A
associate-+r+N/A
lower-+.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6463.6
Applied rewrites63.6%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (* a 27.0) b)) (t_2 (* 27.0 (* a b)))) (if (<= t_1 -5e+79) t_2 (if (<= t_1 4e+56) (+ x x) t_2))))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * 27.0) * b;
double t_2 = 27.0 * (a * b);
double tmp;
if (t_1 <= -5e+79) {
tmp = t_2;
} else if (t_1 <= 4e+56) {
tmp = x + x;
} else {
tmp = t_2;
}
return tmp;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b 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)
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (a * 27.0d0) * b
t_2 = 27.0d0 * (a * b)
if (t_1 <= (-5d+79)) then
tmp = t_2
else if (t_1 <= 4d+56) then
tmp = x + x
else
tmp = t_2
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b;
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * 27.0) * b;
double t_2 = 27.0 * (a * b);
double tmp;
if (t_1 <= -5e+79) {
tmp = t_2;
} else if (t_1 <= 4e+56) {
tmp = x + x;
} else {
tmp = t_2;
}
return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b]) [x, y, z, t, a, b] = sort([x, y, z, t, a, b]) def code(x, y, z, t, a, b): t_1 = (a * 27.0) * b t_2 = 27.0 * (a * b) tmp = 0 if t_1 <= -5e+79: tmp = t_2 elif t_1 <= 4e+56: tmp = x + x else: tmp = t_2 return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b]) x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * 27.0) * b) t_2 = Float64(27.0 * Float64(a * b)) tmp = 0.0 if (t_1 <= -5e+79) tmp = t_2; elseif (t_1 <= 4e+56) tmp = Float64(x + x); else tmp = t_2; end return tmp end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
t_1 = (a * 27.0) * b;
t_2 = 27.0 * (a * b);
tmp = 0.0;
if (t_1 <= -5e+79)
tmp = t_2;
elseif (t_1 <= 4e+56)
tmp = x + x;
else
tmp = t_2;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]}, Block[{t$95$2 = N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+79], t$95$2, If[LessEqual[t$95$1, 4e+56], N[(x + x), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := \left(a \cdot 27\right) \cdot b\\
t_2 := 27 \cdot \left(a \cdot b\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+79}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+56}:\\
\;\;\;\;x + x\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (*.f64 a #s(literal 27 binary64)) b) < -5e79 or 4.00000000000000037e56 < (*.f64 (*.f64 a #s(literal 27 binary64)) b) Initial program 95.5%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6463.7
Applied rewrites63.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6435.0
Applied rewrites35.0%
if -5e79 < (*.f64 (*.f64 a #s(literal 27 binary64)) b) < 4.00000000000000037e56Initial program 95.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6496.1
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
fp-cancel-sub-sign-invN/A
Applied rewrites96.1%
Applied rewrites95.9%
Taylor expanded in x around inf
lower-*.f6430.8
Applied rewrites30.8%
lift-*.f64N/A
count-2-revN/A
lower-+.f6430.8
Applied rewrites30.8%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (+ x x))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
return x + x;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b 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)
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
code = x + x
end function
assert x < y && y < z && z < t && t < a && a < b;
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
return x + x;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b]) [x, y, z, t, a, b] = sort([x, y, z, t, a, b]) def code(x, y, z, t, a, b): return x + x
x, y, z, t, a, b = sort([x, y, z, t, a, b]) x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) return Float64(x + x) end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp = code(x, y, z, t, a, b)
tmp = x + x;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := N[(x + x), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
x + x
\end{array}
Initial program 95.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6496.1
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
add-flipN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
fp-cancel-sub-sign-invN/A
Applied rewrites96.1%
Applied rewrites95.9%
Taylor expanded in x around inf
lower-*.f6430.8
Applied rewrites30.8%
lift-*.f64N/A
count-2-revN/A
lower-+.f6430.8
Applied rewrites30.8%
herbie shell --seed 2025155
(FPCore (x y z t a b)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, A"
:precision binary64
(+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))