
(FPCore (x y z t) :precision binary64 (+ x (* (- y z) (- t x))))
double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y - z) * (t - x))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
def code(x, y, z, t): return x + ((y - z) * (t - x))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - z) * Float64(t - x))) end
function tmp = code(x, y, z, t) tmp = x + ((y - z) * (t - x)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - z\right) \cdot \left(t - x\right)
\end{array}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (* (- y z) (- t x))))
double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y - z) * (t - x))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - z) * (t - x));
}
def code(x, y, z, t): return x + ((y - z) * (t - x))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - z) * Float64(t - x))) end
function tmp = code(x, y, z, t) tmp = x + ((y - z) * (t - x)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - z\right) \cdot \left(t - x\right)
\end{array}
(FPCore (x y z t) :precision binary64 (fma (- y z) (- t x) x))
double code(double x, double y, double z, double t) {
return fma((y - z), (t - x), x);
}
function code(x, y, z, t) return fma(Float64(y - z), Float64(t - x), x) end
code[x_, y_, z_, t_] := N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - z, t - x, x\right)
\end{array}
Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lift--.f64100.0
Applied rewrites100.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- x t) z))) (if (<= z -1.9e+16) t_1 (if (<= z 2e+27) (fma (- t x) y x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (x - t) * z;
double tmp;
if (z <= -1.9e+16) {
tmp = t_1;
} else if (z <= 2e+27) {
tmp = fma((t - x), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(x - t) * z) tmp = 0.0 if (z <= -1.9e+16) tmp = t_1; elseif (z <= 2e+27) tmp = fma(Float64(t - x), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x - t), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -1.9e+16], t$95$1, If[LessEqual[z, 2e+27], N[(N[(t - x), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x - t\right) \cdot z\\
\mathbf{if}\;z \leq -1.9 \cdot 10^{+16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2 \cdot 10^{+27}:\\
\;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.9e16 or 2e27 < z Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
+-commutativeN/A
*-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt-outN/A
associate-*r*N/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
*-lft-identityN/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6496.2
Applied rewrites96.2%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6480.1
Applied rewrites80.1%
if -1.9e16 < z < 2e27Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6488.7
Applied rewrites88.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (- x t) z)))
(if (<= z -8.5e+15)
t_1
(if (<= z 8e-99) (fma y t x) (if (<= z 1.9e+27) (* (- t x) y) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = (x - t) * z;
double tmp;
if (z <= -8.5e+15) {
tmp = t_1;
} else if (z <= 8e-99) {
tmp = fma(y, t, x);
} else if (z <= 1.9e+27) {
tmp = (t - x) * y;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(x - t) * z) tmp = 0.0 if (z <= -8.5e+15) tmp = t_1; elseif (z <= 8e-99) tmp = fma(y, t, x); elseif (z <= 1.9e+27) tmp = Float64(Float64(t - x) * y); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x - t), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -8.5e+15], t$95$1, If[LessEqual[z, 8e-99], N[(y * t + x), $MachinePrecision], If[LessEqual[z, 1.9e+27], N[(N[(t - x), $MachinePrecision] * y), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x - t\right) \cdot z\\
\mathbf{if}\;z \leq -8.5 \cdot 10^{+15}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 8 \cdot 10^{-99}:\\
\;\;\;\;\mathsf{fma}\left(y, t, x\right)\\
\mathbf{elif}\;z \leq 1.9 \cdot 10^{+27}:\\
\;\;\;\;\left(t - x\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -8.5e15 or 1.90000000000000011e27 < z Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
+-commutativeN/A
*-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt-outN/A
associate-*r*N/A
associate-+l+N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
*-lft-identityN/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6496.2
Applied rewrites96.2%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6480.1
Applied rewrites80.1%
if -8.5e15 < z < 8.0000000000000002e-99Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lift--.f64100.0
Applied rewrites100.0%
Taylor expanded in y around inf
Applied rewrites91.8%
Taylor expanded in x around 0
Applied rewrites68.4%
if 8.0000000000000002e-99 < z < 1.90000000000000011e27Initial program 99.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6454.7
Applied rewrites54.7%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- 1.0 y) x))) (if (<= x -3e+41) t_1 (if (<= x 1.08e-10) (* (- y z) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (1.0 - y) * x;
double tmp;
if (x <= -3e+41) {
tmp = t_1;
} else if (x <= 1.08e-10) {
tmp = (y - z) * t;
} else {
tmp = t_1;
}
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)
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) :: t_1
real(8) :: tmp
t_1 = (1.0d0 - y) * x
if (x <= (-3d+41)) then
tmp = t_1
else if (x <= 1.08d-10) then
tmp = (y - z) * t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (1.0 - y) * x;
double tmp;
if (x <= -3e+41) {
tmp = t_1;
} else if (x <= 1.08e-10) {
tmp = (y - z) * t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (1.0 - y) * x tmp = 0 if x <= -3e+41: tmp = t_1 elif x <= 1.08e-10: tmp = (y - z) * t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(1.0 - y) * x) tmp = 0.0 if (x <= -3e+41) tmp = t_1; elseif (x <= 1.08e-10) tmp = Float64(Float64(y - z) * t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (1.0 - y) * x; tmp = 0.0; if (x <= -3e+41) tmp = t_1; elseif (x <= 1.08e-10) tmp = (y - z) * t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(1.0 - y), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -3e+41], t$95$1, If[LessEqual[x, 1.08e-10], N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(1 - y\right) \cdot x\\
\mathbf{if}\;x \leq -3 \cdot 10^{+41}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.08 \cdot 10^{-10}:\\
\;\;\;\;\left(y - z\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -2.9999999999999998e41 or 1.08000000000000002e-10 < x Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lift--.f6482.6
Applied rewrites82.6%
Taylor expanded in y around inf
Applied rewrites55.2%
if -2.9999999999999998e41 < x < 1.08000000000000002e-10Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6469.7
Applied rewrites69.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (- t x) y)))
(if (<= z -2.4e+135)
(- (* t z))
(if (<= z -2.2e-163)
t_1
(if (<= z 8e-99) (fma y t x) (if (<= z 1.65e+59) t_1 (* z x)))))))
double code(double x, double y, double z, double t) {
double t_1 = (t - x) * y;
double tmp;
if (z <= -2.4e+135) {
tmp = -(t * z);
} else if (z <= -2.2e-163) {
tmp = t_1;
} else if (z <= 8e-99) {
tmp = fma(y, t, x);
} else if (z <= 1.65e+59) {
tmp = t_1;
} else {
tmp = z * x;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(t - x) * y) tmp = 0.0 if (z <= -2.4e+135) tmp = Float64(-Float64(t * z)); elseif (z <= -2.2e-163) tmp = t_1; elseif (z <= 8e-99) tmp = fma(y, t, x); elseif (z <= 1.65e+59) tmp = t_1; else tmp = Float64(z * x); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[z, -2.4e+135], (-N[(t * z), $MachinePrecision]), If[LessEqual[z, -2.2e-163], t$95$1, If[LessEqual[z, 8e-99], N[(y * t + x), $MachinePrecision], If[LessEqual[z, 1.65e+59], t$95$1, N[(z * x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(t - x\right) \cdot y\\
\mathbf{if}\;z \leq -2.4 \cdot 10^{+135}:\\
\;\;\;\;-t \cdot z\\
\mathbf{elif}\;z \leq -2.2 \cdot 10^{-163}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 8 \cdot 10^{-99}:\\
\;\;\;\;\mathsf{fma}\left(y, t, x\right)\\
\mathbf{elif}\;z \leq 1.65 \cdot 10^{+59}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -2.39999999999999997e135Initial program 100.0%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6489.6
Applied rewrites89.6%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f6448.1
Applied rewrites48.1%
if -2.39999999999999997e135 < z < -2.20000000000000011e-163 or 8.0000000000000002e-99 < z < 1.65e59Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6451.6
Applied rewrites51.6%
if -2.20000000000000011e-163 < z < 8.0000000000000002e-99Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lift--.f64100.0
Applied rewrites100.0%
Taylor expanded in y around inf
Applied rewrites96.2%
Taylor expanded in x around 0
Applied rewrites73.3%
if 1.65e59 < z Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lift--.f6454.3
Applied rewrites54.3%
Taylor expanded in z around inf
Applied rewrites14.0%
(FPCore (x y z t) :precision binary64 (if (<= z -7.2e+16) (- (* t z)) (if (<= z 1.7e+15) (fma y t x) (* z x))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.2e+16) {
tmp = -(t * z);
} else if (z <= 1.7e+15) {
tmp = fma(y, t, x);
} else {
tmp = z * x;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -7.2e+16) tmp = Float64(-Float64(t * z)); elseif (z <= 1.7e+15) tmp = fma(y, t, x); else tmp = Float64(z * x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -7.2e+16], (-N[(t * z), $MachinePrecision]), If[LessEqual[z, 1.7e+15], N[(y * t + x), $MachinePrecision], N[(z * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.2 \cdot 10^{+16}:\\
\;\;\;\;-t \cdot z\\
\mathbf{elif}\;z \leq 1.7 \cdot 10^{+15}:\\
\;\;\;\;\mathsf{fma}\left(y, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -7.2e16Initial program 100.0%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6478.9
Applied rewrites78.9%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f6442.5
Applied rewrites42.5%
if -7.2e16 < z < 1.7e15Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lift--.f64100.0
Applied rewrites100.0%
Taylor expanded in y around inf
Applied rewrites89.4%
Taylor expanded in x around 0
Applied rewrites65.7%
if 1.7e15 < z Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lift--.f6453.3
Applied rewrites53.3%
Taylor expanded in z around inf
Applied rewrites42.8%
(FPCore (x y z t) :precision binary64 (if (<= z -1.55e-58) (- (* t z)) (if (<= z 1.7e+15) (* t y) (* z x))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.55e-58) {
tmp = -(t * z);
} else if (z <= 1.7e+15) {
tmp = t * y;
} else {
tmp = z * 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)
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) :: tmp
if (z <= (-1.55d-58)) then
tmp = -(t * z)
else if (z <= 1.7d+15) then
tmp = t * y
else
tmp = z * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.55e-58) {
tmp = -(t * z);
} else if (z <= 1.7e+15) {
tmp = t * y;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.55e-58: tmp = -(t * z) elif z <= 1.7e+15: tmp = t * y else: tmp = z * x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.55e-58) tmp = Float64(-Float64(t * z)); elseif (z <= 1.7e+15) tmp = Float64(t * y); else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.55e-58) tmp = -(t * z); elseif (z <= 1.7e+15) tmp = t * y; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.55e-58], (-N[(t * z), $MachinePrecision]), If[LessEqual[z, 1.7e+15], N[(t * y), $MachinePrecision], N[(z * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.55 \cdot 10^{-58}:\\
\;\;\;\;-t \cdot z\\
\mathbf{elif}\;z \leq 1.7 \cdot 10^{+15}:\\
\;\;\;\;t \cdot y\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -1.55e-58Initial program 100.0%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6468.3
Applied rewrites68.3%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f6438.7
Applied rewrites38.7%
if -1.55e-58 < z < 1.7e15Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6460.0
Applied rewrites60.0%
Taylor expanded in x around 0
lower-*.f6436.9
Applied rewrites36.9%
if 1.7e15 < z Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lift--.f6453.3
Applied rewrites53.3%
Taylor expanded in z around inf
Applied rewrites42.8%
(FPCore (x y z t) :precision binary64 (if (<= z -3.1e+86) (* z x) (if (<= z 1.7e+15) (* t y) (* z x))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.1e+86) {
tmp = z * x;
} else if (z <= 1.7e+15) {
tmp = t * y;
} else {
tmp = z * 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)
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) :: tmp
if (z <= (-3.1d+86)) then
tmp = z * x
else if (z <= 1.7d+15) then
tmp = t * y
else
tmp = z * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.1e+86) {
tmp = z * x;
} else if (z <= 1.7e+15) {
tmp = t * y;
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.1e+86: tmp = z * x elif z <= 1.7e+15: tmp = t * y else: tmp = z * x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.1e+86) tmp = Float64(z * x); elseif (z <= 1.7e+15) tmp = Float64(t * y); else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -3.1e+86) tmp = z * x; elseif (z <= 1.7e+15) tmp = t * y; else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.1e+86], N[(z * x), $MachinePrecision], If[LessEqual[z, 1.7e+15], N[(t * y), $MachinePrecision], N[(z * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.1 \cdot 10^{+86}:\\
\;\;\;\;z \cdot x\\
\mathbf{elif}\;z \leq 1.7 \cdot 10^{+15}:\\
\;\;\;\;t \cdot y\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if z < -3.1000000000000002e86 or 1.7e15 < z Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lift--.f6453.2
Applied rewrites53.2%
Taylor expanded in z around inf
Applied rewrites44.0%
if -3.1000000000000002e86 < z < 1.7e15Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6458.2
Applied rewrites58.2%
Taylor expanded in x around 0
lower-*.f6435.0
Applied rewrites35.0%
(FPCore (x y z t) :precision binary64 (* t y))
double code(double x, double y, double z, double t) {
return t * y;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = t * y
end function
public static double code(double x, double y, double z, double t) {
return t * y;
}
def code(x, y, z, t): return t * y
function code(x, y, z, t) return Float64(t * y) end
function tmp = code(x, y, z, t) tmp = t * y; end
code[x_, y_, z_, t_] := N[(t * y), $MachinePrecision]
\begin{array}{l}
\\
t \cdot y
\end{array}
Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift--.f6445.4
Applied rewrites45.4%
Taylor expanded in x around 0
lower-*.f6426.9
Applied rewrites26.9%
herbie shell --seed 2025120
(FPCore (x y z t)
:name "Data.Metrics.Snapshot:quantile from metrics-0.3.0.2"
:precision binary64
(+ x (* (- y z) (- t x))))