
(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 12 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}
(FPCore (x y z t a b c i) :precision binary64 (fma i c (fma b a (fma t z (* y x)))))
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))));
}
function code(x, y, z, t, a, b, c, i) return fma(i, c, fma(b, a, fma(t, z, Float64(y * x)))) end
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}
\\
\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.5%
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
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6497.7
Applied rewrites97.7%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* x y) -2e+157)
(fma b a (fma i c (* y x)))
(if (<= (* x y) 1e+151)
(fma b a (fma i c (* t z)))
(fma i c (fma t z (* y x))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x * y) <= -2e+157) {
tmp = fma(b, a, fma(i, c, (y * x)));
} else if ((x * y) <= 1e+151) {
tmp = fma(b, a, fma(i, c, (t * z)));
} else {
tmp = fma(i, c, fma(t, z, (y * x)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(x * y) <= -2e+157) tmp = fma(b, a, fma(i, c, Float64(y * x))); elseif (Float64(x * y) <= 1e+151) tmp = fma(b, a, fma(i, c, Float64(t * z))); else tmp = fma(i, c, fma(t, z, Float64(y * x))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -2e+157], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e+151], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(i * c + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+157}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\mathbf{elif}\;x \cdot y \leq 10^{+151}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -1.99999999999999997e157Initial program 95.5%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6474.8
Applied rewrites74.8%
if -1.99999999999999997e157 < (*.f64 x y) < 1.00000000000000002e151Initial program 95.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6474.8
Applied rewrites74.8%
if 1.00000000000000002e151 < (*.f64 x y) Initial program 95.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.6
Applied rewrites75.6%
(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) -2e+157)
t_1
(if (<= (* x y) 5e+43) (fma b a (fma i c (* t z))) t_1))))
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) <= -2e+157) {
tmp = t_1;
} else if ((x * y) <= 5e+43) {
tmp = fma(b, a, fma(i, c, (t * z)));
} else {
tmp = t_1;
}
return tmp;
}
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) <= -2e+157) tmp = t_1; elseif (Float64(x * y) <= 5e+43) tmp = fma(b, a, fma(i, c, Float64(t * z))); else tmp = t_1; end return tmp end
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], -2e+157], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 5e+43], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\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 -2 \cdot 10^{+157}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{+43}:\\
\;\;\;\;\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.99999999999999997e157 or 5.0000000000000004e43 < (*.f64 x y) Initial program 95.5%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6474.8
Applied rewrites74.8%
if -1.99999999999999997e157 < (*.f64 x y) < 5.0000000000000004e43Initial program 95.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6474.8
Applied rewrites74.8%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* x y) -1e+234) (* (fma x (/ y t) z) t) (if (<= (* x y) 1e+151) (fma b a (fma i c (* t z))) (fma i c (* y x)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x * y) <= -1e+234) {
tmp = fma(x, (y / t), z) * t;
} else if ((x * y) <= 1e+151) {
tmp = fma(b, a, fma(i, c, (t * z)));
} else {
tmp = fma(i, c, (y * x));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(x * y) <= -1e+234) tmp = Float64(fma(x, Float64(y / t), z) * t); elseif (Float64(x * y) <= 1e+151) tmp = fma(b, a, fma(i, c, Float64(t * z))); else tmp = fma(i, c, Float64(y * x)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -1e+234], N[(N[(x * N[(y / t), $MachinePrecision] + z), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e+151], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+234}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{y}{t}, z\right) \cdot t\\
\mathbf{elif}\;x \cdot y \leq 10^{+151}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -1.00000000000000002e234Initial program 95.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.6
Applied rewrites75.6%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6452.2
Applied rewrites52.2%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6451.8
Applied rewrites51.8%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6447.4
Applied rewrites47.4%
if -1.00000000000000002e234 < (*.f64 x y) < 1.00000000000000002e151Initial program 95.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6474.8
Applied rewrites74.8%
if 1.00000000000000002e151 < (*.f64 x y) Initial program 95.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.6
Applied rewrites75.6%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6452.2
Applied rewrites52.2%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6451.8
Applied rewrites51.8%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6452.3
Applied rewrites52.3%
(FPCore (x y z t a b c i) :precision binary64 (let* ((t_1 (fma t z (* y x))) (t_2 (+ (* x y) (* z t)))) (if (<= t_2 -2e+157) t_1 (if (<= t_2 5e+137) (fma b a (* c i)) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(t, z, (y * x));
double t_2 = (x * y) + (z * t);
double tmp;
if (t_2 <= -2e+157) {
tmp = t_1;
} else if (t_2 <= 5e+137) {
tmp = fma(b, a, (c * i));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(t, z, Float64(y * x)) t_2 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if (t_2 <= -2e+157) tmp = t_1; elseif (t_2 <= 5e+137) tmp = fma(b, a, Float64(c * i)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+157], t$95$1, If[LessEqual[t$95$2, 5e+137], N[(b * a + N[(c * i), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, z, y \cdot x\right)\\
t_2 := x \cdot y + z \cdot t\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+157}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+137}:\\
\;\;\;\;\mathsf{fma}\left(b, a, c \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (*.f64 x y) (*.f64 z t)) < -1.99999999999999997e157 or 5.0000000000000002e137 < (+.f64 (*.f64 x y) (*.f64 z t)) Initial program 95.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.6
Applied rewrites75.6%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6452.2
Applied rewrites52.2%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6451.8
Applied rewrites51.8%
if -1.99999999999999997e157 < (+.f64 (*.f64 x y) (*.f64 z t)) < 5.0000000000000002e137Initial program 95.5%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6474.8
Applied rewrites74.8%
Taylor expanded in x around 0
lower-*.f6451.3
Applied rewrites51.3%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma t z (* y x))) (t_2 (+ (* x y) (* z t))))
(if (<= t_2 -5e+151)
t_1
(if (<= t_2 -1.8e-29)
(fma z t (* c i))
(if (<= t_2 5e+137) (* a b) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(t, z, (y * x));
double t_2 = (x * y) + (z * t);
double tmp;
if (t_2 <= -5e+151) {
tmp = t_1;
} else if (t_2 <= -1.8e-29) {
tmp = fma(z, t, (c * i));
} else if (t_2 <= 5e+137) {
tmp = a * b;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(t, z, Float64(y * x)) t_2 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if (t_2 <= -5e+151) tmp = t_1; elseif (t_2 <= -1.8e-29) tmp = fma(z, t, Float64(c * i)); elseif (t_2 <= 5e+137) tmp = Float64(a * b); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+151], t$95$1, If[LessEqual[t$95$2, -1.8e-29], N[(z * t + N[(c * i), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+137], N[(a * b), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, z, y \cdot x\right)\\
t_2 := x \cdot y + z \cdot t\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+151}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -1.8 \cdot 10^{-29}:\\
\;\;\;\;\mathsf{fma}\left(z, t, c \cdot i\right)\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+137}:\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (*.f64 x y) (*.f64 z t)) < -5.0000000000000002e151 or 5.0000000000000002e137 < (+.f64 (*.f64 x y) (*.f64 z t)) Initial program 95.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.6
Applied rewrites75.6%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6452.2
Applied rewrites52.2%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6451.8
Applied rewrites51.8%
if -5.0000000000000002e151 < (+.f64 (*.f64 x y) (*.f64 z t)) < -1.79999999999999987e-29Initial program 95.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.6
Applied rewrites75.6%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6452.2
Applied rewrites52.2%
if -1.79999999999999987e-29 < (+.f64 (*.f64 x y) (*.f64 z t)) < 5.0000000000000002e137Initial program 95.5%
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
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6497.7
Applied rewrites97.7%
Taylor expanded in a 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-*.f6427.0
Applied rewrites27.0%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma t z (* y x))) (t_2 (+ (* x y) (* z t))))
(if (<= t_2 -5e+151)
t_1
(if (<= t_2 -1.8e-29)
(fma i c (* y x))
(if (<= t_2 5e+137) (* a b) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(t, z, (y * x));
double t_2 = (x * y) + (z * t);
double tmp;
if (t_2 <= -5e+151) {
tmp = t_1;
} else if (t_2 <= -1.8e-29) {
tmp = fma(i, c, (y * x));
} else if (t_2 <= 5e+137) {
tmp = a * b;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(t, z, Float64(y * x)) t_2 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if (t_2 <= -5e+151) tmp = t_1; elseif (t_2 <= -1.8e-29) tmp = fma(i, c, Float64(y * x)); elseif (t_2 <= 5e+137) tmp = Float64(a * b); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+151], t$95$1, If[LessEqual[t$95$2, -1.8e-29], N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+137], N[(a * b), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, z, y \cdot x\right)\\
t_2 := x \cdot y + z \cdot t\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+151}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -1.8 \cdot 10^{-29}:\\
\;\;\;\;\mathsf{fma}\left(i, c, y \cdot x\right)\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+137}:\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (*.f64 x y) (*.f64 z t)) < -5.0000000000000002e151 or 5.0000000000000002e137 < (+.f64 (*.f64 x y) (*.f64 z t)) Initial program 95.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.6
Applied rewrites75.6%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6452.2
Applied rewrites52.2%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6451.8
Applied rewrites51.8%
if -5.0000000000000002e151 < (+.f64 (*.f64 x y) (*.f64 z t)) < -1.79999999999999987e-29Initial program 95.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.6
Applied rewrites75.6%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6452.2
Applied rewrites52.2%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6451.8
Applied rewrites51.8%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6452.3
Applied rewrites52.3%
if -1.79999999999999987e-29 < (+.f64 (*.f64 x y) (*.f64 z t)) < 5.0000000000000002e137Initial program 95.5%
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
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6497.7
Applied rewrites97.7%
Taylor expanded in a 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-*.f6427.0
Applied rewrites27.0%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* z t) -2e+170) (* t z) (if (<= (* z t) 4e+236) (fma i c (* y x)) (* t z))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((z * t) <= -2e+170) {
tmp = t * z;
} else if ((z * t) <= 4e+236) {
tmp = fma(i, c, (y * x));
} else {
tmp = t * z;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -2e+170) tmp = Float64(t * z); elseif (Float64(z * t) <= 4e+236) tmp = fma(i, c, Float64(y * x)); else tmp = Float64(t * z); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -2e+170], N[(t * z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 4e+236], N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision], N[(t * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+170}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;z \cdot t \leq 4 \cdot 10^{+236}:\\
\;\;\;\;\mathsf{fma}\left(i, c, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (*.f64 z t) < -2.00000000000000007e170 or 4.00000000000000021e236 < (*.f64 z t) Initial program 95.5%
Taylor expanded in z around inf
*-commutativeN/A
div-add-revN/A
div-addN/A
lower-*.f64N/A
Applied rewrites83.8%
Taylor expanded in z around inf
Applied rewrites27.5%
if -2.00000000000000007e170 < (*.f64 z t) < 4.00000000000000021e236Initial program 95.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.6
Applied rewrites75.6%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6452.2
Applied rewrites52.2%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6451.8
Applied rewrites51.8%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6452.3
Applied rewrites52.3%
(FPCore (x y z t a b c i) :precision binary64 (let* ((t_1 (+ (* x y) (* z t)))) (if (<= t_1 -2e+170) (* t z) (if (<= t_1 5e+137) (* a b) (* y x)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (x * y) + (z * t);
double tmp;
if (t_1 <= -2e+170) {
tmp = t * z;
} else if (t_1 <= 5e+137) {
tmp = a * b;
} else {
tmp = y * x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i)
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) :: t_1
real(8) :: tmp
t_1 = (x * y) + (z * t)
if (t_1 <= (-2d+170)) then
tmp = t * z
else if (t_1 <= 5d+137) then
tmp = a * b
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (x * y) + (z * t);
double tmp;
if (t_1 <= -2e+170) {
tmp = t * z;
} else if (t_1 <= 5e+137) {
tmp = a * b;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): t_1 = (x * y) + (z * t) tmp = 0 if t_1 <= -2e+170: tmp = t * z elif t_1 <= 5e+137: tmp = a * b else: tmp = y * x return tmp
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if (t_1 <= -2e+170) tmp = Float64(t * z); elseif (t_1 <= 5e+137) tmp = Float64(a * b); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) t_1 = (x * y) + (z * t); tmp = 0.0; if (t_1 <= -2e+170) tmp = t * z; elseif (t_1 <= 5e+137) tmp = a * b; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+170], N[(t * z), $MachinePrecision], If[LessEqual[t$95$1, 5e+137], N[(a * b), $MachinePrecision], N[(y * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+170}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+137}:\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if (+.f64 (*.f64 x y) (*.f64 z t)) < -2.00000000000000007e170Initial program 95.5%
Taylor expanded in z around inf
*-commutativeN/A
div-add-revN/A
div-addN/A
lower-*.f64N/A
Applied rewrites83.8%
Taylor expanded in z around inf
Applied rewrites27.5%
if -2.00000000000000007e170 < (+.f64 (*.f64 x y) (*.f64 z t)) < 5.0000000000000002e137Initial program 95.5%
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
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6497.7
Applied rewrites97.7%
Taylor expanded in a 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-*.f6427.0
Applied rewrites27.0%
if 5.0000000000000002e137 < (+.f64 (*.f64 x y) (*.f64 z t)) Initial program 95.5%
Taylor expanded in z around inf
*-commutativeN/A
div-add-revN/A
div-addN/A
lower-*.f64N/A
Applied rewrites83.8%
Taylor expanded in z around 0
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6461.1
Applied rewrites61.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6427.6
Applied rewrites27.6%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* x y) -1e+234) (* y x) (if (<= (* x y) 1e+151) (* a b) (* y x))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x * y) <= -1e+234) {
tmp = y * x;
} else if ((x * y) <= 1e+151) {
tmp = a * b;
} else {
tmp = y * x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i)
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) <= (-1d+234)) then
tmp = y * x
else if ((x * y) <= 1d+151) then
tmp = a * b
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x * y) <= -1e+234) {
tmp = y * x;
} else if ((x * y) <= 1e+151) {
tmp = a * b;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (x * y) <= -1e+234: tmp = y * x elif (x * y) <= 1e+151: tmp = a * b else: tmp = y * x return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(x * y) <= -1e+234) tmp = Float64(y * x); elseif (Float64(x * y) <= 1e+151) tmp = Float64(a * b); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((x * y) <= -1e+234) tmp = y * x; elseif ((x * y) <= 1e+151) tmp = a * b; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -1e+234], N[(y * x), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e+151], N[(a * b), $MachinePrecision], N[(y * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+234}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \cdot y \leq 10^{+151}:\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if (*.f64 x y) < -1.00000000000000002e234 or 1.00000000000000002e151 < (*.f64 x y) Initial program 95.5%
Taylor expanded in z around inf
*-commutativeN/A
div-add-revN/A
div-addN/A
lower-*.f64N/A
Applied rewrites83.8%
Taylor expanded in z around 0
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6461.1
Applied rewrites61.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6427.6
Applied rewrites27.6%
if -1.00000000000000002e234 < (*.f64 x y) < 1.00000000000000002e151Initial program 95.5%
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
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6497.7
Applied rewrites97.7%
Taylor expanded in a 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-*.f6427.0
Applied rewrites27.0%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* a b) -9500000.0) (* a b) (if (<= (* a b) 4.2e+74) (* i c) (* a b))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((a * b) <= -9500000.0) {
tmp = a * b;
} else if ((a * b) <= 4.2e+74) {
tmp = i * c;
} else {
tmp = a * b;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i)
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 ((a * b) <= (-9500000.0d0)) then
tmp = a * b
else if ((a * b) <= 4.2d+74) then
tmp = i * c
else
tmp = a * b
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((a * b) <= -9500000.0) {
tmp = a * b;
} else if ((a * b) <= 4.2e+74) {
tmp = i * c;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (a * b) <= -9500000.0: tmp = a * b elif (a * b) <= 4.2e+74: tmp = i * c else: tmp = a * b return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(a * b) <= -9500000.0) tmp = Float64(a * b); elseif (Float64(a * b) <= 4.2e+74) tmp = Float64(i * c); else tmp = Float64(a * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((a * b) <= -9500000.0) tmp = a * b; elseif ((a * b) <= 4.2e+74) tmp = i * c; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(a * b), $MachinePrecision], -9500000.0], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 4.2e+74], N[(i * c), $MachinePrecision], N[(a * b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -9500000:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 4.2 \cdot 10^{+74}:\\
\;\;\;\;i \cdot c\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -9.5e6 or 4.1999999999999998e74 < (*.f64 a b) Initial program 95.5%
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
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6497.7
Applied rewrites97.7%
Taylor expanded in a 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-*.f6427.0
Applied rewrites27.0%
if -9.5e6 < (*.f64 a b) < 4.1999999999999998e74Initial program 95.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.6
Applied rewrites75.6%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6452.2
Applied rewrites52.2%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6451.8
Applied rewrites51.8%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6427.9
Applied rewrites27.9%
(FPCore (x y z t a b c i) :precision binary64 (* a b))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return a * 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, 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 = a * b
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return a * b;
}
def code(x, y, z, t, a, b, c, i): return a * b
function code(x, y, z, t, a, b, c, i) return Float64(a * b) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = a * b; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(a * b), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b
\end{array}
Initial program 95.5%
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
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6497.7
Applied rewrites97.7%
Taylor expanded in a 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-*.f6427.0
Applied rewrites27.0%
herbie shell --seed 2025134
(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)))