
(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 8 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 b a (fma t z (* y x))))
double code(double x, double y, double z, double t, double a, double b) {
return fma(b, a, fma(t, z, (y * x)));
}
function code(x, y, z, t, a, b) return fma(b, a, fma(t, z, Float64(y * x))) end
code[x_, y_, z_, t_, a_, b_] := N[(b * a + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right)
\end{array}
Initial program 97.9%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
mul-1-negN/A
distribute-lft-neg-outN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f6499.0
Applied rewrites99.0%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma t z (* y x)))) (if (<= (* z t) -5e+33) t_1 (if (<= (* z t) 2e+39) (fma b a (* x y)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(t, z, (y * x));
double tmp;
if ((z * t) <= -5e+33) {
tmp = t_1;
} else if ((z * t) <= 2e+39) {
tmp = fma(b, a, (x * y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(t, z, Float64(y * x)) tmp = 0.0 if (Float64(z * t) <= -5e+33) tmp = t_1; elseif (Float64(z * t) <= 2e+39) tmp = fma(b, a, Float64(x * y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -5e+33], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 2e+39], N[(b * a + N[(x * y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, z, y \cdot x\right)\\
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+33}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+39}:\\
\;\;\;\;\mathsf{fma}\left(b, a, x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -4.99999999999999973e33 or 1.99999999999999988e39 < (*.f64 z t) Initial program 96.1%
Taylor expanded in a around 0
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
mul-1-negN/A
distribute-lft-neg-outN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f6481.7
Applied rewrites81.7%
if -4.99999999999999973e33 < (*.f64 z t) < 1.99999999999999988e39Initial program 99.4%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
mul-1-negN/A
distribute-lft-neg-outN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
lower-*.f6489.4
Applied rewrites89.4%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma t z (* y x)))) (if (<= (* z t) -5e+33) t_1 (if (<= (* z t) 2e+39) (fma y x (* b a)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(t, z, (y * x));
double tmp;
if ((z * t) <= -5e+33) {
tmp = t_1;
} else if ((z * t) <= 2e+39) {
tmp = fma(y, x, (b * a));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(t, z, Float64(y * x)) tmp = 0.0 if (Float64(z * t) <= -5e+33) tmp = t_1; elseif (Float64(z * t) <= 2e+39) tmp = fma(y, x, Float64(b * a)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -5e+33], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 2e+39], N[(y * x + N[(b * a), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, z, y \cdot x\right)\\
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+33}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+39}:\\
\;\;\;\;\mathsf{fma}\left(y, x, b \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -4.99999999999999973e33 or 1.99999999999999988e39 < (*.f64 z t) Initial program 96.1%
Taylor expanded in a around 0
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
mul-1-negN/A
distribute-lft-neg-outN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f6481.7
Applied rewrites81.7%
if -4.99999999999999973e33 < (*.f64 z t) < 1.99999999999999988e39Initial program 99.4%
Taylor expanded in z around 0
/-rgt-identityN/A
metadata-evalN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
associate-*l*N/A
fp-cancel-sub-sign-invN/A
div-addN/A
frac-2neg-revN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
*-lft-identityN/A
metadata-evalN/A
/-rgt-identityN/A
remove-double-negN/A
Applied rewrites89.4%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma t z (* b a))))
(if (<= (* a b) -5e+139)
t_1
(if (<= (* a b) 1e-87) (fma t z (* y x)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(t, z, (b * a));
double tmp;
if ((a * b) <= -5e+139) {
tmp = t_1;
} else if ((a * b) <= 1e-87) {
tmp = fma(t, z, (y * x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(t, z, Float64(b * a)) tmp = 0.0 if (Float64(a * b) <= -5e+139) tmp = t_1; elseif (Float64(a * b) <= 1e-87) tmp = fma(t, z, Float64(y * x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(t * z + N[(b * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -5e+139], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], 1e-87], N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, z, b \cdot a\right)\\
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+139}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq 10^{-87}:\\
\;\;\;\;\mathsf{fma}\left(t, z, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 a b) < -5.0000000000000003e139 or 1.00000000000000002e-87 < (*.f64 a b) Initial program 96.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6479.2
Applied rewrites79.2%
if -5.0000000000000003e139 < (*.f64 a b) < 1.00000000000000002e-87Initial program 99.2%
Taylor expanded in a around 0
fp-cancel-sign-sub-invN/A
distribute-lft-neg-outN/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
mul-1-negN/A
distribute-lft-neg-outN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f6487.9
Applied rewrites87.9%
(FPCore (x y z t a b) :precision binary64 (if (<= (* x y) -2e+139) (* y x) (if (<= (* x y) 5e+203) (fma t z (* b a)) (* y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -2e+139) {
tmp = y * x;
} else if ((x * y) <= 5e+203) {
tmp = fma(t, z, (b * a));
} else {
tmp = y * x;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x * y) <= -2e+139) tmp = Float64(y * x); elseif (Float64(x * y) <= 5e+203) tmp = fma(t, z, Float64(b * a)); else tmp = Float64(y * x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * y), $MachinePrecision], -2e+139], N[(y * x), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 5e+203], N[(t * z + N[(b * a), $MachinePrecision]), $MachinePrecision], N[(y * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+139}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{+203}:\\
\;\;\;\;\mathsf{fma}\left(t, z, b \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if (*.f64 x y) < -2.00000000000000007e139 or 4.99999999999999994e203 < (*.f64 x y) Initial program 94.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6479.0
Applied rewrites79.0%
if -2.00000000000000007e139 < (*.f64 x y) < 4.99999999999999994e203Initial program 99.2%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6482.8
Applied rewrites82.8%
(FPCore (x y z t a b) :precision binary64 (if (<= (* x y) -2e+139) (* y x) (if (<= (* x y) 5000.0) (* t z) (if (<= (* x y) 4e+68) (* b a) (* y x)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -2e+139) {
tmp = y * x;
} else if ((x * y) <= 5000.0) {
tmp = t * z;
} else if ((x * y) <= 4e+68) {
tmp = b * a;
} else {
tmp = y * x;
}
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 ((x * y) <= (-2d+139)) then
tmp = y * x
else if ((x * y) <= 5000.0d0) then
tmp = t * z
else if ((x * y) <= 4d+68) then
tmp = b * a
else
tmp = y * x
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 ((x * y) <= -2e+139) {
tmp = y * x;
} else if ((x * y) <= 5000.0) {
tmp = t * z;
} else if ((x * y) <= 4e+68) {
tmp = b * a;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x * y) <= -2e+139: tmp = y * x elif (x * y) <= 5000.0: tmp = t * z elif (x * y) <= 4e+68: tmp = b * a else: tmp = y * x return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x * y) <= -2e+139) tmp = Float64(y * x); elseif (Float64(x * y) <= 5000.0) tmp = Float64(t * z); elseif (Float64(x * y) <= 4e+68) tmp = Float64(b * a); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((x * y) <= -2e+139) tmp = y * x; elseif ((x * y) <= 5000.0) tmp = t * z; elseif ((x * y) <= 4e+68) tmp = b * a; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * y), $MachinePrecision], -2e+139], N[(y * x), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 5000.0], N[(t * z), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 4e+68], N[(b * a), $MachinePrecision], N[(y * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+139}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \cdot y \leq 5000:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{+68}:\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if (*.f64 x y) < -2.00000000000000007e139 or 3.99999999999999981e68 < (*.f64 x y) Initial program 95.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6471.4
Applied rewrites71.4%
if -2.00000000000000007e139 < (*.f64 x y) < 5e3Initial program 99.2%
Taylor expanded in z around inf
lower-*.f6445.9
Applied rewrites45.9%
if 5e3 < (*.f64 x y) < 3.99999999999999981e68Initial program 99.3%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6435.6
Applied rewrites35.6%
(FPCore (x y z t a b) :precision binary64 (if (<= (* z t) -5e+33) (* t z) (if (<= (* z t) 5e+78) (* b a) (* t z))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z * t) <= -5e+33) {
tmp = t * z;
} else if ((z * t) <= 5e+78) {
tmp = b * a;
} 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) <= (-5d+33)) then
tmp = t * z
else if ((z * t) <= 5d+78) then
tmp = b * a
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) <= -5e+33) {
tmp = t * z;
} else if ((z * t) <= 5e+78) {
tmp = b * a;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (z * t) <= -5e+33: tmp = t * z elif (z * t) <= 5e+78: tmp = b * a else: tmp = t * z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(z * t) <= -5e+33) tmp = Float64(t * z); elseif (Float64(z * t) <= 5e+78) tmp = Float64(b * a); 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) <= -5e+33) tmp = t * z; elseif ((z * t) <= 5e+78) tmp = b * a; else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(z * t), $MachinePrecision], -5e+33], N[(t * z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+78], N[(b * a), $MachinePrecision], N[(t * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+33}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+78}:\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (*.f64 z t) < -4.99999999999999973e33 or 4.99999999999999984e78 < (*.f64 z t) Initial program 95.8%
Taylor expanded in z around inf
lower-*.f6466.8
Applied rewrites66.8%
if -4.99999999999999973e33 < (*.f64 z t) < 4.99999999999999984e78Initial program 99.4%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6446.4
Applied rewrites46.4%
(FPCore (x y z t a b) :precision binary64 (* b a))
double code(double x, double y, double z, double t, double a, double b) {
return b * a;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
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 = b * a
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return b * a;
}
def code(x, y, z, t, a, b): return b * a
function code(x, y, z, t, a, b) return Float64(b * a) end
function tmp = code(x, y, z, t, a, b) tmp = b * a; end
code[x_, y_, z_, t_, a_, b_] := N[(b * a), $MachinePrecision]
\begin{array}{l}
\\
b \cdot a
\end{array}
Initial program 97.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6435.4
Applied rewrites35.4%
herbie shell --seed 2025130
(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)))