
(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}
(FPCore (x y z t a b c i) :precision binary64 (if (<= (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)) INFINITY) (+ (fma y x (fma b a (* t z))) (* c i)) (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) {
double tmp;
if (((((x * y) + (z * t)) + (a * b)) + (c * i)) <= ((double) INFINITY)) {
tmp = fma(y, x, fma(b, a, (t * z))) + (c * i);
} else {
tmp = fma(b, a, fma(t, z, (y * x)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i)) <= Inf) tmp = Float64(fma(y, x, fma(b, a, Float64(t * z))) + Float64(c * i)); else tmp = fma(b, a, fma(t, z, Float64(y * x))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(y * x + N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(y, x, \mathsf{fma}\left(b, a, t \cdot z\right)\right) + c \cdot i\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i)) < +inf.0Initial program 100.0%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64100.0
Applied rewrites100.0%
if +inf.0 < (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i)) Initial program 0.0%
Taylor expanded in c around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6450.8
Applied rewrites50.8%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma i c (fma y x (* t z)))))
(if (<= (* c i) -1e+82)
t_1
(if (<= (* c i) 1e+106) (fma b a (fma t z (* y x))) t_1))))
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(y, x, (t * z)));
double tmp;
if ((c * i) <= -1e+82) {
tmp = t_1;
} else if ((c * i) <= 1e+106) {
tmp = fma(b, a, fma(t, z, (y * x)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(i, c, fma(y, x, Float64(t * z))) tmp = 0.0 if (Float64(c * i) <= -1e+82) tmp = t_1; elseif (Float64(c * i) <= 1e+106) tmp = fma(b, a, fma(t, z, Float64(y * x))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(i * c + N[(y * x + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(c * i), $MachinePrecision], -1e+82], t$95$1, If[LessEqual[N[(c * i), $MachinePrecision], 1e+106], N[(b * a + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(i, c, \mathsf{fma}\left(y, x, t \cdot z\right)\right)\\
\mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+82}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \cdot i \leq 10^{+106}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 c i) < -9.9999999999999996e81 or 1.00000000000000009e106 < (*.f64 c i) Initial program 92.2%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6493.1
Applied rewrites93.1%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6483.3
Applied rewrites83.3%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6485.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.4
Applied rewrites85.4%
if -9.9999999999999996e81 < (*.f64 c i) < 1.00000000000000009e106Initial program 98.1%
Taylor expanded in c around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6492.5
Applied rewrites92.5%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* c i) -1e+82) (fma i c (* t z)) (if (<= (* c i) 1e+106) (fma b a (fma t z (* y x))) (fma i c (* x y)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c * i) <= -1e+82) {
tmp = fma(i, c, (t * z));
} else if ((c * i) <= 1e+106) {
tmp = fma(b, a, fma(t, z, (y * x)));
} else {
tmp = fma(i, c, (x * y));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(c * i) <= -1e+82) tmp = fma(i, c, Float64(t * z)); elseif (Float64(c * i) <= 1e+106) tmp = fma(b, a, fma(t, z, Float64(y * x))); else tmp = fma(i, c, Float64(x * y)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -1e+82], N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 1e+106], N[(b * a + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(i * c + N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+82}:\\
\;\;\;\;\mathsf{fma}\left(i, c, t \cdot z\right)\\
\mathbf{elif}\;c \cdot i \leq 10^{+106}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, x \cdot y\right)\\
\end{array}
\end{array}
if (*.f64 c i) < -9.9999999999999996e81Initial program 91.9%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6492.8
Applied rewrites92.8%
Taylor expanded in z around inf
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-*.f6472.1
Applied rewrites72.1%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6473.5
*-commutative73.5
*-commutative73.5
+-commutative73.5
*-commutative73.5
+-commutative73.5
lift-*.f64N/A
*-commutativeN/A
associate-+r+N/A
+-commutativeN/A
lower-*.f6473.5
Applied rewrites73.5%
if -9.9999999999999996e81 < (*.f64 c i) < 1.00000000000000009e106Initial program 98.1%
Taylor expanded in c around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6492.5
Applied rewrites92.5%
if 1.00000000000000009e106 < (*.f64 c i) Initial program 92.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6473.7
Applied rewrites73.7%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6474.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6474.4
Applied rewrites74.4%
(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+165)
t_1
(if (<= t_2 2e+133)
(fma i c (* a b))
(if (<= t_2 2e+207) (fma i c (* x y)) 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+165) {
tmp = t_1;
} else if (t_2 <= 2e+133) {
tmp = fma(i, c, (a * b));
} else if (t_2 <= 2e+207) {
tmp = fma(i, c, (x * y));
} 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+165) tmp = t_1; elseif (t_2 <= 2e+133) tmp = fma(i, c, Float64(a * b)); elseif (t_2 <= 2e+207) tmp = fma(i, c, Float64(x * y)); 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+165], t$95$1, If[LessEqual[t$95$2, 2e+133], N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+207], N[(i * c + N[(x * y), $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^{+165}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+133}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+207}:\\
\;\;\;\;\mathsf{fma}\left(i, c, x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (*.f64 x y) (*.f64 z t)) < -1.9999999999999998e165 or 2.0000000000000001e207 < (+.f64 (*.f64 x y) (*.f64 z t)) Initial program 91.9%
Taylor expanded in c around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6488.7
Applied rewrites88.7%
Taylor expanded in a around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6481.3
Applied rewrites81.3%
if -1.9999999999999998e165 < (+.f64 (*.f64 x y) (*.f64 z t)) < 2e133Initial program 98.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6474.3
Applied rewrites74.3%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6474.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6474.8
Applied rewrites74.8%
if 2e133 < (+.f64 (*.f64 x y) (*.f64 z t)) < 2.0000000000000001e207Initial program 99.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6451.6
Applied rewrites51.6%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6451.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6451.6
Applied rewrites51.6%
(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+165) t_1 (if (<= t_2 2e+207) (fma i c (* 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 <= -2e+165) {
tmp = t_1;
} else if (t_2 <= 2e+207) {
tmp = fma(i, c, (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 <= -2e+165) tmp = t_1; elseif (t_2 <= 2e+207) tmp = fma(i, c, 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, -2e+165], t$95$1, If[LessEqual[t$95$2, 2e+207], N[(i * c + N[(a * b), $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^{+165}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+207}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (*.f64 x y) (*.f64 z t)) < -1.9999999999999998e165 or 2.0000000000000001e207 < (+.f64 (*.f64 x y) (*.f64 z t)) Initial program 91.9%
Taylor expanded in c around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6488.7
Applied rewrites88.7%
Taylor expanded in a around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6481.3
Applied rewrites81.3%
if -1.9999999999999998e165 < (+.f64 (*.f64 x y) (*.f64 z t)) < 2.0000000000000001e207Initial program 98.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6471.1
Applied rewrites71.1%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6471.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.6
Applied rewrites71.6%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma b a (* y x))) (t_2 (fma i c (* t z))))
(if (<= (* c i) -4e+64)
t_2
(if (<= (* c i) -2e-134)
t_1
(if (<= (* c i) -1e-307)
(fma b a (* t z))
(if (<= (* c i) 5e+182) t_1 t_2))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(b, a, (y * x));
double t_2 = fma(i, c, (t * z));
double tmp;
if ((c * i) <= -4e+64) {
tmp = t_2;
} else if ((c * i) <= -2e-134) {
tmp = t_1;
} else if ((c * i) <= -1e-307) {
tmp = fma(b, a, (t * z));
} else if ((c * i) <= 5e+182) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(b, a, Float64(y * x)) t_2 = fma(i, c, Float64(t * z)) tmp = 0.0 if (Float64(c * i) <= -4e+64) tmp = t_2; elseif (Float64(c * i) <= -2e-134) tmp = t_1; elseif (Float64(c * i) <= -1e-307) tmp = fma(b, a, Float64(t * z)); elseif (Float64(c * i) <= 5e+182) tmp = t_1; else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(c * i), $MachinePrecision], -4e+64], t$95$2, If[LessEqual[N[(c * i), $MachinePrecision], -2e-134], t$95$1, If[LessEqual[N[(c * i), $MachinePrecision], -1e-307], N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 5e+182], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, y \cdot x\right)\\
t_2 := \mathsf{fma}\left(i, c, t \cdot z\right)\\
\mathbf{if}\;c \cdot i \leq -4 \cdot 10^{+64}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;c \cdot i \leq -2 \cdot 10^{-134}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \cdot i \leq -1 \cdot 10^{-307}:\\
\;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\
\mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{+182}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 c i) < -4.00000000000000009e64 or 4.99999999999999973e182 < (*.f64 c i) Initial program 91.8%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6492.6
Applied rewrites92.6%
Taylor expanded in z around inf
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-*.f6474.0
Applied rewrites74.0%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6475.3
*-commutative75.3
*-commutative75.3
+-commutative75.3
*-commutative75.3
+-commutative75.3
lift-*.f64N/A
*-commutativeN/A
associate-+r+N/A
+-commutativeN/A
lower-*.f6475.3
Applied rewrites75.3%
if -4.00000000000000009e64 < (*.f64 c i) < -2.00000000000000008e-134 or -9.99999999999999909e-308 < (*.f64 c i) < 4.99999999999999973e182Initial program 98.0%
Taylor expanded in c around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6489.8
Applied rewrites89.8%
Taylor expanded in x around inf
*-commutativeN/A
lift-*.f6461.2
Applied rewrites61.2%
if -2.00000000000000008e-134 < (*.f64 c i) < -9.99999999999999909e-308Initial program 97.7%
Taylor expanded in c around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6497.6
Applied rewrites97.6%
Taylor expanded in x around 0
lift-*.f6467.3
Applied rewrites67.3%
(FPCore (x y z t a b c i) :precision binary64 (let* ((t_1 (fma t z (* y x)))) (if (<= (* z t) -2e+67) t_1 (if (<= (* z t) 1e+28) (fma b a (* y x)) 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 tmp;
if ((z * t) <= -2e+67) {
tmp = t_1;
} else if ((z * t) <= 1e+28) {
tmp = fma(b, a, (y * x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(t, z, Float64(y * x)) tmp = 0.0 if (Float64(z * t) <= -2e+67) tmp = t_1; elseif (Float64(z * t) <= 1e+28) tmp = fma(b, a, Float64(y * x)); 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]}, If[LessEqual[N[(z * t), $MachinePrecision], -2e+67], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 1e+28], N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, z, y \cdot x\right)\\
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+67}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 10^{+28}:\\
\;\;\;\;\mathsf{fma}\left(b, a, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -1.99999999999999997e67 or 9.99999999999999958e27 < (*.f64 z t) Initial program 93.6%
Taylor expanded in c around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6483.1
Applied rewrites83.1%
Taylor expanded in a around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6469.4
Applied rewrites69.4%
if -1.99999999999999997e67 < (*.f64 z t) < 9.99999999999999958e27Initial program 97.8%
Taylor expanded in c around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6469.7
Applied rewrites69.7%
Taylor expanded in x around inf
*-commutativeN/A
lift-*.f6464.8
Applied rewrites64.8%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma t z (* y x))))
(if (<= (* x y) -2e+165)
t_1
(if (<= (* x y) 1e+130) (fma b a (* 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(t, z, (y * x));
double tmp;
if ((x * y) <= -2e+165) {
tmp = t_1;
} else if ((x * y) <= 1e+130) {
tmp = fma(b, a, (t * z));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(t, z, Float64(y * x)) tmp = 0.0 if (Float64(x * y) <= -2e+165) tmp = t_1; elseif (Float64(x * y) <= 1e+130) tmp = fma(b, a, 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[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -2e+165], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 1e+130], N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, z, y \cdot x\right)\\
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+165}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot y \leq 10^{+130}:\\
\;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 x y) < -1.9999999999999998e165 or 1.0000000000000001e130 < (*.f64 x y) Initial program 91.8%
Taylor expanded in c around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6487.7
Applied rewrites87.7%
Taylor expanded in a around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6479.0
Applied rewrites79.0%
if -1.9999999999999998e165 < (*.f64 x y) < 1.0000000000000001e130Initial program 97.6%
Taylor expanded in c around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6470.7
Applied rewrites70.7%
Taylor expanded in x around 0
lift-*.f6462.1
Applied rewrites62.1%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* c i) -1e+179) (* i c) (if (<= (* c i) 1e+196) (fma t z (* y x)) (* i c))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c * i) <= -1e+179) {
tmp = i * c;
} else if ((c * i) <= 1e+196) {
tmp = fma(t, z, (y * x));
} else {
tmp = i * c;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(c * i) <= -1e+179) tmp = Float64(i * c); elseif (Float64(c * i) <= 1e+196) tmp = fma(t, z, Float64(y * x)); else tmp = Float64(i * c); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -1e+179], N[(i * c), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 1e+196], N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision], N[(i * c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+179}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;c \cdot i \leq 10^{+196}:\\
\;\;\;\;\mathsf{fma}\left(t, z, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 c i) < -9.9999999999999998e178 or 9.9999999999999995e195 < (*.f64 c i) Initial program 89.8%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6473.8
Applied rewrites73.8%
if -9.9999999999999998e178 < (*.f64 c i) < 9.9999999999999995e195Initial program 98.0%
Taylor expanded in c around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6488.4
Applied rewrites88.4%
Taylor expanded in a around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6459.7
Applied rewrites59.7%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* x y) -5e+84)
(* y x)
(if (<= (* x y) -4e-291)
(* i c)
(if (<= (* x y) 5e-115)
(* t z)
(if (<= (* x y) 1e+130) (* b a) (* 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) <= -5e+84) {
tmp = y * x;
} else if ((x * y) <= -4e-291) {
tmp = i * c;
} else if ((x * y) <= 5e-115) {
tmp = t * z;
} else if ((x * y) <= 1e+130) {
tmp = b * a;
} 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) <= (-5d+84)) then
tmp = y * x
else if ((x * y) <= (-4d-291)) then
tmp = i * c
else if ((x * y) <= 5d-115) then
tmp = t * z
else if ((x * y) <= 1d+130) then
tmp = b * a
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) <= -5e+84) {
tmp = y * x;
} else if ((x * y) <= -4e-291) {
tmp = i * c;
} else if ((x * y) <= 5e-115) {
tmp = t * z;
} else if ((x * y) <= 1e+130) {
tmp = b * a;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (x * y) <= -5e+84: tmp = y * x elif (x * y) <= -4e-291: tmp = i * c elif (x * y) <= 5e-115: tmp = t * z elif (x * y) <= 1e+130: tmp = b * a else: tmp = y * x return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(x * y) <= -5e+84) tmp = Float64(y * x); elseif (Float64(x * y) <= -4e-291) tmp = Float64(i * c); elseif (Float64(x * y) <= 5e-115) tmp = Float64(t * z); elseif (Float64(x * y) <= 1e+130) tmp = Float64(b * a); 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) <= -5e+84) tmp = y * x; elseif ((x * y) <= -4e-291) tmp = i * c; elseif ((x * y) <= 5e-115) tmp = t * z; elseif ((x * y) <= 1e+130) tmp = b * a; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -5e+84], N[(y * x), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -4e-291], N[(i * c), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 5e-115], N[(t * z), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e+130], N[(b * a), $MachinePrecision], N[(y * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+84}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \cdot y \leq -4 \cdot 10^{-291}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{-115}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;x \cdot y \leq 10^{+130}:\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if (*.f64 x y) < -5.0000000000000001e84 or 1.0000000000000001e130 < (*.f64 x y) Initial program 92.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6462.8
Applied rewrites62.8%
if -5.0000000000000001e84 < (*.f64 x y) < -3.99999999999999985e-291Initial program 97.9%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6431.9
Applied rewrites31.9%
if -3.99999999999999985e-291 < (*.f64 x y) < 5.0000000000000003e-115Initial program 97.3%
Taylor expanded in z around inf
lower-*.f6434.3
Applied rewrites34.3%
if 5.0000000000000003e-115 < (*.f64 x y) < 1.0000000000000001e130Initial program 97.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6432.3
Applied rewrites32.3%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* c i) -1e+82) (* i c) (if (<= (* c i) -2e-196) (* b a) (if (<= (* c i) 1e+104) (* t z) (* i c)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c * i) <= -1e+82) {
tmp = i * c;
} else if ((c * i) <= -2e-196) {
tmp = b * a;
} else if ((c * i) <= 1e+104) {
tmp = t * z;
} else {
tmp = i * c;
}
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 ((c * i) <= (-1d+82)) then
tmp = i * c
else if ((c * i) <= (-2d-196)) then
tmp = b * a
else if ((c * i) <= 1d+104) then
tmp = t * z
else
tmp = i * c
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 ((c * i) <= -1e+82) {
tmp = i * c;
} else if ((c * i) <= -2e-196) {
tmp = b * a;
} else if ((c * i) <= 1e+104) {
tmp = t * z;
} else {
tmp = i * c;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (c * i) <= -1e+82: tmp = i * c elif (c * i) <= -2e-196: tmp = b * a elif (c * i) <= 1e+104: tmp = t * z else: tmp = i * c return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(c * i) <= -1e+82) tmp = Float64(i * c); elseif (Float64(c * i) <= -2e-196) tmp = Float64(b * a); elseif (Float64(c * i) <= 1e+104) tmp = Float64(t * z); else tmp = Float64(i * c); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((c * i) <= -1e+82) tmp = i * c; elseif ((c * i) <= -2e-196) tmp = b * a; elseif ((c * i) <= 1e+104) tmp = t * z; else tmp = i * c; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -1e+82], N[(i * c), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -2e-196], N[(b * a), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 1e+104], N[(t * z), $MachinePrecision], N[(i * c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+82}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;c \cdot i \leq -2 \cdot 10^{-196}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;c \cdot i \leq 10^{+104}:\\
\;\;\;\;t \cdot z\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 c i) < -9.9999999999999996e81 or 1e104 < (*.f64 c i) Initial program 92.2%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6461.0
Applied rewrites61.0%
if -9.9999999999999996e81 < (*.f64 c i) < -2.0000000000000001e-196Initial program 98.0%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6433.6
Applied rewrites33.6%
if -2.0000000000000001e-196 < (*.f64 c i) < 1e104Initial program 98.1%
Taylor expanded in z around inf
lower-*.f6433.8
Applied rewrites33.8%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* c i) -1e+82) (* i c) (if (<= (* c i) 1e+106) (* b a) (* i c))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c * i) <= -1e+82) {
tmp = i * c;
} else if ((c * i) <= 1e+106) {
tmp = b * a;
} else {
tmp = i * c;
}
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 ((c * i) <= (-1d+82)) then
tmp = i * c
else if ((c * i) <= 1d+106) then
tmp = b * a
else
tmp = i * c
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 ((c * i) <= -1e+82) {
tmp = i * c;
} else if ((c * i) <= 1e+106) {
tmp = b * a;
} else {
tmp = i * c;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (c * i) <= -1e+82: tmp = i * c elif (c * i) <= 1e+106: tmp = b * a else: tmp = i * c return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(c * i) <= -1e+82) tmp = Float64(i * c); elseif (Float64(c * i) <= 1e+106) tmp = Float64(b * a); else tmp = Float64(i * c); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((c * i) <= -1e+82) tmp = i * c; elseif ((c * i) <= 1e+106) tmp = b * a; else tmp = i * c; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -1e+82], N[(i * c), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 1e+106], N[(b * a), $MachinePrecision], N[(i * c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+82}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;c \cdot i \leq 10^{+106}:\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 c i) < -9.9999999999999996e81 or 1.00000000000000009e106 < (*.f64 c i) Initial program 92.2%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6461.1
Applied rewrites61.1%
if -9.9999999999999996e81 < (*.f64 c i) < 1.00000000000000009e106Initial program 98.1%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6434.2
Applied rewrites34.2%
(FPCore (x y z t a b c i) :precision binary64 (* b a))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return b * a;
}
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 = b * a
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return b * a;
}
def code(x, y, z, t, a, b, c, i): return b * a
function code(x, y, z, t, a, b, c, i) return Float64(b * a) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = b * a; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(b * a), $MachinePrecision]
\begin{array}{l}
\\
b \cdot a
\end{array}
Initial program 96.0%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6428.2
Applied rewrites28.2%
herbie shell --seed 2025112
(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)))