
(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 14 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 (/ z (+ t y)))
(t_2 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))
(t_3 (pow (+ t y) 2.0)))
(if (<= t_2 (- INFINITY))
(-
(fma
(fma (/ y t_3) b (- t_1 (fma (/ z t_3) y (/ a (+ t y)))))
x
(fma t_1 y a))
(* (/ y (+ t y)) b))
(if (<= t_2 2e+251) t_2 (- (+ a z) b)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = z / (t + y);
double t_2 = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
double t_3 = pow((t + y), 2.0);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = fma(fma((y / t_3), b, (t_1 - fma((z / t_3), y, (a / (t + y))))), x, fma(t_1, y, a)) - ((y / (t + y)) * b);
} else if (t_2 <= 2e+251) {
tmp = t_2;
} else {
tmp = (a + z) - b;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(z / Float64(t + y)) t_2 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y)) t_3 = Float64(t + y) ^ 2.0 tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(fma(fma(Float64(y / t_3), b, Float64(t_1 - fma(Float64(z / t_3), y, Float64(a / Float64(t + y))))), x, fma(t_1, y, a)) - Float64(Float64(y / Float64(t + y)) * b)); elseif (t_2 <= 2e+251) tmp = 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[(z / N[(t + y), $MachinePrecision]), $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]}, Block[{t$95$3 = N[Power[N[(t + y), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(N[(N[(y / t$95$3), $MachinePrecision] * b + N[(t$95$1 - N[(N[(z / t$95$3), $MachinePrecision] * y + N[(a / N[(t + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x + N[(t$95$1 * y + a), $MachinePrecision]), $MachinePrecision] - N[(N[(y / N[(t + y), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+251], t$95$2, N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z}{t + y}\\
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}\\
t_3 := {\left(t + y\right)}^{2}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\frac{y}{t\_3}, b, t\_1 - \mathsf{fma}\left(\frac{z}{t\_3}, y, \frac{a}{t + y}\right)\right), x, \mathsf{fma}\left(t\_1, y, a\right)\right) - \frac{y}{t + y} \cdot b\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+251}:\\
\;\;\;\;t\_2\\
\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.0%
Taylor expanded in x around 0
lower--.f64N/A
Applied rewrites88.0%
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.0000000000000001e251Initial program 99.7%
if 2.0000000000000001e251 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 7.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6476.9
Applied rewrites76.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (+ t y) a))
(t_2 (+ (+ x t) y))
(t_3 (/ (- (+ (* (+ x y) z) t_1) (* y b)) t_2)))
(if (<= t_3 (- INFINITY))
(fma (/ y (+ t y)) (- z b) a)
(if (<= t_3 2e+98)
(/ (fma (+ y x) z t_1) (+ (+ y x) t))
(if (<= t_3 2e+243) (/ (fma z x (* y (- z b))) t_2) (- (+ a z) b))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (t + y) * a;
double t_2 = (x + t) + y;
double t_3 = ((((x + y) * z) + t_1) - (y * b)) / t_2;
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = fma((y / (t + y)), (z - b), a);
} else if (t_3 <= 2e+98) {
tmp = fma((y + x), z, t_1) / ((y + x) + t);
} else if (t_3 <= 2e+243) {
tmp = fma(z, x, (y * (z - b))) / t_2;
} else {
tmp = (a + z) - b;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(t + y) * a) t_2 = Float64(Float64(x + t) + y) t_3 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + t_1) - Float64(y * b)) / t_2) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = fma(Float64(y / Float64(t + y)), Float64(z - b), a); elseif (t_3 <= 2e+98) tmp = Float64(fma(Float64(y + x), z, t_1) / Float64(Float64(y + x) + t)); elseif (t_3 <= 2e+243) tmp = Float64(fma(z, x, Float64(y * Float64(z - b))) / 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[(t + y), $MachinePrecision] * a), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + t$95$1), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[(N[(y / N[(t + y), $MachinePrecision]), $MachinePrecision] * N[(z - b), $MachinePrecision] + a), $MachinePrecision], If[LessEqual[t$95$3, 2e+98], N[(N[(N[(y + x), $MachinePrecision] * z + t$95$1), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2e+243], N[(N[(z * x + N[(y * N[(z - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(t + y\right) \cdot a\\
t_2 := \left(x + t\right) + y\\
t_3 := \frac{\left(\left(x + y\right) \cdot z + t\_1\right) - y \cdot b}{t\_2}\\
\mathbf{if}\;t\_3 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t + y}, z - b, a\right)\\
\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{+98}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y + x, z, t\_1\right)}{\left(y + x\right) + t}\\
\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{+243}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, x, y \cdot \left(z - b\right)\right)}{t\_2}\\
\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.0%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
distribute-lft-inN/A
associate--l+N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f648.2
Applied rewrites8.2%
Taylor expanded in a around 0
Applied rewrites87.5%
Applied rewrites87.6%
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 2e98Initial program 99.7%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6478.9
Applied rewrites78.9%
if 2e98 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 2.0000000000000001e243Initial program 99.7%
Taylor expanded in a around 0
distribute-rgt-inN/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f6483.3
Applied rewrites83.3%
if 2.0000000000000001e243 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 9.3%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6476.6
Applied rewrites76.6%
(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 (/ y (+ t y)) (- z b) a)
(if (<= t_1 2e+251) 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((y / (t + y)), (z - b), a);
} else if (t_1 <= 2e+251) {
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(y / Float64(t + y)), Float64(z - b), a); elseif (t_1 <= 2e+251) 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[(y / N[(t + y), $MachinePrecision]), $MachinePrecision] * N[(z - b), $MachinePrecision] + a), $MachinePrecision], If[LessEqual[t$95$1, 2e+251], 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{y}{t + y}, z - b, a\right)\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+251}:\\
\;\;\;\;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.0%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
distribute-lft-inN/A
associate--l+N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f648.2
Applied rewrites8.2%
Taylor expanded in a around 0
Applied rewrites87.5%
Applied rewrites87.6%
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.0000000000000001e251Initial program 99.7%
if 2.0000000000000001e251 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 7.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6476.9
Applied rewrites76.9%
(FPCore (x y z t a b) :precision binary64 (if (or (<= y -9e-108) (not (<= y 4.8e-147))) (fma (/ y (+ t y)) (- z b) a) (/ (fma a t (* z x)) (+ t x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((y <= -9e-108) || !(y <= 4.8e-147)) {
tmp = fma((y / (t + y)), (z - b), a);
} else {
tmp = fma(a, t, (z * x)) / (t + x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((y <= -9e-108) || !(y <= 4.8e-147)) tmp = fma(Float64(y / Float64(t + y)), Float64(z - b), a); else tmp = Float64(fma(a, t, Float64(z * x)) / Float64(t + x)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[y, -9e-108], N[Not[LessEqual[y, 4.8e-147]], $MachinePrecision]], N[(N[(y / N[(t + y), $MachinePrecision]), $MachinePrecision] * N[(z - b), $MachinePrecision] + a), $MachinePrecision], N[(N[(a * t + N[(z * x), $MachinePrecision]), $MachinePrecision] / N[(t + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{-108} \lor \neg \left(y \leq 4.8 \cdot 10^{-147}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t + y}, z - b, a\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, t, z \cdot x\right)}{t + x}\\
\end{array}
\end{array}
if y < -8.99999999999999941e-108 or 4.79999999999999997e-147 < y Initial program 55.7%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
distribute-lft-inN/A
associate--l+N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f6443.3
Applied rewrites43.3%
Taylor expanded in a around 0
Applied rewrites76.4%
Applied rewrites79.2%
if -8.99999999999999941e-108 < y < 4.79999999999999997e-147Initial program 82.4%
Taylor expanded in y around 0
lower-/.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6467.4
Applied rewrites67.4%
Final simplification75.8%
(FPCore (x y z t a b) :precision binary64 (if (or (<= x -1.72e+161) (not (<= x 2.9e+166))) (* (/ (+ y x) (+ t (+ y x))) z) (fma (/ y (+ t y)) (- z b) a)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x <= -1.72e+161) || !(x <= 2.9e+166)) {
tmp = ((y + x) / (t + (y + x))) * z;
} else {
tmp = fma((y / (t + y)), (z - b), a);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((x <= -1.72e+161) || !(x <= 2.9e+166)) tmp = Float64(Float64(Float64(y + x) / Float64(t + Float64(y + x))) * z); else tmp = fma(Float64(y / Float64(t + y)), Float64(z - b), a); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[x, -1.72e+161], N[Not[LessEqual[x, 2.9e+166]], $MachinePrecision]], N[(N[(N[(y + x), $MachinePrecision] / N[(t + N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[(y / N[(t + y), $MachinePrecision]), $MachinePrecision] * N[(z - b), $MachinePrecision] + a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.72 \cdot 10^{+161} \lor \neg \left(x \leq 2.9 \cdot 10^{+166}\right):\\
\;\;\;\;\frac{y + x}{t + \left(y + x\right)} \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t + y}, z - b, a\right)\\
\end{array}
\end{array}
if x < -1.71999999999999996e161 or 2.9000000000000001e166 < x Initial program 56.1%
Taylor expanded in z around inf
*-commutativeN/A
Applied rewrites80.1%
Taylor expanded in z around inf
Applied rewrites60.6%
if -1.71999999999999996e161 < x < 2.9000000000000001e166Initial program 65.5%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
distribute-lft-inN/A
associate--l+N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f6446.6
Applied rewrites46.6%
Taylor expanded in a around 0
Applied rewrites72.7%
Applied rewrites77.9%
Final simplification74.2%
(FPCore (x y z t a b) :precision binary64 (if (or (<= x -1.72e+161) (not (<= x 5.2e+170))) (* 1.0 z) (fma (/ y (+ t y)) (- z b) a)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x <= -1.72e+161) || !(x <= 5.2e+170)) {
tmp = 1.0 * z;
} else {
tmp = fma((y / (t + y)), (z - b), a);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((x <= -1.72e+161) || !(x <= 5.2e+170)) tmp = Float64(1.0 * z); else tmp = fma(Float64(y / Float64(t + y)), Float64(z - b), a); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[x, -1.72e+161], N[Not[LessEqual[x, 5.2e+170]], $MachinePrecision]], N[(1.0 * z), $MachinePrecision], N[(N[(y / N[(t + y), $MachinePrecision]), $MachinePrecision] * N[(z - b), $MachinePrecision] + a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.72 \cdot 10^{+161} \lor \neg \left(x \leq 5.2 \cdot 10^{+170}\right):\\
\;\;\;\;1 \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t + y}, z - b, a\right)\\
\end{array}
\end{array}
if x < -1.71999999999999996e161 or 5.1999999999999996e170 < x Initial program 56.1%
Taylor expanded in z around inf
*-commutativeN/A
Applied rewrites80.1%
Taylor expanded in x around inf
Applied rewrites54.2%
if -1.71999999999999996e161 < x < 5.1999999999999996e170Initial program 65.5%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
distribute-lft-inN/A
associate--l+N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f6446.6
Applied rewrites46.6%
Taylor expanded in a around 0
Applied rewrites72.7%
Applied rewrites77.9%
Final simplification72.9%
(FPCore (x y z t a b) :precision binary64 (if (or (<= x -1.72e+161) (not (<= x 5.2e+170))) (* 1.0 z) (fma y (/ (- z b) (+ t y)) a)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x <= -1.72e+161) || !(x <= 5.2e+170)) {
tmp = 1.0 * z;
} else {
tmp = fma(y, ((z - b) / (t + y)), a);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((x <= -1.72e+161) || !(x <= 5.2e+170)) tmp = Float64(1.0 * z); else tmp = fma(y, Float64(Float64(z - b) / Float64(t + y)), a); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[x, -1.72e+161], N[Not[LessEqual[x, 5.2e+170]], $MachinePrecision]], N[(1.0 * z), $MachinePrecision], N[(y * N[(N[(z - b), $MachinePrecision] / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.72 \cdot 10^{+161} \lor \neg \left(x \leq 5.2 \cdot 10^{+170}\right):\\
\;\;\;\;1 \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - b}{t + y}, a\right)\\
\end{array}
\end{array}
if x < -1.71999999999999996e161 or 5.1999999999999996e170 < x Initial program 56.1%
Taylor expanded in z around inf
*-commutativeN/A
Applied rewrites80.1%
Taylor expanded in x around inf
Applied rewrites54.2%
if -1.71999999999999996e161 < x < 5.1999999999999996e170Initial program 65.5%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
distribute-lft-inN/A
associate--l+N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f6446.6
Applied rewrites46.6%
Taylor expanded in a around 0
Applied rewrites72.7%
Final simplification68.8%
(FPCore (x y z t a b) :precision binary64 (if (<= t -1.7e+132) (fma (/ (- z b) t) y a) (if (<= t 6e+96) (- (+ a z) b) (fma y (/ z (+ t y)) a))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -1.7e+132) {
tmp = fma(((z - b) / t), y, a);
} else if (t <= 6e+96) {
tmp = (a + z) - b;
} else {
tmp = fma(y, (z / (t + y)), a);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -1.7e+132) tmp = fma(Float64(Float64(z - b) / t), y, a); elseif (t <= 6e+96) tmp = Float64(Float64(a + z) - b); else tmp = fma(y, Float64(z / Float64(t + y)), a); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -1.7e+132], N[(N[(N[(z - b), $MachinePrecision] / t), $MachinePrecision] * y + a), $MachinePrecision], If[LessEqual[t, 6e+96], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], N[(y * N[(z / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.7 \cdot 10^{+132}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - b}{t}, y, a\right)\\
\mathbf{elif}\;t \leq 6 \cdot 10^{+96}:\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{t + y}, a\right)\\
\end{array}
\end{array}
if t < -1.70000000000000013e132Initial program 57.5%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
distribute-lft-inN/A
associate--l+N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f6437.7
Applied rewrites37.7%
Taylor expanded in a around 0
Applied rewrites73.3%
Taylor expanded in y around 0
Applied rewrites68.2%
if -1.70000000000000013e132 < t < 6.0000000000000001e96Initial program 68.2%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6460.6
Applied rewrites60.6%
if 6.0000000000000001e96 < t Initial program 44.8%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
distribute-lft-inN/A
associate--l+N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f6439.4
Applied rewrites39.4%
Taylor expanded in a around 0
Applied rewrites82.1%
Taylor expanded in z around inf
Applied rewrites69.9%
(FPCore (x y z t a b) :precision binary64 (if (<= t -2e+132) (* a (/ t (+ t x))) (if (<= t 6e+96) (- (+ a z) b) (fma y (/ z (+ t y)) a))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -2e+132) {
tmp = a * (t / (t + x));
} else if (t <= 6e+96) {
tmp = (a + z) - b;
} else {
tmp = fma(y, (z / (t + y)), a);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -2e+132) tmp = Float64(a * Float64(t / Float64(t + x))); elseif (t <= 6e+96) tmp = Float64(Float64(a + z) - b); else tmp = fma(y, Float64(z / Float64(t + y)), a); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -2e+132], N[(a * N[(t / N[(t + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 6e+96], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision], N[(y * N[(z / N[(t + y), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2 \cdot 10^{+132}:\\
\;\;\;\;a \cdot \frac{t}{t + x}\\
\mathbf{elif}\;t \leq 6 \cdot 10^{+96}:\\
\;\;\;\;\left(a + z\right) - b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{t + y}, a\right)\\
\end{array}
\end{array}
if t < -1.99999999999999998e132Initial program 57.5%
Taylor expanded in a around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6460.3
Applied rewrites60.3%
Taylor expanded in y around 0
Applied rewrites66.4%
if -1.99999999999999998e132 < t < 6.0000000000000001e96Initial program 68.2%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6460.6
Applied rewrites60.6%
if 6.0000000000000001e96 < t Initial program 44.8%
Taylor expanded in x around 0
lower-/.f64N/A
associate--l+N/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
distribute-lft-out--N/A
distribute-lft-inN/A
associate--l+N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f6439.4
Applied rewrites39.4%
Taylor expanded in a around 0
Applied rewrites82.1%
Taylor expanded in z around inf
Applied rewrites69.9%
(FPCore (x y z t a b) :precision binary64 (if (or (<= t -2e+132) (not (<= t 1.02e+102))) (* a (/ t (+ t x))) (- (+ a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((t <= -2e+132) || !(t <= 1.02e+102)) {
tmp = a * (t / (t + 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 ((t <= (-2d+132)) .or. (.not. (t <= 1.02d+102))) then
tmp = a * (t / (t + 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 ((t <= -2e+132) || !(t <= 1.02e+102)) {
tmp = a * (t / (t + x));
} else {
tmp = (a + z) - b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (t <= -2e+132) or not (t <= 1.02e+102): tmp = a * (t / (t + x)) else: tmp = (a + z) - b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((t <= -2e+132) || !(t <= 1.02e+102)) tmp = Float64(a * Float64(t / Float64(t + 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 ((t <= -2e+132) || ~((t <= 1.02e+102))) tmp = a * (t / (t + x)); else tmp = (a + z) - b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[t, -2e+132], N[Not[LessEqual[t, 1.02e+102]], $MachinePrecision]], N[(a * N[(t / N[(t + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2 \cdot 10^{+132} \lor \neg \left(t \leq 1.02 \cdot 10^{+102}\right):\\
\;\;\;\;a \cdot \frac{t}{t + x}\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\end{array}
\end{array}
if t < -1.99999999999999998e132 or 1.01999999999999999e102 < t Initial program 50.3%
Taylor expanded in a around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6457.1
Applied rewrites57.1%
Taylor expanded in y around 0
Applied rewrites62.6%
if -1.99999999999999998e132 < t < 1.01999999999999999e102Initial program 68.2%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6460.6
Applied rewrites60.6%
Final simplification61.1%
(FPCore (x y z t a b) :precision binary64 (if (or (<= z -2.1e+60) (not (<= z 7e+152))) (- z b) (- a b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z <= -2.1e+60) || !(z <= 7e+152)) {
tmp = z - b;
} else {
tmp = a - 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 <= (-2.1d+60)) .or. (.not. (z <= 7d+152))) then
tmp = z - b
else
tmp = a - 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 <= -2.1e+60) || !(z <= 7e+152)) {
tmp = z - b;
} else {
tmp = a - b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (z <= -2.1e+60) or not (z <= 7e+152): tmp = z - b else: tmp = a - b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((z <= -2.1e+60) || !(z <= 7e+152)) tmp = Float64(z - b); else tmp = Float64(a - b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((z <= -2.1e+60) || ~((z <= 7e+152))) tmp = z - b; else tmp = a - b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[z, -2.1e+60], N[Not[LessEqual[z, 7e+152]], $MachinePrecision]], N[(z - b), $MachinePrecision], N[(a - b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.1 \cdot 10^{+60} \lor \neg \left(z \leq 7 \cdot 10^{+152}\right):\\
\;\;\;\;z - b\\
\mathbf{else}:\\
\;\;\;\;a - b\\
\end{array}
\end{array}
if z < -2.1000000000000001e60 or 6.99999999999999963e152 < z Initial program 44.7%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6460.2
Applied rewrites60.2%
Taylor expanded in z around 0
Applied rewrites19.2%
Taylor expanded in a around 0
Applied rewrites60.0%
if -2.1000000000000001e60 < z < 6.99999999999999963e152Initial program 73.1%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6454.1
Applied rewrites54.1%
Taylor expanded in z around 0
Applied rewrites53.0%
Final simplification55.3%
(FPCore (x y z t a b) :precision binary64 (if (<= x -9e+164) (* 1.0 z) (- (+ a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -9e+164) {
tmp = 1.0 * z;
} 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 <= (-9d+164)) then
tmp = 1.0d0 * z
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 <= -9e+164) {
tmp = 1.0 * z;
} else {
tmp = (a + z) - b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if x <= -9e+164: tmp = 1.0 * z else: tmp = (a + z) - b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -9e+164) tmp = Float64(1.0 * z); 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 <= -9e+164) tmp = 1.0 * z; else tmp = (a + z) - b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -9e+164], N[(1.0 * z), $MachinePrecision], N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+164}:\\
\;\;\;\;1 \cdot z\\
\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\
\end{array}
\end{array}
if x < -8.9999999999999995e164Initial program 53.9%
Taylor expanded in z around inf
*-commutativeN/A
Applied rewrites79.4%
Taylor expanded in x around inf
Applied rewrites54.5%
if -8.9999999999999995e164 < x Initial program 64.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6459.5
Applied rewrites59.5%
(FPCore (x y z t a b) :precision binary64 (- a b))
double code(double x, double y, double z, double t, double a, double b) {
return a - b;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = a - b
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return a - b;
}
def code(x, y, z, t, a, b): return a - b
function code(x, y, z, t, a, b) return Float64(a - b) end
function tmp = code(x, y, z, t, a, b) tmp = a - b; end
code[x_, y_, z_, t_, a_, b_] := N[(a - b), $MachinePrecision]
\begin{array}{l}
\\
a - b
\end{array}
Initial program 63.5%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6456.2
Applied rewrites56.2%
Taylor expanded in z around 0
Applied rewrites41.6%
(FPCore (x y z t a b) :precision binary64 (- b))
double code(double x, double y, double z, double t, double a, double b) {
return -b;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = -b
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return -b;
}
def code(x, y, z, t, a, b): return -b
function code(x, y, z, t, a, b) return Float64(-b) end
function tmp = code(x, y, z, t, a, b) tmp = -b; end
code[x_, y_, z_, t_, a_, b_] := (-b)
\begin{array}{l}
\\
-b
\end{array}
Initial program 63.5%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6456.2
Applied rewrites56.2%
Taylor expanded in z around 0
Applied rewrites41.6%
Taylor expanded in a around 0
Applied rewrites16.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 2025017
(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)))