
(FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
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)
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
code = (((x * y) + (z * t)) + (a * b)) + (c * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
def code(x, y, z, t, a, b, c, i): return (((x * y) + (z * t)) + (a * b)) + (c * i)
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (((x * y) + (z * t)) + (a * b)) + (c * i); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
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)
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
code = (((x * y) + (z * t)) + (a * b)) + (c * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
def code(x, y, z, t, a, b, c, i): return (((x * y) + (z * t)) + (a * b)) + (c * i)
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (((x * y) + (z * t)) + (a * b)) + (c * i); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\end{array}
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i) :precision binary64 (if (<= i 5e+141) (+ (fma y x (fma b a (* t z))) (* c i)) (fma i c (fma b a (fma t z (* y x))))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (i <= 5e+141) {
tmp = fma(y, x, fma(b, a, (t * z))) + (c * i);
} else {
tmp = fma(i, c, fma(b, a, fma(t, z, (y * x))));
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (i <= 5e+141) tmp = Float64(fma(y, x, fma(b, a, Float64(t * z))) + Float64(c * i)); else tmp = fma(i, c, fma(b, a, fma(t, z, Float64(y * x)))); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[i, 5e+141], N[(N[(y * x + N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision], N[(i * c + N[(b * a + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;i \leq 5 \cdot 10^{+141}:\\
\;\;\;\;\mathsf{fma}\left(y, x, \mathsf{fma}\left(b, a, t \cdot z\right)\right) + c \cdot i\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, \mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\right)\\
\end{array}
\end{array}
if i < 5.00000000000000025e141Initial program 95.9%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
associate-+l+N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6497.1
Applied rewrites97.1%
if 5.00000000000000025e141 < i Initial program 95.9%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6498.3
Applied rewrites98.3%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i) :precision binary64 (fma i c (fma b a (fma t z (* y x)))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(i, c, fma(b, a, fma(t, z, (y * x))));
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) return fma(i, c, fma(b, a, fma(t, z, Float64(y * x)))) end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(i * c + N[(b * a + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\mathsf{fma}\left(i, c, \mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\right)
\end{array}
Initial program 95.9%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6498.3
Applied rewrites98.3%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma i c (fma x y (* a b)))))
(if (<= (* a b) -1e+86)
t_1
(if (<= (* a b) 4e-11) (fma i c (fma t z (* y x))) t_1))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(i, c, fma(x, y, (a * b)));
double tmp;
if ((a * b) <= -1e+86) {
tmp = t_1;
} else if ((a * b) <= 4e-11) {
tmp = fma(i, c, fma(t, z, (y * x)));
} else {
tmp = t_1;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = fma(i, c, fma(x, y, Float64(a * b))) tmp = 0.0 if (Float64(a * b) <= -1e+86) tmp = t_1; elseif (Float64(a * b) <= 4e-11) tmp = fma(i, c, fma(t, z, Float64(y * x))); else tmp = t_1; end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(i * c + N[(x * y + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -1e+86], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], 4e-11], N[(i * c + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(i, c, \mathsf{fma}\left(x, y, a \cdot b\right)\right)\\
\mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+86}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(i, c, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 a b) < -1e86 or 3.99999999999999976e-11 < (*.f64 a b) Initial program 95.9%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6498.3
Applied rewrites98.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
if -1e86 < (*.f64 a b) < 3.99999999999999976e-11Initial program 95.9%
Taylor expanded in a around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.9
Applied rewrites75.9%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* x y) -2e+59)
(fma i c (fma t z (* y x)))
(if (<= (* x y) 5e+96)
(fma b a (fma i c (* t z)))
(fma b a (fma y x (* c i))))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x * y) <= -2e+59) {
tmp = fma(i, c, fma(t, z, (y * x)));
} else if ((x * y) <= 5e+96) {
tmp = fma(b, a, fma(i, c, (t * z)));
} else {
tmp = fma(b, a, fma(y, x, (c * i)));
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(x * y) <= -2e+59) tmp = fma(i, c, fma(t, z, Float64(y * x))); elseif (Float64(x * y) <= 5e+96) tmp = fma(b, a, fma(i, c, Float64(t * z))); else tmp = fma(b, a, fma(y, x, Float64(c * i))); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -2e+59], N[(i * c + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 5e+96], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(y * x + N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+59}:\\
\;\;\;\;\mathsf{fma}\left(i, c, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{+96}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(y, x, c \cdot i\right)\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -1.99999999999999994e59Initial program 95.9%
Taylor expanded in a around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.9
Applied rewrites75.9%
if -1.99999999999999994e59 < (*.f64 x y) < 5.0000000000000004e96Initial program 95.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
if 5.0000000000000004e96 < (*.f64 x y) Initial program 95.9%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6474.7
Applied rewrites74.7%
lift-*.f64N/A
lift-fma.f64N/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f6474.6
Applied rewrites74.6%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* x y) -1e+140)
(fma b a (fma i c (* y x)))
(if (<= (* x y) 5e+96)
(fma b a (fma i c (* t z)))
(fma b a (fma y x (* c i))))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x * y) <= -1e+140) {
tmp = fma(b, a, fma(i, c, (y * x)));
} else if ((x * y) <= 5e+96) {
tmp = fma(b, a, fma(i, c, (t * z)));
} else {
tmp = fma(b, a, fma(y, x, (c * i)));
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(x * y) <= -1e+140) tmp = fma(b, a, fma(i, c, Float64(y * x))); elseif (Float64(x * y) <= 5e+96) tmp = fma(b, a, fma(i, c, Float64(t * z))); else tmp = fma(b, a, fma(y, x, Float64(c * i))); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -1e+140], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 5e+96], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(y * x + N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+140}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{+96}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(y, x, c \cdot i\right)\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -1.00000000000000006e140Initial program 95.9%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6474.7
Applied rewrites74.7%
if -1.00000000000000006e140 < (*.f64 x y) < 5.0000000000000004e96Initial program 95.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
if 5.0000000000000004e96 < (*.f64 x y) Initial program 95.9%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6474.7
Applied rewrites74.7%
lift-*.f64N/A
lift-fma.f64N/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f6474.6
Applied rewrites74.6%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma b a (fma i c (* y x)))))
(if (<= (* x y) -1e+140)
t_1
(if (<= (* x y) 5e+96) (fma b a (fma i c (* t z))) t_1))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(b, a, fma(i, c, (y * x)));
double tmp;
if ((x * y) <= -1e+140) {
tmp = t_1;
} else if ((x * y) <= 5e+96) {
tmp = fma(b, a, fma(i, c, (t * z)));
} else {
tmp = t_1;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = fma(b, a, fma(i, c, Float64(y * x))) tmp = 0.0 if (Float64(x * y) <= -1e+140) tmp = t_1; elseif (Float64(x * y) <= 5e+96) tmp = fma(b, a, fma(i, c, Float64(t * z))); else tmp = t_1; end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -1e+140], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 5e+96], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+140}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{+96}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 x y) < -1.00000000000000006e140 or 5.0000000000000004e96 < (*.f64 x y) Initial program 95.9%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6474.7
Applied rewrites74.7%
if -1.00000000000000006e140 < (*.f64 x y) < 5.0000000000000004e96Initial program 95.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma i c (* y x))))
(if (<= (* x y) -2e+265)
t_1
(if (<= (* x y) 2e+98) (fma b a (fma i c (* t z))) t_1))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(i, c, (y * x));
double tmp;
if ((x * y) <= -2e+265) {
tmp = t_1;
} else if ((x * y) <= 2e+98) {
tmp = fma(b, a, fma(i, c, (t * z)));
} else {
tmp = t_1;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = fma(i, c, Float64(y * x)) tmp = 0.0 if (Float64(x * y) <= -2e+265) tmp = t_1; elseif (Float64(x * y) <= 2e+98) tmp = fma(b, a, fma(i, c, Float64(t * z))); else tmp = t_1; end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -2e+265], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 2e+98], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(i, c, y \cdot x\right)\\
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+265}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+98}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 x y) < -2.00000000000000013e265 or 2e98 < (*.f64 x y) Initial program 95.9%
Taylor expanded in a around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f6451.7
Applied rewrites51.7%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6447.3
Applied rewrites47.3%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6451.6
Applied rewrites51.6%
if -2.00000000000000013e265 < (*.f64 x y) < 2e98Initial program 95.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* a b) -2e+48)
(fma i c (* a b))
(if (<= (* a b) 1e-242)
(fma i c (* y x))
(if (<= (* a b) 4e-11) (fma z t (* c i)) (fma b a (* c i))))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((a * b) <= -2e+48) {
tmp = fma(i, c, (a * b));
} else if ((a * b) <= 1e-242) {
tmp = fma(i, c, (y * x));
} else if ((a * b) <= 4e-11) {
tmp = fma(z, t, (c * i));
} else {
tmp = fma(b, a, (c * i));
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(a * b) <= -2e+48) tmp = fma(i, c, Float64(a * b)); elseif (Float64(a * b) <= 1e-242) tmp = fma(i, c, Float64(y * x)); elseif (Float64(a * b) <= 4e-11) tmp = fma(z, t, Float64(c * i)); else tmp = fma(b, a, Float64(c * i)); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(a * b), $MachinePrecision], -2e+48], N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1e-242], N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 4e-11], N[(z * t + N[(c * i), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(c * i), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+48}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\
\mathbf{elif}\;a \cdot b \leq 10^{-242}:\\
\;\;\;\;\mathsf{fma}\left(i, c, y \cdot x\right)\\
\mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(z, t, c \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, c \cdot i\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -2.00000000000000009e48Initial program 95.9%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6498.3
Applied rewrites98.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
Taylor expanded in x around 0
lift-*.f6450.5
Applied rewrites50.5%
if -2.00000000000000009e48 < (*.f64 a b) < 1e-242Initial program 95.9%
Taylor expanded in a around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f6451.7
Applied rewrites51.7%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6447.3
Applied rewrites47.3%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6451.6
Applied rewrites51.6%
if 1e-242 < (*.f64 a b) < 3.99999999999999976e-11Initial program 95.9%
Taylor expanded in a around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f6451.7
Applied rewrites51.7%
if 3.99999999999999976e-11 < (*.f64 a b) Initial program 95.9%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6474.7
Applied rewrites74.7%
Taylor expanded in x around 0
lift-*.f6450.5
Applied rewrites50.5%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma b a (* c i))))
(if (<= (* a b) -2e+48)
t_1
(if (<= (* a b) 1e-242)
(fma i c (* y x))
(if (<= (* a b) 4e-11) (fma z t (* c i)) t_1)))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(b, a, (c * i));
double tmp;
if ((a * b) <= -2e+48) {
tmp = t_1;
} else if ((a * b) <= 1e-242) {
tmp = fma(i, c, (y * x));
} else if ((a * b) <= 4e-11) {
tmp = fma(z, t, (c * i));
} else {
tmp = t_1;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = fma(b, a, Float64(c * i)) tmp = 0.0 if (Float64(a * b) <= -2e+48) tmp = t_1; elseif (Float64(a * b) <= 1e-242) tmp = fma(i, c, Float64(y * x)); elseif (Float64(a * b) <= 4e-11) tmp = fma(z, t, Float64(c * i)); else tmp = t_1; end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(b * a + N[(c * i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -2e+48], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], 1e-242], N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 4e-11], N[(z * t + N[(c * i), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, c \cdot i\right)\\
\mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+48}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq 10^{-242}:\\
\;\;\;\;\mathsf{fma}\left(i, c, y \cdot x\right)\\
\mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(z, t, c \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 a b) < -2.00000000000000009e48 or 3.99999999999999976e-11 < (*.f64 a b) Initial program 95.9%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6474.7
Applied rewrites74.7%
Taylor expanded in x around 0
lift-*.f6450.5
Applied rewrites50.5%
if -2.00000000000000009e48 < (*.f64 a b) < 1e-242Initial program 95.9%
Taylor expanded in a around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f6451.7
Applied rewrites51.7%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6447.3
Applied rewrites47.3%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6451.6
Applied rewrites51.6%
if 1e-242 < (*.f64 a b) < 3.99999999999999976e-11Initial program 95.9%
Taylor expanded in a around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f6451.7
Applied rewrites51.7%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma i c (* y x))))
(if (<= (* x y) -1e+140)
t_1
(if (<= (* x y) 2e+98) (fma z t (* c i)) t_1))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(i, c, (y * x));
double tmp;
if ((x * y) <= -1e+140) {
tmp = t_1;
} else if ((x * y) <= 2e+98) {
tmp = fma(z, t, (c * i));
} else {
tmp = t_1;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = fma(i, c, Float64(y * x)) tmp = 0.0 if (Float64(x * y) <= -1e+140) tmp = t_1; elseif (Float64(x * y) <= 2e+98) tmp = fma(z, t, Float64(c * i)); else tmp = t_1; end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -1e+140], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 2e+98], N[(z * t + N[(c * i), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(i, c, y \cdot x\right)\\
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+140}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+98}:\\
\;\;\;\;\mathsf{fma}\left(z, t, c \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 x y) < -1.00000000000000006e140 or 2e98 < (*.f64 x y) Initial program 95.9%
Taylor expanded in a around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f6451.7
Applied rewrites51.7%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6447.3
Applied rewrites47.3%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6451.6
Applied rewrites51.6%
if -1.00000000000000006e140 < (*.f64 x y) < 2e98Initial program 95.9%
Taylor expanded in a around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f6451.7
Applied rewrites51.7%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i) :precision binary64 (fma i c (* y x)))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(i, c, (y * x));
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) return fma(i, c, Float64(y * x)) end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\mathsf{fma}\left(i, c, y \cdot x\right)
\end{array}
Initial program 95.9%
Taylor expanded in a around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f6451.7
Applied rewrites51.7%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6447.3
Applied rewrites47.3%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6451.6
Applied rewrites51.6%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i) :precision binary64 (if (<= (* x y) -1.45e+44) (* x y) (if (<= (* x y) 3.5e+100) (* i c) (* x y))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x * y) <= -1.45e+44) {
tmp = x * y;
} else if ((x * y) <= 3.5e+100) {
tmp = i * c;
} else {
tmp = x * y;
}
return tmp;
}
NOTE: x, y, z, t, a, b, c, and i 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)
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) :: tmp
if ((x * y) <= (-1.45d+44)) then
tmp = x * y
else if ((x * y) <= 3.5d+100) then
tmp = i * c
else
tmp = x * y
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x * y) <= -1.45e+44) {
tmp = x * y;
} else if ((x * y) <= 3.5e+100) {
tmp = i * c;
} else {
tmp = x * y;
}
return tmp;
}
[x, y, z, t, a, b, c, i] = sort([x, y, z, t, a, b, c, i]) def code(x, y, z, t, a, b, c, i): tmp = 0 if (x * y) <= -1.45e+44: tmp = x * y elif (x * y) <= 3.5e+100: tmp = i * c else: tmp = x * y return tmp
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(x * y) <= -1.45e+44) tmp = Float64(x * y); elseif (Float64(x * y) <= 3.5e+100) tmp = Float64(i * c); else tmp = Float64(x * y); end return tmp end
x, y, z, t, a, b, c, i = num2cell(sort([x, y, z, t, a, b, c, i])){:}
function tmp_2 = code(x, y, z, t, a, b, c, i)
tmp = 0.0;
if ((x * y) <= -1.45e+44)
tmp = x * y;
elseif ((x * y) <= 3.5e+100)
tmp = i * c;
else
tmp = x * y;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -1.45e+44], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 3.5e+100], N[(i * c), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1.45 \cdot 10^{+44}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq 3.5 \cdot 10^{+100}:\\
\;\;\;\;i \cdot c\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -1.4500000000000001e44 or 3.49999999999999976e100 < (*.f64 x y) Initial program 95.9%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6498.3
Applied rewrites98.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
Taylor expanded in x around inf
*-commutativeN/A
associate-+r+N/A
*-commutativeN/A
*-commutativeN/A
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-*.f6428.1
Applied rewrites28.1%
if -1.4500000000000001e44 < (*.f64 x y) < 3.49999999999999976e100Initial program 95.9%
Taylor expanded in a around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f6451.7
Applied rewrites51.7%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6447.3
Applied rewrites47.3%
Taylor expanded in z around 0
Applied rewrites26.6%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i) :precision binary64 (* i c))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return i * c;
}
NOTE: x, y, z, t, a, b, c, and i 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)
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
code = i * c
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return i * c;
}
[x, y, z, t, a, b, c, i] = sort([x, y, z, t, a, b, c, i]) def code(x, y, z, t, a, b, c, i): return i * c
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) return Float64(i * c) end
x, y, z, t, a, b, c, i = num2cell(sort([x, y, z, t, a, b, c, i])){:}
function tmp = code(x, y, z, t, a, b, c, i)
tmp = i * c;
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(i * c), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
i \cdot c
\end{array}
Initial program 95.9%
Taylor expanded in a around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f6451.7
Applied rewrites51.7%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6447.3
Applied rewrites47.3%
Taylor expanded in z around 0
Applied rewrites26.6%
herbie shell --seed 2025139
(FPCore (x y z t a b c i)
:name "Linear.V4:$cdot from linear-1.19.1.3, C"
:precision binary64
(+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))