
(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]
x + \left(y - z\right) \cdot \left(t - x\right)
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]
x + \left(y - z\right) \cdot \left(t - x\right)
(FPCore (x y z t) :precision binary64 (fma (- z y) (- x t) x))
double code(double x, double y, double z, double t) {
return fma((z - y), (x - t), x);
}
function code(x, y, z, t) return fma(Float64(z - y), Float64(x - t), x) end
code[x_, y_, z_, t_] := N[(N[(z - y), $MachinePrecision] * N[(x - t), $MachinePrecision] + x), $MachinePrecision]
\mathsf{fma}\left(z - y, x - t, x\right)
Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
(FPCore (x y z t) :precision binary64 (if (<= z -5.9e+74) (* z (- x t)) (if (<= z 1.5e+24) (fma (- t x) y x) (fma z (- x t) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.9e+74) {
tmp = z * (x - t);
} else if (z <= 1.5e+24) {
tmp = fma((t - x), y, x);
} else {
tmp = fma(z, (x - t), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -5.9e+74) tmp = Float64(z * Float64(x - t)); elseif (z <= 1.5e+24) tmp = fma(Float64(t - x), y, x); else tmp = fma(z, Float64(x - t), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -5.9e+74], N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.5e+24], N[(N[(t - x), $MachinePrecision] * y + x), $MachinePrecision], N[(z * N[(x - t), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;z \leq -5.9 \cdot 10^{+74}:\\
\;\;\;\;z \cdot \left(x - t\right)\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{+24}:\\
\;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, x - t, x\right)\\
\end{array}
if z < -5.9000000000000002e74Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6444.8%
Applied rewrites44.8%
if -5.9000000000000002e74 < z < 1.49999999999999997e24Initial program 100.0%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6460.4%
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6460.4%
Applied rewrites60.4%
if 1.49999999999999997e24 < z Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites60.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* z (- x t)))) (if (<= z -5.9e+74) t_1 (if (<= z 1.5e+24) (fma (- t x) y x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = z * (x - t);
double tmp;
if (z <= -5.9e+74) {
tmp = t_1;
} else if (z <= 1.5e+24) {
tmp = fma((t - x), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(z * Float64(x - t)) tmp = 0.0 if (z <= -5.9e+74) tmp = t_1; elseif (z <= 1.5e+24) 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[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5.9e+74], t$95$1, If[LessEqual[z, 1.5e+24], N[(N[(t - x), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := z \cdot \left(x - t\right)\\
\mathbf{if}\;z \leq -5.9 \cdot 10^{+74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{+24}:\\
\;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if z < -5.9000000000000002e74 or 1.49999999999999997e24 < z Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6444.8%
Applied rewrites44.8%
if -5.9000000000000002e74 < z < 1.49999999999999997e24Initial program 100.0%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6460.4%
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6460.4%
Applied rewrites60.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* z (- x t))))
(if (<= z -5.9e+74)
t_1
(if (<= z -9.2e-100) (* y (- t x)) (if (<= z 1.5e+24) (fma t y x) t_1)))))double code(double x, double y, double z, double t) {
double t_1 = z * (x - t);
double tmp;
if (z <= -5.9e+74) {
tmp = t_1;
} else if (z <= -9.2e-100) {
tmp = y * (t - x);
} else if (z <= 1.5e+24) {
tmp = fma(t, y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(z * Float64(x - t)) tmp = 0.0 if (z <= -5.9e+74) tmp = t_1; elseif (z <= -9.2e-100) tmp = Float64(y * Float64(t - x)); elseif (z <= 1.5e+24) tmp = fma(t, y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5.9e+74], t$95$1, If[LessEqual[z, -9.2e-100], N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.5e+24], N[(t * y + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_1 := z \cdot \left(x - t\right)\\
\mathbf{if}\;z \leq -5.9 \cdot 10^{+74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -9.2 \cdot 10^{-100}:\\
\;\;\;\;y \cdot \left(t - x\right)\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{+24}:\\
\;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if z < -5.9000000000000002e74 or 1.49999999999999997e24 < z Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6444.8%
Applied rewrites44.8%
if -5.9000000000000002e74 < z < -9.19999999999999978e-100Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6444.8%
Applied rewrites44.8%
if -9.19999999999999978e-100 < z < 1.49999999999999997e24Initial program 100.0%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6460.4%
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6460.4%
Applied rewrites60.4%
Taylor expanded in x around 0
Applied rewrites41.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (- t x))) (t_2 (* t (- y z))))
(if (<= y -1.45e+51)
t_1
(if (<= y -1.55e-72)
t_2
(if (<= y 6.6e-233) (fma t y x) (if (<= y 59000.0) t_2 t_1))))))double code(double x, double y, double z, double t) {
double t_1 = y * (t - x);
double t_2 = t * (y - z);
double tmp;
if (y <= -1.45e+51) {
tmp = t_1;
} else if (y <= -1.55e-72) {
tmp = t_2;
} else if (y <= 6.6e-233) {
tmp = fma(t, y, x);
} else if (y <= 59000.0) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(y * Float64(t - x)) t_2 = Float64(t * Float64(y - z)) tmp = 0.0 if (y <= -1.45e+51) tmp = t_1; elseif (y <= -1.55e-72) tmp = t_2; elseif (y <= 6.6e-233) tmp = fma(t, y, x); elseif (y <= 59000.0) tmp = t_2; else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.45e+51], t$95$1, If[LessEqual[y, -1.55e-72], t$95$2, If[LessEqual[y, 6.6e-233], N[(t * y + x), $MachinePrecision], If[LessEqual[y, 59000.0], t$95$2, t$95$1]]]]]]
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
t_2 := t \cdot \left(y - z\right)\\
\mathbf{if}\;y \leq -1.45 \cdot 10^{+51}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -1.55 \cdot 10^{-72}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 6.6 \cdot 10^{-233}:\\
\;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
\mathbf{elif}\;y \leq 59000:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -1.4499999999999999e51 or 59000 < y Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6444.8%
Applied rewrites44.8%
if -1.4499999999999999e51 < y < -1.5499999999999999e-72 or 6.6000000000000001e-233 < y < 59000Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6448.6%
Applied rewrites48.6%
if -1.5499999999999999e-72 < y < 6.6000000000000001e-233Initial program 100.0%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6460.4%
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6460.4%
Applied rewrites60.4%
Taylor expanded in x around 0
Applied rewrites41.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* t (- y z))))
(if (<= z -1.2e+196)
(* x z)
(if (<= z -10.5) t_1 (if (<= z 7.5e-5) (fma t y x) t_1)))))double code(double x, double y, double z, double t) {
double t_1 = t * (y - z);
double tmp;
if (z <= -1.2e+196) {
tmp = x * z;
} else if (z <= -10.5) {
tmp = t_1;
} else if (z <= 7.5e-5) {
tmp = fma(t, y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(t * Float64(y - z)) tmp = 0.0 if (z <= -1.2e+196) tmp = Float64(x * z); elseif (z <= -10.5) tmp = t_1; elseif (z <= 7.5e-5) tmp = fma(t, y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.2e+196], N[(x * z), $MachinePrecision], If[LessEqual[z, -10.5], t$95$1, If[LessEqual[z, 7.5e-5], N[(t * y + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_1 := t \cdot \left(y - z\right)\\
\mathbf{if}\;z \leq -1.2 \cdot 10^{+196}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq -10.5:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if z < -1.2e196Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6444.8%
Applied rewrites44.8%
Taylor expanded in x around inf
lower-*.f6422.7%
Applied rewrites22.7%
if -1.2e196 < z < -10.5 or 7.49999999999999934e-5 < z Initial program 100.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6448.6%
Applied rewrites48.6%
if -10.5 < z < 7.49999999999999934e-5Initial program 100.0%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6460.4%
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6460.4%
Applied rewrites60.4%
Taylor expanded in x around 0
Applied rewrites41.7%
(FPCore (x y z t) :precision binary64 (if (<= z -1.4e+163) (* x z) (if (<= z 2.45e+64) (fma t y x) (* x z))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.4e+163) {
tmp = x * z;
} else if (z <= 2.45e+64) {
tmp = fma(t, y, x);
} else {
tmp = x * z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -1.4e+163) tmp = Float64(x * z); elseif (z <= 2.45e+64) tmp = fma(t, y, x); else tmp = Float64(x * z); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.4e+163], N[(x * z), $MachinePrecision], If[LessEqual[z, 2.45e+64], N[(t * y + x), $MachinePrecision], N[(x * z), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{+163}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq 2.45 \cdot 10^{+64}:\\
\;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot z\\
\end{array}
if z < -1.40000000000000007e163 or 2.4500000000000001e64 < z Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6444.8%
Applied rewrites44.8%
Taylor expanded in x around inf
lower-*.f6422.7%
Applied rewrites22.7%
if -1.40000000000000007e163 < z < 2.4500000000000001e64Initial program 100.0%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6460.4%
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6460.4%
Applied rewrites60.4%
Taylor expanded in x around 0
Applied rewrites41.7%
(FPCore (x y z t) :precision binary64 (if (<= z -1.05e+154) (* x z) (if (<= z 6.2e+24) (* t y) (* x z))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.05e+154) {
tmp = x * z;
} else if (z <= 6.2e+24) {
tmp = t * y;
} else {
tmp = x * 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)
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.05d+154)) then
tmp = x * z
else if (z <= 6.2d+24) then
tmp = t * y
else
tmp = x * z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.05e+154) {
tmp = x * z;
} else if (z <= 6.2e+24) {
tmp = t * y;
} else {
tmp = x * z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.05e+154: tmp = x * z elif z <= 6.2e+24: tmp = t * y else: tmp = x * z return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.05e+154) tmp = Float64(x * z); elseif (z <= 6.2e+24) tmp = Float64(t * y); else tmp = Float64(x * z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.05e+154) tmp = x * z; elseif (z <= 6.2e+24) tmp = t * y; else tmp = x * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.05e+154], N[(x * z), $MachinePrecision], If[LessEqual[z, 6.2e+24], N[(t * y), $MachinePrecision], N[(x * z), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{+154}:\\
\;\;\;\;x \cdot z\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{+24}:\\
\;\;\;\;t \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot z\\
\end{array}
if z < -1.04999999999999997e154 or 6.20000000000000022e24 < z Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6444.8%
Applied rewrites44.8%
Taylor expanded in x around inf
lower-*.f6422.7%
Applied rewrites22.7%
if -1.04999999999999997e154 < z < 6.20000000000000022e24Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6444.8%
Applied rewrites44.8%
Taylor expanded in x around 0
lower-*.f6426.3%
Applied rewrites26.3%
(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]
t \cdot y
Initial program 100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6444.8%
Applied rewrites44.8%
Taylor expanded in x around 0
lower-*.f6426.3%
Applied rewrites26.3%
herbie shell --seed 2025183
(FPCore (x y z t)
:name "Data.Metrics.Snapshot:quantile from metrics-0.3.0.2"
:precision binary64
(+ x (* (- y z) (- t x))))