
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / 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)
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 * t)) / a
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
def code(x, y, z, t, a): return ((x * y) - (z * t)) / a
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(z * t)) / a) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - (z * t)) / a; end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - z \cdot t}{a}
\end{array}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / 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)
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 * t)) / a
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - (z * t)) / a;
}
def code(x, y, z, t, a): return ((x * y) - (z * t)) / a
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(z * t)) / a) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - (z * t)) / a; end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - z \cdot t}{a}
\end{array}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ x a) y (* (- z) (/ t a)))) (t_2 (- (* x y) (* z t))))
(if (<= t_2 (- INFINITY))
t_1
(if (<= t_2 5e+234) (/ (fma (- z) t (* y x)) a) t_1))))assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((x / a), y, (-z * (t / a)));
double t_2 = (x * y) - (z * t);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 5e+234) {
tmp = fma(-z, t, (y * x)) / a;
} else {
tmp = t_1;
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) t_1 = fma(Float64(x / a), y, Float64(Float64(-z) * Float64(t / a))) t_2 = Float64(Float64(x * y) - Float64(z * t)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 5e+234) tmp = Float64(fma(Float64(-z), t, Float64(y * x)) / a); else tmp = t_1; end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x / a), $MachinePrecision] * y + N[((-z) * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 5e+234], N[(N[((-z) * t + N[(y * x), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{x}{a}, y, \left(-z\right) \cdot \frac{t}{a}\right)\\
t_2 := x \cdot y - z \cdot t\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+234}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, t, y \cdot x\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -inf.0 or 5.0000000000000003e234 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 91.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
div-addN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
associate-*r/N/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6488.1
Applied rewrites88.1%
if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z t)) < 5.0000000000000003e234Initial program 91.7%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower--.f64N/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6492.0
Applied rewrites92.0%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= a 3.2e+101) (/ (fma (- z) t (* y x)) a) (fma (/ x a) y (* (/ (- z) a) t))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= 3.2e+101) {
tmp = fma(-z, t, (y * x)) / a;
} else {
tmp = fma((x / a), y, ((-z / a) * t));
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (a <= 3.2e+101) tmp = Float64(fma(Float64(-z), t, Float64(y * x)) / a); else tmp = fma(Float64(x / a), y, Float64(Float64(Float64(-z) / a) * t)); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[a, 3.2e+101], N[(N[((-z) * t + N[(y * x), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(x / a), $MachinePrecision] * y + N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3.2 \cdot 10^{+101}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, t, y \cdot x\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{a}, y, \frac{-z}{a} \cdot t\right)\\
\end{array}
\end{array}
if a < 3.20000000000000005e101Initial program 91.7%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower--.f64N/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6492.0
Applied rewrites92.0%
if 3.20000000000000005e101 < a Initial program 91.7%
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6492.1
Applied rewrites92.1%
lift-/.f64N/A
lift-fma.f64N/A
div-addN/A
associate-*l/N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
*-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-outN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites87.3%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (/ (- z) a) t)))
(if (<= (* z t) -1e+295)
t_1
(if (<= (* z t) 2e+272) (/ (- (* x y) (* z t)) a) t_1))))assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double t_1 = (-z / a) * t;
double tmp;
if ((z * t) <= -1e+295) {
tmp = t_1;
} else if ((z * t) <= 2e+272) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = t_1;
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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 = (-z / a) * t
if ((z * t) <= (-1d+295)) then
tmp = t_1
else if ((z * t) <= 2d+272) then
tmp = ((x * y) - (z * t)) / a
else
tmp = t_1
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (-z / a) * t;
double tmp;
if ((z * t) <= -1e+295) {
tmp = t_1;
} else if ((z * t) <= 2e+272) {
tmp = ((x * y) - (z * t)) / a;
} else {
tmp = t_1;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): t_1 = (-z / a) * t tmp = 0 if (z * t) <= -1e+295: tmp = t_1 elif (z * t) <= 2e+272: tmp = ((x * y) - (z * t)) / a else: tmp = t_1 return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(-z) / a) * t) tmp = 0.0 if (Float64(z * t) <= -1e+295) tmp = t_1; elseif (Float64(z * t) <= 2e+272) tmp = Float64(Float64(Float64(x * y) - Float64(z * t)) / a); else tmp = t_1; end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
t_1 = (-z / a) * t;
tmp = 0.0;
if ((z * t) <= -1e+295)
tmp = t_1;
elseif ((z * t) <= 2e+272)
tmp = ((x * y) - (z * t)) / a;
else
tmp = t_1;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -1e+295], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 2e+272], N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := \frac{-z}{a} \cdot t\\
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+295}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+272}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -9.9999999999999998e294 or 2.0000000000000001e272 < (*.f64 z t) Initial program 91.7%
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6492.1
Applied rewrites92.1%
Taylor expanded in x around 0
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-outN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lift-neg.f6451.5
Applied rewrites51.5%
if -9.9999999999999998e294 < (*.f64 z t) < 2.0000000000000001e272Initial program 91.7%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* x y) 2e+211) (/ (fma y x (* (- z) t)) a) (* (/ x a) y)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= 2e+211) {
tmp = fma(y, x, (-z * t)) / a;
} else {
tmp = (x / a) * y;
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= 2e+211) tmp = Float64(fma(y, x, Float64(Float64(-z) * t)) / a); else tmp = Float64(Float64(x / a) * y); end return tmp end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], 2e+211], N[(N[(y * x + N[((-z) * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq 2 \cdot 10^{+211}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, \left(-z\right) \cdot t\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < 1.9999999999999999e211Initial program 91.7%
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6492.1
Applied rewrites92.1%
if 1.9999999999999999e211 < (*.f64 x y) Initial program 91.7%
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6492.1
Applied rewrites92.1%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6478.1
Applied rewrites78.1%
Taylor expanded in x around inf
lift-/.f6451.4
Applied rewrites51.4%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* x y) -5e-201) (/ (* y x) a) (if (<= (* x y) 5e+18) (/ (* (- z) t) a) (* (/ y a) x))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -5e-201) {
tmp = (y * x) / a;
} else if ((x * y) <= 5e+18) {
tmp = (-z * t) / a;
} else {
tmp = (y / a) * x;
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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) :: tmp
if ((x * y) <= (-5d-201)) then
tmp = (y * x) / a
else if ((x * y) <= 5d+18) then
tmp = (-z * t) / a
else
tmp = (y / a) * x
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -5e-201) {
tmp = (y * x) / a;
} else if ((x * y) <= 5e+18) {
tmp = (-z * t) / a;
} else {
tmp = (y / a) * x;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= -5e-201: tmp = (y * x) / a elif (x * y) <= 5e+18: tmp = (-z * t) / a else: tmp = (y / a) * x return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -5e-201) tmp = Float64(Float64(y * x) / a); elseif (Float64(x * y) <= 5e+18) tmp = Float64(Float64(Float64(-z) * t) / a); else tmp = Float64(Float64(y / a) * x); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= -5e-201)
tmp = (y * x) / a;
elseif ((x * y) <= 5e+18)
tmp = (-z * t) / a;
else
tmp = (y / a) * x;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], -5e-201], N[(N[(y * x), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 5e+18], N[(N[((-z) * t), $MachinePrecision] / a), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{-201}:\\
\;\;\;\;\frac{y \cdot x}{a}\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{+18}:\\
\;\;\;\;\frac{\left(-z\right) \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\end{array}
\end{array}
if (*.f64 x y) < -4.9999999999999999e-201Initial program 91.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6450.8
Applied rewrites50.8%
if -4.9999999999999999e-201 < (*.f64 x y) < 5e18Initial program 91.7%
Taylor expanded in x around 0
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6451.4
Applied rewrites51.4%
if 5e18 < (*.f64 x y) Initial program 91.7%
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6492.1
Applied rewrites92.1%
lift-/.f64N/A
lift-fma.f64N/A
div-addN/A
frac-2negN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
*-commutativeN/A
associate-*r/N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-outN/A
mul-1-negN/A
Applied rewrites88.6%
Taylor expanded in x around inf
Applied rewrites78.8%
Taylor expanded in x around inf
lift-/.f6451.3
Applied rewrites51.3%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* x y) -1e-12) (/ (* y x) a) (if (<= (* x y) 5e+18) (* (/ (- z) a) t) (* (/ y a) x))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e-12) {
tmp = (y * x) / a;
} else if ((x * y) <= 5e+18) {
tmp = (-z / a) * t;
} else {
tmp = (y / a) * x;
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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) :: tmp
if ((x * y) <= (-1d-12)) then
tmp = (y * x) / a
else if ((x * y) <= 5d+18) then
tmp = (-z / a) * t
else
tmp = (y / a) * x
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -1e-12) {
tmp = (y * x) / a;
} else if ((x * y) <= 5e+18) {
tmp = (-z / a) * t;
} else {
tmp = (y / a) * x;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= -1e-12: tmp = (y * x) / a elif (x * y) <= 5e+18: tmp = (-z / a) * t else: tmp = (y / a) * x return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -1e-12) tmp = Float64(Float64(y * x) / a); elseif (Float64(x * y) <= 5e+18) tmp = Float64(Float64(Float64(-z) / a) * t); else tmp = Float64(Float64(y / a) * x); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= -1e-12)
tmp = (y * x) / a;
elseif ((x * y) <= 5e+18)
tmp = (-z / a) * t;
else
tmp = (y / a) * x;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], -1e-12], N[(N[(y * x), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 5e+18], N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{-12}:\\
\;\;\;\;\frac{y \cdot x}{a}\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{+18}:\\
\;\;\;\;\frac{-z}{a} \cdot t\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\end{array}
\end{array}
if (*.f64 x y) < -9.9999999999999998e-13Initial program 91.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6450.8
Applied rewrites50.8%
if -9.9999999999999998e-13 < (*.f64 x y) < 5e18Initial program 91.7%
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6492.1
Applied rewrites92.1%
Taylor expanded in x around 0
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-outN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lift-neg.f6451.5
Applied rewrites51.5%
if 5e18 < (*.f64 x y) Initial program 91.7%
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6492.1
Applied rewrites92.1%
lift-/.f64N/A
lift-fma.f64N/A
div-addN/A
frac-2negN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
*-commutativeN/A
associate-*r/N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-outN/A
mul-1-negN/A
Applied rewrites88.6%
Taylor expanded in x around inf
Applied rewrites78.8%
Taylor expanded in x around inf
lift-/.f6451.3
Applied rewrites51.3%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (/ (- (* x y) (* z t)) a) 1e+219) (/ (* y x) a) (* (/ y a) x)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((((x * y) - (z * t)) / a) <= 1e+219) {
tmp = (y * x) / a;
} else {
tmp = (y / a) * x;
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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) :: tmp
if ((((x * y) - (z * t)) / a) <= 1d+219) then
tmp = (y * x) / a
else
tmp = (y / a) * x
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((((x * y) - (z * t)) / a) <= 1e+219) {
tmp = (y * x) / a;
} else {
tmp = (y / a) * x;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (((x * y) - (z * t)) / a) <= 1e+219: tmp = (y * x) / a else: tmp = (y / a) * x return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(Float64(Float64(x * y) - Float64(z * t)) / a) <= 1e+219) tmp = Float64(Float64(y * x) / a); else tmp = Float64(Float64(y / a) * x); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((((x * y) - (z * t)) / a) <= 1e+219)
tmp = (y * x) / a;
else
tmp = (y / a) * x;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], 1e+219], N[(N[(y * x), $MachinePrecision] / a), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot y - z \cdot t}{a} \leq 10^{+219}:\\
\;\;\;\;\frac{y \cdot x}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 x y) (*.f64 z t)) a) < 9.99999999999999965e218Initial program 91.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6450.8
Applied rewrites50.8%
if 9.99999999999999965e218 < (/.f64 (-.f64 (*.f64 x y) (*.f64 z t)) a) Initial program 91.7%
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6492.1
Applied rewrites92.1%
lift-/.f64N/A
lift-fma.f64N/A
div-addN/A
frac-2negN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
*-commutativeN/A
associate-*r/N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-outN/A
mul-1-negN/A
Applied rewrites88.6%
Taylor expanded in x around inf
Applied rewrites78.8%
Taylor expanded in x around inf
lift-/.f6451.3
Applied rewrites51.3%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (- (* x y) (* z t)) -2e+57) (* (/ x a) y) (* (/ y a) x)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) - (z * t)) <= -2e+57) {
tmp = (x / a) * y;
} else {
tmp = (y / a) * x;
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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) :: tmp
if (((x * y) - (z * t)) <= (-2d+57)) then
tmp = (x / a) * y
else
tmp = (y / a) * x
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) - (z * t)) <= -2e+57) {
tmp = (x / a) * y;
} else {
tmp = (y / a) * x;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if ((x * y) - (z * t)) <= -2e+57: tmp = (x / a) * y else: tmp = (y / a) * x return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(Float64(x * y) - Float64(z * t)) <= -2e+57) tmp = Float64(Float64(x / a) * y); else tmp = Float64(Float64(y / a) * x); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if (((x * y) - (z * t)) <= -2e+57)
tmp = (x / a) * y;
else
tmp = (y / a) * x;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision], -2e+57], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \leq -2 \cdot 10^{+57}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -2.0000000000000001e57Initial program 91.7%
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6492.1
Applied rewrites92.1%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6478.1
Applied rewrites78.1%
Taylor expanded in x around inf
lift-/.f6451.4
Applied rewrites51.4%
if -2.0000000000000001e57 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 91.7%
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6492.1
Applied rewrites92.1%
lift-/.f64N/A
lift-fma.f64N/A
div-addN/A
frac-2negN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
*-commutativeN/A
associate-*r/N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-outN/A
mul-1-negN/A
Applied rewrites88.6%
Taylor expanded in x around inf
Applied rewrites78.8%
Taylor expanded in x around inf
lift-/.f6451.3
Applied rewrites51.3%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (* (/ x a) y))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
return (x / a) * y;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
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 / a) * y
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
return (x / a) * y;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): return (x / a) * y
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(Float64(x / a) * y) end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
tmp = (x / a) * y;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\frac{x}{a} \cdot y
\end{array}
Initial program 91.7%
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6492.1
Applied rewrites92.1%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6478.1
Applied rewrites78.1%
Taylor expanded in x around inf
lift-/.f6451.4
Applied rewrites51.4%
herbie shell --seed 2025123
(FPCore (x y z t a)
:name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
:precision binary64
(/ (- (* x y) (* z t)) a))