
(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 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 z t (fma y x (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(z, t, fma(y, x, fma(i, c, (b * a))));
}
function code(x, y, z, t, a, b, c, i) return fma(z, t, fma(y, x, fma(i, c, Float64(b * a)))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(z * t + N[(y * x + N[(i * c + N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, t, \mathsf{fma}\left(y, x, \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
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
remove-double-negN/A
lift-*.f64N/A
associate-+r+N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites96.9%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* c i) -5e+156)
(* i c)
(if (<= (* c i) -5e+28)
(* b a)
(if (<= (* c i) -5e-55)
(* y x)
(if (<= (* c i) -2e-313)
(* t z)
(if (<= (* c i) 5e-262)
(* b a)
(if (<= (* c i) 5e+92) (* 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) <= -5e+156) {
tmp = i * c;
} else if ((c * i) <= -5e+28) {
tmp = b * a;
} else if ((c * i) <= -5e-55) {
tmp = y * x;
} else if ((c * i) <= -2e-313) {
tmp = t * z;
} else if ((c * i) <= 5e-262) {
tmp = b * a;
} else if ((c * i) <= 5e+92) {
tmp = y * x;
} 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) <= (-5d+156)) then
tmp = i * c
else if ((c * i) <= (-5d+28)) then
tmp = b * a
else if ((c * i) <= (-5d-55)) then
tmp = y * x
else if ((c * i) <= (-2d-313)) then
tmp = t * z
else if ((c * i) <= 5d-262) then
tmp = b * a
else if ((c * i) <= 5d+92) then
tmp = y * x
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) <= -5e+156) {
tmp = i * c;
} else if ((c * i) <= -5e+28) {
tmp = b * a;
} else if ((c * i) <= -5e-55) {
tmp = y * x;
} else if ((c * i) <= -2e-313) {
tmp = t * z;
} else if ((c * i) <= 5e-262) {
tmp = b * a;
} else if ((c * i) <= 5e+92) {
tmp = y * x;
} else {
tmp = i * c;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (c * i) <= -5e+156: tmp = i * c elif (c * i) <= -5e+28: tmp = b * a elif (c * i) <= -5e-55: tmp = y * x elif (c * i) <= -2e-313: tmp = t * z elif (c * i) <= 5e-262: tmp = b * a elif (c * i) <= 5e+92: tmp = 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) <= -5e+156) tmp = Float64(i * c); elseif (Float64(c * i) <= -5e+28) tmp = Float64(b * a); elseif (Float64(c * i) <= -5e-55) tmp = Float64(y * x); elseif (Float64(c * i) <= -2e-313) tmp = Float64(t * z); elseif (Float64(c * i) <= 5e-262) tmp = Float64(b * a); elseif (Float64(c * i) <= 5e+92) tmp = Float64(y * x); 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) <= -5e+156) tmp = i * c; elseif ((c * i) <= -5e+28) tmp = b * a; elseif ((c * i) <= -5e-55) tmp = y * x; elseif ((c * i) <= -2e-313) tmp = t * z; elseif ((c * i) <= 5e-262) tmp = b * a; elseif ((c * i) <= 5e+92) tmp = y * x; else tmp = i * c; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -5e+156], N[(i * c), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -5e+28], N[(b * a), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -5e-55], N[(y * x), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -2e-313], N[(t * z), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 5e-262], N[(b * a), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 5e+92], N[(y * x), $MachinePrecision], N[(i * c), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -5 \cdot 10^{+156}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;c \cdot i \leq -5 \cdot 10^{+28}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;c \cdot i \leq -5 \cdot 10^{-55}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;c \cdot i \leq -2 \cdot 10^{-313}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{-262}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{+92}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 c i) < -4.99999999999999992e156 or 5.00000000000000022e92 < (*.f64 c i) Initial program 90.8%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.7
Applied rewrites90.7%
Taylor expanded in c around 0
Applied rewrites24.3%
Taylor expanded in x around 0
Applied rewrites15.0%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6473.8
Applied rewrites73.8%
if -4.99999999999999992e156 < (*.f64 c i) < -4.99999999999999957e28 or -1.99999999998e-313 < (*.f64 c i) < 4.99999999999999992e-262Initial program 94.8%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6479.7
Applied rewrites79.7%
Taylor expanded in c around 0
Applied rewrites71.2%
Taylor expanded in x around 0
Applied rewrites50.0%
if -4.99999999999999957e28 < (*.f64 c i) < -5.0000000000000002e-55 or 4.99999999999999992e-262 < (*.f64 c i) < 5.00000000000000022e92Initial program 98.7%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6475.7
Applied rewrites75.7%
Taylor expanded in c around 0
Applied rewrites69.5%
Taylor expanded in x around 0
Applied rewrites25.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6447.7
Applied rewrites47.7%
if -5.0000000000000002e-55 < (*.f64 c i) < -1.99999999998e-313Initial program 95.7%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6447.5
Applied rewrites47.5%
Taylor expanded in c around 0
Applied rewrites47.6%
Taylor expanded in x around 0
Applied rewrites24.3%
Taylor expanded in z around inf
lower-*.f6454.9
Applied rewrites54.9%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma b a (* y x))))
(if (<= (* c i) -5e+74)
(fma b a (* i c))
(if (<= (* c i) -5e-55)
t_1
(if (<= (* c i) -2e-313)
(fma b a (* t z))
(if (<= (* c i) 5e+92) t_1 (fma i c (* y x))))))))
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 tmp;
if ((c * i) <= -5e+74) {
tmp = fma(b, a, (i * c));
} else if ((c * i) <= -5e-55) {
tmp = t_1;
} else if ((c * i) <= -2e-313) {
tmp = fma(b, a, (t * z));
} else if ((c * i) <= 5e+92) {
tmp = t_1;
} else {
tmp = fma(i, c, (y * x));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(b, a, Float64(y * x)) tmp = 0.0 if (Float64(c * i) <= -5e+74) tmp = fma(b, a, Float64(i * c)); elseif (Float64(c * i) <= -5e-55) tmp = t_1; elseif (Float64(c * i) <= -2e-313) tmp = fma(b, a, Float64(t * z)); elseif (Float64(c * i) <= 5e+92) tmp = t_1; else tmp = fma(i, c, Float64(y * x)); 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]}, If[LessEqual[N[(c * i), $MachinePrecision], -5e+74], N[(b * a + N[(i * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -5e-55], t$95$1, If[LessEqual[N[(c * i), $MachinePrecision], -2e-313], N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 5e+92], t$95$1, N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, y \cdot x\right)\\
\mathbf{if}\;c \cdot i \leq -5 \cdot 10^{+74}:\\
\;\;\;\;\mathsf{fma}\left(b, a, i \cdot c\right)\\
\mathbf{elif}\;c \cdot i \leq -5 \cdot 10^{-55}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \cdot i \leq -2 \cdot 10^{-313}:\\
\;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\
\mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{+92}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 c i) < -4.99999999999999963e74Initial program 92.5%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.2
Applied rewrites90.2%
Taylor expanded in x around 0
Applied rewrites86.9%
if -4.99999999999999963e74 < (*.f64 c i) < -5.0000000000000002e-55 or -1.99999999998e-313 < (*.f64 c i) < 5.00000000000000022e92Initial program 96.7%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6476.8
Applied rewrites76.8%
Taylor expanded in c around 0
Applied rewrites71.3%
if -5.0000000000000002e-55 < (*.f64 c i) < -1.99999999998e-313Initial program 95.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6477.4
Applied rewrites77.4%
Taylor expanded in c around 0
Applied rewrites77.4%
if 5.00000000000000022e92 < (*.f64 c i) Initial program 91.6%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6489.5
Applied rewrites89.5%
Taylor expanded in c around 0
Applied rewrites29.1%
Taylor expanded in x around 0
Applied rewrites16.6%
Taylor expanded in a around 0
Applied rewrites79.9%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma b a (* y x))))
(if (<= (* c i) -1e+157)
(* i c)
(if (<= (* c i) -5e-55)
t_1
(if (<= (* c i) -2e-313)
(fma b a (* t z))
(if (<= (* c i) 5e+92) t_1 (* i c)))))))
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 tmp;
if ((c * i) <= -1e+157) {
tmp = i * c;
} else if ((c * i) <= -5e-55) {
tmp = t_1;
} else if ((c * i) <= -2e-313) {
tmp = fma(b, a, (t * z));
} else if ((c * i) <= 5e+92) {
tmp = t_1;
} else {
tmp = i * c;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(b, a, Float64(y * x)) tmp = 0.0 if (Float64(c * i) <= -1e+157) tmp = Float64(i * c); elseif (Float64(c * i) <= -5e-55) tmp = t_1; elseif (Float64(c * i) <= -2e-313) tmp = fma(b, a, Float64(t * z)); elseif (Float64(c * i) <= 5e+92) tmp = t_1; else tmp = Float64(i * c); 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]}, If[LessEqual[N[(c * i), $MachinePrecision], -1e+157], N[(i * c), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -5e-55], t$95$1, If[LessEqual[N[(c * i), $MachinePrecision], -2e-313], N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 5e+92], t$95$1, N[(i * c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, y \cdot x\right)\\
\mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+157}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;c \cdot i \leq -5 \cdot 10^{-55}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \cdot i \leq -2 \cdot 10^{-313}:\\
\;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\
\mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{+92}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 c i) < -9.99999999999999983e156 or 5.00000000000000022e92 < (*.f64 c i) Initial program 92.0%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.6
Applied rewrites90.6%
Taylor expanded in c around 0
Applied rewrites23.3%
Taylor expanded in x around 0
Applied rewrites15.2%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6474.7
Applied rewrites74.7%
if -9.99999999999999983e156 < (*.f64 c i) < -5.0000000000000002e-55 or -1.99999999998e-313 < (*.f64 c i) < 5.00000000000000022e92Initial program 96.3%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6477.6
Applied rewrites77.6%
Taylor expanded in c around 0
Applied rewrites70.5%
if -5.0000000000000002e-55 < (*.f64 c i) < -1.99999999998e-313Initial program 95.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6477.4
Applied rewrites77.4%
Taylor expanded in c around 0
Applied rewrites77.4%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* c i) -5e+156)
(* i c)
(if (<= (* c i) -5e+38)
(* b a)
(if (<= (* c i) -2e-313)
(* t z)
(if (<= (* c i) 5e+92) (* 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) <= -5e+156) {
tmp = i * c;
} else if ((c * i) <= -5e+38) {
tmp = b * a;
} else if ((c * i) <= -2e-313) {
tmp = t * z;
} else if ((c * i) <= 5e+92) {
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) <= (-5d+156)) then
tmp = i * c
else if ((c * i) <= (-5d+38)) then
tmp = b * a
else if ((c * i) <= (-2d-313)) then
tmp = t * z
else if ((c * i) <= 5d+92) 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) <= -5e+156) {
tmp = i * c;
} else if ((c * i) <= -5e+38) {
tmp = b * a;
} else if ((c * i) <= -2e-313) {
tmp = t * z;
} else if ((c * i) <= 5e+92) {
tmp = b * a;
} else {
tmp = i * c;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (c * i) <= -5e+156: tmp = i * c elif (c * i) <= -5e+38: tmp = b * a elif (c * i) <= -2e-313: tmp = t * z elif (c * i) <= 5e+92: 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) <= -5e+156) tmp = Float64(i * c); elseif (Float64(c * i) <= -5e+38) tmp = Float64(b * a); elseif (Float64(c * i) <= -2e-313) tmp = Float64(t * z); elseif (Float64(c * i) <= 5e+92) 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) <= -5e+156) tmp = i * c; elseif ((c * i) <= -5e+38) tmp = b * a; elseif ((c * i) <= -2e-313) tmp = t * z; elseif ((c * i) <= 5e+92) 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], -5e+156], N[(i * c), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -5e+38], N[(b * a), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -2e-313], N[(t * z), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 5e+92], N[(b * a), $MachinePrecision], N[(i * c), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -5 \cdot 10^{+156}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;c \cdot i \leq -5 \cdot 10^{+38}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;c \cdot i \leq -2 \cdot 10^{-313}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{+92}:\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 c i) < -4.99999999999999992e156 or 5.00000000000000022e92 < (*.f64 c i) Initial program 90.8%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.7
Applied rewrites90.7%
Taylor expanded in c around 0
Applied rewrites24.3%
Taylor expanded in x around 0
Applied rewrites15.0%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6473.8
Applied rewrites73.8%
if -4.99999999999999992e156 < (*.f64 c i) < -4.9999999999999997e38 or -1.99999999998e-313 < (*.f64 c i) < 5.00000000000000022e92Initial program 97.4%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6477.5
Applied rewrites77.5%
Taylor expanded in c around 0
Applied rewrites71.7%
Taylor expanded in x around 0
Applied rewrites39.4%
if -4.9999999999999997e38 < (*.f64 c i) < -1.99999999998e-313Initial program 95.2%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6455.4
Applied rewrites55.4%
Taylor expanded in c around 0
Applied rewrites50.9%
Taylor expanded in x around 0
Applied rewrites21.6%
Taylor expanded in z around inf
lower-*.f6446.9
Applied rewrites46.9%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* x y) -20000000.0) (not (<= (* x y) 5e+170))) (fma i c (fma t z (* y x))) (fma b a (fma i c (* t z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((x * y) <= -20000000.0) || !((x * y) <= 5e+170)) {
tmp = fma(i, c, fma(t, z, (y * x)));
} else {
tmp = fma(b, a, fma(i, c, (t * z)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(x * y) <= -20000000.0) || !(Float64(x * y) <= 5e+170)) tmp = fma(i, c, fma(t, z, Float64(y * x))); else tmp = fma(b, a, fma(i, c, Float64(t * z))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -20000000.0], N[Not[LessEqual[N[(x * y), $MachinePrecision], 5e+170]], $MachinePrecision]], N[(i * c + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -20000000 \lor \neg \left(x \cdot y \leq 5 \cdot 10^{+170}\right):\\
\;\;\;\;\mathsf{fma}\left(i, c, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -2e7 or 4.99999999999999977e170 < (*.f64 x y) Initial program 91.2%
Taylor expanded in a around 0
*-lft-identityN/A
metadata-evalN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.6
Applied rewrites90.6%
if -2e7 < (*.f64 x y) < 4.99999999999999977e170Initial program 97.4%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6496.0
Applied rewrites96.0%
Final simplification93.8%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* x y) -4e+34) (not (<= (* x y) 1e+192))) (fma b a (fma i c (* y x))) (fma b a (fma i c (* t z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((x * y) <= -4e+34) || !((x * y) <= 1e+192)) {
tmp = fma(b, a, fma(i, c, (y * x)));
} else {
tmp = fma(b, a, fma(i, c, (t * z)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(x * y) <= -4e+34) || !(Float64(x * y) <= 1e+192)) tmp = fma(b, a, fma(i, c, Float64(y * x))); else tmp = fma(b, a, fma(i, c, Float64(t * z))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -4e+34], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1e+192]], $MachinePrecision]], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -4 \cdot 10^{+34} \lor \neg \left(x \cdot y \leq 10^{+192}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -3.99999999999999978e34 or 1.00000000000000004e192 < (*.f64 x y) Initial program 90.2%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6487.2
Applied rewrites87.2%
if -3.99999999999999978e34 < (*.f64 x y) < 1.00000000000000004e192Initial program 97.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6494.3
Applied rewrites94.3%
Final simplification91.7%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* x y) -4e+34) (not (<= (* x y) 1e+192))) (fma i c (* y x)) (fma b a (fma i c (* t z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((x * y) <= -4e+34) || !((x * y) <= 1e+192)) {
tmp = fma(i, c, (y * x));
} else {
tmp = fma(b, a, fma(i, c, (t * z)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(x * y) <= -4e+34) || !(Float64(x * y) <= 1e+192)) tmp = fma(i, c, Float64(y * x)); else tmp = fma(b, a, fma(i, c, Float64(t * z))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -4e+34], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1e+192]], $MachinePrecision]], N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -4 \cdot 10^{+34} \lor \neg \left(x \cdot y \leq 10^{+192}\right):\\
\;\;\;\;\mathsf{fma}\left(i, c, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -3.99999999999999978e34 or 1.00000000000000004e192 < (*.f64 x y) Initial program 90.2%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6487.2
Applied rewrites87.2%
Taylor expanded in c around 0
Applied rewrites75.7%
Taylor expanded in x around 0
Applied rewrites13.5%
Taylor expanded in a around 0
Applied rewrites78.9%
if -3.99999999999999978e34 < (*.f64 x y) < 1.00000000000000004e192Initial program 97.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6494.3
Applied rewrites94.3%
Final simplification88.8%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* a b) -2e+119) (not (<= (* a b) 5e+67))) (fma b a (* 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 (((a * b) <= -2e+119) || !((a * b) <= 5e+67)) {
tmp = fma(b, a, (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(a * b) <= -2e+119) || !(Float64(a * b) <= 5e+67)) tmp = fma(b, a, 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[Or[LessEqual[N[(a * b), $MachinePrecision], -2e+119], N[Not[LessEqual[N[(a * b), $MachinePrecision], 5e+67]], $MachinePrecision]], N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision], N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+119} \lor \neg \left(a \cdot b \leq 5 \cdot 10^{+67}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -1.99999999999999989e119 or 4.99999999999999976e67 < (*.f64 a b) Initial program 86.2%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6485.5
Applied rewrites85.5%
Taylor expanded in c around 0
Applied rewrites80.5%
if -1.99999999999999989e119 < (*.f64 a b) < 4.99999999999999976e67Initial program 99.4%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6473.6
Applied rewrites73.6%
Taylor expanded in c around 0
Applied rewrites40.3%
Taylor expanded in x around 0
Applied rewrites7.1%
Taylor expanded in a around 0
Applied rewrites69.0%
Final simplification72.9%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* x y) -4e+34) (not (<= (* x y) 1e+192))) (* y x) (fma 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 (((x * y) <= -4e+34) || !((x * y) <= 1e+192)) {
tmp = y * x;
} else {
tmp = fma(b, a, (t * z));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(x * y) <= -4e+34) || !(Float64(x * y) <= 1e+192)) tmp = Float64(y * x); else tmp = fma(b, a, Float64(t * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -4e+34], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1e+192]], $MachinePrecision]], N[(y * x), $MachinePrecision], N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -4 \cdot 10^{+34} \lor \neg \left(x \cdot y \leq 10^{+192}\right):\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -3.99999999999999978e34 or 1.00000000000000004e192 < (*.f64 x y) Initial program 90.2%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6487.2
Applied rewrites87.2%
Taylor expanded in c around 0
Applied rewrites75.7%
Taylor expanded in x around 0
Applied rewrites13.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6467.6
Applied rewrites67.6%
if -3.99999999999999978e34 < (*.f64 x y) < 1.00000000000000004e192Initial program 97.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6494.3
Applied rewrites94.3%
Taylor expanded in c around 0
Applied rewrites65.0%
Final simplification66.0%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* a b) -0.0001) (not (<= (* a b) 5e+67))) (* 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 (((a * b) <= -0.0001) || !((a * b) <= 5e+67)) {
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 (((a * b) <= (-0.0001d0)) .or. (.not. ((a * b) <= 5d+67))) 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 (((a * b) <= -0.0001) || !((a * b) <= 5e+67)) {
tmp = b * a;
} else {
tmp = i * c;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if ((a * b) <= -0.0001) or not ((a * b) <= 5e+67): tmp = b * a else: tmp = i * c return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(a * b) <= -0.0001) || !(Float64(a * b) <= 5e+67)) 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 (((a * b) <= -0.0001) || ~(((a * b) <= 5e+67))) tmp = b * a; else tmp = i * c; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -0.0001], N[Not[LessEqual[N[(a * b), $MachinePrecision], 5e+67]], $MachinePrecision]], N[(b * a), $MachinePrecision], N[(i * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -0.0001 \lor \neg \left(a \cdot b \leq 5 \cdot 10^{+67}\right):\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 a b) < -1.00000000000000005e-4 or 4.99999999999999976e67 < (*.f64 a b) Initial program 89.7%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6481.4
Applied rewrites81.4%
Taylor expanded in c around 0
Applied rewrites74.0%
Taylor expanded in x around 0
Applied rewrites57.2%
if -1.00000000000000005e-4 < (*.f64 a b) < 4.99999999999999976e67Initial program 99.3%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6471.4
Applied rewrites71.4%
Taylor expanded in c around 0
Applied rewrites34.4%
Taylor expanded in x around 0
Applied rewrites3.1%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6439.1
Applied rewrites39.1%
Final simplification47.3%
(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 z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
*-lft-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6476.0
Applied rewrites76.0%
Taylor expanded in c around 0
Applied rewrites52.5%
Taylor expanded in x around 0
Applied rewrites27.8%
herbie shell --seed 2024354
(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)))