
(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}
Sampling outcomes in binary64 precision:
Herbie found 15 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 (/ (+ y x) t_1)) (t_3 (+ t (+ x y))))
(if (or (<= a -1e-22) (not (<= a 2e-39)))
(* (- (+ (/ (+ t y) t_1) (* (/ z a) t_2)) (* (/ b a) (/ y t_1))) a)
(fma t_2 z (* b (fma -1.0 (/ y t_3) (* (/ a b) (/ (+ t y) t_3))))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (y + x) + t;
double t_2 = (y + x) / t_1;
double t_3 = t + (x + y);
double tmp;
if ((a <= -1e-22) || !(a <= 2e-39)) {
tmp = ((((t + y) / t_1) + ((z / a) * t_2)) - ((b / a) * (y / t_1))) * a;
} else {
tmp = fma(t_2, z, (b * fma(-1.0, (y / t_3), ((a / b) * ((t + y) / t_3)))));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(y + x) + t) t_2 = Float64(Float64(y + x) / t_1) t_3 = Float64(t + Float64(x + y)) tmp = 0.0 if ((a <= -1e-22) || !(a <= 2e-39)) tmp = Float64(Float64(Float64(Float64(Float64(t + y) / t_1) + Float64(Float64(z / a) * t_2)) - Float64(Float64(b / a) * Float64(y / t_1))) * a); else tmp = fma(t_2, z, Float64(b * fma(-1.0, Float64(y / t_3), Float64(Float64(a / b) * Float64(Float64(t + y) / t_3))))); 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[(y + x), $MachinePrecision] / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(t + N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[a, -1e-22], N[Not[LessEqual[a, 2e-39]], $MachinePrecision]], N[(N[(N[(N[(N[(t + y), $MachinePrecision] / t$95$1), $MachinePrecision] + N[(N[(z / a), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] - N[(N[(b / a), $MachinePrecision] * N[(y / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], N[(t$95$2 * z + N[(b * N[(-1.0 * N[(y / t$95$3), $MachinePrecision] + N[(N[(a / b), $MachinePrecision] * N[(N[(t + y), $MachinePrecision] / t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(y + x\right) + t\\
t_2 := \frac{y + x}{t\_1}\\
t_3 := t + \left(x + y\right)\\
\mathbf{if}\;a \leq -1 \cdot 10^{-22} \lor \neg \left(a \leq 2 \cdot 10^{-39}\right):\\
\;\;\;\;\left(\left(\frac{t + y}{t\_1} + \frac{z}{a} \cdot t\_2\right) - \frac{b}{a} \cdot \frac{y}{t\_1}\right) \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_2, z, b \cdot \mathsf{fma}\left(-1, \frac{y}{t\_3}, \frac{a}{b} \cdot \frac{t + y}{t\_3}\right)\right)\\
\end{array}
\end{array}
if a < -1e-22 or 1.99999999999999986e-39 < a Initial program 51.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
if -1e-22 < a < 1.99999999999999986e-39Initial program 66.6%
Applied rewrites88.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
times-fracN/A
div-add-revN/A
lower-*.f64N/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lift-+.f64N/A
lower-+.f64N/A
lower-+.f6498.5
Applied rewrites98.5%
Final simplification98.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 (<= t_2 (- INFINITY))
(- (+ a z) b)
(if (<= t_2 1e+291)
(fma (/ (+ t y) t_1) a (/ (fma (+ y x) z (* (- b) y)) t_1))
(fma (/ (+ y x) t_1) z (* a (* b (/ (+ t y) (* b (+ t (+ x y)))))))))))
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)) {
tmp = (a + z) - b;
} else if (t_2 <= 1e+291) {
tmp = fma(((t + y) / t_1), a, (fma((y + x), z, (-b * y)) / t_1));
} else {
tmp = fma(((y + x) / t_1), z, (a * (b * ((t + y) / (b * (t + (x + y)))))));
}
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)) tmp = Float64(Float64(a + z) - b); elseif (t_2 <= 1e+291) tmp = fma(Float64(Float64(t + y) / t_1), a, Float64(fma(Float64(y + x), z, Float64(Float64(-b) * y)) / t_1)); else tmp = fma(Float64(Float64(y + x) / t_1), z, Float64(a * Float64(b * Float64(Float64(t + y) / Float64(b * Float64(t + Float64(x + y))))))); 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[LessEqual[t$95$2, (-Infinity)], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], If[LessEqual[t$95$2, 1e+291], N[(N[(N[(t + y), $MachinePrecision] / t$95$1), $MachinePrecision] * a + N[(N[(N[(y + x), $MachinePrecision] * z + N[((-b) * y), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y + x), $MachinePrecision] / t$95$1), $MachinePrecision] * z + N[(a * N[(b * N[(N[(t + y), $MachinePrecision] / N[(b * N[(t + N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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:\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{elif}\;t\_2 \leq 10^{+291}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t + y}{t\_1}, a, \frac{\mathsf{fma}\left(y + x, z, \left(-b\right) \cdot y\right)}{t\_1}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y + x}{t\_1}, z, a \cdot \left(b \cdot \frac{t + y}{b \cdot \left(t + \left(x + y\right)\right)}\right)\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.0Initial program 6.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6486.1
Applied rewrites86.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)) < 9.9999999999999996e290Initial program 98.4%
Applied rewrites99.1%
if 9.9999999999999996e290 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 5.5%
Applied rewrites35.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
times-fracN/A
div-add-revN/A
lower-*.f64N/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lift-+.f64N/A
lower-+.f64N/A
lower-+.f6474.3
Applied rewrites74.3%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f64N/A
div-add-revN/A
lower-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f6477.3
Applied rewrites77.3%
Final simplification91.1%
(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 (<= t_2 (- INFINITY))
(- (+ a z) b)
(if (<= t_2 2e+222)
(fma (/ (+ t y) t_1) a (/ (fma (+ y x) z (* (- b) y)) t_1))
(fma (/ (+ y x) t_1) z a)))))
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)) {
tmp = (a + z) - b;
} else if (t_2 <= 2e+222) {
tmp = fma(((t + y) / t_1), a, (fma((y + x), z, (-b * y)) / t_1));
} else {
tmp = fma(((y + x) / t_1), z, a);
}
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)) tmp = Float64(Float64(a + z) - b); elseif (t_2 <= 2e+222) tmp = fma(Float64(Float64(t + y) / t_1), a, Float64(fma(Float64(y + x), z, Float64(Float64(-b) * y)) / t_1)); else tmp = fma(Float64(Float64(y + x) / t_1), z, a); 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[LessEqual[t$95$2, (-Infinity)], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], If[LessEqual[t$95$2, 2e+222], N[(N[(N[(t + y), $MachinePrecision] / t$95$1), $MachinePrecision] * a + N[(N[(N[(y + x), $MachinePrecision] * z + N[((-b) * y), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y + x), $MachinePrecision] / t$95$1), $MachinePrecision] * z + a), $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:\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+222}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t + y}{t\_1}, a, \frac{\mathsf{fma}\left(y + x, z, \left(-b\right) \cdot y\right)}{t\_1}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y + x}{t\_1}, z, a\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.0Initial program 6.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6486.1
Applied rewrites86.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.0000000000000001e222Initial program 98.3%
Applied rewrites99.0%
if 2.0000000000000001e222 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 11.8%
Applied rewrites39.8%
Taylor expanded in t around inf
Applied rewrites76.4%
Final simplification90.4%
(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))
(t_3 (- (+ a z) b)))
(if (<= t_2 (- INFINITY))
t_3
(if (<= t_2 2e+222)
(/ (fma a t (fma t_3 y (* z x))) t_1)
(fma (/ (+ y x) (+ (+ y x) t)) z a)))))
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 t_3 = (a + z) - b;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_3;
} else if (t_2 <= 2e+222) {
tmp = fma(a, t, fma(t_3, y, (z * x))) / t_1;
} else {
tmp = fma(((y + x) / ((y + x) + t)), z, a);
}
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) t_3 = Float64(Float64(a + z) - b) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_3; elseif (t_2 <= 2e+222) tmp = Float64(fma(a, t, fma(t_3, y, Float64(z * x))) / t_1); else tmp = fma(Float64(Float64(y + x) / Float64(Float64(y + x) + t)), z, a); 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]}, Block[{t$95$3 = N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$3, If[LessEqual[t$95$2, 2e+222], N[(N[(a * t + N[(t$95$3 * y + N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(N[(y + x), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision] * z + a), $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}\\
t_3 := \left(a + z\right) - b\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+222}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, t, \mathsf{fma}\left(t\_3, y, z \cdot x\right)\right)}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y + x}{\left(y + x\right) + t}, z, a\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.0Initial program 6.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6486.1
Applied rewrites86.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.0000000000000001e222Initial program 98.3%
Taylor expanded in y around 0
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f6498.3
Applied rewrites98.3%
if 2.0000000000000001e222 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 11.8%
Applied rewrites39.8%
Taylor expanded in t around inf
Applied rewrites76.4%
Final simplification90.0%
(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 -1e+233)
(- (+ a z) b)
(if (<= t_2 2e+161)
(/ (fma (+ t y) a (* (+ y x) z)) t_1)
(fma (/ (+ y x) (+ (+ y x) t)) z a)))))
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 <= -1e+233) {
tmp = (a + z) - b;
} else if (t_2 <= 2e+161) {
tmp = fma((t + y), a, ((y + x) * z)) / t_1;
} else {
tmp = fma(((y + x) / ((y + x) + t)), z, a);
}
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 <= -1e+233) tmp = Float64(Float64(a + z) - b); elseif (t_2 <= 2e+161) tmp = Float64(fma(Float64(t + y), a, Float64(Float64(y + x) * z)) / t_1); else tmp = fma(Float64(Float64(y + x) / Float64(Float64(y + x) + t)), z, a); 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, -1e+233], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], If[LessEqual[t$95$2, 2e+161], N[(N[(N[(t + y), $MachinePrecision] * a + N[(N[(y + x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(N[(y + x), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision] * z + a), $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 -1 \cdot 10^{+233}:\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+161}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t + y, a, \left(y + x\right) \cdot z\right)}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y + x}{\left(y + x\right) + t}, z, a\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)) < -9.99999999999999974e232Initial program 16.4%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6486.7
Applied rewrites86.7%
if -9.99999999999999974e232 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 2.0000000000000001e161Initial program 98.1%
Taylor expanded in b around 0
*-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f6479.6
Applied rewrites79.6%
if 2.0000000000000001e161 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 21.3%
Applied rewrites46.2%
Taylor expanded in t around inf
Applied rewrites74.3%
Final simplification79.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ t (+ x y))) (t_2 (/ (+ y x) (+ (+ y x) t))))
(if (or (<= b -6.5e-64) (not (<= b 4.8e-131)))
(fma t_2 z (* b (fma -1.0 (/ y t_1) (* (/ a b) (/ (+ t y) t_1)))))
(fma t_2 z (* a (* b (/ (+ t y) (* b t_1))))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = t + (x + y);
double t_2 = (y + x) / ((y + x) + t);
double tmp;
if ((b <= -6.5e-64) || !(b <= 4.8e-131)) {
tmp = fma(t_2, z, (b * fma(-1.0, (y / t_1), ((a / b) * ((t + y) / t_1)))));
} else {
tmp = fma(t_2, z, (a * (b * ((t + y) / (b * t_1)))));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(t + Float64(x + y)) t_2 = Float64(Float64(y + x) / Float64(Float64(y + x) + t)) tmp = 0.0 if ((b <= -6.5e-64) || !(b <= 4.8e-131)) tmp = fma(t_2, z, Float64(b * fma(-1.0, Float64(y / t_1), Float64(Float64(a / b) * Float64(Float64(t + y) / t_1))))); else tmp = fma(t_2, z, Float64(a * Float64(b * Float64(Float64(t + y) / Float64(b * t_1))))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(t + N[(x + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y + x), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[b, -6.5e-64], N[Not[LessEqual[b, 4.8e-131]], $MachinePrecision]], N[(t$95$2 * z + N[(b * N[(-1.0 * N[(y / t$95$1), $MachinePrecision] + N[(N[(a / b), $MachinePrecision] * N[(N[(t + y), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$2 * z + N[(a * N[(b * N[(N[(t + y), $MachinePrecision] / N[(b * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t + \left(x + y\right)\\
t_2 := \frac{y + x}{\left(y + x\right) + t}\\
\mathbf{if}\;b \leq -6.5 \cdot 10^{-64} \lor \neg \left(b \leq 4.8 \cdot 10^{-131}\right):\\
\;\;\;\;\mathsf{fma}\left(t\_2, z, b \cdot \mathsf{fma}\left(-1, \frac{y}{t\_1}, \frac{a}{b} \cdot \frac{t + y}{t\_1}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_2, z, a \cdot \left(b \cdot \frac{t + y}{b \cdot t\_1}\right)\right)\\
\end{array}
\end{array}
if b < -6.5000000000000004e-64 or 4.7999999999999999e-131 < b Initial program 56.2%
Applied rewrites71.3%
Taylor expanded in b around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
times-fracN/A
div-add-revN/A
lower-*.f64N/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lift-+.f64N/A
lower-+.f64N/A
lower-+.f6496.9
Applied rewrites96.9%
if -6.5000000000000004e-64 < b < 4.7999999999999999e-131Initial program 61.9%
Applied rewrites73.9%
Taylor expanded in b around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
times-fracN/A
div-add-revN/A
lower-*.f64N/A
lower-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lift-+.f64N/A
lower-+.f64N/A
lower-+.f6467.4
Applied rewrites67.4%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f64N/A
div-add-revN/A
lower-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lift-+.f6495.1
Applied rewrites95.1%
Final simplification96.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma (/ (+ y x) (+ (+ y x) t)) z a)))
(if (<= z -3.4e-93)
t_1
(if (<= z -1e-133)
(/ (- (* z x) (* y b)) (+ (+ x t) y))
(if (<= z 1.2e-177) (* (/ (+ t y) (+ t (+ x y))) a) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(((y + x) / ((y + x) + t)), z, a);
double tmp;
if (z <= -3.4e-93) {
tmp = t_1;
} else if (z <= -1e-133) {
tmp = ((z * x) - (y * b)) / ((x + t) + y);
} else if (z <= 1.2e-177) {
tmp = ((t + y) / (t + (x + y))) * a;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(Float64(Float64(y + x) / Float64(Float64(y + x) + t)), z, a) tmp = 0.0 if (z <= -3.4e-93) tmp = t_1; elseif (z <= -1e-133) tmp = Float64(Float64(Float64(z * x) - Float64(y * b)) / Float64(Float64(x + t) + y)); elseif (z <= 1.2e-177) tmp = Float64(Float64(Float64(t + y) / Float64(t + Float64(x + y))) * a); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(y + x), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision] * z + a), $MachinePrecision]}, If[LessEqual[z, -3.4e-93], t$95$1, If[LessEqual[z, -1e-133], N[(N[(N[(z * x), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.2e-177], N[(N[(N[(t + y), $MachinePrecision] / N[(t + N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{y + x}{\left(y + x\right) + t}, z, a\right)\\
\mathbf{if}\;z \leq -3.4 \cdot 10^{-93}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -1 \cdot 10^{-133}:\\
\;\;\;\;\frac{z \cdot x - y \cdot b}{\left(x + t\right) + y}\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{-177}:\\
\;\;\;\;\frac{t + y}{t + \left(x + y\right)} \cdot a\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.40000000000000001e-93 or 1.1999999999999999e-177 < z Initial program 53.7%
Applied rewrites72.8%
Taylor expanded in t around inf
Applied rewrites79.9%
if -3.40000000000000001e-93 < z < -1.0000000000000001e-133Initial program 79.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6479.2
Applied rewrites79.2%
if -1.0000000000000001e-133 < z < 1.1999999999999999e-177Initial program 69.8%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites86.0%
Taylor expanded in a around inf
div-add-revN/A
lower-/.f64N/A
lift-+.f64N/A
lower-+.f64N/A
lower-+.f6466.2
Applied rewrites66.2%
Final simplification76.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ t (+ x y))) (t_2 (* (/ (+ t y) t_1) a)))
(if (<= a -4.5e+18)
t_2
(if (<= a -2.1e-275)
(* z (/ (+ x y) t_1))
(if (<= a 3.3e+181) (- (+ a z) b) t_2)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = t + (x + y);
double t_2 = ((t + y) / t_1) * a;
double tmp;
if (a <= -4.5e+18) {
tmp = t_2;
} else if (a <= -2.1e-275) {
tmp = z * ((x + y) / t_1);
} else if (a <= 3.3e+181) {
tmp = (a + z) - b;
} else {
tmp = t_2;
}
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) :: tmp
t_1 = t + (x + y)
t_2 = ((t + y) / t_1) * a
if (a <= (-4.5d+18)) then
tmp = t_2
else if (a <= (-2.1d-275)) then
tmp = z * ((x + y) / t_1)
else if (a <= 3.3d+181) then
tmp = (a + z) - b
else
tmp = t_2
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 = t + (x + y);
double t_2 = ((t + y) / t_1) * a;
double tmp;
if (a <= -4.5e+18) {
tmp = t_2;
} else if (a <= -2.1e-275) {
tmp = z * ((x + y) / t_1);
} else if (a <= 3.3e+181) {
tmp = (a + z) - b;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = t + (x + y) t_2 = ((t + y) / t_1) * a tmp = 0 if a <= -4.5e+18: tmp = t_2 elif a <= -2.1e-275: tmp = z * ((x + y) / t_1) elif a <= 3.3e+181: tmp = (a + z) - b else: tmp = t_2 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(t + Float64(x + y)) t_2 = Float64(Float64(Float64(t + y) / t_1) * a) tmp = 0.0 if (a <= -4.5e+18) tmp = t_2; elseif (a <= -2.1e-275) tmp = Float64(z * Float64(Float64(x + y) / t_1)); elseif (a <= 3.3e+181) tmp = Float64(Float64(a + z) - b); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = t + (x + y); t_2 = ((t + y) / t_1) * a; tmp = 0.0; if (a <= -4.5e+18) tmp = t_2; elseif (a <= -2.1e-275) tmp = z * ((x + y) / t_1); elseif (a <= 3.3e+181) tmp = (a + z) - b; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(t + N[(x + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(t + y), $MachinePrecision] / t$95$1), $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[a, -4.5e+18], t$95$2, If[LessEqual[a, -2.1e-275], N[(z * N[(N[(x + y), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 3.3e+181], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t + \left(x + y\right)\\
t_2 := \frac{t + y}{t\_1} \cdot a\\
\mathbf{if}\;a \leq -4.5 \cdot 10^{+18}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;a \leq -2.1 \cdot 10^{-275}:\\
\;\;\;\;z \cdot \frac{x + y}{t\_1}\\
\mathbf{elif}\;a \leq 3.3 \cdot 10^{+181}:\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if a < -4.5e18 or 3.30000000000000017e181 < a Initial program 50.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.8%
Taylor expanded in a around inf
div-add-revN/A
lower-/.f64N/A
lift-+.f64N/A
lower-+.f64N/A
lower-+.f6474.6
Applied rewrites74.6%
if -4.5e18 < a < -2.09999999999999988e-275Initial program 63.2%
Applied rewrites89.1%
Taylor expanded in z around inf
lower-*.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6460.1
Applied rewrites60.1%
if -2.09999999999999988e-275 < a < 3.30000000000000017e181Initial program 62.8%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6466.0
Applied rewrites66.0%
Final simplification67.6%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -5e-39) (not (<= z 1.2e-177))) (fma (/ (+ y x) (+ (+ y x) t)) z a) (* (/ (+ t y) (+ t (+ x y))) a)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -5e-39) || !(z <= 1.2e-177)) {
tmp = fma(((y + x) / ((y + x) + t)), z, a);
} else {
tmp = ((t + y) / (t + (x + y))) * a;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -5e-39) || !(z <= 1.2e-177)) tmp = fma(Float64(Float64(y + x) / Float64(Float64(y + x) + t)), z, a); else tmp = Float64(Float64(Float64(t + y) / Float64(t + Float64(x + y))) * a); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -5e-39], N[Not[LessEqual[z, 1.2e-177]], $MachinePrecision]], N[(N[(N[(y + x), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision] * z + a), $MachinePrecision], N[(N[(N[(t + y), $MachinePrecision] / N[(t + N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{-39} \lor \neg \left(z \leq 1.2 \cdot 10^{-177}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y + x}{\left(y + x\right) + t}, z, a\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t + y}{t + \left(x + y\right)} \cdot a\\
\end{array}
\end{array}
if z < -4.9999999999999998e-39 or 1.1999999999999999e-177 < z Initial program 51.8%
Applied rewrites72.0%
Taylor expanded in t around inf
Applied rewrites81.0%
if -4.9999999999999998e-39 < z < 1.1999999999999999e-177Initial program 73.1%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites85.6%
Taylor expanded in a around inf
div-add-revN/A
lower-/.f64N/A
lift-+.f64N/A
lower-+.f64N/A
lower-+.f6461.2
Applied rewrites61.2%
Final simplification74.8%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -5.1e+117) (not (<= z 1.22e+86))) (* z (/ (+ x y) (+ t (+ x y)))) (- (+ a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -5.1e+117) || !(z <= 1.22e+86)) {
tmp = z * ((x + y) / (t + (x + y)));
} 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 ((z <= (-5.1d+117)) .or. (.not. (z <= 1.22d+86))) then
tmp = z * ((x + y) / (t + (x + y)))
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 ((z <= -5.1e+117) || !(z <= 1.22e+86)) {
tmp = z * ((x + y) / (t + (x + y)));
} else {
tmp = (a + z) - b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (z <= -5.1e+117) or not (z <= 1.22e+86): tmp = z * ((x + y) / (t + (x + y))) else: tmp = (a + z) - b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -5.1e+117) || !(z <= 1.22e+86)) tmp = Float64(z * Float64(Float64(x + y) / Float64(t + Float64(x + y)))); 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 ((z <= -5.1e+117) || ~((z <= 1.22e+86))) tmp = z * ((x + y) / (t + (x + y))); else tmp = (a + z) - b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -5.1e+117], N[Not[LessEqual[z, 1.22e+86]], $MachinePrecision]], N[(z * N[(N[(x + y), $MachinePrecision] / N[(t + N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.1 \cdot 10^{+117} \lor \neg \left(z \leq 1.22 \cdot 10^{+86}\right):\\
\;\;\;\;z \cdot \frac{x + y}{t + \left(x + y\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\end{array}
\end{array}
if z < -5.0999999999999996e117 or 1.21999999999999996e86 < z Initial program 43.2%
Applied rewrites75.0%
Taylor expanded in z around inf
lower-*.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6472.1
Applied rewrites72.1%
if -5.0999999999999996e117 < z < 1.21999999999999996e86Initial program 67.6%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6459.0
Applied rewrites59.0%
Final simplification63.9%
(FPCore (x y z t a b) :precision binary64 (if (<= t -1.25e+87) a (if (<= t 1.18e-57) (- (+ a z) b) (if (<= t 2.2e+194) (+ a z) a))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -1.25e+87) {
tmp = a;
} else if (t <= 1.18e-57) {
tmp = (a + z) - b;
} else if (t <= 2.2e+194) {
tmp = a + z;
} else {
tmp = a;
}
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 (t <= (-1.25d+87)) then
tmp = a
else if (t <= 1.18d-57) then
tmp = (a + z) - b
else if (t <= 2.2d+194) then
tmp = a + z
else
tmp = a
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 (t <= -1.25e+87) {
tmp = a;
} else if (t <= 1.18e-57) {
tmp = (a + z) - b;
} else if (t <= 2.2e+194) {
tmp = a + z;
} else {
tmp = a;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -1.25e+87: tmp = a elif t <= 1.18e-57: tmp = (a + z) - b elif t <= 2.2e+194: tmp = a + z else: tmp = a return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -1.25e+87) tmp = a; elseif (t <= 1.18e-57) tmp = Float64(Float64(a + z) - b); elseif (t <= 2.2e+194) tmp = Float64(a + z); else tmp = a; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (t <= -1.25e+87) tmp = a; elseif (t <= 1.18e-57) tmp = (a + z) - b; elseif (t <= 2.2e+194) tmp = a + z; else tmp = a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -1.25e+87], a, If[LessEqual[t, 1.18e-57], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], If[LessEqual[t, 2.2e+194], N[(a + z), $MachinePrecision], a]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.25 \cdot 10^{+87}:\\
\;\;\;\;a\\
\mathbf{elif}\;t \leq 1.18 \cdot 10^{-57}:\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{elif}\;t \leq 2.2 \cdot 10^{+194}:\\
\;\;\;\;a + z\\
\mathbf{else}:\\
\;\;\;\;a\\
\end{array}
\end{array}
if t < -1.24999999999999995e87 or 2.2000000000000001e194 < t Initial program 50.2%
Taylor expanded in t around inf
Applied rewrites58.9%
if -1.24999999999999995e87 < t < 1.18e-57Initial program 62.6%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6467.8
Applied rewrites67.8%
if 1.18e-57 < t < 2.2000000000000001e194Initial program 58.5%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6453.4
Applied rewrites53.4%
Taylor expanded in b around 0
lift-+.f6464.8
Applied rewrites64.8%
Final simplification64.9%
(FPCore (x y z t a b) :precision binary64 (if (or (<= t -4.2e+104) (not (<= t 2.2e+194))) a (+ a z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((t <= -4.2e+104) || !(t <= 2.2e+194)) {
tmp = a;
} else {
tmp = a + 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 ((t <= (-4.2d+104)) .or. (.not. (t <= 2.2d+194))) then
tmp = a
else
tmp = a + 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 ((t <= -4.2e+104) || !(t <= 2.2e+194)) {
tmp = a;
} else {
tmp = a + z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (t <= -4.2e+104) or not (t <= 2.2e+194): tmp = a else: tmp = a + z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((t <= -4.2e+104) || !(t <= 2.2e+194)) tmp = a; else tmp = Float64(a + z); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((t <= -4.2e+104) || ~((t <= 2.2e+194))) tmp = a; else tmp = a + z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[t, -4.2e+104], N[Not[LessEqual[t, 2.2e+194]], $MachinePrecision]], a, N[(a + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.2 \cdot 10^{+104} \lor \neg \left(t \leq 2.2 \cdot 10^{+194}\right):\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;a + z\\
\end{array}
\end{array}
if t < -4.1999999999999997e104 or 2.2000000000000001e194 < t Initial program 49.3%
Taylor expanded in t around inf
Applied rewrites58.5%
if -4.1999999999999997e104 < t < 2.2000000000000001e194Initial program 61.3%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6462.4
Applied rewrites62.4%
Taylor expanded in b around 0
lift-+.f6459.6
Applied rewrites59.6%
Final simplification59.4%
(FPCore (x y z t a b) :precision binary64 (if (<= a -4.5e+17) a (if (<= a 2.4e-14) z a)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -4.5e+17) {
tmp = a;
} else if (a <= 2.4e-14) {
tmp = z;
} else {
tmp = a;
}
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 <= (-4.5d+17)) then
tmp = a
else if (a <= 2.4d-14) then
tmp = z
else
tmp = a
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 <= -4.5e+17) {
tmp = a;
} else if (a <= 2.4e-14) {
tmp = z;
} else {
tmp = a;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if a <= -4.5e+17: tmp = a elif a <= 2.4e-14: tmp = z else: tmp = a return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -4.5e+17) tmp = a; elseif (a <= 2.4e-14) tmp = z; else tmp = a; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (a <= -4.5e+17) tmp = a; elseif (a <= 2.4e-14) tmp = z; else tmp = a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -4.5e+17], a, If[LessEqual[a, 2.4e-14], z, a]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.5 \cdot 10^{+17}:\\
\;\;\;\;a\\
\mathbf{elif}\;a \leq 2.4 \cdot 10^{-14}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;a\\
\end{array}
\end{array}
if a < -4.5e17 or 2.4e-14 < a Initial program 51.9%
Taylor expanded in t around inf
Applied rewrites54.7%
if -4.5e17 < a < 2.4e-14Initial program 65.7%
Taylor expanded in x around inf
Applied rewrites47.6%
Final simplification51.2%
(FPCore (x y z t a b) :precision binary64 (if (<= b -3.2e+178) (- a b) (+ a z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= -3.2e+178) {
tmp = a - b;
} else {
tmp = a + 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 (b <= (-3.2d+178)) then
tmp = a - b
else
tmp = a + 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 (b <= -3.2e+178) {
tmp = a - b;
} else {
tmp = a + z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if b <= -3.2e+178: tmp = a - b else: tmp = a + z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -3.2e+178) tmp = Float64(a - b); else tmp = Float64(a + z); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (b <= -3.2e+178) tmp = a - b; else tmp = a + z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -3.2e+178], N[(a - b), $MachinePrecision], N[(a + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.2 \cdot 10^{+178}:\\
\;\;\;\;a - b\\
\mathbf{else}:\\
\;\;\;\;a + z\\
\end{array}
\end{array}
if b < -3.2e178Initial program 55.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6437.9
Applied rewrites37.9%
Taylor expanded in z around 0
Applied rewrites41.2%
if -3.2e178 < b Initial program 59.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6459.5
Applied rewrites59.5%
Taylor expanded in b around 0
lift-+.f6460.0
Applied rewrites60.0%
Final simplification58.0%
(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 58.5%
Taylor expanded in t around inf
Applied rewrites35.6%
Final simplification35.6%
(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 2025060
(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)))