
(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 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 (fma z t (fma y x (fma i c (* b a)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(z, t, fma(y, x, fma(i, c, (b * a))));
}
function code(x, y, z, t, a, b, c, i) return fma(z, t, fma(y, x, fma(i, c, Float64(b * a)))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(z * t + N[(y * x + N[(i * c + N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, t, \mathsf{fma}\left(y, x, \mathsf{fma}\left(i, c, b \cdot a\right)\right)\right)
\end{array}
Initial program 91.8%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
remove-double-negN/A
lift-*.f64N/A
associate-+r+N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites95.7%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* z t) -2e+159)
(* t z)
(if (<= (* z t) -2e-7)
(* y x)
(if (<= (* z t) 0.0)
(* b a)
(if (<= (* z t) 2e-145)
(* i c)
(if (<= (* z t) 2e+93) (* y x) (* t z)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((z * t) <= -2e+159) {
tmp = t * z;
} else if ((z * t) <= -2e-7) {
tmp = y * x;
} else if ((z * t) <= 0.0) {
tmp = b * a;
} else if ((z * t) <= 2e-145) {
tmp = i * c;
} else if ((z * t) <= 2e+93) {
tmp = y * x;
} else {
tmp = t * z;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
real(8) :: tmp
if ((z * t) <= (-2d+159)) then
tmp = t * z
else if ((z * t) <= (-2d-7)) then
tmp = y * x
else if ((z * t) <= 0.0d0) then
tmp = b * a
else if ((z * t) <= 2d-145) then
tmp = i * c
else if ((z * t) <= 2d+93) then
tmp = y * x
else
tmp = t * z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((z * t) <= -2e+159) {
tmp = t * z;
} else if ((z * t) <= -2e-7) {
tmp = y * x;
} else if ((z * t) <= 0.0) {
tmp = b * a;
} else if ((z * t) <= 2e-145) {
tmp = i * c;
} else if ((z * t) <= 2e+93) {
tmp = y * x;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (z * t) <= -2e+159: tmp = t * z elif (z * t) <= -2e-7: tmp = y * x elif (z * t) <= 0.0: tmp = b * a elif (z * t) <= 2e-145: tmp = i * c elif (z * t) <= 2e+93: tmp = y * x else: tmp = t * z return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -2e+159) tmp = Float64(t * z); elseif (Float64(z * t) <= -2e-7) tmp = Float64(y * x); elseif (Float64(z * t) <= 0.0) tmp = Float64(b * a); elseif (Float64(z * t) <= 2e-145) tmp = Float64(i * c); elseif (Float64(z * t) <= 2e+93) tmp = Float64(y * x); else tmp = Float64(t * z); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((z * t) <= -2e+159) tmp = t * z; elseif ((z * t) <= -2e-7) tmp = y * x; elseif ((z * t) <= 0.0) tmp = b * a; elseif ((z * t) <= 2e-145) tmp = i * c; elseif ((z * t) <= 2e+93) tmp = y * x; else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -2e+159], N[(t * z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], -2e-7], N[(y * x), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 0.0], N[(b * a), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e-145], N[(i * c), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+93], N[(y * x), $MachinePrecision], N[(t * z), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+159}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;z \cdot t \leq -2 \cdot 10^{-7}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;z \cdot t \leq 0:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{-145}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+93}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (*.f64 z t) < -1.9999999999999999e159 or 2.00000000000000009e93 < (*.f64 z t) Initial program 85.3%
Taylor expanded in z around inf
lower-*.f6468.2
Applied rewrites68.2%
if -1.9999999999999999e159 < (*.f64 z t) < -1.9999999999999999e-7 or 1.99999999999999983e-145 < (*.f64 z t) < 2.00000000000000009e93Initial program 90.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6451.0
Applied rewrites51.0%
if -1.9999999999999999e-7 < (*.f64 z t) < -0.0Initial program 97.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6446.2
Applied rewrites46.2%
if -0.0 < (*.f64 z t) < 1.99999999999999983e-145Initial program 96.8%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6459.4
Applied rewrites59.4%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma i c (* x y))) (t_2 (fma z t (* c i))))
(if (<= (* z t) -2e+159)
t_2
(if (<= (* z t) -2e-7)
t_1
(if (<= (* z t) 2e-265)
(fma i c (* a b))
(if (<= (* z t) 5e+49) t_1 t_2))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(i, c, (x * y));
double t_2 = fma(z, t, (c * i));
double tmp;
if ((z * t) <= -2e+159) {
tmp = t_2;
} else if ((z * t) <= -2e-7) {
tmp = t_1;
} else if ((z * t) <= 2e-265) {
tmp = fma(i, c, (a * b));
} else if ((z * t) <= 5e+49) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(i, c, Float64(x * y)) t_2 = fma(z, t, Float64(c * i)) tmp = 0.0 if (Float64(z * t) <= -2e+159) tmp = t_2; elseif (Float64(z * t) <= -2e-7) tmp = t_1; elseif (Float64(z * t) <= 2e-265) tmp = fma(i, c, Float64(a * b)); elseif (Float64(z * t) <= 5e+49) tmp = t_1; else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(i * c + N[(x * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(z * t + N[(c * i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -2e+159], t$95$2, If[LessEqual[N[(z * t), $MachinePrecision], -2e-7], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 2e-265], N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+49], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(i, c, x \cdot y\right)\\
t_2 := \mathsf{fma}\left(z, t, c \cdot i\right)\\
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+159}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;z \cdot t \leq -2 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{-265}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+49}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 z t) < -1.9999999999999999e159 or 5.0000000000000004e49 < (*.f64 z t) Initial program 85.8%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
remove-double-negN/A
lift-*.f64N/A
associate-+r+N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites91.8%
Taylor expanded in c around inf
lower-*.f6478.6
Applied rewrites78.6%
if -1.9999999999999999e159 < (*.f64 z t) < -1.9999999999999999e-7 or 1.99999999999999997e-265 < (*.f64 z t) < 5.0000000000000004e49Initial program 92.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6469.6
Applied rewrites69.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6473.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6473.1
Applied rewrites73.1%
if -1.9999999999999999e-7 < (*.f64 z t) < 1.99999999999999997e-265Initial program 97.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6472.0
Applied rewrites72.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6474.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6474.4
Applied rewrites74.4%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma i c (* a b))))
(if (<= (* a b) -5e+67)
t_1
(if (<= (* a b) -1e+33)
(* t z)
(if (<= (* a b) 5e+41) (fma i c (* 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(i, c, (a * b));
double tmp;
if ((a * b) <= -5e+67) {
tmp = t_1;
} else if ((a * b) <= -1e+33) {
tmp = t * z;
} else if ((a * b) <= 5e+41) {
tmp = fma(i, c, (x * y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(i, c, Float64(a * b)) tmp = 0.0 if (Float64(a * b) <= -5e+67) tmp = t_1; elseif (Float64(a * b) <= -1e+33) tmp = Float64(t * z); elseif (Float64(a * b) <= 5e+41) tmp = fma(i, c, 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[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -5e+67], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], -1e+33], N[(t * z), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 5e+41], N[(i * c + N[(x * y), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(i, c, a \cdot b\right)\\
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+67}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{+33}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{+41}:\\
\;\;\;\;\mathsf{fma}\left(i, c, x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 a b) < -4.99999999999999976e67 or 5.00000000000000022e41 < (*.f64 a b) Initial program 86.1%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6465.0
Applied rewrites65.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6469.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.7
Applied rewrites69.7%
if -4.99999999999999976e67 < (*.f64 a b) < -9.9999999999999995e32Initial program 100.0%
Taylor expanded in z around inf
lower-*.f6487.6
Applied rewrites87.6%
if -9.9999999999999995e32 < (*.f64 a b) < 5.00000000000000022e41Initial program 95.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6468.8
Applied rewrites68.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6470.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.3
Applied rewrites70.3%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* z t) -2e+159) (not (<= (* z t) 5e+49))) (fma b a (fma t z (* i c))) (fma b a (fma i c (* y x)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((z * t) <= -2e+159) || !((z * t) <= 5e+49)) {
tmp = fma(b, a, fma(t, z, (i * c)));
} else {
tmp = fma(b, a, fma(i, c, (y * x)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(z * t) <= -2e+159) || !(Float64(z * t) <= 5e+49)) tmp = fma(b, a, fma(t, z, Float64(i * c))); else tmp = fma(b, a, fma(i, c, Float64(y * x))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], -2e+159], N[Not[LessEqual[N[(z * t), $MachinePrecision], 5e+49]], $MachinePrecision]], N[(b * a + N[(t * z + N[(i * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+159} \lor \neg \left(z \cdot t \leq 5 \cdot 10^{+49}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, i \cdot c\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -1.9999999999999999e159 or 5.0000000000000004e49 < (*.f64 z t) Initial program 85.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6486.2
Applied rewrites86.2%
if -1.9999999999999999e159 < (*.f64 z t) < 5.0000000000000004e49Initial program 94.7%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6491.8
Applied rewrites91.8%
Final simplification89.9%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* z t) -2e+159) (not (<= (* z t) 5e+101))) (fma z t (* c i)) (fma b a (fma i c (* y x)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((z * t) <= -2e+159) || !((z * t) <= 5e+101)) {
tmp = fma(z, t, (c * i));
} else {
tmp = fma(b, a, fma(i, c, (y * x)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(z * t) <= -2e+159) || !(Float64(z * t) <= 5e+101)) tmp = fma(z, t, Float64(c * i)); else tmp = fma(b, a, fma(i, c, Float64(y * x))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], -2e+159], N[Not[LessEqual[N[(z * t), $MachinePrecision], 5e+101]], $MachinePrecision]], N[(z * t + N[(c * i), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+159} \lor \neg \left(z \cdot t \leq 5 \cdot 10^{+101}\right):\\
\;\;\;\;\mathsf{fma}\left(z, t, c \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -1.9999999999999999e159 or 4.99999999999999989e101 < (*.f64 z t) Initial program 84.6%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
remove-double-negN/A
lift-*.f64N/A
associate-+r+N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites91.0%
Taylor expanded in c around inf
lower-*.f6480.4
Applied rewrites80.4%
if -1.9999999999999999e159 < (*.f64 z t) < 4.99999999999999989e101Initial program 94.9%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6491.0
Applied rewrites91.0%
Final simplification87.8%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* c i) -4e-12)
(fma b a (fma i c (* y x)))
(if (<= (* c i) 2e+25)
(fma z t (fma y x (* a b)))
(fma b a (fma 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) <= -4e-12) {
tmp = fma(b, a, fma(i, c, (y * x)));
} else if ((c * i) <= 2e+25) {
tmp = fma(z, t, fma(y, x, (a * b)));
} else {
tmp = fma(b, a, fma(t, z, (i * c)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(c * i) <= -4e-12) tmp = fma(b, a, fma(i, c, Float64(y * x))); elseif (Float64(c * i) <= 2e+25) tmp = fma(z, t, fma(y, x, Float64(a * b))); else tmp = fma(b, a, fma(t, z, Float64(i * c))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -4e-12], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 2e+25], N[(z * t + N[(y * x + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(t * z + N[(i * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -4 \cdot 10^{-12}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+25}:\\
\;\;\;\;\mathsf{fma}\left(z, t, \mathsf{fma}\left(y, x, a \cdot b\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, i \cdot c\right)\right)\\
\end{array}
\end{array}
if (*.f64 c i) < -3.99999999999999992e-12Initial program 84.6%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6482.0
Applied rewrites82.0%
if -3.99999999999999992e-12 < (*.f64 c i) < 2.00000000000000018e25Initial program 99.2%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
remove-double-negN/A
lift-*.f64N/A
associate-+r+N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites100.0%
Taylor expanded in a around inf
lower-*.f6497.0
Applied rewrites97.0%
if 2.00000000000000018e25 < (*.f64 c i) Initial program 83.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6488.8
Applied rewrites88.8%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* z t) -1e+24) (* t z) (if (<= (* z t) 0.0) (* b a) (if (<= (* z t) 1e+56) (* i c) (* t z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((z * t) <= -1e+24) {
tmp = t * z;
} else if ((z * t) <= 0.0) {
tmp = b * a;
} else if ((z * t) <= 1e+56) {
tmp = i * c;
} else {
tmp = t * z;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
real(8) :: tmp
if ((z * t) <= (-1d+24)) then
tmp = t * z
else if ((z * t) <= 0.0d0) then
tmp = b * a
else if ((z * t) <= 1d+56) then
tmp = i * c
else
tmp = t * z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((z * t) <= -1e+24) {
tmp = t * z;
} else if ((z * t) <= 0.0) {
tmp = b * a;
} else if ((z * t) <= 1e+56) {
tmp = i * c;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (z * t) <= -1e+24: tmp = t * z elif (z * t) <= 0.0: tmp = b * a elif (z * t) <= 1e+56: tmp = i * c else: tmp = t * z return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -1e+24) tmp = Float64(t * z); elseif (Float64(z * t) <= 0.0) tmp = Float64(b * a); elseif (Float64(z * t) <= 1e+56) tmp = Float64(i * c); else tmp = Float64(t * z); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((z * t) <= -1e+24) tmp = t * z; elseif ((z * t) <= 0.0) tmp = b * a; elseif ((z * t) <= 1e+56) tmp = i * c; else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -1e+24], N[(t * z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 0.0], N[(b * a), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1e+56], N[(i * c), $MachinePrecision], N[(t * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+24}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;z \cdot t \leq 0:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;z \cdot t \leq 10^{+56}:\\
\;\;\;\;i \cdot c\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (*.f64 z t) < -9.9999999999999998e23 or 1.00000000000000009e56 < (*.f64 z t) Initial program 86.4%
Taylor expanded in z around inf
lower-*.f6459.0
Applied rewrites59.0%
if -9.9999999999999998e23 < (*.f64 z t) < -0.0Initial program 96.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6445.4
Applied rewrites45.4%
if -0.0 < (*.f64 z t) < 1.00000000000000009e56Initial program 94.1%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6438.0
Applied rewrites38.0%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* x y) -4e+179) (not (<= (* x y) 1e+139))) (* y x) (fma i c (* a b))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((x * y) <= -4e+179) || !((x * y) <= 1e+139)) {
tmp = y * x;
} else {
tmp = fma(i, c, (a * b));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(x * y) <= -4e+179) || !(Float64(x * y) <= 1e+139)) tmp = Float64(y * x); else tmp = fma(i, c, Float64(a * b)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -4e+179], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1e+139]], $MachinePrecision]], N[(y * x), $MachinePrecision], N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -4 \cdot 10^{+179} \lor \neg \left(x \cdot y \leq 10^{+139}\right):\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -3.99999999999999992e179 or 1.00000000000000003e139 < (*.f64 x y) Initial program 84.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6469.8
Applied rewrites69.8%
if -3.99999999999999992e179 < (*.f64 x y) < 1.00000000000000003e139Initial program 94.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6460.3
Applied rewrites60.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6462.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.5
Applied rewrites62.5%
Final simplification64.8%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* a b) -1e+33) (fma z t (* a b)) (if (<= (* a b) 5e+41) (fma i c (* x y)) (fma i c (* a b)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((a * b) <= -1e+33) {
tmp = fma(z, t, (a * b));
} else if ((a * b) <= 5e+41) {
tmp = fma(i, c, (x * y));
} else {
tmp = fma(i, c, (a * b));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(a * b) <= -1e+33) tmp = fma(z, t, Float64(a * b)); elseif (Float64(a * b) <= 5e+41) tmp = fma(i, c, Float64(x * y)); else tmp = fma(i, c, Float64(a * b)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(a * b), $MachinePrecision], -1e+33], N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 5e+41], N[(i * c + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+33}:\\
\;\;\;\;\mathsf{fma}\left(z, t, a \cdot b\right)\\
\mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{+41}:\\
\;\;\;\;\mathsf{fma}\left(i, c, x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -9.9999999999999995e32Initial program 90.9%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
lift-*.f64N/A
remove-double-negN/A
lift-*.f64N/A
associate-+r+N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites95.5%
Taylor expanded in a around inf
lower-*.f6471.0
Applied rewrites71.0%
if -9.9999999999999995e32 < (*.f64 a b) < 5.00000000000000022e41Initial program 95.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6468.8
Applied rewrites68.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6470.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.3
Applied rewrites70.3%
if 5.00000000000000022e41 < (*.f64 a b) Initial program 83.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6467.9
Applied rewrites67.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6473.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6473.3
Applied rewrites73.3%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* a b) -4e+29) (not (<= (* a b) 1e+152))) (* b a) (* i c)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((a * b) <= -4e+29) || !((a * b) <= 1e+152)) {
tmp = b * a;
} else {
tmp = i * c;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
real(8) :: tmp
if (((a * b) <= (-4d+29)) .or. (.not. ((a * b) <= 1d+152))) then
tmp = b * a
else
tmp = i * c
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((a * b) <= -4e+29) || !((a * b) <= 1e+152)) {
tmp = b * a;
} else {
tmp = i * c;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if ((a * b) <= -4e+29) or not ((a * b) <= 1e+152): tmp = b * a else: tmp = i * c return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(a * b) <= -4e+29) || !(Float64(a * b) <= 1e+152)) tmp = Float64(b * a); else tmp = Float64(i * c); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if (((a * b) <= -4e+29) || ~(((a * b) <= 1e+152))) tmp = b * a; else tmp = i * c; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -4e+29], N[Not[LessEqual[N[(a * b), $MachinePrecision], 1e+152]], $MachinePrecision]], N[(b * a), $MachinePrecision], N[(i * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+29} \lor \neg \left(a \cdot b \leq 10^{+152}\right):\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 a b) < -3.99999999999999966e29 or 1e152 < (*.f64 a b) Initial program 87.2%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6450.5
Applied rewrites50.5%
if -3.99999999999999966e29 < (*.f64 a b) < 1e152Initial program 94.8%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6434.8
Applied rewrites34.8%
Final simplification41.0%
(FPCore (x y z t a b c i) :precision binary64 (* b a))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return b * a;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
code = b * a
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return b * a;
}
def code(x, y, z, t, a, b, c, i): return b * a
function code(x, y, z, t, a, b, c, i) return Float64(b * a) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = b * a; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(b * a), $MachinePrecision]
\begin{array}{l}
\\
b \cdot a
\end{array}
Initial program 91.8%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6425.4
Applied rewrites25.4%
herbie shell --seed 2025026
(FPCore (x y z t a b c i)
:name "Linear.V4:$cdot from linear-1.19.1.3, C"
:precision binary64
(+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))