
(FPCore (x y z t a b) :precision binary64 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))
double code(double x, double y, double z, double t, double a, double b) {
return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + 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, 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 + y) * a)) - (y * b)) / ((x + t) + y)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
}
def code(x, y, z, t, a, b): return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y)) end
function tmp = code(x, y, z, t, a, b) tmp = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}
\end{array}
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))
double code(double x, double y, double z, double t, double a, double b) {
return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + 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, 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 + y) * a)) - (y * b)) / ((x + t) + y)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
}
def code(x, y, z, t, a, b): return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y)) end
function tmp = code(x, y, z, t, a, b) tmp = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}
\end{array}
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (+ y x) t)) (t_2 (+ t (+ x y))) (t_3 (/ (+ t y) t_1)))
(if (or (<= z -1.75e-118) (not (<= z 1.5e-16)))
(fma t_3 a (* z (fma -1.0 (* (/ b z) (/ y t_2)) (/ (+ x y) t_2))))
(fma t_3 a (/ (fma (+ y x) z (* (- b) y)) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (y + x) + t;
double t_2 = t + (x + y);
double t_3 = (t + y) / t_1;
double tmp;
if ((z <= -1.75e-118) || !(z <= 1.5e-16)) {
tmp = fma(t_3, a, (z * fma(-1.0, ((b / z) * (y / t_2)), ((x + y) / t_2))));
} else {
tmp = fma(t_3, a, (fma((y + x), z, (-b * y)) / t_1));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(y + x) + t) t_2 = Float64(t + Float64(x + y)) t_3 = Float64(Float64(t + y) / t_1) tmp = 0.0 if ((z <= -1.75e-118) || !(z <= 1.5e-16)) tmp = fma(t_3, a, Float64(z * fma(-1.0, Float64(Float64(b / z) * Float64(y / t_2)), Float64(Float64(x + y) / t_2)))); else tmp = fma(t_3, a, Float64(fma(Float64(y + x), z, Float64(Float64(-b) * y)) / t_1)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(y + x), $MachinePrecision] + t), $MachinePrecision]}, Block[{t$95$2 = N[(t + N[(x + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(t + y), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[Or[LessEqual[z, -1.75e-118], N[Not[LessEqual[z, 1.5e-16]], $MachinePrecision]], N[(t$95$3 * a + N[(z * N[(-1.0 * N[(N[(b / z), $MachinePrecision] * N[(y / t$95$2), $MachinePrecision]), $MachinePrecision] + N[(N[(x + y), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$3 * a + N[(N[(N[(y + x), $MachinePrecision] * z + N[((-b) * y), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(y + x\right) + t\\
t_2 := t + \left(x + y\right)\\
t_3 := \frac{t + y}{t\_1}\\
\mathbf{if}\;z \leq -1.75 \cdot 10^{-118} \lor \neg \left(z \leq 1.5 \cdot 10^{-16}\right):\\
\;\;\;\;\mathsf{fma}\left(t\_3, a, z \cdot \mathsf{fma}\left(-1, \frac{b}{z} \cdot \frac{y}{t\_2}, \frac{x + y}{t\_2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_3, a, \frac{\mathsf{fma}\left(y + x, z, \left(-b\right) \cdot y\right)}{t\_1}\right)\\
\end{array}
\end{array}
if z < -1.75e-118 or 1.49999999999999997e-16 < z Initial program 53.2%
Applied rewrites63.2%
Taylor expanded in z around inf
lower-*.f64N/A
lower-fma.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6497.9
Applied rewrites97.9%
if -1.75e-118 < z < 1.49999999999999997e-16Initial program 72.6%
Applied rewrites87.3%
Final simplification93.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (+ y x) t))
(t_2 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y))))
(if (or (<= t_2 (- INFINITY)) (not (<= t_2 1e+216)))
(fma
(/ (+ t y) t_1)
a
(* z (fma -1.0 (* (/ b z) (/ y (+ t (+ x y)))) 1.0)))
(fma (/ (+ y x) t_1) z (/ (fma (+ t y) a (* (- b) y)) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (y + x) + t;
double t_2 = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
double tmp;
if ((t_2 <= -((double) INFINITY)) || !(t_2 <= 1e+216)) {
tmp = fma(((t + y) / t_1), a, (z * fma(-1.0, ((b / z) * (y / (t + (x + y)))), 1.0)));
} else {
tmp = fma(((y + x) / t_1), z, (fma((t + y), a, (-b * y)) / t_1));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(y + x) + t) t_2 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y)) tmp = 0.0 if ((t_2 <= Float64(-Inf)) || !(t_2 <= 1e+216)) tmp = fma(Float64(Float64(t + y) / t_1), a, Float64(z * fma(-1.0, Float64(Float64(b / z) * Float64(y / Float64(t + Float64(x + y)))), 1.0))); else tmp = fma(Float64(Float64(y + x) / t_1), z, Float64(fma(Float64(t + y), a, Float64(Float64(-b) * y)) / t_1)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(y + x), $MachinePrecision] + t), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$2, (-Infinity)], N[Not[LessEqual[t$95$2, 1e+216]], $MachinePrecision]], N[(N[(N[(t + y), $MachinePrecision] / t$95$1), $MachinePrecision] * a + N[(z * N[(-1.0 * N[(N[(b / z), $MachinePrecision] * N[(y / N[(t + N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y + x), $MachinePrecision] / t$95$1), $MachinePrecision] * z + N[(N[(N[(t + y), $MachinePrecision] * a + N[((-b) * y), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(y + x\right) + t\\
t_2 := \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\\
\mathbf{if}\;t\_2 \leq -\infty \lor \neg \left(t\_2 \leq 10^{+216}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{t + y}{t\_1}, a, z \cdot \mathsf{fma}\left(-1, \frac{b}{z} \cdot \frac{y}{t + \left(x + y\right)}, 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y + x}{t\_1}, z, \frac{\mathsf{fma}\left(t + y, a, \left(-b\right) \cdot y\right)}{t\_1}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -inf.0 or 1e216 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 11.4%
Applied rewrites38.8%
Taylor expanded in z around inf
lower-*.f64N/A
lower-fma.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6487.5
Applied rewrites87.5%
Taylor expanded in x around inf
Applied rewrites78.3%
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 1e216Initial program 99.4%
Applied rewrites99.2%
Final simplification90.0%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))
(t_2 (+ (+ y x) t)))
(if (<= t_1 (- INFINITY))
(fma (/ (+ t y) t_2) a z)
(if (<= t_1 2e+244)
(fma (/ (+ y x) t_2) z (/ (fma (+ t y) a (* (- b) y)) t_2))
(- (+ a z) b)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
double t_2 = (y + x) + t;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma(((t + y) / t_2), a, z);
} else if (t_1 <= 2e+244) {
tmp = fma(((y + x) / t_2), z, (fma((t + y), a, (-b * y)) / t_2));
} else {
tmp = (a + z) - b;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y)) t_2 = Float64(Float64(y + x) + t) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = fma(Float64(Float64(t + y) / t_2), a, z); elseif (t_1 <= 2e+244) tmp = fma(Float64(Float64(y + x) / t_2), z, Float64(fma(Float64(t + y), a, Float64(Float64(-b) * y)) / t_2)); else tmp = Float64(Float64(a + z) - b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y + x), $MachinePrecision] + t), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(N[(t + y), $MachinePrecision] / t$95$2), $MachinePrecision] * a + z), $MachinePrecision], If[LessEqual[t$95$1, 2e+244], N[(N[(N[(y + x), $MachinePrecision] / t$95$2), $MachinePrecision] * z + N[(N[(N[(t + y), $MachinePrecision] * a + N[((-b) * y), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\\
t_2 := \left(y + x\right) + t\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{t + y}{t\_2}, a, z\right)\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+244}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y + x}{t\_2}, z, \frac{\mathsf{fma}\left(t + y, a, \left(-b\right) \cdot y\right)}{t\_2}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -inf.0Initial program 6.4%
Applied rewrites39.9%
Taylor expanded in x around inf
Applied rewrites74.1%
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 2.00000000000000015e244Initial program 99.4%
Applied rewrites99.2%
if 2.00000000000000015e244 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 11.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6471.2
Applied rewrites71.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))
(t_2 (+ (+ y x) t))
(t_3 (/ (+ t y) t_2)))
(if (<= t_1 (- INFINITY))
(fma t_3 a z)
(if (<= t_1 2e+244)
(fma t_3 a (/ (fma (+ y x) z (* (- b) y)) t_2))
(- (+ a z) b)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
double t_2 = (y + x) + t;
double t_3 = (t + y) / t_2;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma(t_3, a, z);
} else if (t_1 <= 2e+244) {
tmp = fma(t_3, a, (fma((y + x), z, (-b * y)) / t_2));
} else {
tmp = (a + z) - b;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y)) t_2 = Float64(Float64(y + x) + t) t_3 = Float64(Float64(t + y) / t_2) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = fma(t_3, a, z); elseif (t_1 <= 2e+244) tmp = fma(t_3, a, Float64(fma(Float64(y + x), z, Float64(Float64(-b) * y)) / t_2)); else tmp = Float64(Float64(a + z) - b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y + x), $MachinePrecision] + t), $MachinePrecision]}, Block[{t$95$3 = N[(N[(t + y), $MachinePrecision] / t$95$2), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(t$95$3 * a + z), $MachinePrecision], If[LessEqual[t$95$1, 2e+244], N[(t$95$3 * a + N[(N[(N[(y + x), $MachinePrecision] * z + N[((-b) * y), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\\
t_2 := \left(y + x\right) + t\\
t_3 := \frac{t + y}{t\_2}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(t\_3, a, z\right)\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+244}:\\
\;\;\;\;\mathsf{fma}\left(t\_3, a, \frac{\mathsf{fma}\left(y + x, z, \left(-b\right) \cdot y\right)}{t\_2}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -inf.0Initial program 6.4%
Applied rewrites39.9%
Taylor expanded in x around inf
Applied rewrites74.1%
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 2.00000000000000015e244Initial program 99.4%
Applied rewrites99.1%
if 2.00000000000000015e244 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 11.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6471.2
Applied rewrites71.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y))))
(if (<= t_1 (- INFINITY))
(fma (/ (+ t y) (+ (+ y x) t)) a z)
(if (<= t_1 2e+244) t_1 (- (+ a z) b)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma(((t + y) / ((y + x) + t)), a, z);
} else if (t_1 <= 2e+244) {
tmp = t_1;
} else {
tmp = (a + z) - b;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = fma(Float64(Float64(t + y) / Float64(Float64(y + x) + t)), a, z); elseif (t_1 <= 2e+244) tmp = t_1; else tmp = Float64(Float64(a + z) - b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(N[(t + y), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision] * a + z), $MachinePrecision], If[LessEqual[t$95$1, 2e+244], t$95$1, N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{t + y}{\left(y + x\right) + t}, a, z\right)\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+244}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -inf.0Initial program 6.4%
Applied rewrites39.9%
Taylor expanded in x around inf
Applied rewrites74.1%
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 2.00000000000000015e244Initial program 99.4%
if 2.00000000000000015e244 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 11.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6471.2
Applied rewrites71.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (+ x t) y))
(t_2 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) t_1)))
(if (<= t_2 (- INFINITY))
(fma (/ (+ t y) (+ (+ y x) t)) a z)
(if (<= t_2 1e+201)
(/ (fma (+ t y) a (* (+ y x) z)) t_1)
(- (+ a z) b)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x + t) + y;
double t_2 = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / t_1;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = fma(((t + y) / ((y + x) + t)), a, z);
} else if (t_2 <= 1e+201) {
tmp = fma((t + y), a, ((y + x) * z)) / t_1;
} else {
tmp = (a + z) - b;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(x + t) + y) t_2 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / t_1) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = fma(Float64(Float64(t + y) / Float64(Float64(y + x) + t)), a, z); elseif (t_2 <= 1e+201) tmp = Float64(fma(Float64(t + y), a, Float64(Float64(y + x) * z)) / t_1); else tmp = Float64(Float64(a + z) - b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(N[(t + y), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision] * a + z), $MachinePrecision], If[LessEqual[t$95$2, 1e+201], N[(N[(N[(t + y), $MachinePrecision] * a + N[(N[(y + x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x + t\right) + y\\
t_2 := \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{t\_1}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{t + y}{\left(y + x\right) + t}, a, z\right)\\
\mathbf{elif}\;t\_2 \leq 10^{+201}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t + y, a, \left(y + x\right) \cdot z\right)}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -inf.0Initial program 6.4%
Applied rewrites39.9%
Taylor expanded in x around inf
Applied rewrites74.1%
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 1.00000000000000004e201Initial program 99.4%
Taylor expanded in b around 0
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f6477.6
Applied rewrites77.6%
if 1.00000000000000004e201 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 16.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6471.1
Applied rewrites71.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y))))
(if (or (<= t_1 -5e+90) (not (<= t_1 4e+56)))
(- (+ a z) b)
(/ (fma a t (* z x)) (+ t x)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
double tmp;
if ((t_1 <= -5e+90) || !(t_1 <= 4e+56)) {
tmp = (a + z) - b;
} else {
tmp = fma(a, t, (z * x)) / (t + x);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y)) tmp = 0.0 if ((t_1 <= -5e+90) || !(t_1 <= 4e+56)) tmp = Float64(Float64(a + z) - b); else tmp = Float64(fma(a, t, Float64(z * x)) / Float64(t + x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -5e+90], N[Not[LessEqual[t$95$1, 4e+56]], $MachinePrecision]], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], N[(N[(a * t + N[(z * x), $MachinePrecision]), $MachinePrecision] / N[(t + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+90} \lor \neg \left(t\_1 \leq 4 \cdot 10^{+56}\right):\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, t, z \cdot x\right)}{t + x}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -5.0000000000000004e90 or 4.00000000000000037e56 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 38.2%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6467.7
Applied rewrites67.7%
if -5.0000000000000004e90 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 4.00000000000000037e56Initial program 99.3%
Taylor expanded in y around 0
lower-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6462.1
Applied rewrites62.1%
Final simplification65.7%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- (+ a z) b)) (t_2 (+ t (+ x y))) (t_3 (* z (/ (+ x y) t_2))))
(if (<= z -2e+34)
t_3
(if (<= z -2e-117)
t_1
(if (<= z 6.6e-132)
(* (/ (+ t y) t_2) a)
(if (<= z 7.2e+141) t_1 t_3))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a + z) - b;
double t_2 = t + (x + y);
double t_3 = z * ((x + y) / t_2);
double tmp;
if (z <= -2e+34) {
tmp = t_3;
} else if (z <= -2e-117) {
tmp = t_1;
} else if (z <= 6.6e-132) {
tmp = ((t + y) / t_2) * a;
} else if (z <= 7.2e+141) {
tmp = t_1;
} else {
tmp = t_3;
}
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) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_1 = (a + z) - b
t_2 = t + (x + y)
t_3 = z * ((x + y) / t_2)
if (z <= (-2d+34)) then
tmp = t_3
else if (z <= (-2d-117)) then
tmp = t_1
else if (z <= 6.6d-132) then
tmp = ((t + y) / t_2) * a
else if (z <= 7.2d+141) then
tmp = t_1
else
tmp = t_3
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a + z) - b;
double t_2 = t + (x + y);
double t_3 = z * ((x + y) / t_2);
double tmp;
if (z <= -2e+34) {
tmp = t_3;
} else if (z <= -2e-117) {
tmp = t_1;
} else if (z <= 6.6e-132) {
tmp = ((t + y) / t_2) * a;
} else if (z <= 7.2e+141) {
tmp = t_1;
} else {
tmp = t_3;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a + z) - b t_2 = t + (x + y) t_3 = z * ((x + y) / t_2) tmp = 0 if z <= -2e+34: tmp = t_3 elif z <= -2e-117: tmp = t_1 elif z <= 6.6e-132: tmp = ((t + y) / t_2) * a elif z <= 7.2e+141: tmp = t_1 else: tmp = t_3 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a + z) - b) t_2 = Float64(t + Float64(x + y)) t_3 = Float64(z * Float64(Float64(x + y) / t_2)) tmp = 0.0 if (z <= -2e+34) tmp = t_3; elseif (z <= -2e-117) tmp = t_1; elseif (z <= 6.6e-132) tmp = Float64(Float64(Float64(t + y) / t_2) * a); elseif (z <= 7.2e+141) tmp = t_1; else tmp = t_3; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a + z) - b; t_2 = t + (x + y); t_3 = z * ((x + y) / t_2); tmp = 0.0; if (z <= -2e+34) tmp = t_3; elseif (z <= -2e-117) tmp = t_1; elseif (z <= 6.6e-132) tmp = ((t + y) / t_2) * a; elseif (z <= 7.2e+141) tmp = t_1; else tmp = t_3; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]}, Block[{t$95$2 = N[(t + N[(x + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(z * N[(N[(x + y), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2e+34], t$95$3, If[LessEqual[z, -2e-117], t$95$1, If[LessEqual[z, 6.6e-132], N[(N[(N[(t + y), $MachinePrecision] / t$95$2), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[z, 7.2e+141], t$95$1, t$95$3]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a + z\right) - b\\
t_2 := t + \left(x + y\right)\\
t_3 := z \cdot \frac{x + y}{t\_2}\\
\mathbf{if}\;z \leq -2 \cdot 10^{+34}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;z \leq -2 \cdot 10^{-117}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 6.6 \cdot 10^{-132}:\\
\;\;\;\;\frac{t + y}{t\_2} \cdot a\\
\mathbf{elif}\;z \leq 7.2 \cdot 10^{+141}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if z < -1.99999999999999989e34 or 7.2000000000000003e141 < z Initial program 42.8%
Applied rewrites49.7%
Taylor expanded in z around inf
lower-*.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6468.5
Applied rewrites68.5%
if -1.99999999999999989e34 < z < -2.00000000000000006e-117 or 6.5999999999999994e-132 < z < 7.2000000000000003e141Initial program 69.3%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6454.3
Applied rewrites54.3%
if -2.00000000000000006e-117 < z < 6.5999999999999994e-132Initial program 71.8%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites85.7%
Taylor expanded in a around inf
div-add-revN/A
lower-/.f64N/A
lift-+.f64N/A
lower-+.f64N/A
lower-+.f6457.4
Applied rewrites57.4%
Final simplification60.2%
(FPCore (x y z t a b) :precision binary64 (if (or (<= y -5.2e+82) (not (<= y 2e+63))) (- (+ a z) b) (fma (/ (+ t y) (+ (+ y x) t)) a z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((y <= -5.2e+82) || !(y <= 2e+63)) {
tmp = (a + z) - b;
} else {
tmp = fma(((t + y) / ((y + x) + t)), a, z);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((y <= -5.2e+82) || !(y <= 2e+63)) tmp = Float64(Float64(a + z) - b); else tmp = fma(Float64(Float64(t + y) / Float64(Float64(y + x) + t)), a, z); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[y, -5.2e+82], N[Not[LessEqual[y, 2e+63]], $MachinePrecision]], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], N[(N[(N[(t + y), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision] * a + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{+82} \lor \neg \left(y \leq 2 \cdot 10^{+63}\right):\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t + y}{\left(y + x\right) + t}, a, z\right)\\
\end{array}
\end{array}
if y < -5.1999999999999997e82 or 2.00000000000000012e63 < y Initial program 36.6%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6476.6
Applied rewrites76.6%
if -5.1999999999999997e82 < y < 2.00000000000000012e63Initial program 76.1%
Applied rewrites86.7%
Taylor expanded in x around inf
Applied rewrites65.1%
Final simplification69.6%
(FPCore (x y z t a b) :precision binary64 (if (or (<= x -5.4e+149) (not (<= x 5e+167))) (+ z (* t (/ a x))) (- (+ a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x <= -5.4e+149) || !(x <= 5e+167)) {
tmp = z + (t * (a / x));
} else {
tmp = (a + z) - b;
}
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 <= (-5.4d+149)) .or. (.not. (x <= 5d+167))) then
tmp = z + (t * (a / x))
else
tmp = (a + z) - b
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 <= -5.4e+149) || !(x <= 5e+167)) {
tmp = z + (t * (a / x));
} else {
tmp = (a + z) - b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x <= -5.4e+149) or not (x <= 5e+167): tmp = z + (t * (a / x)) else: tmp = (a + z) - b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((x <= -5.4e+149) || !(x <= 5e+167)) tmp = Float64(z + Float64(t * Float64(a / x))); else tmp = Float64(Float64(a + z) - b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((x <= -5.4e+149) || ~((x <= 5e+167))) tmp = z + (t * (a / x)); else tmp = (a + z) - b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[x, -5.4e+149], N[Not[LessEqual[x, 5e+167]], $MachinePrecision]], N[(z + N[(t * N[(a / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.4 \cdot 10^{+149} \lor \neg \left(x \leq 5 \cdot 10^{+167}\right):\\
\;\;\;\;z + t \cdot \frac{a}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\end{array}
\end{array}
if x < -5.4000000000000002e149 or 4.9999999999999997e167 < x Initial program 45.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6434.2
Applied rewrites34.2%
Taylor expanded in t around 0
lower-+.f64N/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f6460.1
Applied rewrites60.1%
Taylor expanded in z around 0
Applied rewrites60.4%
if -5.4000000000000002e149 < x < 4.9999999999999997e167Initial program 65.6%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6460.4
Applied rewrites60.4%
Final simplification60.4%
(FPCore (x y z t a b) :precision binary64 (if (<= x -6.9e+149) z (if (<= x 3.3e+178) (- (+ a z) b) z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -6.9e+149) {
tmp = z;
} else if (x <= 3.3e+178) {
tmp = (a + z) - b;
} else {
tmp = 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 (x <= (-6.9d+149)) then
tmp = z
else if (x <= 3.3d+178) then
tmp = (a + z) - b
else
tmp = 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 (x <= -6.9e+149) {
tmp = z;
} else if (x <= 3.3e+178) {
tmp = (a + z) - b;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if x <= -6.9e+149: tmp = z elif x <= 3.3e+178: tmp = (a + z) - b else: tmp = z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -6.9e+149) tmp = z; elseif (x <= 3.3e+178) tmp = Float64(Float64(a + z) - b); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (x <= -6.9e+149) tmp = z; elseif (x <= 3.3e+178) tmp = (a + z) - b; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -6.9e+149], z, If[LessEqual[x, 3.3e+178], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.9 \cdot 10^{+149}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{+178}:\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if x < -6.9000000000000004e149 or 3.2999999999999998e178 < x Initial program 45.3%
Taylor expanded in x around inf
Applied rewrites52.3%
if -6.9000000000000004e149 < x < 3.2999999999999998e178Initial program 65.5%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6460.1
Applied rewrites60.1%
(FPCore (x y z t a b) :precision binary64 (if (or (<= a -1.6e-99) (not (<= a 175000.0))) (+ a z) (- z b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a <= -1.6e-99) || !(a <= 175000.0)) {
tmp = a + z;
} else {
tmp = z - b;
}
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 <= (-1.6d-99)) .or. (.not. (a <= 175000.0d0))) then
tmp = a + z
else
tmp = z - b
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 <= -1.6e-99) || !(a <= 175000.0)) {
tmp = a + z;
} else {
tmp = z - b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a <= -1.6e-99) or not (a <= 175000.0): tmp = a + z else: tmp = z - b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((a <= -1.6e-99) || !(a <= 175000.0)) tmp = Float64(a + z); else tmp = Float64(z - b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((a <= -1.6e-99) || ~((a <= 175000.0))) tmp = a + z; else tmp = z - b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[a, -1.6e-99], N[Not[LessEqual[a, 175000.0]], $MachinePrecision]], N[(a + z), $MachinePrecision], N[(z - b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6 \cdot 10^{-99} \lor \neg \left(a \leq 175000\right):\\
\;\;\;\;a + z\\
\mathbf{else}:\\
\;\;\;\;z - b\\
\end{array}
\end{array}
if a < -1.6e-99 or 175000 < a Initial program 52.4%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6459.2
Applied rewrites59.2%
Taylor expanded in b around 0
lift-+.f6457.7
Applied rewrites57.7%
if -1.6e-99 < a < 175000Initial program 72.2%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6450.5
Applied rewrites50.5%
Taylor expanded in z around inf
Applied rewrites47.0%
Final simplification53.2%
(FPCore (x y z t a b) :precision binary64 (if (<= x 2.6e-279) (+ a z) (if (<= x 2.5e-5) (- a b) z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= 2.6e-279) {
tmp = a + z;
} else if (x <= 2.5e-5) {
tmp = a - b;
} else {
tmp = 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 (x <= 2.6d-279) then
tmp = a + z
else if (x <= 2.5d-5) then
tmp = a - b
else
tmp = 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 (x <= 2.6e-279) {
tmp = a + z;
} else if (x <= 2.5e-5) {
tmp = a - b;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if x <= 2.6e-279: tmp = a + z elif x <= 2.5e-5: tmp = a - b else: tmp = z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= 2.6e-279) tmp = Float64(a + z); elseif (x <= 2.5e-5) tmp = Float64(a - b); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (x <= 2.6e-279) tmp = a + z; elseif (x <= 2.5e-5) tmp = a - b; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, 2.6e-279], N[(a + z), $MachinePrecision], If[LessEqual[x, 2.5e-5], N[(a - b), $MachinePrecision], z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.6 \cdot 10^{-279}:\\
\;\;\;\;a + z\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-5}:\\
\;\;\;\;a - b\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if x < 2.6000000000000002e-279Initial program 61.3%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6456.6
Applied rewrites56.6%
Taylor expanded in b around 0
lift-+.f6452.4
Applied rewrites52.4%
if 2.6000000000000002e-279 < x < 2.50000000000000012e-5Initial program 65.8%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6463.7
Applied rewrites63.7%
Taylor expanded in z around 0
Applied rewrites51.4%
if 2.50000000000000012e-5 < x Initial program 55.1%
Taylor expanded in x around inf
Applied rewrites42.6%
(FPCore (x y z t a b) :precision binary64 (if (<= x -5e-91) z (if (<= x 1.7e-35) a z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -5e-91) {
tmp = z;
} else if (x <= 1.7e-35) {
tmp = a;
} else {
tmp = 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 (x <= (-5d-91)) then
tmp = z
else if (x <= 1.7d-35) then
tmp = a
else
tmp = 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 (x <= -5e-91) {
tmp = z;
} else if (x <= 1.7e-35) {
tmp = a;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if x <= -5e-91: tmp = z elif x <= 1.7e-35: tmp = a else: tmp = z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -5e-91) tmp = z; elseif (x <= 1.7e-35) tmp = a; else tmp = z; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (x <= -5e-91) tmp = z; elseif (x <= 1.7e-35) tmp = a; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -5e-91], z, If[LessEqual[x, 1.7e-35], a, z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-91}:\\
\;\;\;\;z\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-35}:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if x < -4.99999999999999997e-91 or 1.7000000000000001e-35 < x Initial program 56.7%
Taylor expanded in x around inf
Applied rewrites39.6%
if -4.99999999999999997e-91 < x < 1.7000000000000001e-35Initial program 66.8%
Taylor expanded in t around inf
Applied rewrites46.5%
(FPCore (x y z t a b) :precision binary64 (if (<= x 4.1e+178) (+ a z) z))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= 4.1e+178) {
tmp = a + z;
} else {
tmp = 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 (x <= 4.1d+178) then
tmp = a + z
else
tmp = 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 (x <= 4.1e+178) {
tmp = a + z;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if x <= 4.1e+178: tmp = a + z else: tmp = z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= 4.1e+178) tmp = Float64(a + z); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (x <= 4.1e+178) tmp = a + z; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, 4.1e+178], N[(a + z), $MachinePrecision], z]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.1 \cdot 10^{+178}:\\
\;\;\;\;a + z\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if x < 4.09999999999999996e178Initial program 62.7%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6457.4
Applied rewrites57.4%
Taylor expanded in b around 0
lift-+.f6452.6
Applied rewrites52.6%
if 4.09999999999999996e178 < x Initial program 44.3%
Taylor expanded in x around inf
Applied rewrites55.9%
(FPCore (x y z t a b) :precision binary64 a)
double code(double x, double y, double z, double t, double a, double b) {
return 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 = a
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return a;
}
def code(x, y, z, t, a, b): return a
function code(x, y, z, t, a, b) return a end
function tmp = code(x, y, z, t, a, b) tmp = a; end
code[x_, y_, z_, t_, a_, b_] := a
\begin{array}{l}
\\
a
\end{array}
Initial program 60.7%
Taylor expanded in t around inf
Applied rewrites32.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (+ x t) y))
(t_2 (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)))
(t_3 (/ t_2 t_1))
(t_4 (- (+ z a) b)))
(if (< t_3 -3.5813117084150564e+153)
t_4
(if (< t_3 1.2285964308315609e+82) (/ 1.0 (/ t_1 t_2)) t_4))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x + t) + y;
double t_2 = (((x + y) * z) + ((t + y) * a)) - (y * b);
double t_3 = t_2 / t_1;
double t_4 = (z + a) - b;
double tmp;
if (t_3 < -3.5813117084150564e+153) {
tmp = t_4;
} else if (t_3 < 1.2285964308315609e+82) {
tmp = 1.0 / (t_1 / t_2);
} else {
tmp = t_4;
}
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) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_1 = (x + t) + y
t_2 = (((x + y) * z) + ((t + y) * a)) - (y * b)
t_3 = t_2 / t_1
t_4 = (z + a) - b
if (t_3 < (-3.5813117084150564d+153)) then
tmp = t_4
else if (t_3 < 1.2285964308315609d+82) then
tmp = 1.0d0 / (t_1 / t_2)
else
tmp = t_4
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x + t) + y;
double t_2 = (((x + y) * z) + ((t + y) * a)) - (y * b);
double t_3 = t_2 / t_1;
double t_4 = (z + a) - b;
double tmp;
if (t_3 < -3.5813117084150564e+153) {
tmp = t_4;
} else if (t_3 < 1.2285964308315609e+82) {
tmp = 1.0 / (t_1 / t_2);
} else {
tmp = t_4;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (x + t) + y t_2 = (((x + y) * z) + ((t + y) * a)) - (y * b) t_3 = t_2 / t_1 t_4 = (z + a) - b tmp = 0 if t_3 < -3.5813117084150564e+153: tmp = t_4 elif t_3 < 1.2285964308315609e+82: tmp = 1.0 / (t_1 / t_2) else: tmp = t_4 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(x + t) + y) t_2 = Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) t_3 = Float64(t_2 / t_1) t_4 = Float64(Float64(z + a) - b) tmp = 0.0 if (t_3 < -3.5813117084150564e+153) tmp = t_4; elseif (t_3 < 1.2285964308315609e+82) tmp = Float64(1.0 / Float64(t_1 / t_2)); else tmp = t_4; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (x + t) + y; t_2 = (((x + y) * z) + ((t + y) * a)) - (y * b); t_3 = t_2 / t_1; t_4 = (z + a) - b; tmp = 0.0; if (t_3 < -3.5813117084150564e+153) tmp = t_4; elseif (t_3 < 1.2285964308315609e+82) tmp = 1.0 / (t_1 / t_2); else tmp = t_4; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 / t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision]}, If[Less[t$95$3, -3.5813117084150564e+153], t$95$4, If[Less[t$95$3, 1.2285964308315609e+82], N[(1.0 / N[(t$95$1 / t$95$2), $MachinePrecision]), $MachinePrecision], t$95$4]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x + t\right) + y\\
t_2 := \left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\\
t_3 := \frac{t\_2}{t\_1}\\
t_4 := \left(z + a\right) - b\\
\mathbf{if}\;t\_3 < -3.5813117084150564 \cdot 10^{+153}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;t\_3 < 1.2285964308315609 \cdot 10^{+82}:\\
\;\;\;\;\frac{1}{\frac{t\_1}{t\_2}}\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\end{array}
\end{array}
herbie shell --seed 2025086
(FPCore (x y z t a b)
:name "AI.Clustering.Hierarchical.Internal:ward from clustering-0.2.1"
:precision binary64
:alt
(! :herbie-platform default (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) -3581311708415056400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (+ z a) b) (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) 12285964308315609000000000000000000000000000000000000000000000000000000000000000000) (/ 1 (/ (+ (+ x t) y) (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)))) (- (+ z a) b))))
(/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))