
(FPCore (x y z t a b) :precision binary64 (+ (+ (* x y) (* z t)) (* a b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * t)) + (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)
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
code = ((x * y) + (z * t)) + (a * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * t)) + (a * b);
}
def code(x, y, z, t, a, b): return ((x * y) + (z * t)) + (a * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * y) + (z * t)) + (a * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y + z \cdot t\right) + a \cdot b
\end{array}
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (+ (+ (* x y) (* z t)) (* a b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * t)) + (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)
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
code = ((x * y) + (z * t)) + (a * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * t)) + (a * b);
}
def code(x, y, z, t, a, b): return ((x * y) + (z * t)) + (a * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * y) + (z * t)) + (a * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y + z \cdot t\right) + a \cdot b
\end{array}
(FPCore (x y z t a b) :precision binary64 (fma z t (fma y x (* b a))))
double code(double x, double y, double z, double t, double a, double b) {
return fma(z, t, fma(y, x, (b * a)));
}
function code(x, y, z, t, a, b) return fma(z, t, fma(y, x, Float64(b * a))) end
code[x_, y_, z_, t_, a_, b_] := N[(z * t + N[(y * x + N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, t, \mathsf{fma}\left(y, x, b \cdot a\right)\right)
\end{array}
Initial program 97.6%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6498.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.8
Applied rewrites98.8%
(FPCore (x y z t a b) :precision binary64 (if (<= (* x y) -34000.0) (fma t z (* x y)) (if (<= (* x y) 1.95e-8) (fma a b (* t z)) (fma a b (* x y)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -34000.0) {
tmp = fma(t, z, (x * y));
} else if ((x * y) <= 1.95e-8) {
tmp = fma(a, b, (t * z));
} else {
tmp = fma(a, b, (x * y));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x * y) <= -34000.0) tmp = fma(t, z, Float64(x * y)); elseif (Float64(x * y) <= 1.95e-8) tmp = fma(a, b, Float64(t * z)); else tmp = fma(a, b, Float64(x * y)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * y), $MachinePrecision], -34000.0], N[(t * z + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1.95e-8], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision], N[(a * b + N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -34000:\\
\;\;\;\;\mathsf{fma}\left(t, z, x \cdot y\right)\\
\mathbf{elif}\;x \cdot y \leq 1.95 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, x \cdot y\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -34000Initial program 97.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6466.9
Applied rewrites66.9%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-*.f6467.3
Applied rewrites67.3%
if -34000 < (*.f64 x y) < 1.94999999999999992e-8Initial program 97.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6466.9
Applied rewrites66.9%
if 1.94999999999999992e-8 < (*.f64 x y) Initial program 97.6%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6468.4
Applied rewrites68.4%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma a b (* t z))))
(if (<= (* z t) -2e-57)
t_1
(if (<= (* z t) 1e+104) (fma a b (* x y)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(a, b, (t * z));
double tmp;
if ((z * t) <= -2e-57) {
tmp = t_1;
} else if ((z * t) <= 1e+104) {
tmp = fma(a, b, (x * y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(a, b, Float64(t * z)) tmp = 0.0 if (Float64(z * t) <= -2e-57) tmp = t_1; elseif (Float64(z * t) <= 1e+104) tmp = fma(a, b, Float64(x * y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -2e-57], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 1e+104], N[(a * b + N[(x * y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, b, t \cdot z\right)\\
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{-57}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 10^{+104}:\\
\;\;\;\;\mathsf{fma}\left(a, b, x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -1.99999999999999991e-57 or 1e104 < (*.f64 z t) Initial program 97.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6466.9
Applied rewrites66.9%
if -1.99999999999999991e-57 < (*.f64 z t) < 1e104Initial program 97.6%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6468.4
Applied rewrites68.4%
(FPCore (x y z t a b) :precision binary64 (if (<= (* x y) -7.7e+177) (* x y) (if (<= (* x y) 1.65e+125) (fma a b (* t z)) (* x y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -7.7e+177) {
tmp = x * y;
} else if ((x * y) <= 1.65e+125) {
tmp = fma(a, b, (t * z));
} else {
tmp = x * y;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x * y) <= -7.7e+177) tmp = Float64(x * y); elseif (Float64(x * y) <= 1.65e+125) tmp = fma(a, b, Float64(t * z)); else tmp = Float64(x * y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * y), $MachinePrecision], -7.7e+177], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1.65e+125], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -7.7 \cdot 10^{+177}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq 1.65 \cdot 10^{+125}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -7.6999999999999997e177 or 1.65000000000000003e125 < (*.f64 x y) Initial program 97.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6466.9
Applied rewrites66.9%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-*.f6467.3
Applied rewrites67.3%
Taylor expanded in x around 0
lower-*.f6434.5
Applied rewrites34.5%
Taylor expanded in x around inf
lower-*.f6436.3
Applied rewrites36.3%
if -7.6999999999999997e177 < (*.f64 x y) < 1.65000000000000003e125Initial program 97.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6466.9
Applied rewrites66.9%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* a b) -3.3e+199)
(* a b)
(if (<= (* a b) 3.6e-87)
(* x y)
(if (<= (* a b) 4.4e+103) (* t z) (* a b)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -3.3e+199) {
tmp = a * b;
} else if ((a * b) <= 3.6e-87) {
tmp = x * y;
} else if ((a * b) <= 4.4e+103) {
tmp = t * z;
} 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)
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) :: tmp
if ((a * b) <= (-3.3d+199)) then
tmp = a * b
else if ((a * b) <= 3.6d-87) then
tmp = x * y
else if ((a * b) <= 4.4d+103) then
tmp = t * z
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 tmp;
if ((a * b) <= -3.3e+199) {
tmp = a * b;
} else if ((a * b) <= 3.6e-87) {
tmp = x * y;
} else if ((a * b) <= 4.4e+103) {
tmp = t * z;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -3.3e+199: tmp = a * b elif (a * b) <= 3.6e-87: tmp = x * y elif (a * b) <= 4.4e+103: tmp = t * z else: tmp = a * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -3.3e+199) tmp = Float64(a * b); elseif (Float64(a * b) <= 3.6e-87) tmp = Float64(x * y); elseif (Float64(a * b) <= 4.4e+103) tmp = Float64(t * z); else tmp = Float64(a * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((a * b) <= -3.3e+199) tmp = a * b; elseif ((a * b) <= 3.6e-87) tmp = x * y; elseif ((a * b) <= 4.4e+103) tmp = t * z; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a * b), $MachinePrecision], -3.3e+199], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 3.6e-87], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 4.4e+103], N[(t * z), $MachinePrecision], N[(a * b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -3.3 \cdot 10^{+199}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 3.6 \cdot 10^{-87}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 4.4 \cdot 10^{+103}:\\
\;\;\;\;t \cdot z\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -3.2999999999999998e199 or 4.39999999999999985e103 < (*.f64 a b) Initial program 97.6%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6468.4
Applied rewrites68.4%
Taylor expanded in x around 0
lower-*.f6435.7
Applied rewrites35.7%
if -3.2999999999999998e199 < (*.f64 a b) < 3.59999999999999993e-87Initial program 97.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6466.9
Applied rewrites66.9%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-*.f6467.3
Applied rewrites67.3%
Taylor expanded in x around 0
lower-*.f6434.5
Applied rewrites34.5%
Taylor expanded in x around inf
lower-*.f6436.3
Applied rewrites36.3%
if 3.59999999999999993e-87 < (*.f64 a b) < 4.39999999999999985e103Initial program 97.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6466.9
Applied rewrites66.9%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-*.f6467.3
Applied rewrites67.3%
Taylor expanded in x around 0
lower-*.f6434.5
Applied rewrites34.5%
(FPCore (x y z t a b) :precision binary64 (if (<= (* z t) -2e+64) (* t z) (if (<= (* z t) 1e+25) (* a b) (* t z))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z * t) <= -2e+64) {
tmp = t * z;
} else if ((z * t) <= 1e+25) {
tmp = a * b;
} 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)
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) :: tmp
if ((z * t) <= (-2d+64)) then
tmp = t * z
else if ((z * t) <= 1d+25) then
tmp = a * b
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 tmp;
if ((z * t) <= -2e+64) {
tmp = t * z;
} else if ((z * t) <= 1e+25) {
tmp = a * b;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (z * t) <= -2e+64: tmp = t * z elif (z * t) <= 1e+25: tmp = a * b else: tmp = t * z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(z * t) <= -2e+64) tmp = Float64(t * z); elseif (Float64(z * t) <= 1e+25) tmp = Float64(a * b); else tmp = Float64(t * z); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((z * t) <= -2e+64) tmp = t * z; elseif ((z * t) <= 1e+25) tmp = a * b; else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(z * t), $MachinePrecision], -2e+64], N[(t * z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1e+25], N[(a * b), $MachinePrecision], N[(t * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+64}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;z \cdot t \leq 10^{+25}:\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (*.f64 z t) < -2.00000000000000004e64 or 1.00000000000000009e25 < (*.f64 z t) Initial program 97.6%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6466.9
Applied rewrites66.9%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-*.f6467.3
Applied rewrites67.3%
Taylor expanded in x around 0
lower-*.f6434.5
Applied rewrites34.5%
if -2.00000000000000004e64 < (*.f64 z t) < 1.00000000000000009e25Initial program 97.6%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6468.4
Applied rewrites68.4%
Taylor expanded in x around 0
lower-*.f6435.7
Applied rewrites35.7%
(FPCore (x y z t a b) :precision binary64 (* a b))
double code(double x, double y, double z, double t, double a, double b) {
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)
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
code = a * b
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return a * b;
}
def code(x, y, z, t, a, b): return a * b
function code(x, y, z, t, a, b) return Float64(a * b) end
function tmp = code(x, y, z, t, a, b) tmp = a * b; end
code[x_, y_, z_, t_, a_, b_] := N[(a * b), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b
\end{array}
Initial program 97.6%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6468.4
Applied rewrites68.4%
Taylor expanded in x around 0
lower-*.f6435.7
Applied rewrites35.7%
herbie shell --seed 2025142
(FPCore (x y z t a b)
:name "Linear.V3:$cdot from linear-1.19.1.3, B"
:precision binary64
(+ (+ (* x y) (* z t)) (* a b)))