
(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 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
code = (((x * y) + (z * t)) + (a * b)) + (c * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
def code(x, y, z, t, a, b, c, i): return (((x * y) + (z * t)) + (a * b)) + (c * i)
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (((x * y) + (z * t)) + (a * b)) + (c * i); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\end{array}
(FPCore (x y z t a b c i) :precision binary64 (if (<= (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)) 1e+308) (+ (fma y x (fma b a (* t z))) (* c i)) (* (+ (/ (fma i c (fma t z (* y x))) a) b) a)))
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)) <= 1e+308) {
tmp = fma(y, x, fma(b, a, (t * z))) + (c * i);
} else {
tmp = ((fma(i, c, fma(t, z, (y * x))) / a) + b) * a;
}
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)) <= 1e+308) tmp = Float64(fma(y, x, fma(b, a, Float64(t * z))) + Float64(c * i)); else tmp = Float64(Float64(Float64(fma(i, c, fma(t, z, Float64(y * x))) / a) + b) * a); 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], 1e+308], N[(N[(y * x + N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(i * c + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] + b), $MachinePrecision] * a), $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 10^{+308}:\\
\;\;\;\;\mathsf{fma}\left(y, x, \mathsf{fma}\left(b, a, t \cdot z\right)\right) + c \cdot i\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(i, c, \mathsf{fma}\left(t, z, y \cdot x\right)\right)}{a} + b\right) \cdot a\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i)) < 1e308Initial 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 1e308 < (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i)) Initial program 82.1%
Taylor expanded in a around inf
*-commutativeN/A
div-add-revN/A
div-addN/A
lower-*.f64N/A
Applied rewrites91.2%
(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 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 (((((x * y) + (z * t)) + (a * b)) + (c * i)) <= ((double) INFINITY)) {
tmp = fma(y, x, fma(b, a, (t * z))) + (c * i);
} else {
tmp = fma(i, c, (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(i, c, 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[(i * c + N[(y * x), $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(i, c, y \cdot x\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 x around inf
*-commutativeN/A
lower-*.f6435.5
Applied rewrites35.5%
lift-+.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6444.1
+-commutative44.1
*-commutative44.1
*-commutative44.1
*-commutative44.1
+-commutative44.1
Applied rewrites44.1%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma t z (* y x))))
(if (<= (* c i) -1e+162)
(* i c)
(if (<= (* c i) -1e-107)
t_1
(if (<= (* c i) 1e-67)
(fma z t (* a b))
(if (<= (* c i) 2e+76) t_1 (* i c)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(t, z, (y * x));
double tmp;
if ((c * i) <= -1e+162) {
tmp = i * c;
} else if ((c * i) <= -1e-107) {
tmp = t_1;
} else if ((c * i) <= 1e-67) {
tmp = fma(z, t, (a * b));
} else if ((c * i) <= 2e+76) {
tmp = t_1;
} else {
tmp = i * c;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(t, z, Float64(y * x)) tmp = 0.0 if (Float64(c * i) <= -1e+162) tmp = Float64(i * c); elseif (Float64(c * i) <= -1e-107) tmp = t_1; elseif (Float64(c * i) <= 1e-67) tmp = fma(z, t, Float64(a * b)); elseif (Float64(c * i) <= 2e+76) tmp = t_1; else tmp = Float64(i * c); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(c * i), $MachinePrecision], -1e+162], N[(i * c), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -1e-107], t$95$1, If[LessEqual[N[(c * i), $MachinePrecision], 1e-67], N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 2e+76], t$95$1, N[(i * c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, z, y \cdot x\right)\\
\mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+162}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;c \cdot i \leq -1 \cdot 10^{-107}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \cdot i \leq 10^{-67}:\\
\;\;\;\;\mathsf{fma}\left(z, t, a \cdot b\right)\\
\mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+76}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 c i) < -9.9999999999999994e161 or 2.0000000000000001e76 < (*.f64 c i) Initial program 92.3%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6464.2
Applied rewrites64.2%
if -9.9999999999999994e161 < (*.f64 c i) < -1e-107 or 9.99999999999999943e-68 < (*.f64 c i) < 2.0000000000000001e76Initial program 98.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-*.f6484.0
Applied rewrites84.0%
Taylor expanded in a around 0
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6457.2
Applied rewrites57.2%
if -1e-107 < (*.f64 c i) < 9.99999999999999943e-68Initial program 97.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6466.1
Applied rewrites66.1%
Taylor expanded in c around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6464.6
Applied rewrites64.6%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* c i) -4e+86)
(* i c)
(if (<= (* c i) -2e-192)
(* y x)
(if (<= (* c i) 5e-69) (* b a) (if (<= (* c i) 2e+76) (* y x) (* i c))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c * i) <= -4e+86) {
tmp = i * c;
} else if ((c * i) <= -2e-192) {
tmp = y * x;
} else if ((c * i) <= 5e-69) {
tmp = b * a;
} else if ((c * i) <= 2e+76) {
tmp = y * x;
} else {
tmp = i * c;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
real(8) :: tmp
if ((c * i) <= (-4d+86)) then
tmp = i * c
else if ((c * i) <= (-2d-192)) then
tmp = y * x
else if ((c * i) <= 5d-69) then
tmp = b * a
else if ((c * i) <= 2d+76) then
tmp = y * x
else
tmp = i * c
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c * i) <= -4e+86) {
tmp = i * c;
} else if ((c * i) <= -2e-192) {
tmp = y * x;
} else if ((c * i) <= 5e-69) {
tmp = b * a;
} else if ((c * i) <= 2e+76) {
tmp = y * x;
} else {
tmp = i * c;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (c * i) <= -4e+86: tmp = i * c elif (c * i) <= -2e-192: tmp = y * x elif (c * i) <= 5e-69: tmp = b * a elif (c * i) <= 2e+76: tmp = y * x else: tmp = i * c return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(c * i) <= -4e+86) tmp = Float64(i * c); elseif (Float64(c * i) <= -2e-192) tmp = Float64(y * x); elseif (Float64(c * i) <= 5e-69) tmp = Float64(b * a); elseif (Float64(c * i) <= 2e+76) tmp = Float64(y * x); else tmp = Float64(i * c); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((c * i) <= -4e+86) tmp = i * c; elseif ((c * i) <= -2e-192) tmp = y * x; elseif ((c * i) <= 5e-69) tmp = b * a; elseif ((c * i) <= 2e+76) tmp = y * x; else tmp = i * c; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -4e+86], N[(i * c), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -2e-192], N[(y * x), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 5e-69], N[(b * a), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 2e+76], N[(y * x), $MachinePrecision], N[(i * c), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -4 \cdot 10^{+86}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;c \cdot i \leq -2 \cdot 10^{-192}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{-69}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+76}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 c i) < -4.0000000000000001e86 or 2.0000000000000001e76 < (*.f64 c i) Initial program 92.9%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6460.3
Applied rewrites60.3%
if -4.0000000000000001e86 < (*.f64 c i) < -2.0000000000000002e-192 or 5.00000000000000033e-69 < (*.f64 c i) < 2.0000000000000001e76Initial program 97.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6432.1
Applied rewrites32.1%
if -2.0000000000000002e-192 < (*.f64 c i) < 5.00000000000000033e-69Initial program 97.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6433.8
Applied rewrites33.8%
(FPCore (x y z t a b c i) :precision binary64 (let* ((t_1 (fma y x (* t z))) (t_2 (+ (* x y) (* z t)))) (if (<= t_2 -2e+121) t_1 (if (<= t_2 1e+212) (fma b a (* i c)) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(y, x, (t * z));
double t_2 = (x * y) + (z * t);
double tmp;
if (t_2 <= -2e+121) {
tmp = t_1;
} else if (t_2 <= 1e+212) {
tmp = fma(b, a, (i * c));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(y, x, Float64(t * z)) t_2 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if (t_2 <= -2e+121) tmp = t_1; elseif (t_2 <= 1e+212) tmp = fma(b, a, Float64(i * c)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(y * x + N[(t * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+121], t$95$1, If[LessEqual[t$95$2, 1e+212], N[(b * a + N[(i * c), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, x, t \cdot z\right)\\
t_2 := x \cdot y + z \cdot t\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+121}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 10^{+212}:\\
\;\;\;\;\mathsf{fma}\left(b, a, i \cdot c\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (*.f64 x y) (*.f64 z t)) < -2.00000000000000007e121 or 9.9999999999999991e211 < (+.f64 (*.f64 x y) (*.f64 z t)) Initial program 92.4%
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.7
Applied rewrites87.7%
lift-fma.f64N/A
*-commutativeN/A
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6487.6
Applied rewrites87.6%
Taylor expanded in z around inf
lift-*.f6478.5
Applied rewrites78.5%
if -2.00000000000000007e121 < (+.f64 (*.f64 x y) (*.f64 z t)) < 9.9999999999999991e211Initial program 99.1%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6485.6
Applied rewrites85.6%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f6472.9
Applied rewrites72.9%
(FPCore (x y z t a b c i) :precision binary64 (let* ((t_1 (fma t z (* y x))) (t_2 (+ (* x y) (* z t)))) (if (<= t_2 -2e+121) t_1 (if (<= t_2 1e+212) (fma b a (* i c)) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(t, z, (y * x));
double t_2 = (x * y) + (z * t);
double tmp;
if (t_2 <= -2e+121) {
tmp = t_1;
} else if (t_2 <= 1e+212) {
tmp = fma(b, a, (i * c));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(t, z, Float64(y * x)) t_2 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if (t_2 <= -2e+121) tmp = t_1; elseif (t_2 <= 1e+212) tmp = fma(b, a, Float64(i * c)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+121], t$95$1, If[LessEqual[t$95$2, 1e+212], N[(b * a + N[(i * c), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, z, y \cdot x\right)\\
t_2 := x \cdot y + z \cdot t\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+121}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 10^{+212}:\\
\;\;\;\;\mathsf{fma}\left(b, a, i \cdot c\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (*.f64 x y) (*.f64 z t)) < -2.00000000000000007e121 or 9.9999999999999991e211 < (+.f64 (*.f64 x y) (*.f64 z t)) Initial program 92.4%
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.7
Applied rewrites87.7%
Taylor expanded in a around 0
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6478.7
Applied rewrites78.7%
if -2.00000000000000007e121 < (+.f64 (*.f64 x y) (*.f64 z t)) < 9.9999999999999991e211Initial program 99.1%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6485.6
Applied rewrites85.6%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f6472.9
Applied rewrites72.9%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma b a (fma i c (* t z)))))
(if (<= (* c i) -1e+113)
t_1
(if (<= (* c i) 2e+71) (fma b a (fma t z (* y x))) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(b, a, fma(i, c, (t * z)));
double tmp;
if ((c * i) <= -1e+113) {
tmp = t_1;
} else if ((c * i) <= 2e+71) {
tmp = fma(b, a, fma(t, z, (y * x)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(b, a, fma(i, c, Float64(t * z))) tmp = 0.0 if (Float64(c * i) <= -1e+113) tmp = t_1; elseif (Float64(c * i) <= 2e+71) tmp = fma(b, a, fma(t, z, Float64(y * x))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(c * i), $MachinePrecision], -1e+113], t$95$1, If[LessEqual[N[(c * i), $MachinePrecision], 2e+71], N[(b * a + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+113}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+71}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 c i) < -1e113 or 2.0000000000000001e71 < (*.f64 c i) Initial program 92.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6485.7
Applied rewrites85.7%
if -1e113 < (*.f64 c i) < 2.0000000000000001e71Initial program 97.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-*.f6492.3
Applied rewrites92.3%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* x y) -2e+84) (fma y x (* t z)) (if (<= (* x y) 1e+234) (fma b a (fma i c (* 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 ((x * y) <= -2e+84) {
tmp = fma(y, x, (t * z));
} else if ((x * y) <= 1e+234) {
tmp = fma(b, a, fma(i, c, (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(x * y) <= -2e+84) tmp = fma(y, x, Float64(t * z)); elseif (Float64(x * y) <= 1e+234) tmp = fma(b, a, fma(i, c, 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[LessEqual[N[(x * y), $MachinePrecision], -2e+84], N[(y * x + N[(t * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e+234], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+84}:\\
\;\;\;\;\mathsf{fma}\left(y, x, t \cdot z\right)\\
\mathbf{elif}\;x \cdot y \leq 10^{+234}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -2.00000000000000012e84Initial program 93.3%
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-*.f6484.9
Applied rewrites84.9%
lift-fma.f64N/A
*-commutativeN/A
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6485.1
Applied rewrites85.1%
Taylor expanded in z around inf
lift-*.f6473.8
Applied rewrites73.8%
if -2.00000000000000012e84 < (*.f64 x y) < 1.00000000000000002e234Initial program 97.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6488.6
Applied rewrites88.6%
if 1.00000000000000002e234 < (*.f64 x y) Initial program 88.7%
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.7
Applied rewrites90.7%
Taylor expanded in x around inf
*-commutativeN/A
lift-*.f6486.0
Applied rewrites86.0%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* c i) -1e+58) (* i c) (if (<= (* c i) -1e-107) (* t z) (if (<= (* c i) 5e+124) (* b a) (* i c)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c * i) <= -1e+58) {
tmp = i * c;
} else if ((c * i) <= -1e-107) {
tmp = t * z;
} else if ((c * i) <= 5e+124) {
tmp = b * a;
} else {
tmp = i * c;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
real(8) :: tmp
if ((c * i) <= (-1d+58)) then
tmp = i * c
else if ((c * i) <= (-1d-107)) then
tmp = t * z
else if ((c * i) <= 5d+124) then
tmp = b * a
else
tmp = i * c
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c * i) <= -1e+58) {
tmp = i * c;
} else if ((c * i) <= -1e-107) {
tmp = t * z;
} else if ((c * i) <= 5e+124) {
tmp = b * a;
} else {
tmp = i * c;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (c * i) <= -1e+58: tmp = i * c elif (c * i) <= -1e-107: tmp = t * z elif (c * i) <= 5e+124: tmp = b * a else: tmp = i * c return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(c * i) <= -1e+58) tmp = Float64(i * c); elseif (Float64(c * i) <= -1e-107) tmp = Float64(t * z); elseif (Float64(c * i) <= 5e+124) tmp = Float64(b * a); else tmp = Float64(i * c); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((c * i) <= -1e+58) tmp = i * c; elseif ((c * i) <= -1e-107) tmp = t * z; elseif ((c * i) <= 5e+124) tmp = b * a; else tmp = i * c; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -1e+58], N[(i * c), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -1e-107], N[(t * z), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 5e+124], N[(b * a), $MachinePrecision], N[(i * c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+58}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;c \cdot i \leq -1 \cdot 10^{-107}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{+124}:\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 c i) < -9.99999999999999944e57 or 4.9999999999999996e124 < (*.f64 c i) Initial program 92.7%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6461.3
Applied rewrites61.3%
if -9.99999999999999944e57 < (*.f64 c i) < -1e-107Initial program 98.1%
Taylor expanded in z around inf
lower-*.f6431.5
Applied rewrites31.5%
if -1e-107 < (*.f64 c i) < 4.9999999999999996e124Initial program 97.8%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6433.5
Applied rewrites33.5%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* c i) (- INFINITY)) (* i c) (if (<= (* c i) 5e+124) (fma z t (* a b)) (* i c))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c * i) <= -((double) INFINITY)) {
tmp = i * c;
} else if ((c * i) <= 5e+124) {
tmp = fma(z, t, (a * b));
} else {
tmp = i * c;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(c * i) <= Float64(-Inf)) tmp = Float64(i * c); elseif (Float64(c * i) <= 5e+124) tmp = fma(z, t, Float64(a * b)); else tmp = Float64(i * c); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], (-Infinity)], N[(i * c), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 5e+124], N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision], N[(i * c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -\infty:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{+124}:\\
\;\;\;\;\mathsf{fma}\left(z, t, a \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 c i) < -inf.0 or 4.9999999999999996e124 < (*.f64 c i) Initial program 89.8%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6473.2
Applied rewrites73.2%
if -inf.0 < (*.f64 c i) < 4.9999999999999996e124Initial program 97.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6470.5
Applied rewrites70.5%
Taylor expanded in c around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6458.1
Applied rewrites58.1%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* c i) -1e+58) (* i c) (if (<= (* c i) 5e+124) (* b a) (* i c))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c * i) <= -1e+58) {
tmp = i * c;
} else if ((c * i) <= 5e+124) {
tmp = b * a;
} else {
tmp = i * c;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
real(8) :: tmp
if ((c * i) <= (-1d+58)) then
tmp = i * c
else if ((c * i) <= 5d+124) then
tmp = b * a
else
tmp = i * c
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c * i) <= -1e+58) {
tmp = i * c;
} else if ((c * i) <= 5e+124) {
tmp = b * a;
} else {
tmp = i * c;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (c * i) <= -1e+58: tmp = i * c elif (c * i) <= 5e+124: tmp = b * a else: tmp = i * c return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(c * i) <= -1e+58) tmp = Float64(i * c); elseif (Float64(c * i) <= 5e+124) tmp = Float64(b * a); else tmp = Float64(i * c); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((c * i) <= -1e+58) tmp = i * c; elseif ((c * i) <= 5e+124) tmp = b * a; else tmp = i * c; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -1e+58], N[(i * c), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 5e+124], N[(b * a), $MachinePrecision], N[(i * c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+58}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{+124}:\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 c i) < -9.99999999999999944e57 or 4.9999999999999996e124 < (*.f64 c i) Initial program 92.7%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6461.3
Applied rewrites61.3%
if -9.99999999999999944e57 < (*.f64 c i) < 4.9999999999999996e124Initial program 97.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6433.0
Applied rewrites33.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 96.0%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6427.5
Applied rewrites27.5%
herbie shell --seed 2025095
(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)))