
(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 (fma i c (fma x y (fma z t (* a b)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(i, c, fma(x, y, fma(z, t, (a * b))));
}
function code(x, y, z, t, a, b, c, i) return fma(i, c, fma(x, y, fma(z, t, Float64(a * b)))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(i * c + N[(x * y + N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(i, c, \mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)\right)
\end{array}
Initial program 95.9%
Applied rewrites97.9%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* z t) -5e+164)
(fma a b (fma c i (* t z)))
(if (<= (* z t) 2e+138)
(fma a b (fma c i (* x y)))
(fma a b (fma z t (* c i))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((z * t) <= -5e+164) {
tmp = fma(a, b, fma(c, i, (t * z)));
} else if ((z * t) <= 2e+138) {
tmp = fma(a, b, fma(c, i, (x * y)));
} else {
tmp = fma(a, b, fma(z, t, (c * i)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -5e+164) tmp = fma(a, b, fma(c, i, Float64(t * z))); elseif (Float64(z * t) <= 2e+138) tmp = fma(a, b, fma(c, i, Float64(x * y))); else tmp = fma(a, b, fma(z, t, Float64(c * i))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -5e+164], N[(a * b + N[(c * i + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+138], N[(a * b + N[(c * i + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * b + N[(z * t + N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+164}:\\
\;\;\;\;\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, t \cdot z\right)\right)\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+138}:\\
\;\;\;\;\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, x \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, \mathsf{fma}\left(z, t, c \cdot i\right)\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -4.9999999999999995e164Initial program 95.9%
Taylor expanded in x around 0
Applied rewrites75.3%
if -4.9999999999999995e164 < (*.f64 z t) < 2.0000000000000001e138Initial program 95.9%
Taylor expanded in z around 0
Applied rewrites75.9%
if 2.0000000000000001e138 < (*.f64 z t) Initial program 95.9%
Taylor expanded in x around 0
Applied rewrites75.3%
Applied rewrites75.2%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma a b (fma c i (* t z)))))
(if (<= (* z t) -5e+164)
t_1
(if (<= (* z t) 2e+138) (fma a b (fma c i (* x y))) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(a, b, fma(c, i, (t * z)));
double tmp;
if ((z * t) <= -5e+164) {
tmp = t_1;
} else if ((z * t) <= 2e+138) {
tmp = fma(a, b, fma(c, i, (x * y)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(a, b, fma(c, i, Float64(t * z))) tmp = 0.0 if (Float64(z * t) <= -5e+164) tmp = t_1; elseif (Float64(z * t) <= 2e+138) tmp = fma(a, b, fma(c, i, Float64(x * y))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(a * b + N[(c * i + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -5e+164], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 2e+138], N[(a * b + N[(c * i + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, t \cdot z\right)\right)\\
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+164}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+138}:\\
\;\;\;\;\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, x \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -4.9999999999999995e164 or 2.0000000000000001e138 < (*.f64 z t) Initial program 95.9%
Taylor expanded in x around 0
Applied rewrites75.3%
if -4.9999999999999995e164 < (*.f64 z t) < 2.0000000000000001e138Initial program 95.9%
Taylor expanded in z around 0
Applied rewrites75.9%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* x y) -1.02e+300) (* x y) (if (<= (* x y) 1.9e+175) (fma a b (fma c i (* t z))) (* x y))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x * y) <= -1.02e+300) {
tmp = x * y;
} else if ((x * y) <= 1.9e+175) {
tmp = fma(a, b, fma(c, i, (t * z)));
} else {
tmp = x * y;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(x * y) <= -1.02e+300) tmp = Float64(x * y); elseif (Float64(x * y) <= 1.9e+175) tmp = fma(a, b, fma(c, i, Float64(t * z))); else tmp = Float64(x * y); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -1.02e+300], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1.9e+175], N[(a * b + N[(c * i + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1.02 \cdot 10^{+300}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq 1.9 \cdot 10^{+175}:\\
\;\;\;\;\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -1.02000000000000002e300 or 1.8999999999999998e175 < (*.f64 x y) Initial program 95.9%
Applied rewrites97.9%
Taylor expanded in z around 0
Applied rewrites76.0%
Taylor expanded in x around 0
Applied rewrites52.5%
Taylor expanded in x around inf
Applied rewrites27.5%
if -1.02000000000000002e300 < (*.f64 x y) < 1.8999999999999998e175Initial program 95.9%
Taylor expanded in x around 0
Applied rewrites75.3%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma c i (* t z))))
(if (<= (* z t) -2e+109)
t_1
(if (<= (* z t) 5e+153) (fma a b (* c i)) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(c, i, (t * z));
double tmp;
if ((z * t) <= -2e+109) {
tmp = t_1;
} else if ((z * t) <= 5e+153) {
tmp = fma(a, b, (c * i));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(c, i, Float64(t * z)) tmp = 0.0 if (Float64(z * t) <= -2e+109) tmp = t_1; elseif (Float64(z * t) <= 5e+153) tmp = fma(a, b, Float64(c * i)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(c * i + N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -2e+109], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 5e+153], N[(a * b + N[(c * i), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(c, i, t \cdot z\right)\\
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+109}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+153}:\\
\;\;\;\;\mathsf{fma}\left(a, b, c \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -1.99999999999999996e109 or 5.00000000000000018e153 < (*.f64 z t) Initial program 95.9%
Taylor expanded in a around 0
Applied rewrites74.7%
Taylor expanded in x around 0
Applied rewrites51.2%
if -1.99999999999999996e109 < (*.f64 z t) < 5.00000000000000018e153Initial program 95.9%
Taylor expanded in z around 0
Applied rewrites75.9%
Taylor expanded in x around 0
Applied rewrites52.5%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* z t) -1e+232) (* t z) (if (<= (* z t) 5e+153) (fma a b (* c i)) (* 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+232) {
tmp = t * z;
} else if ((z * t) <= 5e+153) {
tmp = fma(a, b, (c * i));
} else {
tmp = t * z;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -1e+232) tmp = Float64(t * z); elseif (Float64(z * t) <= 5e+153) tmp = fma(a, b, Float64(c * i)); else tmp = Float64(t * z); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -1e+232], N[(t * z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+153], N[(a * b + N[(c * i), $MachinePrecision]), $MachinePrecision], N[(t * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+232}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+153}:\\
\;\;\;\;\mathsf{fma}\left(a, b, c \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (*.f64 z t) < -1.00000000000000006e232 or 5.00000000000000018e153 < (*.f64 z t) Initial program 95.9%
Applied rewrites97.9%
Taylor expanded in z around 0
Applied rewrites76.0%
Taylor expanded in x around 0
Applied rewrites52.5%
Taylor expanded in z around inf
Applied rewrites26.8%
if -1.00000000000000006e232 < (*.f64 z t) < 5.00000000000000018e153Initial program 95.9%
Taylor expanded in z around 0
Applied rewrites75.9%
Taylor expanded in x around 0
Applied rewrites52.5%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* z t) -1e+156)
(* t z)
(if (<= (* z t) -2e-142)
(* x y)
(if (<= (* z t) 0.02) (* c i) (if (<= (* z t) 5e+209) (* x y) (* 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+156) {
tmp = t * z;
} else if ((z * t) <= -2e-142) {
tmp = x * y;
} else if ((z * t) <= 0.02) {
tmp = c * i;
} else if ((z * t) <= 5e+209) {
tmp = x * y;
} 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+156)) then
tmp = t * z
else if ((z * t) <= (-2d-142)) then
tmp = x * y
else if ((z * t) <= 0.02d0) then
tmp = c * i
else if ((z * t) <= 5d+209) then
tmp = x * y
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+156) {
tmp = t * z;
} else if ((z * t) <= -2e-142) {
tmp = x * y;
} else if ((z * t) <= 0.02) {
tmp = c * i;
} else if ((z * t) <= 5e+209) {
tmp = x * y;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (z * t) <= -1e+156: tmp = t * z elif (z * t) <= -2e-142: tmp = x * y elif (z * t) <= 0.02: tmp = c * i elif (z * t) <= 5e+209: tmp = x * y else: tmp = t * z return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -1e+156) tmp = Float64(t * z); elseif (Float64(z * t) <= -2e-142) tmp = Float64(x * y); elseif (Float64(z * t) <= 0.02) tmp = Float64(c * i); elseif (Float64(z * t) <= 5e+209) tmp = Float64(x * y); 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+156) tmp = t * z; elseif ((z * t) <= -2e-142) tmp = x * y; elseif ((z * t) <= 0.02) tmp = c * i; elseif ((z * t) <= 5e+209) tmp = x * y; 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+156], N[(t * z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], -2e-142], N[(x * y), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 0.02], N[(c * i), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+209], N[(x * y), $MachinePrecision], N[(t * z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+156}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;z \cdot t \leq -2 \cdot 10^{-142}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;z \cdot t \leq 0.02:\\
\;\;\;\;c \cdot i\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+209}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (*.f64 z t) < -9.9999999999999998e155 or 4.99999999999999964e209 < (*.f64 z t) Initial program 95.9%
Applied rewrites97.9%
Taylor expanded in z around 0
Applied rewrites76.0%
Taylor expanded in x around 0
Applied rewrites52.5%
Taylor expanded in z around inf
Applied rewrites26.8%
if -9.9999999999999998e155 < (*.f64 z t) < -2.0000000000000001e-142 or 0.0200000000000000004 < (*.f64 z t) < 4.99999999999999964e209Initial program 95.9%
Applied rewrites97.9%
Taylor expanded in z around 0
Applied rewrites76.0%
Taylor expanded in x around 0
Applied rewrites52.5%
Taylor expanded in x around inf
Applied rewrites27.5%
if -2.0000000000000001e-142 < (*.f64 z t) < 0.0200000000000000004Initial program 95.9%
Applied rewrites97.9%
Taylor expanded in z around 0
Applied rewrites76.0%
Taylor expanded in x around 0
Applied rewrites52.5%
Taylor expanded in c around inf
Applied rewrites27.5%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* z t) -5e+164) (* t z) (if (<= (* z t) 5e+153) (* c i) (* 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) <= -5e+164) {
tmp = t * z;
} else if ((z * t) <= 5e+153) {
tmp = c * i;
} 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) <= (-5d+164)) then
tmp = t * z
else if ((z * t) <= 5d+153) then
tmp = c * i
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) <= -5e+164) {
tmp = t * z;
} else if ((z * t) <= 5e+153) {
tmp = c * i;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (z * t) <= -5e+164: tmp = t * z elif (z * t) <= 5e+153: tmp = c * i else: tmp = t * z return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -5e+164) tmp = Float64(t * z); elseif (Float64(z * t) <= 5e+153) tmp = Float64(c * i); 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) <= -5e+164) tmp = t * z; elseif ((z * t) <= 5e+153) tmp = c * i; else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -5e+164], N[(t * z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+153], N[(c * i), $MachinePrecision], N[(t * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+164}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+153}:\\
\;\;\;\;c \cdot i\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (*.f64 z t) < -4.9999999999999995e164 or 5.00000000000000018e153 < (*.f64 z t) Initial program 95.9%
Applied rewrites97.9%
Taylor expanded in z around 0
Applied rewrites76.0%
Taylor expanded in x around 0
Applied rewrites52.5%
Taylor expanded in z around inf
Applied rewrites26.8%
if -4.9999999999999995e164 < (*.f64 z t) < 5.00000000000000018e153Initial program 95.9%
Applied rewrites97.9%
Taylor expanded in z around 0
Applied rewrites76.0%
Taylor expanded in x around 0
Applied rewrites52.5%
Taylor expanded in c around inf
Applied rewrites27.5%
(FPCore (x y z t a b c i) :precision binary64 (* c i))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 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 = 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 c * i;
}
def code(x, y, z, t, a, b, c, i): return c * i
function code(x, y, z, t, a, b, c, i) return Float64(c * i) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = c * i; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(c * i), $MachinePrecision]
\begin{array}{l}
\\
c \cdot i
\end{array}
Initial program 95.9%
Applied rewrites97.9%
Taylor expanded in z around 0
Applied rewrites76.0%
Taylor expanded in x around 0
Applied rewrites52.5%
Taylor expanded in c around inf
Applied rewrites27.5%
herbie shell --seed 2025161
(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)))