
(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 (if (<= (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)) INFINITY) (+ (fma y x (fma b a (* t z))) (* c i)) (fma b a (fma t z (* y x)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((((x * y) + (z * t)) + (a * b)) + (c * i)) <= ((double) INFINITY)) {
tmp = fma(y, x, fma(b, a, (t * z))) + (c * i);
} else {
tmp = fma(b, a, fma(t, z, (y * x)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i)) <= Inf) tmp = Float64(fma(y, x, fma(b, a, Float64(t * z))) + Float64(c * i)); else tmp = fma(b, a, fma(t, z, Float64(y * x))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(y * x + N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(y, x, \mathsf{fma}\left(b, a, t \cdot z\right)\right) + c \cdot i\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i)) < +inf.0Initial program 100.0%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64100.0
Applied rewrites100.0%
if +inf.0 < (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i)) Initial program 0.0%
Taylor expanded in c around 0
Applied rewrites76.2%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma b a (* y x))) (t_2 (fma i c (* t z))))
(if (<= (* z t) -2e+158)
t_2
(if (<= (* z t) -500000000.0)
t_1
(if (<= (* z t) -2e-236)
(fma i c (* a b))
(if (<= (* z t) 0.0)
t_1
(if (<= (* z t) 2e-145)
(fma i c (* x y))
(if (<= (* z t) 5e+17) t_1 t_2))))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(b, a, (y * x));
double t_2 = fma(i, c, (t * z));
double tmp;
if ((z * t) <= -2e+158) {
tmp = t_2;
} else if ((z * t) <= -500000000.0) {
tmp = t_1;
} else if ((z * t) <= -2e-236) {
tmp = fma(i, c, (a * b));
} else if ((z * t) <= 0.0) {
tmp = t_1;
} else if ((z * t) <= 2e-145) {
tmp = fma(i, c, (x * y));
} else if ((z * t) <= 5e+17) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(b, a, Float64(y * x)) t_2 = fma(i, c, Float64(t * z)) tmp = 0.0 if (Float64(z * t) <= -2e+158) tmp = t_2; elseif (Float64(z * t) <= -500000000.0) tmp = t_1; elseif (Float64(z * t) <= -2e-236) tmp = fma(i, c, Float64(a * b)); elseif (Float64(z * t) <= 0.0) tmp = t_1; elseif (Float64(z * t) <= 2e-145) tmp = fma(i, c, Float64(x * y)); elseif (Float64(z * t) <= 5e+17) tmp = t_1; else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -2e+158], t$95$2, If[LessEqual[N[(z * t), $MachinePrecision], -500000000.0], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], -2e-236], N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 0.0], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 2e-145], N[(i * c + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+17], t$95$1, t$95$2]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, y \cdot x\right)\\
t_2 := \mathsf{fma}\left(i, c, t \cdot z\right)\\
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+158}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;z \cdot t \leq -500000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq -2 \cdot 10^{-236}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\
\mathbf{elif}\;z \cdot t \leq 0:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{-145}:\\
\;\;\;\;\mathsf{fma}\left(i, c, x \cdot y\right)\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+17}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 z t) < -1.99999999999999991e158 or 5e17 < (*.f64 z t) Initial program 86.8%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6491.2
Applied rewrites91.2%
Taylor expanded in z around inf
Applied rewrites75.4%
lift-+.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6477.6
Applied rewrites77.6%
if -1.99999999999999991e158 < (*.f64 z t) < -5e8 or -2.0000000000000001e-236 < (*.f64 z t) < -0.0 or 1.99999999999999983e-145 < (*.f64 z t) < 5e17Initial program 93.3%
Taylor expanded in c around 0
Applied rewrites87.0%
Taylor expanded in x around inf
Applied rewrites81.2%
if -5e8 < (*.f64 z t) < -2.0000000000000001e-236Initial program 95.5%
Taylor expanded in a around inf
Applied rewrites71.3%
lift-+.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6475.8
Applied rewrites75.8%
if -0.0 < (*.f64 z t) < 1.99999999999999983e-145Initial program 96.8%
Taylor expanded in x around inf
Applied rewrites84.0%
lift-+.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6484.0
Applied rewrites84.0%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* z t) -2e+159)
(* t z)
(if (<= (* z t) -2e-7)
(* y x)
(if (<= (* z t) 0.0)
(* b a)
(if (<= (* z t) 2e-145)
(* i c)
(if (<= (* z t) 2e+93) (* y x) (* t z)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((z * t) <= -2e+159) {
tmp = t * z;
} else if ((z * t) <= -2e-7) {
tmp = y * x;
} else if ((z * t) <= 0.0) {
tmp = b * a;
} else if ((z * t) <= 2e-145) {
tmp = i * c;
} else if ((z * t) <= 2e+93) {
tmp = y * x;
} 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) <= (-2d+159)) then
tmp = t * z
else if ((z * t) <= (-2d-7)) then
tmp = y * x
else if ((z * t) <= 0.0d0) then
tmp = b * a
else if ((z * t) <= 2d-145) then
tmp = i * c
else if ((z * t) <= 2d+93) then
tmp = y * x
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) <= -2e+159) {
tmp = t * z;
} else if ((z * t) <= -2e-7) {
tmp = y * x;
} else if ((z * t) <= 0.0) {
tmp = b * a;
} else if ((z * t) <= 2e-145) {
tmp = i * c;
} else if ((z * t) <= 2e+93) {
tmp = y * x;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (z * t) <= -2e+159: tmp = t * z elif (z * t) <= -2e-7: tmp = y * x elif (z * t) <= 0.0: tmp = b * a elif (z * t) <= 2e-145: tmp = i * c elif (z * t) <= 2e+93: tmp = y * x else: tmp = t * z return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -2e+159) tmp = Float64(t * z); elseif (Float64(z * t) <= -2e-7) tmp = Float64(y * x); elseif (Float64(z * t) <= 0.0) tmp = Float64(b * a); elseif (Float64(z * t) <= 2e-145) tmp = Float64(i * c); elseif (Float64(z * t) <= 2e+93) tmp = Float64(y * x); 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) <= -2e+159) tmp = t * z; elseif ((z * t) <= -2e-7) tmp = y * x; elseif ((z * t) <= 0.0) tmp = b * a; elseif ((z * t) <= 2e-145) tmp = i * c; elseif ((z * t) <= 2e+93) tmp = y * x; else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -2e+159], N[(t * z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], -2e-7], N[(y * x), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 0.0], N[(b * a), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e-145], N[(i * c), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+93], N[(y * x), $MachinePrecision], N[(t * z), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+159}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;z \cdot t \leq -2 \cdot 10^{-7}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;z \cdot t \leq 0:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{-145}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+93}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (*.f64 z t) < -1.9999999999999999e159 or 2.00000000000000009e93 < (*.f64 z t) Initial program 85.3%
Taylor expanded in z around inf
Applied rewrites68.2%
if -1.9999999999999999e159 < (*.f64 z t) < -1.9999999999999999e-7 or 1.99999999999999983e-145 < (*.f64 z t) < 2.00000000000000009e93Initial program 90.6%
Taylor expanded in x around inf
Applied rewrites51.0%
if -1.9999999999999999e-7 < (*.f64 z t) < -0.0Initial program 97.5%
Taylor expanded in a around inf
Applied rewrites46.2%
if -0.0 < (*.f64 z t) < 1.99999999999999983e-145Initial program 96.8%
Taylor expanded in c around inf
Applied rewrites59.4%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma b a (* y x))) (t_2 (fma i c (* t z))))
(if (<= (* z t) -2e+158)
t_2
(if (<= (* z t) -500000000.0)
t_1
(if (<= (* z t) 5e-115)
(fma i c (* a b))
(if (<= (* z t) 5e+17) t_1 t_2))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(b, a, (y * x));
double t_2 = fma(i, c, (t * z));
double tmp;
if ((z * t) <= -2e+158) {
tmp = t_2;
} else if ((z * t) <= -500000000.0) {
tmp = t_1;
} else if ((z * t) <= 5e-115) {
tmp = fma(i, c, (a * b));
} else if ((z * t) <= 5e+17) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(b, a, Float64(y * x)) t_2 = fma(i, c, Float64(t * z)) tmp = 0.0 if (Float64(z * t) <= -2e+158) tmp = t_2; elseif (Float64(z * t) <= -500000000.0) tmp = t_1; elseif (Float64(z * t) <= 5e-115) tmp = fma(i, c, Float64(a * b)); elseif (Float64(z * t) <= 5e+17) tmp = t_1; else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -2e+158], t$95$2, If[LessEqual[N[(z * t), $MachinePrecision], -500000000.0], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 5e-115], N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+17], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, y \cdot x\right)\\
t_2 := \mathsf{fma}\left(i, c, t \cdot z\right)\\
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+158}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;z \cdot t \leq -500000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{-115}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+17}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 z t) < -1.99999999999999991e158 or 5e17 < (*.f64 z t) Initial program 86.8%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6491.2
Applied rewrites91.2%
Taylor expanded in z around inf
Applied rewrites75.4%
lift-+.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6477.6
Applied rewrites77.6%
if -1.99999999999999991e158 < (*.f64 z t) < -5e8 or 5.0000000000000003e-115 < (*.f64 z t) < 5e17Initial program 87.9%
Taylor expanded in c around 0
Applied rewrites90.3%
Taylor expanded in x around inf
Applied rewrites79.8%
if -5e8 < (*.f64 z t) < 5.0000000000000003e-115Initial program 97.4%
Taylor expanded in a around inf
Applied rewrites70.6%
lift-+.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6472.3
Applied rewrites72.3%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma b a (* y x))) (t_2 (fma b a (* t z))))
(if (<= (* z t) -2e+159)
t_2
(if (<= (* z t) -500000000.0)
t_1
(if (<= (* z t) 5e-115)
(fma i c (* a b))
(if (<= (* z t) 2e+93) t_1 t_2))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(b, a, (y * x));
double t_2 = fma(b, a, (t * z));
double tmp;
if ((z * t) <= -2e+159) {
tmp = t_2;
} else if ((z * t) <= -500000000.0) {
tmp = t_1;
} else if ((z * t) <= 5e-115) {
tmp = fma(i, c, (a * b));
} else if ((z * t) <= 2e+93) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(b, a, Float64(y * x)) t_2 = fma(b, a, Float64(t * z)) tmp = 0.0 if (Float64(z * t) <= -2e+159) tmp = t_2; elseif (Float64(z * t) <= -500000000.0) tmp = t_1; elseif (Float64(z * t) <= 5e-115) tmp = fma(i, c, Float64(a * b)); elseif (Float64(z * t) <= 2e+93) tmp = t_1; else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -2e+159], t$95$2, If[LessEqual[N[(z * t), $MachinePrecision], -500000000.0], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 5e-115], N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+93], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, y \cdot x\right)\\
t_2 := \mathsf{fma}\left(b, a, t \cdot z\right)\\
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+159}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;z \cdot t \leq -500000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{-115}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+93}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 z t) < -1.9999999999999999e159 or 2.00000000000000009e93 < (*.f64 z t) Initial program 85.3%
Taylor expanded in c around 0
Applied rewrites84.5%
Taylor expanded in x around 0
Applied rewrites77.5%
if -1.9999999999999999e159 < (*.f64 z t) < -5e8 or 5.0000000000000003e-115 < (*.f64 z t) < 2.00000000000000009e93Initial program 89.8%
Taylor expanded in c around 0
Applied rewrites85.3%
Taylor expanded in x around inf
Applied rewrites73.2%
if -5e8 < (*.f64 z t) < 5.0000000000000003e-115Initial program 97.4%
Taylor expanded in a around inf
Applied rewrites70.6%
lift-+.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6472.3
Applied rewrites72.3%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* z t) -5e+71) (not (<= (* z t) 1e+56))) (fma b a (fma t z (* y x))) (fma i c (fma y x (* b a)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((z * t) <= -5e+71) || !((z * t) <= 1e+56)) {
tmp = fma(b, a, fma(t, z, (y * x)));
} else {
tmp = fma(i, c, fma(y, x, (b * a)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(z * t) <= -5e+71) || !(Float64(z * t) <= 1e+56)) tmp = fma(b, a, fma(t, z, Float64(y * x))); else tmp = fma(i, c, fma(y, x, Float64(b * a))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], -5e+71], N[Not[LessEqual[N[(z * t), $MachinePrecision], 1e+56]], $MachinePrecision]], N[(b * a + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(i * c + N[(y * x + N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+71} \lor \neg \left(z \cdot t \leq 10^{+56}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, \mathsf{fma}\left(y, x, b \cdot a\right)\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -4.99999999999999972e71 or 1.00000000000000009e56 < (*.f64 z t) Initial program 86.0%
Taylor expanded in c around 0
Applied rewrites85.3%
if -4.99999999999999972e71 < (*.f64 z t) < 1.00000000000000009e56Initial program 95.1%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6495.1
Applied rewrites95.1%
Taylor expanded in z around 0
Applied rewrites90.6%
lift-+.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6494.9
Applied rewrites94.9%
Final simplification91.4%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* z t) -5e+71) (not (<= (* z t) 1e+56))) (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+71) || !((z * t) <= 1e+56)) {
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+71) || !(Float64(z * t) <= 1e+56)) 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+71], N[Not[LessEqual[N[(z * t), $MachinePrecision], 1e+56]], $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^{+71} \lor \neg \left(z \cdot t \leq 10^{+56}\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.99999999999999972e71 or 1.00000000000000009e56 < (*.f64 z t) Initial program 86.0%
Taylor expanded in c around 0
Applied rewrites85.3%
if -4.99999999999999972e71 < (*.f64 z t) < 1.00000000000000009e56Initial program 95.1%
Taylor expanded in z around 0
Applied rewrites92.5%
Final simplification89.9%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* z t) -2e+159) (not (<= (* z t) 5e+101))) (fma i c (* t z)) (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) <= -2e+159) || !((z * t) <= 5e+101)) {
tmp = fma(i, c, (t * z));
} 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) <= -2e+159) || !(Float64(z * t) <= 5e+101)) tmp = fma(i, c, Float64(t * z)); 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], -2e+159], N[Not[LessEqual[N[(z * t), $MachinePrecision], 5e+101]], $MachinePrecision]], N[(i * c + N[(t * z), $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 -2 \cdot 10^{+159} \lor \neg \left(z \cdot t \leq 5 \cdot 10^{+101}\right):\\
\;\;\;\;\mathsf{fma}\left(i, c, t \cdot z\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) < -1.9999999999999999e159 or 4.99999999999999989e101 < (*.f64 z t) Initial program 84.6%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6489.7
Applied rewrites89.7%
Taylor expanded in z around inf
Applied rewrites77.8%
lift-+.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6480.4
Applied rewrites80.4%
if -1.9999999999999999e159 < (*.f64 z t) < 4.99999999999999989e101Initial program 94.9%
Taylor expanded in z around 0
Applied rewrites91.0%
Final simplification87.8%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* z t) -1e+24) (* t z) (if (<= (* z t) 0.0) (* b a) (if (<= (* z t) 1e+56) (* 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 ((z * t) <= -1e+24) {
tmp = t * z;
} else if ((z * t) <= 0.0) {
tmp = b * a;
} else if ((z * t) <= 1e+56) {
tmp = i * c;
} 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+24)) then
tmp = t * z
else if ((z * t) <= 0.0d0) then
tmp = b * a
else if ((z * t) <= 1d+56) then
tmp = i * c
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+24) {
tmp = t * z;
} else if ((z * t) <= 0.0) {
tmp = b * a;
} else if ((z * t) <= 1e+56) {
tmp = i * c;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (z * t) <= -1e+24: tmp = t * z elif (z * t) <= 0.0: tmp = b * a elif (z * t) <= 1e+56: tmp = i * c else: tmp = t * z return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -1e+24) tmp = Float64(t * z); elseif (Float64(z * t) <= 0.0) tmp = Float64(b * a); elseif (Float64(z * t) <= 1e+56) tmp = Float64(i * c); 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+24) tmp = t * z; elseif ((z * t) <= 0.0) tmp = b * a; elseif ((z * t) <= 1e+56) tmp = i * c; 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+24], N[(t * z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 0.0], N[(b * a), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1e+56], N[(i * c), $MachinePrecision], N[(t * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+24}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;z \cdot t \leq 0:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;z \cdot t \leq 10^{+56}:\\
\;\;\;\;i \cdot c\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (*.f64 z t) < -9.9999999999999998e23 or 1.00000000000000009e56 < (*.f64 z t) Initial program 86.4%
Taylor expanded in z around inf
Applied rewrites59.0%
if -9.9999999999999998e23 < (*.f64 z t) < -0.0Initial program 96.5%
Taylor expanded in a around inf
Applied rewrites45.4%
if -0.0 < (*.f64 z t) < 1.00000000000000009e56Initial program 94.1%
Taylor expanded in c around inf
Applied rewrites38.0%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* z t) -2e+159) (not (<= (* z t) 2e+93))) (fma b a (* t z)) (fma b a (* y x))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((z * t) <= -2e+159) || !((z * t) <= 2e+93)) {
tmp = fma(b, a, (t * z));
} else {
tmp = fma(b, a, (y * x));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(z * t) <= -2e+159) || !(Float64(z * t) <= 2e+93)) tmp = fma(b, a, Float64(t * z)); else tmp = fma(b, a, Float64(y * x)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], -2e+159], N[Not[LessEqual[N[(z * t), $MachinePrecision], 2e+93]], $MachinePrecision]], N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+159} \lor \neg \left(z \cdot t \leq 2 \cdot 10^{+93}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -1.9999999999999999e159 or 2.00000000000000009e93 < (*.f64 z t) Initial program 85.3%
Taylor expanded in c around 0
Applied rewrites84.5%
Taylor expanded in x around 0
Applied rewrites77.5%
if -1.9999999999999999e159 < (*.f64 z t) < 2.00000000000000009e93Initial program 94.8%
Taylor expanded in c around 0
Applied rewrites72.4%
Taylor expanded in x around inf
Applied rewrites66.6%
Final simplification70.1%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* x y) -4e+179) (not (<= (* x y) 2e+102))) (* 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+179) || !((x * y) <= 2e+102)) {
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+179) || !(Float64(x * y) <= 2e+102)) 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+179], N[Not[LessEqual[N[(x * y), $MachinePrecision], 2e+102]], $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^{+179} \lor \neg \left(x \cdot y \leq 2 \cdot 10^{+102}\right):\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -3.99999999999999992e179 or 1.99999999999999995e102 < (*.f64 x y) Initial program 85.7%
Taylor expanded in x around inf
Applied rewrites68.1%
if -3.99999999999999992e179 < (*.f64 x y) < 1.99999999999999995e102Initial program 94.7%
Taylor expanded in c around 0
Applied rewrites70.9%
Taylor expanded in x around 0
Applied rewrites62.4%
Final simplification64.3%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* a b) -4e+29) (not (<= (* a b) 1e+152))) (* 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) <= -4e+29) || !((a * b) <= 1e+152)) {
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) <= (-4d+29)) .or. (.not. ((a * b) <= 1d+152))) 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) <= -4e+29) || !((a * b) <= 1e+152)) {
tmp = b * a;
} else {
tmp = i * c;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if ((a * b) <= -4e+29) or not ((a * b) <= 1e+152): 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) <= -4e+29) || !(Float64(a * b) <= 1e+152)) 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) <= -4e+29) || ~(((a * b) <= 1e+152))) 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], -4e+29], N[Not[LessEqual[N[(a * b), $MachinePrecision], 1e+152]], $MachinePrecision]], N[(b * a), $MachinePrecision], N[(i * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+29} \lor \neg \left(a \cdot b \leq 10^{+152}\right):\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 a b) < -3.99999999999999966e29 or 1e152 < (*.f64 a b) Initial program 87.2%
Taylor expanded in a around inf
Applied rewrites50.5%
if -3.99999999999999966e29 < (*.f64 a b) < 1e152Initial program 94.8%
Taylor expanded in c around inf
Applied rewrites34.8%
Final simplification41.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 91.8%
Taylor expanded in a around inf
Applied rewrites25.4%
herbie shell --seed 2025026
(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)))