
(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 (fma i c (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) {
return fma(i, c, fma(b, a, fma(t, z, (y * x))));
}
function code(x, y, z, t, a, b, c, i) return fma(i, c, fma(b, a, fma(t, z, Float64(y * x)))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(i * c + N[(b * a + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(i, c, \mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\right)
\end{array}
Initial program 96.5%
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6498.8
Applied rewrites98.8%
(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 -5e+113)
t_1
(if (<= t_2 2e+35)
(fma i c (* a b))
(if (<= t_2 4e+289) (fma b a (* t z)) 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 <= -5e+113) {
tmp = t_1;
} else if (t_2 <= 2e+35) {
tmp = fma(i, c, (a * b));
} else if (t_2 <= 4e+289) {
tmp = fma(b, a, (t * z));
} 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 <= -5e+113) tmp = t_1; elseif (t_2 <= 2e+35) tmp = fma(i, c, Float64(a * b)); elseif (t_2 <= 4e+289) tmp = fma(b, a, Float64(t * z)); 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, -5e+113], t$95$1, If[LessEqual[t$95$2, 2e+35], N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 4e+289], N[(b * a + N[(t * z), $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 -5 \cdot 10^{+113}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+35}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+289}:\\
\;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (*.f64 x y) (*.f64 z t)) < -5e113 or 4.0000000000000002e289 < (+.f64 (*.f64 x y) (*.f64 z t)) Initial program 94.5%
Taylor expanded in c around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6493.9
Applied rewrites93.9%
Taylor expanded in a around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6486.9
Applied rewrites86.9%
if -5e113 < (+.f64 (*.f64 x y) (*.f64 z t)) < 1.9999999999999999e35Initial program 97.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6473.1
Applied rewrites73.1%
lift-+.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6473.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6473.1
Applied rewrites73.1%
if 1.9999999999999999e35 < (+.f64 (*.f64 x y) (*.f64 z t)) < 4.0000000000000002e289Initial program 98.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-*.f6485.5
Applied rewrites85.5%
Taylor expanded in x around 0
lower-*.f6466.7
Applied rewrites66.7%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma b a (* t z))))
(if (<= (* z t) -5e+91)
t_1
(if (<= (* z t) 1e-167)
(fma i c (* x y))
(if (<= (* z t) 2e+35) (fma i c (* a b)) 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, (t * z));
double tmp;
if ((z * t) <= -5e+91) {
tmp = t_1;
} else if ((z * t) <= 1e-167) {
tmp = fma(i, c, (x * y));
} else if ((z * t) <= 2e+35) {
tmp = fma(i, c, (a * b));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(b, a, Float64(t * z)) tmp = 0.0 if (Float64(z * t) <= -5e+91) tmp = t_1; elseif (Float64(z * t) <= 1e-167) tmp = fma(i, c, Float64(x * y)); elseif (Float64(z * t) <= 2e+35) tmp = fma(i, c, Float64(a * b)); 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[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -5e+91], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 1e-167], N[(i * c + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+35], N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, t \cdot z\right)\\
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+91}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 10^{-167}:\\
\;\;\;\;\mathsf{fma}\left(i, c, x \cdot y\right)\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+35}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -5.0000000000000002e91 or 1.9999999999999999e35 < (*.f64 z t) Initial program 94.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-*.f6489.0
Applied rewrites89.0%
Taylor expanded in x around 0
lower-*.f6475.9
Applied rewrites75.9%
if -5.0000000000000002e91 < (*.f64 z t) < 1e-167Initial program 98.2%
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
Taylor expanded in x around inf
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-*.f6482.3
Applied rewrites82.3%
if 1e-167 < (*.f64 z t) < 1.9999999999999999e35Initial program 97.2%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6478.4
Applied rewrites78.4%
lift-+.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6481.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6481.2
Applied rewrites81.2%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* a b) -2e+228) (not (<= (* a b) 5e+43))) (fma b a (fma t z (* y x))) (fma i c (fma x y (* z t)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((a * b) <= -2e+228) || !((a * b) <= 5e+43)) {
tmp = fma(b, a, fma(t, z, (y * x)));
} else {
tmp = fma(i, c, fma(x, y, (z * t)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(a * b) <= -2e+228) || !(Float64(a * b) <= 5e+43)) tmp = fma(b, a, fma(t, z, Float64(y * x))); else tmp = fma(i, c, fma(x, y, Float64(z * t))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -2e+228], N[Not[LessEqual[N[(a * b), $MachinePrecision], 5e+43]], $MachinePrecision]], N[(b * a + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(i * c + N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+228} \lor \neg \left(a \cdot b \leq 5 \cdot 10^{+43}\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(x, y, z \cdot t\right)\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -1.9999999999999998e228 or 5.0000000000000004e43 < (*.f64 a b) Initial program 90.6%
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-*.f6493.4
Applied rewrites93.4%
if -1.9999999999999998e228 < (*.f64 a b) < 5.0000000000000004e43Initial program 98.9%
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in a around 0
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6494.9
Applied rewrites94.9%
Final simplification94.4%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* c i) -1e-16) (not (<= (* c i) 5e+111))) (fma b a (fma i c (* y x))) (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 (((c * i) <= -1e-16) || !((c * i) <= 5e+111)) {
tmp = fma(b, a, fma(i, c, (y * x)));
} 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(c * i) <= -1e-16) || !(Float64(c * i) <= 5e+111)) tmp = fma(b, a, fma(i, c, Float64(y * x))); 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[Or[LessEqual[N[(c * i), $MachinePrecision], -1e-16], N[Not[LessEqual[N[(c * i), $MachinePrecision], 5e+111]], $MachinePrecision]], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -1 \cdot 10^{-16} \lor \neg \left(c \cdot i \leq 5 \cdot 10^{+111}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\end{array}
\end{array}
if (*.f64 c i) < -9.9999999999999998e-17 or 4.9999999999999997e111 < (*.f64 c i) Initial program 93.2%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.5
Applied rewrites90.5%
if -9.9999999999999998e-17 < (*.f64 c i) < 4.9999999999999997e111Initial program 98.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-*.f6495.9
Applied rewrites95.9%
Final simplification93.8%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* z t) -5e+168) (fma b a (* t z)) (if (<= (* z t) 5e+272) (fma b a (fma i c (* y x))) (fma t z (* y x)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((z * t) <= -5e+168) {
tmp = fma(b, a, (t * z));
} else if ((z * t) <= 5e+272) {
tmp = fma(b, a, fma(i, c, (y * x)));
} else {
tmp = fma(t, z, (y * x));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -5e+168) tmp = fma(b, a, Float64(t * z)); elseif (Float64(z * t) <= 5e+272) tmp = fma(b, a, fma(i, c, Float64(y * x))); else tmp = fma(t, z, Float64(y * x)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -5e+168], N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+272], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+168}:\\
\;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+272}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, z, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -4.99999999999999967e168Initial program 99.9%
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-*.f6496.1
Applied rewrites96.1%
Taylor expanded in x around 0
lower-*.f6492.8
Applied rewrites92.8%
if -4.99999999999999967e168 < (*.f64 z t) < 4.99999999999999973e272Initial program 97.6%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6489.9
Applied rewrites89.9%
if 4.99999999999999973e272 < (*.f64 z t) Initial program 81.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-*.f6495.5
Applied rewrites95.5%
Taylor expanded in a around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6495.5
Applied rewrites95.5%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* z t) -1e+138) (* t z) (if (<= (* z t) 1e-167) (* y x) (if (<= (* z t) 5e+272) (* 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 ((z * t) <= -1e+138) {
tmp = t * z;
} else if ((z * t) <= 1e-167) {
tmp = y * x;
} else if ((z * t) <= 5e+272) {
tmp = b * a;
} 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+138)) then
tmp = t * z
else if ((z * t) <= 1d-167) then
tmp = y * x
else if ((z * t) <= 5d+272) then
tmp = b * a
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+138) {
tmp = t * z;
} else if ((z * t) <= 1e-167) {
tmp = y * x;
} else if ((z * t) <= 5e+272) {
tmp = b * a;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (z * t) <= -1e+138: tmp = t * z elif (z * t) <= 1e-167: tmp = y * x elif (z * t) <= 5e+272: tmp = b * a else: tmp = t * z return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -1e+138) tmp = Float64(t * z); elseif (Float64(z * t) <= 1e-167) tmp = Float64(y * x); elseif (Float64(z * t) <= 5e+272) tmp = Float64(b * a); 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+138) tmp = t * z; elseif ((z * t) <= 1e-167) tmp = y * x; elseif ((z * t) <= 5e+272) tmp = b * a; 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+138], N[(t * z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1e-167], N[(y * x), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+272], N[(b * a), $MachinePrecision], N[(t * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+138}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;z \cdot t \leq 10^{-167}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+272}:\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (*.f64 z t) < -1e138 or 4.99999999999999973e272 < (*.f64 z t) Initial program 92.2%
Taylor expanded in z around inf
lower-*.f6479.7
Applied rewrites79.7%
if -1e138 < (*.f64 z t) < 1e-167Initial program 98.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6453.5
Applied rewrites53.5%
if 1e-167 < (*.f64 z t) < 4.99999999999999973e272Initial program 96.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6437.6
Applied rewrites37.6%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* c i) -1e+32) (* i c) (if (<= (* c i) 0.0) (* b a) (if (<= (* c i) 5e+111) (* t z) (* 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+32) {
tmp = i * c;
} else if ((c * i) <= 0.0) {
tmp = b * a;
} else if ((c * i) <= 5e+111) {
tmp = t * z;
} 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+32)) then
tmp = i * c
else if ((c * i) <= 0.0d0) then
tmp = b * a
else if ((c * i) <= 5d+111) then
tmp = t * z
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+32) {
tmp = i * c;
} else if ((c * i) <= 0.0) {
tmp = b * a;
} else if ((c * i) <= 5e+111) {
tmp = t * z;
} else {
tmp = i * c;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (c * i) <= -1e+32: tmp = i * c elif (c * i) <= 0.0: tmp = b * a elif (c * i) <= 5e+111: tmp = t * z else: tmp = i * c return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(c * i) <= -1e+32) tmp = Float64(i * c); elseif (Float64(c * i) <= 0.0) tmp = Float64(b * a); elseif (Float64(c * i) <= 5e+111) tmp = Float64(t * z); 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+32) tmp = i * c; elseif ((c * i) <= 0.0) tmp = b * a; elseif ((c * i) <= 5e+111) tmp = t * z; 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+32], N[(i * c), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 0.0], N[(b * a), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 5e+111], N[(t * z), $MachinePrecision], N[(i * c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+32}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;c \cdot i \leq 0:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{+111}:\\
\;\;\;\;t \cdot z\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 c i) < -1.00000000000000005e32 or 4.9999999999999997e111 < (*.f64 c i) Initial program 92.4%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6460.9
Applied rewrites60.9%
if -1.00000000000000005e32 < (*.f64 c i) < -0.0Initial program 99.1%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6434.7
Applied rewrites34.7%
if -0.0 < (*.f64 c i) < 4.9999999999999997e111Initial program 98.1%
Taylor expanded in z around inf
lower-*.f6443.1
Applied rewrites43.1%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* a b) -2e+157) (not (<= (* a b) 2e-34))) (fma b a (* x y)) (fma t z (* y x))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((a * b) <= -2e+157) || !((a * b) <= 2e-34)) {
tmp = fma(b, a, (x * y));
} else {
tmp = fma(t, z, (y * x));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(a * b) <= -2e+157) || !(Float64(a * b) <= 2e-34)) tmp = fma(b, a, Float64(x * y)); else tmp = fma(t, z, Float64(y * x)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -2e+157], N[Not[LessEqual[N[(a * b), $MachinePrecision], 2e-34]], $MachinePrecision]], N[(b * a + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+157} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{-34}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, z, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -1.99999999999999997e157 or 1.99999999999999986e-34 < (*.f64 a b) Initial program 93.1%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6485.7
Applied rewrites85.7%
Taylor expanded in x around inf
lower-*.f6472.9
Applied rewrites72.9%
if -1.99999999999999997e157 < (*.f64 a b) < 1.99999999999999986e-34Initial program 98.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-*.f6472.5
Applied rewrites72.5%
Taylor expanded in a around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6470.4
Applied rewrites70.4%
Final simplification71.4%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* a b) -2e+228) (not (<= (* a b) 5e+153))) (* b a) (fma t z (* y x))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((a * b) <= -2e+228) || !((a * b) <= 5e+153)) {
tmp = b * a;
} else {
tmp = fma(t, z, (y * x));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(a * b) <= -2e+228) || !(Float64(a * b) <= 5e+153)) tmp = Float64(b * a); else tmp = fma(t, z, Float64(y * x)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -2e+228], N[Not[LessEqual[N[(a * b), $MachinePrecision], 5e+153]], $MachinePrecision]], N[(b * a), $MachinePrecision], N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+228} \lor \neg \left(a \cdot b \leq 5 \cdot 10^{+153}\right):\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, z, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -1.9999999999999998e228 or 5.00000000000000018e153 < (*.f64 a b) Initial program 88.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6477.2
Applied rewrites77.2%
if -1.9999999999999998e228 < (*.f64 a b) < 5.00000000000000018e153Initial program 98.9%
Taylor expanded in c around 0
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6472.7
Applied rewrites72.7%
Taylor expanded in a around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6467.1
Applied rewrites67.1%
Final simplification69.6%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* a b) -2e+228) (fma b a (* t z)) (if (<= (* a b) 2e-34) (fma t z (* y x)) (fma b a (* x y)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((a * b) <= -2e+228) {
tmp = fma(b, a, (t * z));
} else if ((a * b) <= 2e-34) {
tmp = fma(t, z, (y * x));
} else {
tmp = fma(b, a, (x * y));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(a * b) <= -2e+228) tmp = fma(b, a, Float64(t * z)); elseif (Float64(a * b) <= 2e-34) tmp = fma(t, z, Float64(y * x)); else tmp = fma(b, a, Float64(x * y)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(a * b), $MachinePrecision], -2e+228], N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2e-34], N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+228}:\\
\;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\
\mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-34}:\\
\;\;\;\;\mathsf{fma}\left(t, z, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, x \cdot y\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -1.9999999999999998e228Initial program 74.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-*.f6488.9
Applied rewrites88.9%
Taylor expanded in x around 0
lower-*.f6485.2
Applied rewrites85.2%
if -1.9999999999999998e228 < (*.f64 a b) < 1.99999999999999986e-34Initial program 98.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-*.f6472.0
Applied rewrites72.0%
Taylor expanded in a around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6470.1
Applied rewrites70.1%
if 1.99999999999999986e-34 < (*.f64 a b) Initial program 100.0%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6486.0
Applied rewrites86.0%
Taylor expanded in x around inf
lower-*.f6472.3
Applied rewrites72.3%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* a b) -2e+228) (not (<= (* a b) 5e+43))) (* 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) <= -2e+228) || !((a * b) <= 5e+43)) {
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) <= (-2d+228)) .or. (.not. ((a * b) <= 5d+43))) 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) <= -2e+228) || !((a * b) <= 5e+43)) {
tmp = b * a;
} else {
tmp = i * c;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if ((a * b) <= -2e+228) or not ((a * b) <= 5e+43): 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) <= -2e+228) || !(Float64(a * b) <= 5e+43)) 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) <= -2e+228) || ~(((a * b) <= 5e+43))) 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], -2e+228], N[Not[LessEqual[N[(a * b), $MachinePrecision], 5e+43]], $MachinePrecision]], N[(b * a), $MachinePrecision], N[(i * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+228} \lor \neg \left(a \cdot b \leq 5 \cdot 10^{+43}\right):\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 a b) < -1.9999999999999998e228 or 5.0000000000000004e43 < (*.f64 a b) Initial program 90.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6470.3
Applied rewrites70.3%
if -1.9999999999999998e228 < (*.f64 a b) < 5.0000000000000004e43Initial program 98.9%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6431.8
Applied rewrites31.8%
Final simplification43.1%
(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.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6425.2
Applied rewrites25.2%
herbie shell --seed 2025051
(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)))