
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
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)
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
code = ((x * y) - ((z * 9.0d0) * t)) / (a * 2.0d0)
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
def code(x, y, z, t, a): return ((x * y) - ((z * 9.0) * t)) / (a * 2.0)
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(Float64(z * 9.0) * t)) / Float64(a * 2.0)) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - ((z * 9.0) * t)) / (a * 2.0); end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
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)
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
code = ((x * y) - ((z * 9.0d0) * t)) / (a * 2.0d0)
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
def code(x, y, z, t, a): return ((x * y) - ((z * 9.0) * t)) / (a * 2.0)
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(Float64(z * 9.0) * t)) / Float64(a * 2.0)) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - ((z * 9.0) * t)) / (a * 2.0); end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
(FPCore (x y z t a)
:precision binary64
(let* ((t_1
(fma
(/ (fmax x y) (+ a a))
(fmin x y)
(* (/ (- (fmin z t)) a) (* (fmax z t) 4.5))))
(t_2
(-
(* (fmin x y) (fmax x y))
(* (* (fmin z t) 9.0) (fmax z t)))))
(if (<= t_2 -1e+303)
t_1
(if (<= t_2 1e+231)
(/
(fma (* (fmax z t) (fmin z t)) -9.0 (* (fmax x y) (fmin x y)))
(+ a a))
t_1))))double code(double x, double y, double z, double t, double a) {
double t_1 = fma((fmax(x, y) / (a + a)), fmin(x, y), ((-fmin(z, t) / a) * (fmax(z, t) * 4.5)));
double t_2 = (fmin(x, y) * fmax(x, y)) - ((fmin(z, t) * 9.0) * fmax(z, t));
double tmp;
if (t_2 <= -1e+303) {
tmp = t_1;
} else if (t_2 <= 1e+231) {
tmp = fma((fmax(z, t) * fmin(z, t)), -9.0, (fmax(x, y) * fmin(x, y))) / (a + a);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(fmax(x, y) / Float64(a + a)), fmin(x, y), Float64(Float64(Float64(-fmin(z, t)) / a) * Float64(fmax(z, t) * 4.5))) t_2 = Float64(Float64(fmin(x, y) * fmax(x, y)) - Float64(Float64(fmin(z, t) * 9.0) * fmax(z, t))) tmp = 0.0 if (t_2 <= -1e+303) tmp = t_1; elseif (t_2 <= 1e+231) tmp = Float64(fma(Float64(fmax(z, t) * fmin(z, t)), -9.0, Float64(fmax(x, y) * fmin(x, y))) / Float64(a + a)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[Max[x, y], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision] * N[Min[x, y], $MachinePrecision] + N[(N[((-N[Min[z, t], $MachinePrecision]) / a), $MachinePrecision] * N[(N[Max[z, t], $MachinePrecision] * 4.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Min[x, y], $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Min[z, t], $MachinePrecision] * 9.0), $MachinePrecision] * N[Max[z, t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+303], t$95$1, If[LessEqual[t$95$2, 1e+231], N[(N[(N[(N[Max[z, t], $MachinePrecision] * N[Min[z, t], $MachinePrecision]), $MachinePrecision] * -9.0 + N[(N[Max[x, y], $MachinePrecision] * N[Min[x, y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{\mathsf{max}\left(x, y\right)}{a + a}, \mathsf{min}\left(x, y\right), \frac{-\mathsf{min}\left(z, t\right)}{a} \cdot \left(\mathsf{max}\left(z, t\right) \cdot 4.5\right)\right)\\
t_2 := \mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right) - \left(\mathsf{min}\left(z, t\right) \cdot 9\right) \cdot \mathsf{max}\left(z, t\right)\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+303}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 10^{+231}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{max}\left(z, t\right) \cdot \mathsf{min}\left(z, t\right), -9, \mathsf{max}\left(x, y\right) \cdot \mathsf{min}\left(x, y\right)\right)}{a + a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (-.f64 (*.f64 x y) (*.f64 (*.f64 z #s(literal 9 binary64)) t)) < -1e303 or 1.0000000000000001e231 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z #s(literal 9 binary64)) t)) Initial program 91.7%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-flipN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
distribute-neg-fracN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
Applied rewrites87.6%
if -1e303 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z #s(literal 9 binary64)) t)) < 1.0000000000000001e231Initial program 91.7%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval91.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6491.7%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6491.7%
Applied rewrites91.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1
(fma
(- (fmax z t))
(* 4.5 (/ (fmin z t) a))
(* (/ x (+ a a)) y)))
(t_2 (- (* x y) (* (* (fmin z t) 9.0) (fmax z t)))))
(if (<= t_2 -1e+303)
t_1
(if (<= t_2 5e+307)
(/ (fma (* (fmax z t) (fmin z t)) -9.0 (* y x)) (+ a a))
t_1))))double code(double x, double y, double z, double t, double a) {
double t_1 = fma(-fmax(z, t), (4.5 * (fmin(z, t) / a)), ((x / (a + a)) * y));
double t_2 = (x * y) - ((fmin(z, t) * 9.0) * fmax(z, t));
double tmp;
if (t_2 <= -1e+303) {
tmp = t_1;
} else if (t_2 <= 5e+307) {
tmp = fma((fmax(z, t) * fmin(z, t)), -9.0, (y * x)) / (a + a);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(-fmax(z, t)), Float64(4.5 * Float64(fmin(z, t) / a)), Float64(Float64(x / Float64(a + a)) * y)) t_2 = Float64(Float64(x * y) - Float64(Float64(fmin(z, t) * 9.0) * fmax(z, t))) tmp = 0.0 if (t_2 <= -1e+303) tmp = t_1; elseif (t_2 <= 5e+307) tmp = Float64(fma(Float64(fmax(z, t) * fmin(z, t)), -9.0, Float64(y * x)) / Float64(a + a)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[((-N[Max[z, t], $MachinePrecision]) * N[(4.5 * N[(N[Min[z, t], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] + N[(N[(x / N[(a + a), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] - N[(N[(N[Min[z, t], $MachinePrecision] * 9.0), $MachinePrecision] * N[Max[z, t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+303], t$95$1, If[LessEqual[t$95$2, 5e+307], N[(N[(N[(N[Max[z, t], $MachinePrecision] * N[Min[z, t], $MachinePrecision]), $MachinePrecision] * -9.0 + N[(y * x), $MachinePrecision]), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(-\mathsf{max}\left(z, t\right), 4.5 \cdot \frac{\mathsf{min}\left(z, t\right)}{a}, \frac{x}{a + a} \cdot y\right)\\
t_2 := x \cdot y - \left(\mathsf{min}\left(z, t\right) \cdot 9\right) \cdot \mathsf{max}\left(z, t\right)\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+303}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+307}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{max}\left(z, t\right) \cdot \mathsf{min}\left(z, t\right), -9, y \cdot x\right)}{a + a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (-.f64 (*.f64 x y) (*.f64 (*.f64 z #s(literal 9 binary64)) t)) < -1e303 or 5.0000000000000001e307 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z #s(literal 9 binary64)) t)) Initial program 91.7%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
metadata-evalN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites86.9%
if -1e303 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z #s(literal 9 binary64)) t)) < 5.0000000000000001e307Initial program 91.7%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval91.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6491.7%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6491.7%
Applied rewrites91.7%
(FPCore (x y z t a)
:precision binary64
(*
(copysign 1.0 a)
(if (<= (fabs a) 2e-33)
(/
(fma (* -9.0 (fmax z t)) (fmin z t) (* (fmax x y) (fmin x y)))
(* (fabs a) 2.0))
(fma
(/ (- (fmax z t)) (fabs a))
(* (fmin z t) 4.5)
(* (/ (fmin x y) (+ (fabs a) (fabs a))) (fmax x y))))))double code(double x, double y, double z, double t, double a) {
double tmp;
if (fabs(a) <= 2e-33) {
tmp = fma((-9.0 * fmax(z, t)), fmin(z, t), (fmax(x, y) * fmin(x, y))) / (fabs(a) * 2.0);
} else {
tmp = fma((-fmax(z, t) / fabs(a)), (fmin(z, t) * 4.5), ((fmin(x, y) / (fabs(a) + fabs(a))) * fmax(x, y)));
}
return copysign(1.0, a) * tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (abs(a) <= 2e-33) tmp = Float64(fma(Float64(-9.0 * fmax(z, t)), fmin(z, t), Float64(fmax(x, y) * fmin(x, y))) / Float64(abs(a) * 2.0)); else tmp = fma(Float64(Float64(-fmax(z, t)) / abs(a)), Float64(fmin(z, t) * 4.5), Float64(Float64(fmin(x, y) / Float64(abs(a) + abs(a))) * fmax(x, y))); end return Float64(copysign(1.0, a) * tmp) end
code[x_, y_, z_, t_, a_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[a], $MachinePrecision], 2e-33], N[(N[(N[(-9.0 * N[Max[z, t], $MachinePrecision]), $MachinePrecision] * N[Min[z, t], $MachinePrecision] + N[(N[Max[x, y], $MachinePrecision] * N[Min[x, y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Abs[a], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[((-N[Max[z, t], $MachinePrecision]) / N[Abs[a], $MachinePrecision]), $MachinePrecision] * N[(N[Min[z, t], $MachinePrecision] * 4.5), $MachinePrecision] + N[(N[(N[Min[x, y], $MachinePrecision] / N[(N[Abs[a], $MachinePrecision] + N[Abs[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, a\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|a\right| \leq 2 \cdot 10^{-33}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-9 \cdot \mathsf{max}\left(z, t\right), \mathsf{min}\left(z, t\right), \mathsf{max}\left(x, y\right) \cdot \mathsf{min}\left(x, y\right)\right)}{\left|a\right| \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-\mathsf{max}\left(z, t\right)}{\left|a\right|}, \mathsf{min}\left(z, t\right) \cdot 4.5, \frac{\mathsf{min}\left(x, y\right)}{\left|a\right| + \left|a\right|} \cdot \mathsf{max}\left(x, y\right)\right)\\
\end{array}
if a < 2.0000000000000001e-33Initial program 91.7%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval92.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6492.0%
Applied rewrites92.0%
if 2.0000000000000001e-33 < a Initial program 91.7%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-flipN/A
+-commutativeN/A
distribute-neg-fracN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lift-*.f64N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites87.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (fmin x y) (fmax x y))))
(if (<= t_1 (- INFINITY))
(/ 1.0 (/ 1.0 (/ (fmax x y) (/ (+ a a) (fmin x y)))))
(if (<= t_1 1e+245)
(/ (fma (* t z) -9.0 (* (fmax x y) (fmin x y))) (+ a a))
(* 0.5 (* (/ (fmax x y) a) (fmin x y)))))))double code(double x, double y, double z, double t, double a) {
double t_1 = fmin(x, y) * fmax(x, y);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = 1.0 / (1.0 / (fmax(x, y) / ((a + a) / fmin(x, y))));
} else if (t_1 <= 1e+245) {
tmp = fma((t * z), -9.0, (fmax(x, y) * fmin(x, y))) / (a + a);
} else {
tmp = 0.5 * ((fmax(x, y) / a) * fmin(x, y));
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(fmin(x, y) * fmax(x, y)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(1.0 / Float64(1.0 / Float64(fmax(x, y) / Float64(Float64(a + a) / fmin(x, y))))); elseif (t_1 <= 1e+245) tmp = Float64(fma(Float64(t * z), -9.0, Float64(fmax(x, y) * fmin(x, y))) / Float64(a + a)); else tmp = Float64(0.5 * Float64(Float64(fmax(x, y) / a) * fmin(x, y))); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[Min[x, y], $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(1.0 / N[(1.0 / N[(N[Max[x, y], $MachinePrecision] / N[(N[(a + a), $MachinePrecision] / N[Min[x, y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+245], N[(N[(N[(t * z), $MachinePrecision] * -9.0 + N[(N[Max[x, y], $MachinePrecision] * N[Min[x, y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(N[Max[x, y], $MachinePrecision] / a), $MachinePrecision] * N[Min[x, y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\frac{1}{\frac{1}{\frac{\mathsf{max}\left(x, y\right)}{\frac{a + a}{\mathsf{min}\left(x, y\right)}}}}\\
\mathbf{elif}\;t\_1 \leq 10^{+245}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t \cdot z, -9, \mathsf{max}\left(x, y\right) \cdot \mathsf{min}\left(x, y\right)\right)}{a + a}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\frac{\mathsf{max}\left(x, y\right)}{a} \cdot \mathsf{min}\left(x, y\right)\right)\\
\end{array}
if (*.f64 x y) < -inf.0Initial program 91.7%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6491.4%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6491.4%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval91.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6491.4%
Applied rewrites91.4%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6450.5%
Applied rewrites50.5%
lift-*.f64N/A
count-2-revN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
div-add-revN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
div-add-revN/A
lift-+.f64N/A
lower-/.f6450.9%
Applied rewrites50.9%
if -inf.0 < (*.f64 x y) < 1e245Initial program 91.7%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval91.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6491.7%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6491.7%
Applied rewrites91.7%
if 1e245 < (*.f64 x y) Initial program 91.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6450.6%
Applied rewrites50.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.7%
Applied rewrites51.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (fmin x y) (fmax x y)))
(t_2 (* 0.5 (* (/ (fmax x y) a) (fmin x y)))))
(if (<= t_1 (- INFINITY))
t_2
(if (<= t_1 1e+245)
(/ (fma (* t z) -9.0 (* (fmax x y) (fmin x y))) (+ a a))
t_2))))double code(double x, double y, double z, double t, double a) {
double t_1 = fmin(x, y) * fmax(x, y);
double t_2 = 0.5 * ((fmax(x, y) / a) * fmin(x, y));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 <= 1e+245) {
tmp = fma((t * z), -9.0, (fmax(x, y) * fmin(x, y))) / (a + a);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(fmin(x, y) * fmax(x, y)) t_2 = Float64(0.5 * Float64(Float64(fmax(x, y) / a) * fmin(x, y))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_2; elseif (t_1 <= 1e+245) tmp = Float64(fma(Float64(t * z), -9.0, Float64(fmax(x, y) * fmin(x, y))) / Float64(a + a)); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[Min[x, y], $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(0.5 * N[(N[(N[Max[x, y], $MachinePrecision] / a), $MachinePrecision] * N[Min[x, y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$2, If[LessEqual[t$95$1, 1e+245], N[(N[(N[(t * z), $MachinePrecision] * -9.0 + N[(N[Max[x, y], $MachinePrecision] * N[Min[x, y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
t_1 := \mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right)\\
t_2 := 0.5 \cdot \left(\frac{\mathsf{max}\left(x, y\right)}{a} \cdot \mathsf{min}\left(x, y\right)\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{+245}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t \cdot z, -9, \mathsf{max}\left(x, y\right) \cdot \mathsf{min}\left(x, y\right)\right)}{a + a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if (*.f64 x y) < -inf.0 or 1e245 < (*.f64 x y) Initial program 91.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6450.6%
Applied rewrites50.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.7%
Applied rewrites51.7%
if -inf.0 < (*.f64 x y) < 1e245Initial program 91.7%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval91.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6491.7%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6491.7%
Applied rewrites91.7%
(FPCore (x y z t a)
:precision binary64
(*
(copysign 1.0 a)
(if (<= (fabs a) 20000000.0)
(/
(fma (* -9.0 (fmax z t)) (fmin z t) (* (fmax x y) (fmin x y)))
(* (fabs a) 2.0))
(fma
(/ (fmin x y) (+ (fabs a) (fabs a)))
(fmax x y)
(* (/ (* (fmin z t) (fmax z t)) (fabs a)) -4.5)))))double code(double x, double y, double z, double t, double a) {
double tmp;
if (fabs(a) <= 20000000.0) {
tmp = fma((-9.0 * fmax(z, t)), fmin(z, t), (fmax(x, y) * fmin(x, y))) / (fabs(a) * 2.0);
} else {
tmp = fma((fmin(x, y) / (fabs(a) + fabs(a))), fmax(x, y), (((fmin(z, t) * fmax(z, t)) / fabs(a)) * -4.5));
}
return copysign(1.0, a) * tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (abs(a) <= 20000000.0) tmp = Float64(fma(Float64(-9.0 * fmax(z, t)), fmin(z, t), Float64(fmax(x, y) * fmin(x, y))) / Float64(abs(a) * 2.0)); else tmp = fma(Float64(fmin(x, y) / Float64(abs(a) + abs(a))), fmax(x, y), Float64(Float64(Float64(fmin(z, t) * fmax(z, t)) / abs(a)) * -4.5)); end return Float64(copysign(1.0, a) * tmp) end
code[x_, y_, z_, t_, a_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[a], $MachinePrecision], 20000000.0], N[(N[(N[(-9.0 * N[Max[z, t], $MachinePrecision]), $MachinePrecision] * N[Min[z, t], $MachinePrecision] + N[(N[Max[x, y], $MachinePrecision] * N[Min[x, y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Abs[a], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Min[x, y], $MachinePrecision] / N[(N[Abs[a], $MachinePrecision] + N[Abs[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Max[x, y], $MachinePrecision] + N[(N[(N[(N[Min[z, t], $MachinePrecision] * N[Max[z, t], $MachinePrecision]), $MachinePrecision] / N[Abs[a], $MachinePrecision]), $MachinePrecision] * -4.5), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, a\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|a\right| \leq 20000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(-9 \cdot \mathsf{max}\left(z, t\right), \mathsf{min}\left(z, t\right), \mathsf{max}\left(x, y\right) \cdot \mathsf{min}\left(x, y\right)\right)}{\left|a\right| \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{min}\left(x, y\right)}{\left|a\right| + \left|a\right|}, \mathsf{max}\left(x, y\right), \frac{\mathsf{min}\left(z, t\right) \cdot \mathsf{max}\left(z, t\right)}{\left|a\right|} \cdot -4.5\right)\\
\end{array}
if a < 2e7Initial program 91.7%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval92.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6492.0%
Applied rewrites92.0%
if 2e7 < a Initial program 91.7%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-flipN/A
+-commutativeN/A
distribute-neg-fracN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lift-*.f64N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites87.6%
Applied rewrites88.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (fmin x y) (fmax x y)))
(t_2 (* (/ (fmin x y) (+ a a)) (fmax x y))))
(if (<= t_1 -5e+81)
t_2
(if (<= t_1 5e-76) (* -4.5 (/ (* t z) a)) t_2))))double code(double x, double y, double z, double t, double a) {
double t_1 = fmin(x, y) * fmax(x, y);
double t_2 = (fmin(x, y) / (a + a)) * fmax(x, y);
double tmp;
if (t_1 <= -5e+81) {
tmp = t_2;
} else if (t_1 <= 5e-76) {
tmp = -4.5 * ((t * z) / a);
} 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)
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = fmin(x, y) * fmax(x, y)
t_2 = (fmin(x, y) / (a + a)) * fmax(x, y)
if (t_1 <= (-5d+81)) then
tmp = t_2
else if (t_1 <= 5d-76) then
tmp = (-4.5d0) * ((t * z) / a)
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 t_1 = fmin(x, y) * fmax(x, y);
double t_2 = (fmin(x, y) / (a + a)) * fmax(x, y);
double tmp;
if (t_1 <= -5e+81) {
tmp = t_2;
} else if (t_1 <= 5e-76) {
tmp = -4.5 * ((t * z) / a);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = fmin(x, y) * fmax(x, y) t_2 = (fmin(x, y) / (a + a)) * fmax(x, y) tmp = 0 if t_1 <= -5e+81: tmp = t_2 elif t_1 <= 5e-76: tmp = -4.5 * ((t * z) / a) else: tmp = t_2 return tmp
function code(x, y, z, t, a) t_1 = Float64(fmin(x, y) * fmax(x, y)) t_2 = Float64(Float64(fmin(x, y) / Float64(a + a)) * fmax(x, y)) tmp = 0.0 if (t_1 <= -5e+81) tmp = t_2; elseif (t_1 <= 5e-76) tmp = Float64(-4.5 * Float64(Float64(t * z) / a)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = min(x, y) * max(x, y); t_2 = (min(x, y) / (a + a)) * max(x, y); tmp = 0.0; if (t_1 <= -5e+81) tmp = t_2; elseif (t_1 <= 5e-76) tmp = -4.5 * ((t * z) / a); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[Min[x, y], $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Min[x, y], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+81], t$95$2, If[LessEqual[t$95$1, 5e-76], N[(-4.5 * N[(N[(t * z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
t_1 := \mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right)\\
t_2 := \frac{\mathsf{min}\left(x, y\right)}{a + a} \cdot \mathsf{max}\left(x, y\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+81}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-76}:\\
\;\;\;\;-4.5 \cdot \frac{t \cdot z}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if (*.f64 x y) < -4.9999999999999998e81 or 4.9999999999999998e-76 < (*.f64 x y) Initial program 91.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6450.6%
Applied rewrites50.6%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
*-commutativeN/A
count-2N/A
lift-+.f64N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6451.0%
Applied rewrites51.0%
if -4.9999999999999998e81 < (*.f64 x y) < 4.9999999999999998e-76Initial program 91.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6451.6%
Applied rewrites51.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (* (fmin z t) 9.0) (fmax z t))))
(if (<= t_1 -5e-73)
(* -4.5 (* (fmin z t) (/ (fmax z t) a)))
(if (<= t_1 5e-9)
(* (/ (fmin x y) (+ a a)) (fmax x y))
(* -4.5 (* (/ (fmin z t) a) (fmax z t)))))))double code(double x, double y, double z, double t, double a) {
double t_1 = (fmin(z, t) * 9.0) * fmax(z, t);
double tmp;
if (t_1 <= -5e-73) {
tmp = -4.5 * (fmin(z, t) * (fmax(z, t) / a));
} else if (t_1 <= 5e-9) {
tmp = (fmin(x, y) / (a + a)) * fmax(x, y);
} else {
tmp = -4.5 * ((fmin(z, t) / a) * fmax(z, t));
}
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)
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) :: t_1
real(8) :: tmp
t_1 = (fmin(z, t) * 9.0d0) * fmax(z, t)
if (t_1 <= (-5d-73)) then
tmp = (-4.5d0) * (fmin(z, t) * (fmax(z, t) / a))
else if (t_1 <= 5d-9) then
tmp = (fmin(x, y) / (a + a)) * fmax(x, y)
else
tmp = (-4.5d0) * ((fmin(z, t) / a) * fmax(z, t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (fmin(z, t) * 9.0) * fmax(z, t);
double tmp;
if (t_1 <= -5e-73) {
tmp = -4.5 * (fmin(z, t) * (fmax(z, t) / a));
} else if (t_1 <= 5e-9) {
tmp = (fmin(x, y) / (a + a)) * fmax(x, y);
} else {
tmp = -4.5 * ((fmin(z, t) / a) * fmax(z, t));
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (fmin(z, t) * 9.0) * fmax(z, t) tmp = 0 if t_1 <= -5e-73: tmp = -4.5 * (fmin(z, t) * (fmax(z, t) / a)) elif t_1 <= 5e-9: tmp = (fmin(x, y) / (a + a)) * fmax(x, y) else: tmp = -4.5 * ((fmin(z, t) / a) * fmax(z, t)) return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(fmin(z, t) * 9.0) * fmax(z, t)) tmp = 0.0 if (t_1 <= -5e-73) tmp = Float64(-4.5 * Float64(fmin(z, t) * Float64(fmax(z, t) / a))); elseif (t_1 <= 5e-9) tmp = Float64(Float64(fmin(x, y) / Float64(a + a)) * fmax(x, y)); else tmp = Float64(-4.5 * Float64(Float64(fmin(z, t) / a) * fmax(z, t))); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (min(z, t) * 9.0) * max(z, t); tmp = 0.0; if (t_1 <= -5e-73) tmp = -4.5 * (min(z, t) * (max(z, t) / a)); elseif (t_1 <= 5e-9) tmp = (min(x, y) / (a + a)) * max(x, y); else tmp = -4.5 * ((min(z, t) / a) * max(z, t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[Min[z, t], $MachinePrecision] * 9.0), $MachinePrecision] * N[Max[z, t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-73], N[(-4.5 * N[(N[Min[z, t], $MachinePrecision] * N[(N[Max[z, t], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-9], N[(N[(N[Min[x, y], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision], N[(-4.5 * N[(N[(N[Min[z, t], $MachinePrecision] / a), $MachinePrecision] * N[Max[z, t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \left(\mathsf{min}\left(z, t\right) \cdot 9\right) \cdot \mathsf{max}\left(z, t\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-73}:\\
\;\;\;\;-4.5 \cdot \left(\mathsf{min}\left(z, t\right) \cdot \frac{\mathsf{max}\left(z, t\right)}{a}\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{min}\left(x, y\right)}{a + a} \cdot \mathsf{max}\left(x, y\right)\\
\mathbf{else}:\\
\;\;\;\;-4.5 \cdot \left(\frac{\mathsf{min}\left(z, t\right)}{a} \cdot \mathsf{max}\left(z, t\right)\right)\\
\end{array}
if (*.f64 (*.f64 z #s(literal 9 binary64)) t) < -4.9999999999999998e-73Initial program 91.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6451.6%
Applied rewrites51.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6451.9%
Applied rewrites51.9%
if -4.9999999999999998e-73 < (*.f64 (*.f64 z #s(literal 9 binary64)) t) < 5.0000000000000001e-9Initial program 91.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6450.6%
Applied rewrites50.6%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
*-commutativeN/A
count-2N/A
lift-+.f64N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6451.0%
Applied rewrites51.0%
if 5.0000000000000001e-9 < (*.f64 (*.f64 z #s(literal 9 binary64)) t) Initial program 91.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6451.6%
Applied rewrites51.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.3%
Applied rewrites51.3%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (* (fmin z t) 9.0) (fmax z t)))
(t_2 (* -4.5 (* (fmin z t) (/ (fmax z t) a)))))
(if (<= t_1 -5e-73)
t_2
(if (<= t_1 5e+98) (* (/ (fmin x y) (+ a a)) (fmax x y)) t_2))))double code(double x, double y, double z, double t, double a) {
double t_1 = (fmin(z, t) * 9.0) * fmax(z, t);
double t_2 = -4.5 * (fmin(z, t) * (fmax(z, t) / a));
double tmp;
if (t_1 <= -5e-73) {
tmp = t_2;
} else if (t_1 <= 5e+98) {
tmp = (fmin(x, y) / (a + a)) * fmax(x, y);
} 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)
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (fmin(z, t) * 9.0d0) * fmax(z, t)
t_2 = (-4.5d0) * (fmin(z, t) * (fmax(z, t) / a))
if (t_1 <= (-5d-73)) then
tmp = t_2
else if (t_1 <= 5d+98) then
tmp = (fmin(x, y) / (a + a)) * fmax(x, y)
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 t_1 = (fmin(z, t) * 9.0) * fmax(z, t);
double t_2 = -4.5 * (fmin(z, t) * (fmax(z, t) / a));
double tmp;
if (t_1 <= -5e-73) {
tmp = t_2;
} else if (t_1 <= 5e+98) {
tmp = (fmin(x, y) / (a + a)) * fmax(x, y);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (fmin(z, t) * 9.0) * fmax(z, t) t_2 = -4.5 * (fmin(z, t) * (fmax(z, t) / a)) tmp = 0 if t_1 <= -5e-73: tmp = t_2 elif t_1 <= 5e+98: tmp = (fmin(x, y) / (a + a)) * fmax(x, y) else: tmp = t_2 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(fmin(z, t) * 9.0) * fmax(z, t)) t_2 = Float64(-4.5 * Float64(fmin(z, t) * Float64(fmax(z, t) / a))) tmp = 0.0 if (t_1 <= -5e-73) tmp = t_2; elseif (t_1 <= 5e+98) tmp = Float64(Float64(fmin(x, y) / Float64(a + a)) * fmax(x, y)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (min(z, t) * 9.0) * max(z, t); t_2 = -4.5 * (min(z, t) * (max(z, t) / a)); tmp = 0.0; if (t_1 <= -5e-73) tmp = t_2; elseif (t_1 <= 5e+98) tmp = (min(x, y) / (a + a)) * max(x, y); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[Min[z, t], $MachinePrecision] * 9.0), $MachinePrecision] * N[Max[z, t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(-4.5 * N[(N[Min[z, t], $MachinePrecision] * N[(N[Max[z, t], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-73], t$95$2, If[LessEqual[t$95$1, 5e+98], N[(N[(N[Min[x, y], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
t_1 := \left(\mathsf{min}\left(z, t\right) \cdot 9\right) \cdot \mathsf{max}\left(z, t\right)\\
t_2 := -4.5 \cdot \left(\mathsf{min}\left(z, t\right) \cdot \frac{\mathsf{max}\left(z, t\right)}{a}\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-73}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+98}:\\
\;\;\;\;\frac{\mathsf{min}\left(x, y\right)}{a + a} \cdot \mathsf{max}\left(x, y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if (*.f64 (*.f64 z #s(literal 9 binary64)) t) < -4.9999999999999998e-73 or 4.9999999999999998e98 < (*.f64 (*.f64 z #s(literal 9 binary64)) t) Initial program 91.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6451.6%
Applied rewrites51.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6451.9%
Applied rewrites51.9%
if -4.9999999999999998e-73 < (*.f64 (*.f64 z #s(literal 9 binary64)) t) < 4.9999999999999998e98Initial program 91.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6450.6%
Applied rewrites50.6%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
*-commutativeN/A
count-2N/A
lift-+.f64N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6451.0%
Applied rewrites51.0%
(FPCore (x y z t a) :precision binary64 (* (/ (fmin x y) (+ a a)) (fmax x y)))
double code(double x, double y, double z, double t, double a) {
return (fmin(x, y) / (a + a)) * fmax(x, 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)
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
code = (fmin(x, y) / (a + a)) * fmax(x, y)
end function
public static double code(double x, double y, double z, double t, double a) {
return (fmin(x, y) / (a + a)) * fmax(x, y);
}
def code(x, y, z, t, a): return (fmin(x, y) / (a + a)) * fmax(x, y)
function code(x, y, z, t, a) return Float64(Float64(fmin(x, y) / Float64(a + a)) * fmax(x, y)) end
function tmp = code(x, y, z, t, a) tmp = (min(x, y) / (a + a)) * max(x, y); end
code[x_, y_, z_, t_, a_] := N[(N[(N[Min[x, y], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision]
\frac{\mathsf{min}\left(x, y\right)}{a + a} \cdot \mathsf{max}\left(x, y\right)
Initial program 91.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6450.6%
Applied rewrites50.6%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
*-commutativeN/A
count-2N/A
lift-+.f64N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6451.0%
Applied rewrites51.0%
herbie shell --seed 2025212
(FPCore (x y z t a)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, I"
:precision binary64
(/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))