
(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 9 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 (let* ((t_1 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))) (if (<= t_1 INFINITY) t_1 (fma b a (* t z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (((x * y) + (z * t)) + (a * b)) + (c * i);
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = fma(b, a, (t * z));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i)) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = fma(b, a, Float64(t * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\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%
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-*.f6441.7
Applied rewrites41.7%
Taylor expanded in x around 0
lift-*.f6458.3
Applied rewrites58.3%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* a b) -5e+138)
(* b a)
(if (<= (* a b) -4e-121)
(* y x)
(if (<= (* a b) 0.0)
(* i c)
(if (<= (* a b) 2e-97)
(* y x)
(if (<= (* a b) 2e+38) (* t z) (* b a)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((a * b) <= -5e+138) {
tmp = b * a;
} else if ((a * b) <= -4e-121) {
tmp = y * x;
} else if ((a * b) <= 0.0) {
tmp = i * c;
} else if ((a * b) <= 2e-97) {
tmp = y * x;
} else if ((a * b) <= 2e+38) {
tmp = t * z;
} 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 ((a * b) <= (-5d+138)) then
tmp = b * a
else if ((a * b) <= (-4d-121)) then
tmp = y * x
else if ((a * b) <= 0.0d0) then
tmp = i * c
else if ((a * b) <= 2d-97) then
tmp = y * x
else if ((a * b) <= 2d+38) then
tmp = t * z
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 ((a * b) <= -5e+138) {
tmp = b * a;
} else if ((a * b) <= -4e-121) {
tmp = y * x;
} else if ((a * b) <= 0.0) {
tmp = i * c;
} else if ((a * b) <= 2e-97) {
tmp = y * x;
} else if ((a * b) <= 2e+38) {
tmp = t * z;
} else {
tmp = b * a;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (a * b) <= -5e+138: tmp = b * a elif (a * b) <= -4e-121: tmp = y * x elif (a * b) <= 0.0: tmp = i * c elif (a * b) <= 2e-97: tmp = y * x elif (a * b) <= 2e+38: tmp = t * z else: tmp = b * a return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(a * b) <= -5e+138) tmp = Float64(b * a); elseif (Float64(a * b) <= -4e-121) tmp = Float64(y * x); elseif (Float64(a * b) <= 0.0) tmp = Float64(i * c); elseif (Float64(a * b) <= 2e-97) tmp = Float64(y * x); elseif (Float64(a * b) <= 2e+38) tmp = Float64(t * z); 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 ((a * b) <= -5e+138) tmp = b * a; elseif ((a * b) <= -4e-121) tmp = y * x; elseif ((a * b) <= 0.0) tmp = i * c; elseif ((a * b) <= 2e-97) tmp = y * x; elseif ((a * b) <= 2e+38) tmp = t * z; else tmp = b * a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(a * b), $MachinePrecision], -5e+138], N[(b * a), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -4e-121], N[(y * x), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 0.0], N[(i * c), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2e-97], N[(y * x), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2e+38], N[(t * z), $MachinePrecision], N[(b * a), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+138}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;a \cdot b \leq -4 \cdot 10^{-121}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;a \cdot b \leq 0:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-97}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+38}:\\
\;\;\;\;t \cdot z\\
\mathbf{else}:\\
\;\;\;\;b \cdot a\\
\end{array}
\end{array}
if (*.f64 a b) < -5.00000000000000016e138 or 1.99999999999999995e38 < (*.f64 a b) Initial program 87.1%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6467.8
Applied rewrites67.8%
if -5.00000000000000016e138 < (*.f64 a b) < -3.9999999999999999e-121 or 0.0 < (*.f64 a b) < 2.00000000000000007e-97Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6447.9
Applied rewrites47.9%
if -3.9999999999999999e-121 < (*.f64 a b) < 0.0Initial program 100.0%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6444.5
Applied rewrites44.5%
if 2.00000000000000007e-97 < (*.f64 a b) < 1.99999999999999995e38Initial program 100.0%
Taylor expanded in z around inf
lower-*.f6449.5
Applied rewrites49.5%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* a b) -2e+87)
(* b a)
(if (<= (* a b) -2e-100)
(* t z)
(if (<= (* a b) 1e-153)
(* i c)
(if (<= (* a b) 2e+38) (* t z) (* b a))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((a * b) <= -2e+87) {
tmp = b * a;
} else if ((a * b) <= -2e-100) {
tmp = t * z;
} else if ((a * b) <= 1e-153) {
tmp = i * c;
} else if ((a * b) <= 2e+38) {
tmp = t * z;
} 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 ((a * b) <= (-2d+87)) then
tmp = b * a
else if ((a * b) <= (-2d-100)) then
tmp = t * z
else if ((a * b) <= 1d-153) then
tmp = i * c
else if ((a * b) <= 2d+38) then
tmp = t * z
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 ((a * b) <= -2e+87) {
tmp = b * a;
} else if ((a * b) <= -2e-100) {
tmp = t * z;
} else if ((a * b) <= 1e-153) {
tmp = i * c;
} else if ((a * b) <= 2e+38) {
tmp = t * z;
} else {
tmp = b * a;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (a * b) <= -2e+87: tmp = b * a elif (a * b) <= -2e-100: tmp = t * z elif (a * b) <= 1e-153: tmp = i * c elif (a * b) <= 2e+38: tmp = t * z else: tmp = b * a return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(a * b) <= -2e+87) tmp = Float64(b * a); elseif (Float64(a * b) <= -2e-100) tmp = Float64(t * z); elseif (Float64(a * b) <= 1e-153) tmp = Float64(i * c); elseif (Float64(a * b) <= 2e+38) tmp = Float64(t * z); 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 ((a * b) <= -2e+87) tmp = b * a; elseif ((a * b) <= -2e-100) tmp = t * z; elseif ((a * b) <= 1e-153) tmp = i * c; elseif ((a * b) <= 2e+38) tmp = t * z; else tmp = b * a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(a * b), $MachinePrecision], -2e+87], N[(b * a), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -2e-100], N[(t * z), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1e-153], N[(i * c), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2e+38], N[(t * z), $MachinePrecision], N[(b * a), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+87}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;a \cdot b \leq -2 \cdot 10^{-100}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;a \cdot b \leq 10^{-153}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+38}:\\
\;\;\;\;t \cdot z\\
\mathbf{else}:\\
\;\;\;\;b \cdot a\\
\end{array}
\end{array}
if (*.f64 a b) < -1.9999999999999999e87 or 1.99999999999999995e38 < (*.f64 a b) Initial program 88.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6463.7
Applied rewrites63.7%
if -1.9999999999999999e87 < (*.f64 a b) < -2e-100 or 1.00000000000000004e-153 < (*.f64 a b) < 1.99999999999999995e38Initial program 100.0%
Taylor expanded in z around inf
lower-*.f6442.4
Applied rewrites42.4%
if -2e-100 < (*.f64 a b) < 1.00000000000000004e-153Initial program 100.0%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6438.3
Applied rewrites38.3%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (+ (* x y) (* z t))))
(if (or (<= t_1 -2e+113) (not (<= t_1 3.65e+185)))
(fma t z (* y x))
(fma b a (* i c)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (x * y) + (z * t);
double tmp;
if ((t_1 <= -2e+113) || !(t_1 <= 3.65e+185)) {
tmp = fma(t, z, (y * x));
} else {
tmp = fma(b, a, (i * c));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if ((t_1 <= -2e+113) || !(t_1 <= 3.65e+185)) tmp = fma(t, z, Float64(y * x)); else tmp = fma(b, a, Float64(i * c)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+113], N[Not[LessEqual[t$95$1, 3.65e+185]], $MachinePrecision]], N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(i * c), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+113} \lor \neg \left(t\_1 \leq 3.65 \cdot 10^{+185}\right):\\
\;\;\;\;\mathsf{fma}\left(t, z, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, i \cdot c\right)\\
\end{array}
\end{array}
if (+.f64 (*.f64 x y) (*.f64 z t)) < -2e113 or 3.64999999999999971e185 < (+.f64 (*.f64 x y) (*.f64 z t)) Initial program 91.2%
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.0
Applied rewrites87.0%
Taylor expanded in a around 0
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6477.9
Applied rewrites77.9%
if -2e113 < (+.f64 (*.f64 x y) (*.f64 z t)) < 3.64999999999999971e185Initial program 99.2%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6491.1
Applied rewrites91.1%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f6476.6
Applied rewrites76.6%
Final simplification77.3%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* z t) -5e+48) (not (<= (* z t) 1e+38))) (fma b a (fma t z (* y x))) (fma b a (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 (((z * t) <= -5e+48) || !((z * t) <= 1e+38)) {
tmp = fma(b, a, fma(t, z, (y * x)));
} else {
tmp = fma(b, a, fma(i, c, (y * x)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(z * t) <= -5e+48) || !(Float64(z * t) <= 1e+38)) tmp = fma(b, a, fma(t, z, Float64(y * x))); else tmp = fma(b, a, fma(i, c, Float64(y * x))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], -5e+48], N[Not[LessEqual[N[(z * t), $MachinePrecision], 1e+38]], $MachinePrecision]], N[(b * a + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+48} \lor \neg \left(z \cdot t \leq 10^{+38}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -4.99999999999999973e48 or 9.99999999999999977e37 < (*.f64 z t) Initial program 93.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.3
Applied rewrites87.3%
if -4.99999999999999973e48 < (*.f64 z t) < 9.99999999999999977e37Initial program 96.2%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6495.0
Applied rewrites95.0%
Final simplification92.1%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* z t) -2e+160) (fma b a (* t z)) (if (<= (* z t) 2e+175) (fma b a (fma i c (* y x))) (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 ((z * t) <= -2e+160) {
tmp = fma(b, a, (t * z));
} else if ((z * t) <= 2e+175) {
tmp = fma(b, a, fma(i, c, (y * x)));
} else {
tmp = fma(t, z, (y * x));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -2e+160) tmp = fma(b, a, Float64(t * z)); elseif (Float64(z * t) <= 2e+175) tmp = fma(b, a, fma(i, c, Float64(y * x))); else tmp = fma(t, z, Float64(y * x)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -2e+160], N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+175], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+160}:\\
\;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+175}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, z, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -2.00000000000000001e160Initial program 87.5%
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 0
lift-*.f6487.3
Applied rewrites87.3%
if -2.00000000000000001e160 < (*.f64 z t) < 1.9999999999999999e175Initial program 96.9%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6491.0
Applied rewrites91.0%
if 1.9999999999999999e175 < (*.f64 z t) Initial program 95.2%
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-*.f6490.5
Applied rewrites90.5%
Taylor expanded in a around 0
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6489.6
Applied rewrites89.6%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* a b) -5e+138) (not (<= (* a b) 2e+38))) (* 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 (((a * b) <= -5e+138) || !((a * b) <= 2e+38)) {
tmp = b * a;
} else {
tmp = fma(t, z, (y * x));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(a * b) <= -5e+138) || !(Float64(a * b) <= 2e+38)) tmp = Float64(b * a); else tmp = fma(t, z, Float64(y * x)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -5e+138], N[Not[LessEqual[N[(a * b), $MachinePrecision], 2e+38]], $MachinePrecision]], N[(b * a), $MachinePrecision], N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+138} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{+38}\right):\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, z, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -5.00000000000000016e138 or 1.99999999999999995e38 < (*.f64 a b) Initial program 87.1%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6467.8
Applied rewrites67.8%
if -5.00000000000000016e138 < (*.f64 a b) < 1.99999999999999995e38Initial program 100.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-*.f6472.1
Applied rewrites72.1%
Taylor expanded in a around 0
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6465.7
Applied rewrites65.7%
Final simplification66.5%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* a b) -5e+252) (not (<= (* a b) 1e-7))) (* 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) <= -5e+252) || !((a * b) <= 1e-7)) {
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) <= (-5d+252)) .or. (.not. ((a * b) <= 1d-7))) 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) <= -5e+252) || !((a * b) <= 1e-7)) {
tmp = b * a;
} else {
tmp = i * c;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if ((a * b) <= -5e+252) or not ((a * b) <= 1e-7): 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) <= -5e+252) || !(Float64(a * b) <= 1e-7)) 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) <= -5e+252) || ~(((a * b) <= 1e-7))) 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], -5e+252], N[Not[LessEqual[N[(a * b), $MachinePrecision], 1e-7]], $MachinePrecision]], N[(b * a), $MachinePrecision], N[(i * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+252} \lor \neg \left(a \cdot b \leq 10^{-7}\right):\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 a b) < -4.9999999999999997e252 or 9.9999999999999995e-8 < (*.f64 a b) Initial program 87.2%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6466.0
Applied rewrites66.0%
if -4.9999999999999997e252 < (*.f64 a b) < 9.9999999999999995e-8Initial program 100.0%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6432.8
Applied rewrites32.8%
Final simplification45.0%
(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 95.3%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6429.9
Applied rewrites29.9%
herbie shell --seed 2025084
(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)))