
(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]
\left(x \cdot y + z \cdot t\right) + a \cdot b
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]
\left(x \cdot y + z \cdot t\right) + a \cdot b
(FPCore (x y z t a b) :precision binary64 (fma z t (fma b a (* y x))))
double code(double x, double y, double z, double t, double a, double b) {
return fma(z, t, fma(b, a, (y * x)));
}
function code(x, y, z, t, a, b) return fma(z, t, fma(b, a, Float64(y * x))) end
code[x_, y_, z_, t_, a_, b_] := N[(z * t + N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(z, t, \mathsf{fma}\left(b, a, y \cdot x\right)\right)
Initial program 97.5%
lift-+.f64N/A
lift-+.f64N/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.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.9%
Applied rewrites98.9%
(FPCore (x y z t a b) :precision binary64 (if (<= (* z t) -1e+110) (fma a b (* t z)) (if (<= (* z t) 2000000000.0) (fma a b (* x y)) (fma t z (* x y)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z * t) <= -1e+110) {
tmp = fma(a, b, (t * z));
} else if ((z * t) <= 2000000000.0) {
tmp = fma(a, b, (x * y));
} else {
tmp = fma(t, z, (x * y));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(z * t) <= -1e+110) tmp = fma(a, b, Float64(t * z)); elseif (Float64(z * t) <= 2000000000.0) tmp = fma(a, b, Float64(x * y)); else tmp = fma(t, z, Float64(x * y)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(z * t), $MachinePrecision], -1e+110], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2000000000.0], N[(a * b + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(t * z + N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+110}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\mathbf{elif}\;z \cdot t \leq 2000000000:\\
\;\;\;\;\mathsf{fma}\left(a, b, x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, z, x \cdot y\right)\\
\end{array}
if (*.f64 z t) < -1e110Initial program 97.5%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6467.5%
Applied rewrites67.5%
if -1e110 < (*.f64 z t) < 2e9Initial program 97.5%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6468.1%
Applied rewrites68.1%
if 2e9 < (*.f64 z t) Initial program 97.5%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6467.5%
Applied rewrites67.5%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-*.f6466.5%
Applied rewrites66.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma a b (* t z))))
(if (<= (* z t) -1e+110)
t_1
(if (<= (* z t) 5e+68) (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) <= -1e+110) {
tmp = t_1;
} else if ((z * t) <= 5e+68) {
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) <= -1e+110) tmp = t_1; elseif (Float64(z * t) <= 5e+68) 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], -1e+110], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 5e+68], N[(a * b + N[(x * y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, b, t \cdot z\right)\\
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+110}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+68}:\\
\;\;\;\;\mathsf{fma}\left(a, b, x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (*.f64 z t) < -1e110 or 5.0000000000000004e68 < (*.f64 z t) Initial program 97.5%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6467.5%
Applied rewrites67.5%
if -1e110 < (*.f64 z t) < 5.0000000000000004e68Initial program 97.5%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6468.1%
Applied rewrites68.1%
(FPCore (x y z t a b) :precision binary64 (if (<= (* x y) -6.6e+223) (* x y) (if (<= (* x y) 1.1e+205) (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) <= -6.6e+223) {
tmp = x * y;
} else if ((x * y) <= 1.1e+205) {
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) <= -6.6e+223) tmp = Float64(x * y); elseif (Float64(x * y) <= 1.1e+205) 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], -6.6e+223], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1.1e+205], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -6.6 \cdot 10^{+223}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq 1.1 \cdot 10^{+205}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
if (*.f64 x y) < -6.5999999999999999e223 or 1.0999999999999999e205 < (*.f64 x y) Initial program 97.5%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6467.5%
Applied rewrites67.5%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-*.f6466.5%
Applied rewrites66.5%
Taylor expanded in x around 0
lower-*.f6434.8%
Applied rewrites34.8%
Taylor expanded in x around inf
lower-*.f6435.1%
Applied rewrites35.1%
if -6.5999999999999999e223 < (*.f64 x y) < 1.0999999999999999e205Initial program 97.5%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6467.5%
Applied rewrites67.5%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* z t) -1e+110)
(* t z)
(if (<= (* z t) -2e-80)
(* x y)
(if (<= (* z t) 40000000000000.0)
(* a b)
(if (<= (* z t) 5e+109) (* x y) (* t z))))))double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z * t) <= -1e+110) {
tmp = t * z;
} else if ((z * t) <= -2e-80) {
tmp = x * y;
} else if ((z * t) <= 40000000000000.0) {
tmp = a * b;
} else if ((z * t) <= 5e+109) {
tmp = x * y;
} 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) <= (-1d+110)) then
tmp = t * z
else if ((z * t) <= (-2d-80)) then
tmp = x * y
else if ((z * t) <= 40000000000000.0d0) then
tmp = a * b
else if ((z * t) <= 5d+109) then
tmp = x * y
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) <= -1e+110) {
tmp = t * z;
} else if ((z * t) <= -2e-80) {
tmp = x * y;
} else if ((z * t) <= 40000000000000.0) {
tmp = a * b;
} else if ((z * t) <= 5e+109) {
tmp = x * y;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (z * t) <= -1e+110: tmp = t * z elif (z * t) <= -2e-80: tmp = x * y elif (z * t) <= 40000000000000.0: tmp = a * b elif (z * t) <= 5e+109: tmp = x * y else: tmp = t * z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(z * t) <= -1e+110) tmp = Float64(t * z); elseif (Float64(z * t) <= -2e-80) tmp = Float64(x * y); elseif (Float64(z * t) <= 40000000000000.0) tmp = Float64(a * b); elseif (Float64(z * t) <= 5e+109) tmp = Float64(x * y); 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) <= -1e+110) tmp = t * z; elseif ((z * t) <= -2e-80) tmp = x * y; elseif ((z * t) <= 40000000000000.0) tmp = a * b; elseif ((z * t) <= 5e+109) tmp = x * y; else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(z * t), $MachinePrecision], -1e+110], N[(t * z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], -2e-80], N[(x * y), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 40000000000000.0], N[(a * b), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+109], N[(x * y), $MachinePrecision], N[(t * z), $MachinePrecision]]]]]
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+110}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;z \cdot t \leq -2 \cdot 10^{-80}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;z \cdot t \leq 40000000000000:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+109}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
if (*.f64 z t) < -1e110 or 5.0000000000000001e109 < (*.f64 z t) Initial program 97.5%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6467.5%
Applied rewrites67.5%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-*.f6466.5%
Applied rewrites66.5%
Taylor expanded in x around 0
lower-*.f6434.8%
Applied rewrites34.8%
if -1e110 < (*.f64 z t) < -1.99999999999999992e-80 or 4e13 < (*.f64 z t) < 5.0000000000000001e109Initial program 97.5%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6467.5%
Applied rewrites67.5%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-*.f6466.5%
Applied rewrites66.5%
Taylor expanded in x around 0
lower-*.f6434.8%
Applied rewrites34.8%
Taylor expanded in x around inf
lower-*.f6435.1%
Applied rewrites35.1%
if -1.99999999999999992e-80 < (*.f64 z t) < 4e13Initial program 97.5%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6468.1%
Applied rewrites68.1%
Taylor expanded in x around 0
lower-*.f6436.1%
Applied rewrites36.1%
(FPCore (x y z t a b) :precision binary64 (if (<= (* z t) -500.0) (* t z) (if (<= (* z t) 2000000000.0) (* a b) (* t z))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z * t) <= -500.0) {
tmp = t * z;
} else if ((z * t) <= 2000000000.0) {
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) <= (-500.0d0)) then
tmp = t * z
else if ((z * t) <= 2000000000.0d0) 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) <= -500.0) {
tmp = t * z;
} else if ((z * t) <= 2000000000.0) {
tmp = a * b;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (z * t) <= -500.0: tmp = t * z elif (z * t) <= 2000000000.0: tmp = a * b else: tmp = t * z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(z * t) <= -500.0) tmp = Float64(t * z); elseif (Float64(z * t) <= 2000000000.0) 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) <= -500.0) tmp = t * z; elseif ((z * t) <= 2000000000.0) 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], -500.0], N[(t * z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2000000000.0], N[(a * b), $MachinePrecision], N[(t * z), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -500:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;z \cdot t \leq 2000000000:\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
if (*.f64 z t) < -500 or 2e9 < (*.f64 z t) Initial program 97.5%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-*.f6467.5%
Applied rewrites67.5%
Taylor expanded in a around 0
lower-fma.f64N/A
lower-*.f6466.5%
Applied rewrites66.5%
Taylor expanded in x around 0
lower-*.f6434.8%
Applied rewrites34.8%
if -500 < (*.f64 z t) < 2e9Initial program 97.5%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6468.1%
Applied rewrites68.1%
Taylor expanded in x around 0
lower-*.f6436.1%
Applied rewrites36.1%
(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]
a \cdot b
Initial program 97.5%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6468.1%
Applied rewrites68.1%
Taylor expanded in x around 0
lower-*.f6436.1%
Applied rewrites36.1%
herbie shell --seed 2025187
(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)))