
(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 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 y x (fma i c (fma b a (* t z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(y, x, fma(i, c, fma(b, a, (t * z))));
}
function code(x, y, z, t, a, b, c, i) return fma(y, x, fma(i, c, fma(b, a, Float64(t * z)))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(y * x + N[(i * c + N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, x, \mathsf{fma}\left(i, c, \mathsf{fma}\left(b, a, t \cdot z\right)\right)\right)
\end{array}
Initial program 95.9%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate--l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6498.1
Applied rewrites98.1%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* a b) -2e+78)
(fma a b (fma c i (* t z)))
(if (<= (* a b) 1e+127)
(fma y x (fma i c (* t z)))
(fma z t (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) <= -2e+78) {
tmp = fma(a, b, fma(c, i, (t * z)));
} else if ((a * b) <= 1e+127) {
tmp = fma(y, x, fma(i, c, (t * z)));
} else {
tmp = fma(z, t, fma(i, c, (a * b)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(a * b) <= -2e+78) tmp = fma(a, b, fma(c, i, Float64(t * z))); elseif (Float64(a * b) <= 1e+127) tmp = fma(y, x, fma(i, c, Float64(t * z))); else tmp = fma(z, t, 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], -2e+78], N[(a * b + N[(c * i + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1e+127], N[(y * x + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * t + N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+78}:\\
\;\;\;\;\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, t \cdot z\right)\right)\\
\mathbf{elif}\;a \cdot b \leq 10^{+127}:\\
\;\;\;\;\mathsf{fma}\left(y, x, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t, \mathsf{fma}\left(i, c, a \cdot b\right)\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -2.00000000000000002e78Initial program 95.9%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
if -2.00000000000000002e78 < (*.f64 a b) < 9.99999999999999955e126Initial program 95.9%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.1
Applied rewrites75.1%
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.f6475.2
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6475.2
Applied rewrites75.2%
if 9.99999999999999955e126 < (*.f64 a b) Initial program 95.9%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
lower-fma.f64N/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6498.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
Taylor expanded in x around 0
lower-*.f6475.3
Applied rewrites75.3%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma a b (fma c i (* t z)))))
(if (<= (* a b) -2e+78)
t_1
(if (<= (* a b) 1e+127) (fma y x (fma i c (* 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(a, b, fma(c, i, (t * z)));
double tmp;
if ((a * b) <= -2e+78) {
tmp = t_1;
} else if ((a * b) <= 1e+127) {
tmp = fma(y, x, fma(i, c, (t * z)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(a, b, fma(c, i, Float64(t * z))) tmp = 0.0 if (Float64(a * b) <= -2e+78) tmp = t_1; elseif (Float64(a * b) <= 1e+127) tmp = fma(y, x, fma(i, c, 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[(a * b + N[(c * i + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -2e+78], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], 1e+127], N[(y * x + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, t \cdot z\right)\right)\\
\mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+78}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq 10^{+127}:\\
\;\;\;\;\mathsf{fma}\left(y, x, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 a b) < -2.00000000000000002e78 or 9.99999999999999955e126 < (*.f64 a b) Initial program 95.9%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
if -2.00000000000000002e78 < (*.f64 a b) < 9.99999999999999955e126Initial program 95.9%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.1
Applied rewrites75.1%
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.f6475.2
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6475.2
Applied rewrites75.2%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma a b (fma c i (* t z)))))
(if (<= (* a b) -2e+78)
t_1
(if (<= (* a b) 1e+127) (fma c i (fma t z (* x y))) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(a, b, fma(c, i, (t * z)));
double tmp;
if ((a * b) <= -2e+78) {
tmp = t_1;
} else if ((a * b) <= 1e+127) {
tmp = fma(c, i, fma(t, z, (x * y)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(a, b, fma(c, i, Float64(t * z))) tmp = 0.0 if (Float64(a * b) <= -2e+78) tmp = t_1; elseif (Float64(a * b) <= 1e+127) tmp = fma(c, i, fma(t, z, Float64(x * y))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(a * b + N[(c * i + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -2e+78], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], 1e+127], N[(c * i + N[(t * z + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, t \cdot z\right)\right)\\
\mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+78}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq 10^{+127}:\\
\;\;\;\;\mathsf{fma}\left(c, i, \mathsf{fma}\left(t, z, x \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 a b) < -2.00000000000000002e78 or 9.99999999999999955e126 < (*.f64 a b) Initial program 95.9%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
if -2.00000000000000002e78 < (*.f64 a b) < 9.99999999999999955e126Initial program 95.9%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.1
Applied rewrites75.1%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma t z (* x y))))
(if (<= (* x y) -5e+144)
t_1
(if (<= (* x y) 5e+85) (fma a b (fma c i (* 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, (x * y));
double tmp;
if ((x * y) <= -5e+144) {
tmp = t_1;
} else if ((x * y) <= 5e+85) {
tmp = fma(a, b, fma(c, i, (t * z)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(t, z, Float64(x * y)) tmp = 0.0 if (Float64(x * y) <= -5e+144) tmp = t_1; elseif (Float64(x * y) <= 5e+85) tmp = fma(a, b, fma(c, i, 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[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -5e+144], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 5e+85], N[(a * b + N[(c * i + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, z, x \cdot y\right)\\
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+144}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{+85}:\\
\;\;\;\;\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 x y) < -4.9999999999999999e144 or 5.0000000000000001e85 < (*.f64 x y) Initial program 95.9%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.1
Applied rewrites75.1%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
Taylor expanded in x around 0
lower-*.f6427.5
Applied rewrites27.5%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6451.5
Applied rewrites51.5%
if -4.9999999999999999e144 < (*.f64 x y) < 5.0000000000000001e85Initial program 95.9%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
(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+194) t_1 (if (<= t_2 2e+180) (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+194) {
tmp = t_1;
} else if (t_2 <= 2e+180) {
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+194) tmp = t_1; elseif (t_2 <= 2e+180) 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+194], t$95$1, If[LessEqual[t$95$2, 2e+180], 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^{+194}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+180}:\\
\;\;\;\;\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)) < -4.99999999999999989e194 or 2e180 < (+.f64 (*.f64 x y) (*.f64 z t)) Initial program 95.9%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.1
Applied rewrites75.1%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
Taylor expanded in x around 0
lower-*.f6427.5
Applied rewrites27.5%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6451.5
Applied rewrites51.5%
if -4.99999999999999989e194 < (+.f64 (*.f64 x y) (*.f64 z t)) < 2e180Initial program 95.9%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
Taylor expanded in z around 0
lower-*.f6451.7
Applied rewrites51.7%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma t z (* x y))) (t_2 (fma a b (* t z))))
(if (<= (* a b) -2e+78)
t_2
(if (<= (* a b) 1e-228)
t_1
(if (<= (* a b) 1e-58)
(fma y x (* c i))
(if (<= (* a b) 1e+127) 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(t, z, (x * y));
double t_2 = fma(a, b, (t * z));
double tmp;
if ((a * b) <= -2e+78) {
tmp = t_2;
} else if ((a * b) <= 1e-228) {
tmp = t_1;
} else if ((a * b) <= 1e-58) {
tmp = fma(y, x, (c * i));
} else if ((a * b) <= 1e+127) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(t, z, Float64(x * y)) t_2 = fma(a, b, Float64(t * z)) tmp = 0.0 if (Float64(a * b) <= -2e+78) tmp = t_2; elseif (Float64(a * b) <= 1e-228) tmp = t_1; elseif (Float64(a * b) <= 1e-58) tmp = fma(y, x, Float64(c * i)); elseif (Float64(a * b) <= 1e+127) 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[(t * z + N[(x * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -2e+78], t$95$2, If[LessEqual[N[(a * b), $MachinePrecision], 1e-228], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], 1e-58], N[(y * x + N[(c * i), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1e+127], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, z, x \cdot y\right)\\
t_2 := \mathsf{fma}\left(a, b, t \cdot z\right)\\
\mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+78}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;a \cdot b \leq 10^{-228}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq 10^{-58}:\\
\;\;\;\;\mathsf{fma}\left(y, x, c \cdot i\right)\\
\mathbf{elif}\;a \cdot b \leq 10^{+127}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 a b) < -2.00000000000000002e78 or 9.99999999999999955e126 < (*.f64 a b) Initial program 95.9%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
Taylor expanded in z around 0
lower-*.f6451.7
Applied rewrites51.7%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6451.5
Applied rewrites51.5%
if -2.00000000000000002e78 < (*.f64 a b) < 1.00000000000000003e-228 or 1e-58 < (*.f64 a b) < 9.99999999999999955e126Initial program 95.9%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.1
Applied rewrites75.1%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
Taylor expanded in x around 0
lower-*.f6427.5
Applied rewrites27.5%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6451.5
Applied rewrites51.5%
if 1.00000000000000003e-228 < (*.f64 a b) < 1e-58Initial program 95.9%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.1
Applied rewrites75.1%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
lift-*.f64N/A
lift-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f6452.0
Applied rewrites52.0%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma t z (* x y))) (t_2 (fma a b (* t z))))
(if (<= (* a b) -2e+78)
t_2
(if (<= (* a b) 1e-228)
t_1
(if (<= (* a b) 1e-58)
(fma c i (* x y))
(if (<= (* a b) 1e+127) 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(t, z, (x * y));
double t_2 = fma(a, b, (t * z));
double tmp;
if ((a * b) <= -2e+78) {
tmp = t_2;
} else if ((a * b) <= 1e-228) {
tmp = t_1;
} else if ((a * b) <= 1e-58) {
tmp = fma(c, i, (x * y));
} else if ((a * b) <= 1e+127) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(t, z, Float64(x * y)) t_2 = fma(a, b, Float64(t * z)) tmp = 0.0 if (Float64(a * b) <= -2e+78) tmp = t_2; elseif (Float64(a * b) <= 1e-228) tmp = t_1; elseif (Float64(a * b) <= 1e-58) tmp = fma(c, i, Float64(x * y)); elseif (Float64(a * b) <= 1e+127) 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[(t * z + N[(x * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -2e+78], t$95$2, If[LessEqual[N[(a * b), $MachinePrecision], 1e-228], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], 1e-58], N[(c * i + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1e+127], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, z, x \cdot y\right)\\
t_2 := \mathsf{fma}\left(a, b, t \cdot z\right)\\
\mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+78}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;a \cdot b \leq 10^{-228}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq 10^{-58}:\\
\;\;\;\;\mathsf{fma}\left(c, i, x \cdot y\right)\\
\mathbf{elif}\;a \cdot b \leq 10^{+127}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 a b) < -2.00000000000000002e78 or 9.99999999999999955e126 < (*.f64 a b) Initial program 95.9%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
Taylor expanded in z around 0
lower-*.f6451.7
Applied rewrites51.7%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6451.5
Applied rewrites51.5%
if -2.00000000000000002e78 < (*.f64 a b) < 1.00000000000000003e-228 or 1e-58 < (*.f64 a b) < 9.99999999999999955e126Initial program 95.9%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.1
Applied rewrites75.1%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
Taylor expanded in x around 0
lower-*.f6427.5
Applied rewrites27.5%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6451.5
Applied rewrites51.5%
if 1.00000000000000003e-228 < (*.f64 a b) < 1e-58Initial program 95.9%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.1
Applied rewrites75.1%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
(FPCore (x y z t a b c i) :precision binary64 (if (<= z -5.2e+34) (fma z t (* b a)) (if (<= z 1.4e+29) (fma c i (* 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 <= -5.2e+34) {
tmp = fma(z, t, (b * a));
} else if (z <= 1.4e+29) {
tmp = fma(c, i, (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 (z <= -5.2e+34) tmp = fma(z, t, Float64(b * a)); elseif (z <= 1.4e+29) tmp = fma(c, i, 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[z, -5.2e+34], N[(z * t + N[(b * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.4e+29], N[(c * i + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{+34}:\\
\;\;\;\;\mathsf{fma}\left(z, t, b \cdot a\right)\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{+29}:\\
\;\;\;\;\mathsf{fma}\left(c, i, x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\end{array}
\end{array}
if z < -5.19999999999999995e34Initial program 95.9%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
Taylor expanded in z around 0
lower-*.f6451.7
Applied rewrites51.7%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6451.5
Applied rewrites51.5%
lift-*.f64N/A
lift-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6451.5
Applied rewrites51.5%
if -5.19999999999999995e34 < z < 1.4e29Initial program 95.9%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.1
Applied rewrites75.1%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
if 1.4e29 < z Initial program 95.9%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
Taylor expanded in z around 0
lower-*.f6451.7
Applied rewrites51.7%
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 (<= (* c i) -3.4e+201) (* c i) (if (<= (* c i) 2.6e+299) (fma a b (* t z)) (* c i))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c * i) <= -3.4e+201) {
tmp = c * i;
} else if ((c * i) <= 2.6e+299) {
tmp = fma(a, b, (t * z));
} else {
tmp = c * i;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(c * i) <= -3.4e+201) tmp = Float64(c * i); elseif (Float64(c * i) <= 2.6e+299) tmp = fma(a, b, Float64(t * z)); else tmp = Float64(c * i); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -3.4e+201], N[(c * i), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 2.6e+299], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision], N[(c * i), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -3.4 \cdot 10^{+201}:\\
\;\;\;\;c \cdot i\\
\mathbf{elif}\;c \cdot i \leq 2.6 \cdot 10^{+299}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot i\\
\end{array}
\end{array}
if (*.f64 c i) < -3.4e201 or 2.6e299 < (*.f64 c i) Initial program 95.9%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.1
Applied rewrites75.1%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
Taylor expanded in x around 0
lower-*.f6427.5
Applied rewrites27.5%
if -3.4e201 < (*.f64 c i) < 2.6e299Initial program 95.9%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
Taylor expanded in z around 0
lower-*.f6451.7
Applied rewrites51.7%
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 (<= (* a b) -1.1e+99)
(* a b)
(if (<= (* a b) 4e-276)
(* x y)
(if (<= (* a b) 3.4e-52)
(* c i)
(if (<= (* a b) 8.2e+126) (* 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) <= -1.1e+99) {
tmp = a * b;
} else if ((a * b) <= 4e-276) {
tmp = x * y;
} else if ((a * b) <= 3.4e-52) {
tmp = c * i;
} else if ((a * b) <= 8.2e+126) {
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) <= (-1.1d+99)) then
tmp = a * b
else if ((a * b) <= 4d-276) then
tmp = x * y
else if ((a * b) <= 3.4d-52) then
tmp = c * i
else if ((a * b) <= 8.2d+126) 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) <= -1.1e+99) {
tmp = a * b;
} else if ((a * b) <= 4e-276) {
tmp = x * y;
} else if ((a * b) <= 3.4e-52) {
tmp = c * i;
} else if ((a * b) <= 8.2e+126) {
tmp = x * y;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (a * b) <= -1.1e+99: tmp = a * b elif (a * b) <= 4e-276: tmp = x * y elif (a * b) <= 3.4e-52: tmp = c * i elif (a * b) <= 8.2e+126: 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) <= -1.1e+99) tmp = Float64(a * b); elseif (Float64(a * b) <= 4e-276) tmp = Float64(x * y); elseif (Float64(a * b) <= 3.4e-52) tmp = Float64(c * i); elseif (Float64(a * b) <= 8.2e+126) 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) <= -1.1e+99) tmp = a * b; elseif ((a * b) <= 4e-276) tmp = x * y; elseif ((a * b) <= 3.4e-52) tmp = c * i; elseif ((a * b) <= 8.2e+126) 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], -1.1e+99], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 4e-276], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 3.4e-52], N[(c * i), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 8.2e+126], N[(x * y), $MachinePrecision], N[(a * b), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.1 \cdot 10^{+99}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{-276}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 3.4 \cdot 10^{-52}:\\
\;\;\;\;c \cdot i\\
\mathbf{elif}\;a \cdot b \leq 8.2 \cdot 10^{+126}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -1.09999999999999989e99 or 8.2000000000000001e126 < (*.f64 a b) Initial program 95.9%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
Taylor expanded in z around 0
lower-*.f6451.7
Applied rewrites51.7%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6451.5
Applied rewrites51.5%
Taylor expanded in z around 0
lower-*.f6427.6
Applied rewrites27.6%
if -1.09999999999999989e99 < (*.f64 a b) < 4e-276 or 3.40000000000000017e-52 < (*.f64 a b) < 8.2000000000000001e126Initial program 95.9%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
Taylor expanded in z around 0
lower-*.f6451.7
Applied rewrites51.7%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6451.5
Applied rewrites51.5%
Taylor expanded in x around inf
lower-*.f6427.5
Applied rewrites27.5%
if 4e-276 < (*.f64 a b) < 3.40000000000000017e-52Initial program 95.9%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.1
Applied rewrites75.1%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
Taylor expanded in x around 0
lower-*.f6427.5
Applied rewrites27.5%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* a b) -2.7e+14) (* a b) (if (<= (* a b) 3.15e+182) (* c i) (* 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) <= -2.7e+14) {
tmp = a * b;
} else if ((a * b) <= 3.15e+182) {
tmp = c * i;
} 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) <= (-2.7d+14)) then
tmp = a * b
else if ((a * b) <= 3.15d+182) then
tmp = c * i
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) <= -2.7e+14) {
tmp = a * b;
} else if ((a * b) <= 3.15e+182) {
tmp = c * i;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (a * b) <= -2.7e+14: tmp = a * b elif (a * b) <= 3.15e+182: tmp = c * i else: tmp = a * b return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(a * b) <= -2.7e+14) tmp = Float64(a * b); elseif (Float64(a * b) <= 3.15e+182) tmp = Float64(c * i); 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) <= -2.7e+14) tmp = a * b; elseif ((a * b) <= 3.15e+182) tmp = c * i; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(a * b), $MachinePrecision], -2.7e+14], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 3.15e+182], N[(c * i), $MachinePrecision], N[(a * b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -2.7 \cdot 10^{+14}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 3.15 \cdot 10^{+182}:\\
\;\;\;\;c \cdot i\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -2.7e14 or 3.15000000000000014e182 < (*.f64 a b) Initial program 95.9%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
Taylor expanded in z around 0
lower-*.f6451.7
Applied rewrites51.7%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6451.5
Applied rewrites51.5%
Taylor expanded in z around 0
lower-*.f6427.6
Applied rewrites27.6%
if -2.7e14 < (*.f64 a b) < 3.15000000000000014e182Initial program 95.9%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6475.1
Applied rewrites75.1%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
Taylor expanded in x around 0
lower-*.f6427.5
Applied rewrites27.5%
(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.9%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-fma.f64N/A
lower-*.f6474.7
Applied rewrites74.7%
Taylor expanded in z around 0
lower-*.f6451.7
Applied rewrites51.7%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f6451.5
Applied rewrites51.5%
Taylor expanded in z around 0
lower-*.f6427.6
Applied rewrites27.6%
herbie shell --seed 2025159
(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)))