
(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}
Sampling outcomes in binary64 precision:
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 (fma y x (fma t z (fma i c (* b a)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(y, x, fma(t, z, fma(i, c, (b * a))));
}
function code(x, y, z, t, a, b, c, i) return fma(y, x, fma(t, z, fma(i, c, Float64(b * a)))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(y * x + N[(t * z + N[(i * c + N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, x, \mathsf{fma}\left(t, z, \mathsf{fma}\left(i, c, b \cdot a\right)\right)\right)
\end{array}
Initial program 94.9%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
lower-fma.f64N/A
associate-+r+N/A
lift-*.f64N/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
Applied rewrites98.4%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma y x (* z t))) (t_2 (+ (* x y) (* z t))))
(if (<= t_2 -2e+292)
t_1
(if (<= t_2 -2e+153)
(+ (* t z) (* c i))
(if (<= t_2 -2e+50)
(fma y x (* a b))
(if (<= t_2 1e+69) (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(y, x, (z * t));
double t_2 = (x * y) + (z * t);
double tmp;
if (t_2 <= -2e+292) {
tmp = t_1;
} else if (t_2 <= -2e+153) {
tmp = (t * z) + (c * i);
} else if (t_2 <= -2e+50) {
tmp = fma(y, x, (a * b));
} else if (t_2 <= 1e+69) {
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(y, x, Float64(z * t)) t_2 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if (t_2 <= -2e+292) tmp = t_1; elseif (t_2 <= -2e+153) tmp = Float64(Float64(t * z) + Float64(c * i)); elseif (t_2 <= -2e+50) tmp = fma(y, x, Float64(a * b)); elseif (t_2 <= 1e+69) 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[(y * x + N[(z * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+292], t$95$1, If[LessEqual[t$95$2, -2e+153], N[(N[(t * z), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -2e+50], N[(y * x + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e+69], N[(b * a + N[(c * i), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, x, z \cdot t\right)\\
t_2 := x \cdot y + z \cdot t\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+292}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -2 \cdot 10^{+153}:\\
\;\;\;\;t \cdot z + c \cdot i\\
\mathbf{elif}\;t\_2 \leq -2 \cdot 10^{+50}:\\
\;\;\;\;\mathsf{fma}\left(y, x, a \cdot b\right)\\
\mathbf{elif}\;t\_2 \leq 10^{+69}:\\
\;\;\;\;\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)) < -2e292 or 1.0000000000000001e69 < (+.f64 (*.f64 x y) (*.f64 z t)) Initial program 89.9%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
lower-fma.f64N/A
associate-+r+N/A
lift-*.f64N/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
Applied rewrites96.6%
Taylor expanded in z around inf
Applied rewrites77.7%
if -2e292 < (+.f64 (*.f64 x y) (*.f64 z t)) < -2e153Initial program 100.0%
Taylor expanded in z around inf
Applied rewrites74.5%
if -2e153 < (+.f64 (*.f64 x y) (*.f64 z t)) < -2.0000000000000002e50Initial program 95.0%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
lower-fma.f64N/A
associate-+r+N/A
lift-*.f64N/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
Applied rewrites100.0%
Taylor expanded in a around inf
Applied rewrites80.9%
if -2.0000000000000002e50 < (+.f64 (*.f64 x y) (*.f64 z t)) < 1.0000000000000001e69Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites94.5%
Taylor expanded in z around 0
Applied rewrites89.0%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma y x (* z t))) (t_2 (+ (* x y) (* z t))))
(if (<= t_2 -2e+292)
t_1
(if (<= t_2 -2e+153)
(fma i c (* t z))
(if (<= t_2 -2e+50)
(fma y x (* a b))
(if (<= t_2 1e+69) (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(y, x, (z * t));
double t_2 = (x * y) + (z * t);
double tmp;
if (t_2 <= -2e+292) {
tmp = t_1;
} else if (t_2 <= -2e+153) {
tmp = fma(i, c, (t * z));
} else if (t_2 <= -2e+50) {
tmp = fma(y, x, (a * b));
} else if (t_2 <= 1e+69) {
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(y, x, Float64(z * t)) t_2 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if (t_2 <= -2e+292) tmp = t_1; elseif (t_2 <= -2e+153) tmp = fma(i, c, Float64(t * z)); elseif (t_2 <= -2e+50) tmp = fma(y, x, Float64(a * b)); elseif (t_2 <= 1e+69) 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[(y * x + N[(z * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+292], t$95$1, If[LessEqual[t$95$2, -2e+153], N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -2e+50], N[(y * x + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e+69], N[(b * a + N[(c * i), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, x, z \cdot t\right)\\
t_2 := x \cdot y + z \cdot t\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+292}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -2 \cdot 10^{+153}:\\
\;\;\;\;\mathsf{fma}\left(i, c, t \cdot z\right)\\
\mathbf{elif}\;t\_2 \leq -2 \cdot 10^{+50}:\\
\;\;\;\;\mathsf{fma}\left(y, x, a \cdot b\right)\\
\mathbf{elif}\;t\_2 \leq 10^{+69}:\\
\;\;\;\;\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)) < -2e292 or 1.0000000000000001e69 < (+.f64 (*.f64 x y) (*.f64 z t)) Initial program 89.9%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
lower-fma.f64N/A
associate-+r+N/A
lift-*.f64N/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
Applied rewrites96.6%
Taylor expanded in z around inf
Applied rewrites77.7%
if -2e292 < (+.f64 (*.f64 x y) (*.f64 z t)) < -2e153Initial program 100.0%
Taylor expanded in a around inf
Applied rewrites46.3%
Taylor expanded in z around inf
Applied rewrites74.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6474.5
Applied rewrites74.5%
if -2e153 < (+.f64 (*.f64 x y) (*.f64 z t)) < -2.0000000000000002e50Initial program 95.0%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
lower-fma.f64N/A
associate-+r+N/A
lift-*.f64N/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
Applied rewrites100.0%
Taylor expanded in a around inf
Applied rewrites80.9%
if -2.0000000000000002e50 < (+.f64 (*.f64 x y) (*.f64 z t)) < 1.0000000000000001e69Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites94.5%
Taylor expanded in z around 0
Applied rewrites89.0%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* z t) -1e+147)
(fma i c (* t z))
(if (<= (* z t) 2e-105)
(fma y x (* a b))
(if (<= (* z t) 1e+69) (fma b a (* c i)) (fma b a (* z t))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((z * t) <= -1e+147) {
tmp = fma(i, c, (t * z));
} else if ((z * t) <= 2e-105) {
tmp = fma(y, x, (a * b));
} else if ((z * t) <= 1e+69) {
tmp = fma(b, a, (c * i));
} else {
tmp = fma(b, a, (z * t));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -1e+147) tmp = fma(i, c, Float64(t * z)); elseif (Float64(z * t) <= 2e-105) tmp = fma(y, x, Float64(a * b)); elseif (Float64(z * t) <= 1e+69) tmp = fma(b, a, Float64(c * i)); else tmp = fma(b, a, Float64(z * t)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -1e+147], N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e-105], N[(y * x + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1e+69], N[(b * a + N[(c * i), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(z * t), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+147}:\\
\;\;\;\;\mathsf{fma}\left(i, c, t \cdot z\right)\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{-105}:\\
\;\;\;\;\mathsf{fma}\left(y, x, a \cdot b\right)\\
\mathbf{elif}\;z \cdot t \leq 10^{+69}:\\
\;\;\;\;\mathsf{fma}\left(b, a, c \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, z \cdot t\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -9.9999999999999998e146Initial program 91.2%
Taylor expanded in a around inf
Applied rewrites33.7%
Taylor expanded in z around inf
Applied rewrites85.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6485.6
Applied rewrites85.6%
if -9.9999999999999998e146 < (*.f64 z t) < 1.99999999999999993e-105Initial program 97.8%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
lower-fma.f64N/A
associate-+r+N/A
lift-*.f64N/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
Applied rewrites100.0%
Taylor expanded in a around inf
Applied rewrites72.2%
if 1.99999999999999993e-105 < (*.f64 z t) < 1.0000000000000001e69Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites86.0%
Taylor expanded in z around 0
Applied rewrites79.3%
if 1.0000000000000001e69 < (*.f64 z t) Initial program 87.9%
Taylor expanded in x around 0
Applied rewrites82.4%
Taylor expanded in z around inf
Applied rewrites74.2%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* c i) -2e+120)
(fma i c (* t z))
(if (<= (* c i) 1e+81)
(fma b a (* z t))
(if (<= (* c i) 5e+161) (* y x) (fma b a (* c i))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c * i) <= -2e+120) {
tmp = fma(i, c, (t * z));
} else if ((c * i) <= 1e+81) {
tmp = fma(b, a, (z * t));
} else if ((c * i) <= 5e+161) {
tmp = y * x;
} else {
tmp = fma(b, a, (c * i));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(c * i) <= -2e+120) tmp = fma(i, c, Float64(t * z)); elseif (Float64(c * i) <= 1e+81) tmp = fma(b, a, Float64(z * t)); elseif (Float64(c * i) <= 5e+161) tmp = Float64(y * x); else tmp = fma(b, a, Float64(c * i)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -2e+120], N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 1e+81], N[(b * a + N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 5e+161], N[(y * x), $MachinePrecision], N[(b * a + N[(c * i), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+120}:\\
\;\;\;\;\mathsf{fma}\left(i, c, t \cdot z\right)\\
\mathbf{elif}\;c \cdot i \leq 10^{+81}:\\
\;\;\;\;\mathsf{fma}\left(b, a, z \cdot t\right)\\
\mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{+161}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, c \cdot i\right)\\
\end{array}
\end{array}
if (*.f64 c i) < -2e120Initial program 92.3%
Taylor expanded in a around inf
Applied rewrites75.9%
Taylor expanded in z around inf
Applied rewrites81.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6481.5
Applied rewrites81.5%
if -2e120 < (*.f64 c i) < 9.99999999999999921e80Initial program 97.0%
Taylor expanded in x around 0
Applied rewrites70.2%
Taylor expanded in z around inf
Applied rewrites66.2%
if 9.99999999999999921e80 < (*.f64 c i) < 4.9999999999999997e161Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites75.3%
if 4.9999999999999997e161 < (*.f64 c i) Initial program 86.8%
Taylor expanded in x around 0
Applied rewrites89.7%
Taylor expanded in z around 0
Applied rewrites80.9%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma b a (* c i))))
(if (<= (* c i) -2e+148)
t_1
(if (<= (* c i) 1e+81)
(fma b a (* z t))
(if (<= (* c i) 5e+161) (* 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(b, a, (c * i));
double tmp;
if ((c * i) <= -2e+148) {
tmp = t_1;
} else if ((c * i) <= 1e+81) {
tmp = fma(b, a, (z * t));
} else if ((c * i) <= 5e+161) {
tmp = y * x;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(b, a, Float64(c * i)) tmp = 0.0 if (Float64(c * i) <= -2e+148) tmp = t_1; elseif (Float64(c * i) <= 1e+81) tmp = fma(b, a, Float64(z * t)); elseif (Float64(c * i) <= 5e+161) tmp = 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[(b * a + N[(c * i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(c * i), $MachinePrecision], -2e+148], t$95$1, If[LessEqual[N[(c * i), $MachinePrecision], 1e+81], N[(b * a + N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 5e+161], N[(y * x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, c \cdot i\right)\\
\mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+148}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \cdot i \leq 10^{+81}:\\
\;\;\;\;\mathsf{fma}\left(b, a, z \cdot t\right)\\
\mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{+161}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 c i) < -2.0000000000000001e148 or 4.9999999999999997e161 < (*.f64 c i) Initial program 89.2%
Taylor expanded in x around 0
Applied rewrites88.2%
Taylor expanded in z around 0
Applied rewrites80.2%
if -2.0000000000000001e148 < (*.f64 c i) < 9.99999999999999921e80Initial program 97.0%
Taylor expanded in x around 0
Applied rewrites70.2%
Taylor expanded in z around inf
Applied rewrites65.6%
if 9.99999999999999921e80 < (*.f64 c i) < 4.9999999999999997e161Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites75.3%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* c i) -1e+104) (not (<= (* c i) 5e+161))) (fma b a (fma t z (* 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) {
double tmp;
if (((c * i) <= -1e+104) || !((c * i) <= 5e+161)) {
tmp = fma(b, a, fma(t, z, (i * c)));
} 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(c * i) <= -1e+104) || !(Float64(c * i) <= 5e+161)) tmp = fma(b, a, fma(t, z, Float64(i * c))); 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[Or[LessEqual[N[(c * i), $MachinePrecision], -1e+104], N[Not[LessEqual[N[(c * i), $MachinePrecision], 5e+161]], $MachinePrecision]], N[(b * a + N[(t * z + N[(i * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+104} \lor \neg \left(c \cdot i \leq 5 \cdot 10^{+161}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, i \cdot c\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\end{array}
\end{array}
if (*.f64 c i) < -1e104 or 4.9999999999999997e161 < (*.f64 c i) Initial program 88.6%
Taylor expanded in x around 0
Applied rewrites87.7%
if -1e104 < (*.f64 c i) < 4.9999999999999997e161Initial program 97.7%
Taylor expanded in c around 0
Applied rewrites95.6%
Final simplification93.2%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* x y) -2e+75) (fma y x (* a b)) (if (<= (* x y) 1e+114) (fma b a (fma t z (* i c))) (fma y x (* z t)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x * y) <= -2e+75) {
tmp = fma(y, x, (a * b));
} else if ((x * y) <= 1e+114) {
tmp = fma(b, a, fma(t, z, (i * c)));
} else {
tmp = fma(y, x, (z * t));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(x * y) <= -2e+75) tmp = fma(y, x, Float64(a * b)); elseif (Float64(x * y) <= 1e+114) tmp = fma(b, a, fma(t, z, Float64(i * c))); else tmp = fma(y, x, Float64(z * t)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -2e+75], N[(y * x + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e+114], N[(b * a + N[(t * z + N[(i * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * x + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+75}:\\
\;\;\;\;\mathsf{fma}\left(y, x, a \cdot b\right)\\
\mathbf{elif}\;x \cdot y \leq 10^{+114}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, i \cdot c\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, x, z \cdot t\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -1.99999999999999985e75Initial program 89.6%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
lower-fma.f64N/A
associate-+r+N/A
lift-*.f64N/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
Applied rewrites95.8%
Taylor expanded in a around inf
Applied rewrites73.9%
if -1.99999999999999985e75 < (*.f64 x y) < 1e114Initial program 98.1%
Taylor expanded in x around 0
Applied rewrites94.0%
if 1e114 < (*.f64 x y) Initial program 89.8%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
lower-fma.f64N/A
associate-+r+N/A
lift-*.f64N/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
Applied rewrites98.0%
Taylor expanded in z around inf
Applied rewrites84.3%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* z t) -1e+147) (* t z) (if (<= (* z t) 1e-320) (* y x) (if (<= (* z t) 5e+42) (* b a) (* 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) <= -1e+147) {
tmp = t * z;
} else if ((z * t) <= 1e-320) {
tmp = y * x;
} else if ((z * t) <= 5e+42) {
tmp = b * a;
} else {
tmp = t * z;
}
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 ((z * t) <= (-1d+147)) then
tmp = t * z
else if ((z * t) <= 1d-320) then
tmp = y * x
else if ((z * t) <= 5d+42) then
tmp = b * a
else
tmp = t * z
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 ((z * t) <= -1e+147) {
tmp = t * z;
} else if ((z * t) <= 1e-320) {
tmp = y * x;
} else if ((z * t) <= 5e+42) {
tmp = b * a;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (z * t) <= -1e+147: tmp = t * z elif (z * t) <= 1e-320: tmp = y * x elif (z * t) <= 5e+42: tmp = b * a else: tmp = t * z return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -1e+147) tmp = Float64(t * z); elseif (Float64(z * t) <= 1e-320) tmp = Float64(y * x); elseif (Float64(z * t) <= 5e+42) tmp = Float64(b * a); else tmp = Float64(t * z); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((z * t) <= -1e+147) tmp = t * z; elseif ((z * t) <= 1e-320) tmp = y * x; elseif ((z * t) <= 5e+42) tmp = b * a; else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -1e+147], N[(t * z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1e-320], N[(y * x), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+42], N[(b * a), $MachinePrecision], N[(t * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+147}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;z \cdot t \leq 10^{-320}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+42}:\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (*.f64 z t) < -9.9999999999999998e146 or 5.00000000000000007e42 < (*.f64 z t) Initial program 89.7%
Taylor expanded in z around inf
Applied rewrites61.6%
if -9.9999999999999998e146 < (*.f64 z t) < 9.99989e-321Initial program 97.1%
Taylor expanded in x around inf
Applied rewrites44.7%
if 9.99989e-321 < (*.f64 z t) < 5.00000000000000007e42Initial program 100.0%
Taylor expanded in a around inf
Applied rewrites46.9%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* c i) -2e+120) (* i c) (if (<= (* c i) -5e-303) (* b a) (if (<= (* c i) 5e+231) (* 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) <= -2e+120) {
tmp = i * c;
} else if ((c * i) <= -5e-303) {
tmp = b * a;
} else if ((c * i) <= 5e+231) {
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) <= (-2d+120)) then
tmp = i * c
else if ((c * i) <= (-5d-303)) then
tmp = b * a
else if ((c * i) <= 5d+231) 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) <= -2e+120) {
tmp = i * c;
} else if ((c * i) <= -5e-303) {
tmp = b * a;
} else if ((c * i) <= 5e+231) {
tmp = t * z;
} else {
tmp = i * c;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (c * i) <= -2e+120: tmp = i * c elif (c * i) <= -5e-303: tmp = b * a elif (c * i) <= 5e+231: 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) <= -2e+120) tmp = Float64(i * c); elseif (Float64(c * i) <= -5e-303) tmp = Float64(b * a); elseif (Float64(c * i) <= 5e+231) 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) <= -2e+120) tmp = i * c; elseif ((c * i) <= -5e-303) tmp = b * a; elseif ((c * i) <= 5e+231) 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], -2e+120], N[(i * c), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -5e-303], N[(b * a), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 5e+231], N[(t * z), $MachinePrecision], N[(i * c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+120}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;c \cdot i \leq -5 \cdot 10^{-303}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{+231}:\\
\;\;\;\;t \cdot z\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 c i) < -2e120 or 5.00000000000000028e231 < (*.f64 c i) Initial program 90.6%
Taylor expanded in c around inf
Applied rewrites73.3%
if -2e120 < (*.f64 c i) < -4.9999999999999998e-303Initial program 96.3%
Taylor expanded in a around inf
Applied rewrites43.4%
if -4.9999999999999998e-303 < (*.f64 c i) < 5.00000000000000028e231Initial program 96.4%
Taylor expanded in z around inf
Applied rewrites37.7%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* x y) -2e+75) (not (<= (* x y) 1e+114))) (* y x) (fma b a (* 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+75) || !((x * y) <= 1e+114)) {
tmp = y * x;
} else {
tmp = fma(b, a, (c * i));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(x * y) <= -2e+75) || !(Float64(x * y) <= 1e+114)) tmp = Float64(y * x); else tmp = fma(b, a, Float64(c * i)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -2e+75], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1e+114]], $MachinePrecision]], N[(y * x), $MachinePrecision], N[(b * a + N[(c * i), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+75} \lor \neg \left(x \cdot y \leq 10^{+114}\right):\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, c \cdot i\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -1.99999999999999985e75 or 1e114 < (*.f64 x y) Initial program 89.7%
Taylor expanded in x around inf
Applied rewrites63.7%
if -1.99999999999999985e75 < (*.f64 x y) < 1e114Initial program 98.1%
Taylor expanded in x around 0
Applied rewrites94.0%
Taylor expanded in z around 0
Applied rewrites63.9%
Final simplification63.9%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* c i) -2e+120) (not (<= (* c i) 1e+291))) (* i c) (* b a)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((c * i) <= -2e+120) || !((c * i) <= 1e+291)) {
tmp = i * c;
} else {
tmp = b * a;
}
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) <= (-2d+120)) .or. (.not. ((c * i) <= 1d+291))) then
tmp = i * c
else
tmp = b * a
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) <= -2e+120) || !((c * i) <= 1e+291)) {
tmp = i * c;
} else {
tmp = b * a;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if ((c * i) <= -2e+120) or not ((c * i) <= 1e+291): tmp = i * c else: tmp = b * a return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(c * i) <= -2e+120) || !(Float64(c * i) <= 1e+291)) tmp = Float64(i * c); else tmp = Float64(b * a); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if (((c * i) <= -2e+120) || ~(((c * i) <= 1e+291))) tmp = i * c; else tmp = b * a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(c * i), $MachinePrecision], -2e+120], N[Not[LessEqual[N[(c * i), $MachinePrecision], 1e+291]], $MachinePrecision]], N[(i * c), $MachinePrecision], N[(b * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+120} \lor \neg \left(c \cdot i \leq 10^{+291}\right):\\
\;\;\;\;i \cdot c\\
\mathbf{else}:\\
\;\;\;\;b \cdot a\\
\end{array}
\end{array}
if (*.f64 c i) < -2e120 or 9.9999999999999996e290 < (*.f64 c i) Initial program 88.9%
Taylor expanded in c around inf
Applied rewrites80.0%
if -2e120 < (*.f64 c i) < 9.9999999999999996e290Initial program 96.5%
Taylor expanded in a around inf
Applied rewrites34.6%
Final simplification44.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 94.9%
Taylor expanded in a around inf
Applied rewrites29.4%
herbie shell --seed 2025022
(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)))