
(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}
Sampling outcomes in binary64 precision:
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 y x (fma b a (* t z))))
double code(double x, double y, double z, double t, double a, double b) {
return fma(y, x, fma(b, a, (t * z)));
}
function code(x, y, z, t, a, b) return fma(y, x, fma(b, a, Float64(t * z))) end
code[x_, y_, z_, t_, a_, b_] := N[(y * x + N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, x, \mathsf{fma}\left(b, a, t \cdot z\right)\right)
\end{array}
Initial program 96.1%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6497.7
Applied rewrites97.7%
(FPCore (x y z t a b) :precision binary64 (if (<= (* x y) -6e+69) (* y x) (if (<= (* x y) 1e-255) (* b a) (if (<= (* x y) 5e+104) (* t z) (* y x)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -6e+69) {
tmp = y * x;
} else if ((x * y) <= 1e-255) {
tmp = b * a;
} else if ((x * y) <= 5e+104) {
tmp = t * z;
} 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) <= (-6d+69)) then
tmp = y * x
else if ((x * y) <= 1d-255) then
tmp = b * a
else if ((x * y) <= 5d+104) then
tmp = t * z
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) <= -6e+69) {
tmp = y * x;
} else if ((x * y) <= 1e-255) {
tmp = b * a;
} else if ((x * y) <= 5e+104) {
tmp = t * z;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x * y) <= -6e+69: tmp = y * x elif (x * y) <= 1e-255: tmp = b * a elif (x * y) <= 5e+104: tmp = t * z else: tmp = y * x return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x * y) <= -6e+69) tmp = Float64(y * x); elseif (Float64(x * y) <= 1e-255) tmp = Float64(b * a); elseif (Float64(x * y) <= 5e+104) tmp = Float64(t * z); 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) <= -6e+69) tmp = y * x; elseif ((x * y) <= 1e-255) tmp = b * a; elseif ((x * y) <= 5e+104) tmp = t * z; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * y), $MachinePrecision], -6e+69], N[(y * x), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e-255], N[(b * a), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 5e+104], N[(t * z), $MachinePrecision], N[(y * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -6 \cdot 10^{+69}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \cdot y \leq 10^{-255}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{+104}:\\
\;\;\;\;t \cdot z\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if (*.f64 x y) < -5.99999999999999967e69 or 4.9999999999999997e104 < (*.f64 x y) Initial program 91.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6470.9
Applied rewrites70.9%
if -5.99999999999999967e69 < (*.f64 x y) < 1e-255Initial program 98.0%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6458.1
Applied rewrites58.1%
if 1e-255 < (*.f64 x y) < 4.9999999999999997e104Initial program 100.0%
Taylor expanded in z around inf
lower-*.f6456.5
Applied rewrites56.5%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* a b) -5e+98) (not (<= (* a b) 1e+59))) (fma b a (* y x)) (fma y x (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -5e+98) || !((a * b) <= 1e+59)) {
tmp = fma(b, a, (y * x));
} else {
tmp = fma(y, x, (z * t));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(a * b) <= -5e+98) || !(Float64(a * b) <= 1e+59)) tmp = fma(b, a, Float64(y * x)); else tmp = fma(y, x, Float64(z * t)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -5e+98], N[Not[LessEqual[N[(a * b), $MachinePrecision], 1e+59]], $MachinePrecision]], N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision], N[(y * x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+98} \lor \neg \left(a \cdot b \leq 10^{+59}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, x, z \cdot t\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -4.9999999999999998e98 or 9.99999999999999972e58 < (*.f64 a b) Initial program 93.8%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6487.9
Applied rewrites87.9%
if -4.9999999999999998e98 < (*.f64 a b) < 9.99999999999999972e58Initial program 97.5%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6498.7
Applied rewrites98.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6489.1
Applied rewrites89.1%
Final simplification88.7%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* a b) -5e+98) (not (<= (* a b) 1e+59))) (fma b a (* y x)) (fma t z (* y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -5e+98) || !((a * b) <= 1e+59)) {
tmp = fma(b, a, (y * x));
} else {
tmp = fma(t, z, (y * x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(a * b) <= -5e+98) || !(Float64(a * b) <= 1e+59)) tmp = fma(b, a, Float64(y * x)); else tmp = fma(t, z, Float64(y * x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -5e+98], N[Not[LessEqual[N[(a * b), $MachinePrecision], 1e+59]], $MachinePrecision]], N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision], N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+98} \lor \neg \left(a \cdot b \leq 10^{+59}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, z, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -4.9999999999999998e98 or 9.99999999999999972e58 < (*.f64 a b) Initial program 93.8%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6487.9
Applied rewrites87.9%
if -4.9999999999999998e98 < (*.f64 a b) < 9.99999999999999972e58Initial program 97.5%
Taylor expanded in a around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6489.1
Applied rewrites89.1%
Final simplification88.7%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* z t) -5e+162) (not (<= (* z t) 2e+189))) (* t z) (fma b a (* y x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((z * t) <= -5e+162) || !((z * t) <= 2e+189)) {
tmp = t * z;
} else {
tmp = fma(b, a, (y * x));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(z * t) <= -5e+162) || !(Float64(z * t) <= 2e+189)) tmp = Float64(t * z); else tmp = fma(b, a, Float64(y * x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], -5e+162], N[Not[LessEqual[N[(z * t), $MachinePrecision], 2e+189]], $MachinePrecision]], N[(t * z), $MachinePrecision], N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+162} \lor \neg \left(z \cdot t \leq 2 \cdot 10^{+189}\right):\\
\;\;\;\;t \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -4.9999999999999997e162 or 2e189 < (*.f64 z t) Initial program 87.8%
Taylor expanded in z around inf
lower-*.f6481.3
Applied rewrites81.3%
if -4.9999999999999997e162 < (*.f64 z t) < 2e189Initial program 99.4%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6484.0
Applied rewrites84.0%
Final simplification83.2%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* a b) -1e+63) (not (<= (* a b) 1e+59))) (* b a) (* t z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -1e+63) || !((a * b) <= 1e+59)) {
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 (((a * b) <= (-1d+63)) .or. (.not. ((a * b) <= 1d+59))) 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 (((a * b) <= -1e+63) || !((a * b) <= 1e+59)) {
tmp = b * a;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((a * b) <= -1e+63) or not ((a * b) <= 1e+59): tmp = b * a else: tmp = t * z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(a * b) <= -1e+63) || !(Float64(a * b) <= 1e+59)) 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 (((a * b) <= -1e+63) || ~(((a * b) <= 1e+59))) tmp = b * a; else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -1e+63], N[Not[LessEqual[N[(a * b), $MachinePrecision], 1e+59]], $MachinePrecision]], N[(b * a), $MachinePrecision], N[(t * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+63} \lor \neg \left(a \cdot b \leq 10^{+59}\right):\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (*.f64 a b) < -1.00000000000000006e63 or 9.99999999999999972e58 < (*.f64 a b) Initial program 94.2%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6471.4
Applied rewrites71.4%
if -1.00000000000000006e63 < (*.f64 a b) < 9.99999999999999972e58Initial program 97.4%
Taylor expanded in z around inf
lower-*.f6450.5
Applied rewrites50.5%
Final simplification59.0%
(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 96.1%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6436.3
Applied rewrites36.3%
herbie shell --seed 2025037
(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)))