
(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 14 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 y x (fma t z (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(y, x, fma(t, z, fma(i, c, (b * a))));
}
function code(x, y, z, t, a, b, c, i) return fma(y, x, fma(t, z, fma(i, c, Float64(b * a)))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(y * x + N[(t * z + N[(i * c + N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, x, \mathsf{fma}\left(t, z, \mathsf{fma}\left(i, c, b \cdot a\right)\right)\right)
\end{array}
Initial program 95.6%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6497.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6497.8
Applied rewrites97.8%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma c i (fma t z (* x y)))))
(if (<= (* z t) -2e+239)
(fma z t (* b a))
(if (<= (* z t) -5e+21)
t_1
(if (<= (* z t) 2e+122) (fma y x (fma i c (* b a))) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(c, i, fma(t, z, (x * y)));
double tmp;
if ((z * t) <= -2e+239) {
tmp = fma(z, t, (b * a));
} else if ((z * t) <= -5e+21) {
tmp = t_1;
} else if ((z * t) <= 2e+122) {
tmp = fma(y, x, fma(i, c, (b * a)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(c, i, fma(t, z, Float64(x * y))) tmp = 0.0 if (Float64(z * t) <= -2e+239) tmp = fma(z, t, Float64(b * a)); elseif (Float64(z * t) <= -5e+21) tmp = t_1; elseif (Float64(z * t) <= 2e+122) tmp = fma(y, x, fma(i, c, Float64(b * a))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(c * i + N[(t * z + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -2e+239], N[(z * t + N[(b * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], -5e+21], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 2e+122], N[(y * x + N[(i * c + N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(c, i, \mathsf{fma}\left(t, z, x \cdot y\right)\right)\\
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+239}:\\
\;\;\;\;\mathsf{fma}\left(z, t, b \cdot a\right)\\
\mathbf{elif}\;z \cdot t \leq -5 \cdot 10^{+21}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+122}:\\
\;\;\;\;\mathsf{fma}\left(y, x, \mathsf{fma}\left(i, c, b \cdot a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -1.99999999999999998e239Initial program 95.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6452.2
Applied rewrites52.2%
if -1.99999999999999998e239 < (*.f64 z t) < -5e21 or 2.00000000000000003e122 < (*.f64 z t) Initial program 95.6%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.4
Applied rewrites74.4%
if -5e21 < (*.f64 z t) < 2.00000000000000003e122Initial program 95.6%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
lift-fma.f64N/A
+-commutativeN/A
lift-fma.f64N/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6475.1
Applied rewrites75.1%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma c i (fma t z (* x y)))))
(if (<= (* z t) -2e+239)
(fma z t (* b a))
(if (<= (* z t) -5e+21)
t_1
(if (<= (* z t) 2e+122) (fma a b (fma c i (* x y))) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(c, i, fma(t, z, (x * y)));
double tmp;
if ((z * t) <= -2e+239) {
tmp = fma(z, t, (b * a));
} else if ((z * t) <= -5e+21) {
tmp = t_1;
} else if ((z * t) <= 2e+122) {
tmp = fma(a, b, fma(c, i, (x * y)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(c, i, fma(t, z, Float64(x * y))) tmp = 0.0 if (Float64(z * t) <= -2e+239) tmp = fma(z, t, Float64(b * a)); elseif (Float64(z * t) <= -5e+21) tmp = t_1; elseif (Float64(z * t) <= 2e+122) tmp = fma(a, b, fma(c, i, Float64(x * y))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(c * i + N[(t * z + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -2e+239], N[(z * t + N[(b * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], -5e+21], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 2e+122], N[(a * b + N[(c * i + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(c, i, \mathsf{fma}\left(t, z, x \cdot y\right)\right)\\
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+239}:\\
\;\;\;\;\mathsf{fma}\left(z, t, b \cdot a\right)\\
\mathbf{elif}\;z \cdot t \leq -5 \cdot 10^{+21}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+122}:\\
\;\;\;\;\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, x \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -1.99999999999999998e239Initial program 95.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6452.2
Applied rewrites52.2%
if -1.99999999999999998e239 < (*.f64 z t) < -5e21 or 2.00000000000000003e122 < (*.f64 z t) Initial program 95.6%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.4
Applied rewrites74.4%
if -5e21 < (*.f64 z t) < 2.00000000000000003e122Initial program 95.6%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma i c (* b a))))
(if (<= (* z t) -2e+60)
(fma z t t_1)
(if (<= (* z t) 2e+122) (fma y x t_1) (fma c i (fma t z (* x y)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(i, c, (b * a));
double tmp;
if ((z * t) <= -2e+60) {
tmp = fma(z, t, t_1);
} else if ((z * t) <= 2e+122) {
tmp = fma(y, x, t_1);
} else {
tmp = fma(c, i, fma(t, z, (x * y)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(i, c, Float64(b * a)) tmp = 0.0 if (Float64(z * t) <= -2e+60) tmp = fma(z, t, t_1); elseif (Float64(z * t) <= 2e+122) tmp = fma(y, x, t_1); else tmp = fma(c, i, fma(t, z, Float64(x * y))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(i * c + N[(b * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -2e+60], N[(z * t + t$95$1), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+122], N[(y * x + t$95$1), $MachinePrecision], N[(c * i + N[(t * z + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(i, c, b \cdot a\right)\\
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+60}:\\
\;\;\;\;\mathsf{fma}\left(z, t, t\_1\right)\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+122}:\\
\;\;\;\;\mathsf{fma}\left(y, x, t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(c, i, \mathsf{fma}\left(t, z, x \cdot y\right)\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -1.9999999999999999e60Initial program 95.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
lift-fma.f64N/A
+-commutativeN/A
lift-fma.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-fma.f64N/A
lower-fma.f6475.3
Applied rewrites75.3%
if -1.9999999999999999e60 < (*.f64 z t) < 2.00000000000000003e122Initial program 95.6%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
lift-fma.f64N/A
+-commutativeN/A
lift-fma.f64N/A
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6475.1
Applied rewrites75.1%
if 2.00000000000000003e122 < (*.f64 z t) Initial program 95.6%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.4
Applied rewrites74.4%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma c i (* t z))))
(if (<= (* z t) -2e+60)
(fma a b t_1)
(if (<= (* z t) 4e+179) (fma a b (fma c i (* x y))) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(c, i, (t * z));
double tmp;
if ((z * t) <= -2e+60) {
tmp = fma(a, b, t_1);
} else if ((z * t) <= 4e+179) {
tmp = fma(a, b, fma(c, i, (x * y)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(c, i, Float64(t * z)) tmp = 0.0 if (Float64(z * t) <= -2e+60) tmp = fma(a, b, t_1); elseif (Float64(z * t) <= 4e+179) tmp = fma(a, b, fma(c, i, Float64(x * y))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(c * i + N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -2e+60], N[(a * b + t$95$1), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 4e+179], N[(a * b + N[(c * i + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(c, i, t \cdot z\right)\\
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+60}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t\_1\right)\\
\mathbf{elif}\;z \cdot t \leq 4 \cdot 10^{+179}:\\
\;\;\;\;\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, x \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -1.9999999999999999e60Initial program 95.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
if -1.9999999999999999e60 < (*.f64 z t) < 3.99999999999999992e179Initial program 95.6%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
if 3.99999999999999992e179 < (*.f64 z t) Initial program 95.6%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.4
Applied rewrites74.4%
Taylor expanded in x around 0
lower-*.f6451.1
Applied rewrites51.1%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* x y) -2e+266) (fma y x (* b a)) (if (<= (* x y) 2e+200) (fma a b (fma c i (* t z))) (fma a b (* x y)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x * y) <= -2e+266) {
tmp = fma(y, x, (b * a));
} else if ((x * y) <= 2e+200) {
tmp = fma(a, b, fma(c, i, (t * z)));
} else {
tmp = fma(a, b, (x * y));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(x * y) <= -2e+266) tmp = fma(y, x, Float64(b * a)); elseif (Float64(x * y) <= 2e+200) tmp = fma(a, b, fma(c, i, Float64(t * z))); else tmp = fma(a, b, Float64(x * y)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -2e+266], N[(y * x + N[(b * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+200], N[(a * b + N[(c * i + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * b + N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+266}:\\
\;\;\;\;\mathsf{fma}\left(y, x, b \cdot a\right)\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+200}:\\
\;\;\;\;\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, x \cdot y\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -2.0000000000000001e266Initial program 95.6%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.4
Applied rewrites52.4%
lift-*.f64N/A
lift-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6452.3
Applied rewrites52.3%
if -2.0000000000000001e266 < (*.f64 x y) < 1.9999999999999999e200Initial program 95.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
if 1.9999999999999999e200 < (*.f64 x y) Initial program 95.6%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.4
Applied rewrites52.4%
(FPCore (x y z t a b c i) :precision binary64 (let* ((t_1 (fma t z (* x y))) (t_2 (+ (* x y) (* z t)))) (if (<= t_2 -5e+197) t_1 (if (<= t_2 1e+200) (fma a b (* c i)) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(t, z, (x * y));
double t_2 = (x * y) + (z * t);
double tmp;
if (t_2 <= -5e+197) {
tmp = t_1;
} else if (t_2 <= 1e+200) {
tmp = fma(a, b, (c * i));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(t, z, Float64(x * y)) t_2 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if (t_2 <= -5e+197) tmp = t_1; elseif (t_2 <= 1e+200) tmp = fma(a, b, Float64(c * i)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(t * z + N[(x * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+197], t$95$1, If[LessEqual[t$95$2, 1e+200], N[(a * b + N[(c * i), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, z, x \cdot y\right)\\
t_2 := x \cdot y + z \cdot t\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+197}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 10^{+200}:\\
\;\;\;\;\mathsf{fma}\left(a, b, c \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (*.f64 x y) (*.f64 z t)) < -5.00000000000000009e197 or 9.9999999999999997e199 < (+.f64 (*.f64 x y) (*.f64 z t)) Initial program 95.6%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.4
Applied rewrites74.4%
lift-fma.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f64N/A
lower-fma.f6474.3
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6474.3
Applied rewrites74.3%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6451.5
Applied rewrites51.5%
if -5.00000000000000009e197 < (+.f64 (*.f64 x y) (*.f64 z t)) < 9.9999999999999997e199Initial program 95.6%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in x around 0
lower-*.f6452.0
Applied rewrites52.0%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* z t) -5e+59) (fma z t (* b a)) (if (<= (* z t) 2e+122) (fma y x (* b a)) (fma t z (* x y)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((z * t) <= -5e+59) {
tmp = fma(z, t, (b * a));
} else if ((z * t) <= 2e+122) {
tmp = fma(y, x, (b * a));
} else {
tmp = fma(t, z, (x * y));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -5e+59) tmp = fma(z, t, Float64(b * a)); elseif (Float64(z * t) <= 2e+122) tmp = fma(y, x, Float64(b * a)); else tmp = fma(t, z, Float64(x * y)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -5e+59], N[(z * t + N[(b * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+122], N[(y * x + N[(b * a), $MachinePrecision]), $MachinePrecision], N[(t * z + N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+59}:\\
\;\;\;\;\mathsf{fma}\left(z, t, b \cdot a\right)\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+122}:\\
\;\;\;\;\mathsf{fma}\left(y, x, b \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, z, x \cdot y\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -4.9999999999999997e59Initial program 95.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6452.2
Applied rewrites52.2%
if -4.9999999999999997e59 < (*.f64 z t) < 2.00000000000000003e122Initial program 95.6%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.4
Applied rewrites52.4%
lift-*.f64N/A
lift-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6452.3
Applied rewrites52.3%
if 2.00000000000000003e122 < (*.f64 z t) Initial program 95.6%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.4
Applied rewrites74.4%
lift-fma.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f64N/A
lower-fma.f6474.3
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6474.3
Applied rewrites74.3%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6451.5
Applied rewrites51.5%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* z t) -5e+59) (fma z t (* b a)) (if (<= (* z t) 4e+179) (fma y x (* b a)) (fma a b (* t z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((z * t) <= -5e+59) {
tmp = fma(z, t, (b * a));
} else if ((z * t) <= 4e+179) {
tmp = fma(y, x, (b * a));
} else {
tmp = fma(a, b, (t * z));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -5e+59) tmp = fma(z, t, Float64(b * a)); elseif (Float64(z * t) <= 4e+179) tmp = fma(y, x, Float64(b * a)); else tmp = fma(a, b, Float64(t * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -5e+59], N[(z * t + N[(b * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 4e+179], N[(y * x + N[(b * a), $MachinePrecision]), $MachinePrecision], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+59}:\\
\;\;\;\;\mathsf{fma}\left(z, t, b \cdot a\right)\\
\mathbf{elif}\;z \cdot t \leq 4 \cdot 10^{+179}:\\
\;\;\;\;\mathsf{fma}\left(y, x, b \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -4.9999999999999997e59Initial program 95.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6452.2
Applied rewrites52.2%
if -4.9999999999999997e59 < (*.f64 z t) < 3.99999999999999992e179Initial program 95.6%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.4
Applied rewrites52.4%
lift-*.f64N/A
lift-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6452.3
Applied rewrites52.3%
if 3.99999999999999992e179 < (*.f64 z t) Initial program 95.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* z t) -5e+59) (fma z t (* b a)) (if (<= (* z t) 4e+179) (fma a b (* x y)) (fma a b (* t z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((z * t) <= -5e+59) {
tmp = fma(z, t, (b * a));
} else if ((z * t) <= 4e+179) {
tmp = fma(a, b, (x * y));
} else {
tmp = fma(a, b, (t * z));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -5e+59) tmp = fma(z, t, Float64(b * a)); elseif (Float64(z * t) <= 4e+179) tmp = fma(a, b, Float64(x * y)); else tmp = fma(a, b, Float64(t * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -5e+59], N[(z * t + N[(b * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 4e+179], N[(a * b + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+59}:\\
\;\;\;\;\mathsf{fma}\left(z, t, b \cdot a\right)\\
\mathbf{elif}\;z \cdot t \leq 4 \cdot 10^{+179}:\\
\;\;\;\;\mathsf{fma}\left(a, b, x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -4.9999999999999997e59Initial program 95.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6452.2
Applied rewrites52.2%
if -4.9999999999999997e59 < (*.f64 z t) < 3.99999999999999992e179Initial program 95.6%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.4
Applied rewrites52.4%
if 3.99999999999999992e179 < (*.f64 z t) Initial program 95.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* x y) -8.2e+270) (* x y) (if (<= (* x y) 69000000000000.0) (fma z t (* 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 ((x * y) <= -8.2e+270) {
tmp = x * y;
} else if ((x * y) <= 69000000000000.0) {
tmp = fma(z, t, (b * a));
} else {
tmp = x * y;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(x * y) <= -8.2e+270) tmp = Float64(x * y); elseif (Float64(x * y) <= 69000000000000.0) tmp = fma(z, t, Float64(b * a)); else tmp = Float64(x * y); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -8.2e+270], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 69000000000000.0], N[(z * t + N[(b * a), $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -8.2 \cdot 10^{+270}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq 69000000000000:\\
\;\;\;\;\mathsf{fma}\left(z, t, b \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -8.19999999999999991e270 or 6.9e13 < (*.f64 x y) Initial program 95.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6452.2
Applied rewrites52.2%
Taylor expanded in x around inf
lower-*.f6427.4
Applied rewrites27.4%
if -8.19999999999999991e270 < (*.f64 x y) < 6.9e13Initial program 95.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6452.2
Applied rewrites52.2%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* x y) -8.2e+270) (* x y) (if (<= (* x y) 69000000000000.0) (fma a b (* t z)) (* x y))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x * y) <= -8.2e+270) {
tmp = x * y;
} else if ((x * y) <= 69000000000000.0) {
tmp = fma(a, b, (t * z));
} else {
tmp = x * y;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(x * y) <= -8.2e+270) tmp = Float64(x * y); elseif (Float64(x * y) <= 69000000000000.0) tmp = fma(a, b, Float64(t * z)); else tmp = Float64(x * y); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -8.2e+270], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 69000000000000.0], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -8.2 \cdot 10^{+270}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq 69000000000000:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -8.19999999999999991e270 or 6.9e13 < (*.f64 x y) Initial program 95.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6452.2
Applied rewrites52.2%
Taylor expanded in x around inf
lower-*.f6427.4
Applied rewrites27.4%
if -8.19999999999999991e270 < (*.f64 x y) < 6.9e13Initial program 95.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* a b) -8e+113) (* a b) (if (<= (* a b) 1.15e+46) (* x y) (* 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) <= -8e+113) {
tmp = a * b;
} else if ((a * b) <= 1.15e+46) {
tmp = x * y;
} else {
tmp = a * b;
}
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) <= (-8d+113)) then
tmp = a * b
else if ((a * b) <= 1.15d+46) then
tmp = x * y
else
tmp = a * b
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) <= -8e+113) {
tmp = a * b;
} else if ((a * b) <= 1.15e+46) {
tmp = x * y;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (a * b) <= -8e+113: tmp = a * b elif (a * b) <= 1.15e+46: tmp = x * y else: tmp = a * b return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(a * b) <= -8e+113) tmp = Float64(a * b); elseif (Float64(a * b) <= 1.15e+46) tmp = Float64(x * y); else tmp = Float64(a * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((a * b) <= -8e+113) tmp = a * b; elseif ((a * b) <= 1.15e+46) tmp = x * y; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(a * b), $MachinePrecision], -8e+113], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1.15e+46], N[(x * y), $MachinePrecision], N[(a * b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -8 \cdot 10^{+113}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 1.15 \cdot 10^{+46}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -8e113 or 1.15e46 < (*.f64 a b) Initial program 95.6%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.4
Applied rewrites52.4%
Taylor expanded in x around 0
lower-*.f6428.1
Applied rewrites28.1%
if -8e113 < (*.f64 a b) < 1.15e46Initial program 95.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6452.2
Applied rewrites52.2%
Taylor expanded in x around inf
lower-*.f6427.4
Applied rewrites27.4%
(FPCore (x y z t a b c i) :precision binary64 (* a b))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return a * b;
}
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 = a * b
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return a * b;
}
def code(x, y, z, t, a, b, c, i): return a * b
function code(x, y, z, t, a, b, c, i) return Float64(a * b) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = a * b; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(a * b), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b
\end{array}
Initial program 95.6%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.2
Applied rewrites75.2%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6452.4
Applied rewrites52.4%
Taylor expanded in x around 0
lower-*.f6428.1
Applied rewrites28.1%
herbie shell --seed 2025142
(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)))