
(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]
\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}
Herbie found 13 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]
\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))
(t_2 (+ (+ t x) y))
(t_3 (/ (+ y x) t_2))
(t_4 (fma z t_3 (- (* (/ a t_2) (+ t y)) (* b (/ y t_2))))))
(if (<= t_1 (- INFINITY))
t_4
(if (<= t_1 5e+284) (fma z t_3 (/ (- (* a (+ t y)) (* b y)) t_2)) t_4))))double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
double t_2 = (t + x) + y;
double t_3 = (y + x) / t_2;
double t_4 = fma(z, t_3, (((a / t_2) * (t + y)) - (b * (y / t_2))));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_4;
} else if (t_1 <= 5e+284) {
tmp = fma(z, t_3, (((a * (t + y)) - (b * y)) / t_2));
} else {
tmp = t_4;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y)) t_2 = Float64(Float64(t + x) + y) t_3 = Float64(Float64(y + x) / t_2) t_4 = fma(z, t_3, Float64(Float64(Float64(a / t_2) * Float64(t + y)) - Float64(b * Float64(y / t_2)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_4; elseif (t_1 <= 5e+284) tmp = fma(z, t_3, Float64(Float64(Float64(a * Float64(t + y)) - Float64(b * y)) / t_2)); else tmp = t_4; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t + x), $MachinePrecision] + y), $MachinePrecision]}, Block[{t$95$3 = N[(N[(y + x), $MachinePrecision] / t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(z * t$95$3 + N[(N[(N[(a / t$95$2), $MachinePrecision] * N[(t + y), $MachinePrecision]), $MachinePrecision] - N[(b * N[(y / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$4, If[LessEqual[t$95$1, 5e+284], N[(z * t$95$3 + N[(N[(N[(a * N[(t + y), $MachinePrecision]), $MachinePrecision] - N[(b * y), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision], t$95$4]]]]]]
\begin{array}{l}
t_1 := \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\\
t_2 := \left(t + x\right) + y\\
t_3 := \frac{y + x}{t\_2}\\
t_4 := \mathsf{fma}\left(z, t\_3, \frac{a}{t\_2} \cdot \left(t + y\right) - b \cdot \frac{y}{t\_2}\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+284}:\\
\;\;\;\;\mathsf{fma}\left(z, t\_3, \frac{a \cdot \left(t + y\right) - b \cdot y}{t\_2}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -inf.0 or 4.9999999999999999e284 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 60.9%
lift-/.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
div-addN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites73.1%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
add-flipN/A
sub-negate-revN/A
sub-negateN/A
Applied rewrites83.3%
lift-fma.f64N/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
associate--r-N/A
lift-neg.f64N/A
add-flipN/A
lift-+.f64N/A
lift-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6494.1
Applied rewrites94.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)) < 4.9999999999999999e284Initial program 60.9%
lift-/.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
div-addN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites73.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))
(t_2 (+ (+ t x) y))
(t_3 (/ (+ y x) t_2))
(t_4 (fma z t_3 (- a (* b (/ y t_2))))))
(if (<= t_1 (- INFINITY))
t_4
(if (<= t_1 2e+293) (fma z t_3 (/ (- (* a (+ t y)) (* b y)) t_2)) t_4))))double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
double t_2 = (t + x) + y;
double t_3 = (y + x) / t_2;
double t_4 = fma(z, t_3, (a - (b * (y / t_2))));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_4;
} else if (t_1 <= 2e+293) {
tmp = fma(z, t_3, (((a * (t + y)) - (b * y)) / t_2));
} else {
tmp = t_4;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y)) t_2 = Float64(Float64(t + x) + y) t_3 = Float64(Float64(y + x) / t_2) t_4 = fma(z, t_3, Float64(a - Float64(b * Float64(y / t_2)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_4; elseif (t_1 <= 2e+293) tmp = fma(z, t_3, Float64(Float64(Float64(a * Float64(t + y)) - Float64(b * y)) / t_2)); else tmp = t_4; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t + x), $MachinePrecision] + y), $MachinePrecision]}, Block[{t$95$3 = N[(N[(y + x), $MachinePrecision] / t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(z * t$95$3 + N[(a - N[(b * N[(y / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$4, If[LessEqual[t$95$1, 2e+293], N[(z * t$95$3 + N[(N[(N[(a * N[(t + y), $MachinePrecision]), $MachinePrecision] - N[(b * y), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision], t$95$4]]]]]]
\begin{array}{l}
t_1 := \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\\
t_2 := \left(t + x\right) + y\\
t_3 := \frac{y + x}{t\_2}\\
t_4 := \mathsf{fma}\left(z, t\_3, a - b \cdot \frac{y}{t\_2}\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+293}:\\
\;\;\;\;\mathsf{fma}\left(z, t\_3, \frac{a \cdot \left(t + y\right) - b \cdot y}{t\_2}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -inf.0 or 1.9999999999999998e293 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 60.9%
lift-/.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
div-addN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites73.1%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
add-flipN/A
sub-negate-revN/A
sub-negateN/A
Applied rewrites83.3%
lift-fma.f64N/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
associate--r-N/A
lift-neg.f64N/A
add-flipN/A
lift-+.f64N/A
lift-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6494.1
Applied rewrites94.1%
Taylor expanded in x around 0
Applied rewrites84.3%
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 1.9999999999999998e293Initial program 60.9%
lift-/.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
div-addN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites73.1%
(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 (+ (+ t x) y))
(t_4 (fma z (/ (+ y x) t_3) (- a (* b (/ y t_3))))))
(if (<= t_2 -2e+215)
t_4
(if (<= t_2 2e+293)
(/ (fma (- y) b (fma a (+ t y) (* z (+ y x)))) t_1)
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)) / t_1;
double t_3 = (t + x) + y;
double t_4 = fma(z, ((y + x) / t_3), (a - (b * (y / t_3))));
double tmp;
if (t_2 <= -2e+215) {
tmp = t_4;
} else if (t_2 <= 2e+293) {
tmp = fma(-y, b, fma(a, (t + y), (z * (y + x)))) / t_1;
} 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(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / t_1) t_3 = Float64(Float64(t + x) + y) t_4 = fma(z, Float64(Float64(y + x) / t_3), Float64(a - Float64(b * Float64(y / t_3)))) tmp = 0.0 if (t_2 <= -2e+215) tmp = t_4; elseif (t_2 <= 2e+293) tmp = Float64(fma(Float64(-y), b, fma(a, Float64(t + y), Float64(z * Float64(y + x)))) / t_1); else tmp = t_4; 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[(t + x), $MachinePrecision] + y), $MachinePrecision]}, Block[{t$95$4 = N[(z * N[(N[(y + x), $MachinePrecision] / t$95$3), $MachinePrecision] + N[(a - N[(b * N[(y / t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+215], t$95$4, If[LessEqual[t$95$2, 2e+293], N[(N[((-y) * b + N[(a * N[(t + y), $MachinePrecision] + N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], t$95$4]]]]]]
\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(t + x\right) + y\\
t_4 := \mathsf{fma}\left(z, \frac{y + x}{t\_3}, a - b \cdot \frac{y}{t\_3}\right)\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+215}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+293}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-y, b, \mathsf{fma}\left(a, t + y, z \cdot \left(y + x\right)\right)\right)}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -1.99999999999999981e215 or 1.9999999999999998e293 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 60.9%
lift-/.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
div-addN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites73.1%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
add-flipN/A
sub-negate-revN/A
sub-negateN/A
Applied rewrites83.3%
lift-fma.f64N/A
add-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift-*.f64N/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
associate--r-N/A
lift-neg.f64N/A
add-flipN/A
lift-+.f64N/A
lift-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6494.1
Applied rewrites94.1%
Taylor expanded in x around 0
Applied rewrites84.3%
if -1.99999999999999981e215 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 1.9999999999999998e293Initial program 60.9%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
lower-neg.f6461.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-fma.f6461.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6461.1
lift-+.f64N/A
+-commutativeN/A
lower-+.f6461.1
Applied rewrites61.1%
(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 (fma (/ (+ x y) (+ (+ t x) y)) z (- a (* (/ y (+ t y)) b)))))
(if (<= t_2 -2e+215)
t_3
(if (<= t_2 2e+293)
(/ (fma (- y) b (fma a (+ t y) (* z (+ y x)))) t_1)
t_3))))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 = fma(((x + y) / ((t + x) + y)), z, (a - ((y / (t + y)) * b)));
double tmp;
if (t_2 <= -2e+215) {
tmp = t_3;
} else if (t_2 <= 2e+293) {
tmp = fma(-y, b, fma(a, (t + y), (z * (y + x)))) / t_1;
} else {
tmp = t_3;
}
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 = fma(Float64(Float64(x + y) / Float64(Float64(t + x) + y)), z, Float64(a - Float64(Float64(y / Float64(t + y)) * b))) tmp = 0.0 if (t_2 <= -2e+215) tmp = t_3; elseif (t_2 <= 2e+293) tmp = Float64(fma(Float64(-y), b, fma(a, Float64(t + y), Float64(z * Float64(y + x)))) / t_1); else tmp = t_3; 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[(N[(x + y), $MachinePrecision] / N[(N[(t + x), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] * z + N[(a - N[(N[(y / N[(t + y), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+215], t$95$3, If[LessEqual[t$95$2, 2e+293], N[(N[((-y) * b + N[(a * N[(t + y), $MachinePrecision] + N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], t$95$3]]]]]
\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 := \mathsf{fma}\left(\frac{x + y}{\left(t + x\right) + y}, z, a - \frac{y}{t + y} \cdot b\right)\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+215}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+293}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-y, b, \mathsf{fma}\left(a, t + y, z \cdot \left(y + x\right)\right)\right)}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -1.99999999999999981e215 or 1.9999999999999998e293 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 60.9%
lift-/.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
div-addN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites73.1%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
lift-+.f64N/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
add-flipN/A
sub-negate-revN/A
sub-negateN/A
Applied rewrites83.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6468.6
Applied rewrites68.6%
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6468.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6468.6
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
Applied rewrites78.2%
if -1.99999999999999981e215 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 1.9999999999999998e293Initial program 60.9%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
lower-neg.f6461.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-fma.f6461.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6461.1
lift-+.f64N/A
+-commutativeN/A
lower-+.f6461.1
Applied rewrites61.1%
(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 (- b z))))
(if (<= t_2 (- INFINITY))
t_3
(if (<= t_2 2e+293)
(/ (fma (- y) b (fma a (+ t y) (* z (+ y x)))) t_1)
t_3))))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 - (b - z);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_3;
} else if (t_2 <= 2e+293) {
tmp = fma(-y, b, fma(a, (t + y), (z * (y + x)))) / t_1;
} else {
tmp = t_3;
}
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(a - Float64(b - z)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_3; elseif (t_2 <= 2e+293) tmp = Float64(fma(Float64(-y), b, fma(a, Float64(t + y), Float64(z * Float64(y + x)))) / t_1); else tmp = t_3; 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[(a - N[(b - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$3, If[LessEqual[t$95$2, 2e+293], N[(N[((-y) * b + N[(a * N[(t + y), $MachinePrecision] + N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], t$95$3]]]]]
\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 := a - \left(b - z\right)\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+293}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-y, b, \mathsf{fma}\left(a, t + y, z \cdot \left(y + x\right)\right)\right)}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -inf.0 or 1.9999999999999998e293 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 60.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6455.4
Applied rewrites55.4%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f6455.4
Applied rewrites55.4%
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 1.9999999999999998e293Initial program 60.9%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
lower-neg.f6461.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-fma.f6461.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6461.1
lift-+.f64N/A
+-commutativeN/A
lower-+.f6461.1
Applied rewrites61.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- (+ a (/ (* y z) (+ t y))) (/ (* b y) (+ t y))))
(t_2 (* (/ (+ x y) (+ (+ t x) y)) z)))
(if (<= z -5.2e+58)
t_2
(if (<= z -1.2e-98)
t_1
(if (<= z 3.5e-103)
(/ (- (* a (+ t y)) (* y b)) (+ (+ x t) y))
(if (<= z 4.2e+105) t_1 t_2))))))double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a + ((y * z) / (t + y))) - ((b * y) / (t + y));
double t_2 = ((x + y) / ((t + x) + y)) * z;
double tmp;
if (z <= -5.2e+58) {
tmp = t_2;
} else if (z <= -1.2e-98) {
tmp = t_1;
} else if (z <= 3.5e-103) {
tmp = ((a * (t + y)) - (y * b)) / ((x + t) + y);
} else if (z <= 4.2e+105) {
tmp = t_1;
} 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 = (a + ((y * z) / (t + y))) - ((b * y) / (t + y))
t_2 = ((x + y) / ((t + x) + y)) * z
if (z <= (-5.2d+58)) then
tmp = t_2
else if (z <= (-1.2d-98)) then
tmp = t_1
else if (z <= 3.5d-103) then
tmp = ((a * (t + y)) - (y * b)) / ((x + t) + y)
else if (z <= 4.2d+105) then
tmp = t_1
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 = (a + ((y * z) / (t + y))) - ((b * y) / (t + y));
double t_2 = ((x + y) / ((t + x) + y)) * z;
double tmp;
if (z <= -5.2e+58) {
tmp = t_2;
} else if (z <= -1.2e-98) {
tmp = t_1;
} else if (z <= 3.5e-103) {
tmp = ((a * (t + y)) - (y * b)) / ((x + t) + y);
} else if (z <= 4.2e+105) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a + ((y * z) / (t + y))) - ((b * y) / (t + y)) t_2 = ((x + y) / ((t + x) + y)) * z tmp = 0 if z <= -5.2e+58: tmp = t_2 elif z <= -1.2e-98: tmp = t_1 elif z <= 3.5e-103: tmp = ((a * (t + y)) - (y * b)) / ((x + t) + y) elif z <= 4.2e+105: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a + Float64(Float64(y * z) / Float64(t + y))) - Float64(Float64(b * y) / Float64(t + y))) t_2 = Float64(Float64(Float64(x + y) / Float64(Float64(t + x) + y)) * z) tmp = 0.0 if (z <= -5.2e+58) tmp = t_2; elseif (z <= -1.2e-98) tmp = t_1; elseif (z <= 3.5e-103) tmp = Float64(Float64(Float64(a * Float64(t + y)) - Float64(y * b)) / Float64(Float64(x + t) + y)); elseif (z <= 4.2e+105) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a + ((y * z) / (t + y))) - ((b * y) / (t + y)); t_2 = ((x + y) / ((t + x) + y)) * z; tmp = 0.0; if (z <= -5.2e+58) tmp = t_2; elseif (z <= -1.2e-98) tmp = t_1; elseif (z <= 3.5e-103) tmp = ((a * (t + y)) - (y * b)) / ((x + t) + y); elseif (z <= 4.2e+105) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a + N[(N[(y * z), $MachinePrecision] / N[(t + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(b * y), $MachinePrecision] / N[(t + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(x + y), $MachinePrecision] / N[(N[(t + x), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -5.2e+58], t$95$2, If[LessEqual[z, -1.2e-98], t$95$1, If[LessEqual[z, 3.5e-103], N[(N[(N[(a * N[(t + y), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.2e+105], t$95$1, t$95$2]]]]]]
\begin{array}{l}
t_1 := \left(a + \frac{y \cdot z}{t + y}\right) - \frac{b \cdot y}{t + y}\\
t_2 := \frac{x + y}{\left(t + x\right) + y} \cdot z\\
\mathbf{if}\;z \leq -5.2 \cdot 10^{+58}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;z \leq -1.2 \cdot 10^{-98}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{-103}:\\
\;\;\;\;\frac{a \cdot \left(t + y\right) - y \cdot b}{\left(x + t\right) + y}\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{+105}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if z < -5.19999999999999976e58 or 4.2000000000000002e105 < z Initial program 60.9%
Taylor expanded in z around inf
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-+.f6425.8
Applied rewrites25.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
lift-+.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6440.9
lift-+.f64N/A
+-commutativeN/A
lift-+.f6440.9
Applied rewrites40.9%
if -5.19999999999999976e58 < z < -1.20000000000000002e-98 or 3.50000000000000016e-103 < z < 4.2000000000000002e105Initial program 60.9%
lift-/.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
div-addN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites73.1%
Taylor expanded in x around 0
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6450.0
Applied rewrites50.0%
if -1.20000000000000002e-98 < z < 3.50000000000000016e-103Initial program 60.9%
Taylor expanded in z around 0
lower-*.f64N/A
lower-+.f6437.4
Applied rewrites37.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 (- b z))))
(if (<= t_2 -1e+247)
t_3
(if (<= t_2 5000000000.0)
(/ (fma a t (* x z)) (+ t x))
(if (<= t_2 1e+137) (/ (fma x z (* y (- z b))) t_1) t_3)))))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 - (b - z);
double tmp;
if (t_2 <= -1e+247) {
tmp = t_3;
} else if (t_2 <= 5000000000.0) {
tmp = fma(a, t, (x * z)) / (t + x);
} else if (t_2 <= 1e+137) {
tmp = fma(x, z, (y * (z - b))) / t_1;
} else {
tmp = t_3;
}
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(a - Float64(b - z)) tmp = 0.0 if (t_2 <= -1e+247) tmp = t_3; elseif (t_2 <= 5000000000.0) tmp = Float64(fma(a, t, Float64(x * z)) / Float64(t + x)); elseif (t_2 <= 1e+137) tmp = Float64(fma(x, z, Float64(y * Float64(z - b))) / t_1); else tmp = t_3; 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[(a - N[(b - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+247], t$95$3, If[LessEqual[t$95$2, 5000000000.0], N[(N[(a * t + N[(x * z), $MachinePrecision]), $MachinePrecision] / N[(t + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e+137], N[(N[(x * z + N[(y * N[(z - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], t$95$3]]]]]]
\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 := a - \left(b - z\right)\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+247}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 5000000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, t, x \cdot z\right)}{t + x}\\
\mathbf{elif}\;t\_2 \leq 10^{+137}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, z, y \cdot \left(z - b\right)\right)}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\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.99999999999999952e246 or 1e137 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 60.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6455.4
Applied rewrites55.4%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f6455.4
Applied rewrites55.4%
if -9.99999999999999952e246 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 5e9Initial program 60.9%
Taylor expanded in y around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-+.f6441.3
Applied rewrites41.3%
if 5e9 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 1e137Initial program 60.9%
Taylor expanded in a around 0
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6437.8
Applied rewrites37.8%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lower--.f6437.9
Applied rewrites37.9%
(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 (- b z))))
(if (<= t_2 -1e+247)
t_3
(if (<= t_2 5e-30)
(/ (fma a t (* x z)) (+ t x))
(if (<= t_2 1e+127) (/ (* y (- (+ a z) b)) t_1) t_3)))))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 - (b - z);
double tmp;
if (t_2 <= -1e+247) {
tmp = t_3;
} else if (t_2 <= 5e-30) {
tmp = fma(a, t, (x * z)) / (t + x);
} else if (t_2 <= 1e+127) {
tmp = (y * ((a + z) - b)) / t_1;
} else {
tmp = t_3;
}
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(a - Float64(b - z)) tmp = 0.0 if (t_2 <= -1e+247) tmp = t_3; elseif (t_2 <= 5e-30) tmp = Float64(fma(a, t, Float64(x * z)) / Float64(t + x)); elseif (t_2 <= 1e+127) tmp = Float64(Float64(y * Float64(Float64(a + z) - b)) / t_1); else tmp = t_3; 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[(a - N[(b - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+247], t$95$3, If[LessEqual[t$95$2, 5e-30], N[(N[(a * t + N[(x * z), $MachinePrecision]), $MachinePrecision] / N[(t + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e+127], N[(N[(y * N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], t$95$3]]]]]]
\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 := a - \left(b - z\right)\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+247}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-30}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, t, x \cdot z\right)}{t + x}\\
\mathbf{elif}\;t\_2 \leq 10^{+127}:\\
\;\;\;\;\frac{y \cdot \left(\left(a + z\right) - b\right)}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\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.99999999999999952e246 or 9.99999999999999955e126 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 60.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6455.4
Applied rewrites55.4%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f6455.4
Applied rewrites55.4%
if -9.99999999999999952e246 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 4.99999999999999972e-30Initial program 60.9%
Taylor expanded in y around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-+.f6441.3
Applied rewrites41.3%
if 4.99999999999999972e-30 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 9.99999999999999955e126Initial program 60.9%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f64N/A
lower-+.f6430.4
Applied rewrites30.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 (- b z))))
(if (<= t_2 -1e+247)
t_3
(if (<= t_2 5000000000.0)
(/ (fma a t (* x z)) (+ t x))
(if (<= t_2 1e+127) (/ (* y (- z b)) t_1) t_3)))))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 - (b - z);
double tmp;
if (t_2 <= -1e+247) {
tmp = t_3;
} else if (t_2 <= 5000000000.0) {
tmp = fma(a, t, (x * z)) / (t + x);
} else if (t_2 <= 1e+127) {
tmp = (y * (z - b)) / t_1;
} else {
tmp = t_3;
}
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(a - Float64(b - z)) tmp = 0.0 if (t_2 <= -1e+247) tmp = t_3; elseif (t_2 <= 5000000000.0) tmp = Float64(fma(a, t, Float64(x * z)) / Float64(t + x)); elseif (t_2 <= 1e+127) tmp = Float64(Float64(y * Float64(z - b)) / t_1); else tmp = t_3; 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[(a - N[(b - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+247], t$95$3, If[LessEqual[t$95$2, 5000000000.0], N[(N[(a * t + N[(x * z), $MachinePrecision]), $MachinePrecision] / N[(t + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e+127], N[(N[(y * N[(z - b), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], t$95$3]]]]]]
\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 := a - \left(b - z\right)\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+247}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 5000000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, t, x \cdot z\right)}{t + x}\\
\mathbf{elif}\;t\_2 \leq 10^{+127}:\\
\;\;\;\;\frac{y \cdot \left(z - b\right)}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\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.99999999999999952e246 or 9.99999999999999955e126 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 60.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6455.4
Applied rewrites55.4%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f6455.4
Applied rewrites55.4%
if -9.99999999999999952e246 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 5e9Initial program 60.9%
Taylor expanded in y around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-+.f6441.3
Applied rewrites41.3%
if 5e9 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 9.99999999999999955e126Initial program 60.9%
Taylor expanded in a around 0
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6437.8
Applied rewrites37.8%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6422.5
Applied rewrites22.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))
(t_2 (- a (- b z))))
(if (<= t_1 -1e+247)
t_2
(if (<= t_1 1e+137) (/ (fma a t (* x z)) (+ t x)) t_2))))double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
double t_2 = a - (b - z);
double tmp;
if (t_1 <= -1e+247) {
tmp = t_2;
} else if (t_1 <= 1e+137) {
tmp = fma(a, t, (x * z)) / (t + x);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y)) t_2 = Float64(a - Float64(b - z)) tmp = 0.0 if (t_1 <= -1e+247) tmp = t_2; elseif (t_1 <= 1e+137) tmp = Float64(fma(a, t, Float64(x * z)) / Float64(t + x)); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(a - N[(b - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+247], t$95$2, If[LessEqual[t$95$1, 1e+137], N[(N[(a * t + N[(x * z), $MachinePrecision]), $MachinePrecision] / N[(t + x), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
t_1 := \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\\
t_2 := a - \left(b - z\right)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+247}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{+137}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, t, x \cdot z\right)}{t + x}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\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.99999999999999952e246 or 1e137 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 60.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6455.4
Applied rewrites55.4%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f6455.4
Applied rewrites55.4%
if -9.99999999999999952e246 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 1e137Initial program 60.9%
Taylor expanded in y around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-+.f6441.3
Applied rewrites41.3%
(FPCore (x y z t a b) :precision binary64 (if (<= t -2.2e+173) a (- a (- b z))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -2.2e+173) {
tmp = a;
} else {
tmp = a - (b - 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 <= (-2.2d+173)) then
tmp = a
else
tmp = a - (b - 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 <= -2.2e+173) {
tmp = a;
} else {
tmp = a - (b - z);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -2.2e+173: tmp = a else: tmp = a - (b - z) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -2.2e+173) tmp = a; else tmp = Float64(a - Float64(b - z)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (t <= -2.2e+173) tmp = a; else tmp = a - (b - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -2.2e+173], a, N[(a - N[(b - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;t \leq -2.2 \cdot 10^{+173}:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;a - \left(b - z\right)\\
\end{array}
if t < -2.2e173Initial program 60.9%
Taylor expanded in t around inf
Applied rewrites32.5%
if -2.2e173 < t Initial program 60.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-+.f6455.4
Applied rewrites55.4%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f6455.4
Applied rewrites55.4%
(FPCore (x y z t a b) :precision binary64 (if (<= z -8.5e-29) z (if (<= z 4.2e+105) a z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -8.5e-29) {
tmp = z;
} else if (z <= 4.2e+105) {
tmp = a;
} else {
tmp = z;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (z <= (-8.5d-29)) then
tmp = z
else if (z <= 4.2d+105) then
tmp = a
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -8.5e-29) {
tmp = z;
} else if (z <= 4.2e+105) {
tmp = a;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if z <= -8.5e-29: tmp = z elif z <= 4.2e+105: tmp = a else: tmp = z return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -8.5e-29) tmp = z; elseif (z <= 4.2e+105) tmp = a; else tmp = z; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (z <= -8.5e-29) tmp = z; elseif (z <= 4.2e+105) tmp = a; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -8.5e-29], z, If[LessEqual[z, 4.2e+105], a, z]]
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{-29}:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{+105}:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
if z < -8.5000000000000001e-29 or 4.2000000000000002e105 < z Initial program 60.9%
Taylor expanded in x around inf
Applied rewrites33.3%
if -8.5000000000000001e-29 < z < 4.2000000000000002e105Initial program 60.9%
Taylor expanded in t around inf
Applied rewrites32.5%
(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
a
Initial program 60.9%
Taylor expanded in t around inf
Applied rewrites32.5%
herbie shell --seed 2025170
(FPCore (x y z t a b)
:name "AI.Clustering.Hierarchical.Internal:ward from clustering-0.2.1"
:precision binary64
(/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))