
(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 10 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 (* (- z) (/ t a))) (t_2 (- (* x y) (* z t))))
(if (<= t_2 -5e+301)
(fma (/ y a) x t_1)
(if (<= t_2 5e+196) (/ (fma (- z) t (* y x)) a) (fma (/ x a) y 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 * (t / a);
double t_2 = (x * y) - (z * t);
double tmp;
if (t_2 <= -5e+301) {
tmp = fma((y / a), x, t_1);
} else if (t_2 <= 5e+196) {
tmp = fma(-z, t, (y * x)) / a;
} else {
tmp = fma((x / a), y, 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(-z) * Float64(t / a)) t_2 = Float64(Float64(x * y) - Float64(z * t)) tmp = 0.0 if (t_2 <= -5e+301) tmp = fma(Float64(y / a), x, t_1); elseif (t_2 <= 5e+196) tmp = Float64(fma(Float64(-z), t, Float64(y * x)) / a); else tmp = fma(Float64(x / a), y, 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[((-z) * N[(t / a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+301], N[(N[(y / a), $MachinePrecision] * x + t$95$1), $MachinePrecision], If[LessEqual[t$95$2, 5e+196], N[(N[((-z) * t + N[(y * x), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(x / a), $MachinePrecision] * y + t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := \left(-z\right) \cdot \frac{t}{a}\\
t_2 := x \cdot y - z \cdot t\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+301}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, x, t\_1\right)\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+196}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, t, y \cdot x\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{a}, y, t\_1\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -5.0000000000000004e301Initial program 91.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
div-addN/A
*-commutativeN/A
associate-*l/N/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
associate-*r/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-/.f6487.7
Applied rewrites87.7%
if -5.0000000000000004e301 < (-.f64 (*.f64 x y) (*.f64 z t)) < 4.9999999999999998e196Initial program 91.4%
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-*.f6491.6
Applied rewrites91.6%
if 4.9999999999999998e196 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 91.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
div-addN/A
associate-*l/N/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
associate-*r/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.7
Applied rewrites88.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
(let* ((t_1 (- (* x y) (* z t))) (t_2 (fma (/ x a) y (* (- z) (/ t a)))))
(if (<= t_1 -5e+301)
t_2
(if (<= t_1 5e+196) (/ (fma (- z) t (* y x)) a) t_2))))assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double t_1 = (x * y) - (z * t);
double t_2 = fma((x / a), y, (-z * (t / a)));
double tmp;
if (t_1 <= -5e+301) {
tmp = t_2;
} else if (t_1 <= 5e+196) {
tmp = fma(-z, t, (y * x)) / a;
} else {
tmp = t_2;
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) t_1 = Float64(Float64(x * y) - Float64(z * t)) t_2 = fma(Float64(x / a), y, Float64(Float64(-z) * Float64(t / a))) tmp = 0.0 if (t_1 <= -5e+301) tmp = t_2; elseif (t_1 <= 5e+196) tmp = Float64(fma(Float64(-z), t, Float64(y * x)) / a); else tmp = t_2; 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 * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x / a), $MachinePrecision] * y + N[((-z) * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+301], t$95$2, If[LessEqual[t$95$1, 5e+196], N[(N[((-z) * t + N[(y * x), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
t_2 := \mathsf{fma}\left(\frac{x}{a}, y, \left(-z\right) \cdot \frac{t}{a}\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+301}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+196}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, t, y \cdot x\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -5.0000000000000004e301 or 4.9999999999999998e196 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 91.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
fp-cancel-sub-sign-invN/A
div-addN/A
associate-*l/N/A
distribute-lft-neg-outN/A
*-commutativeN/A
mul-1-negN/A
associate-*r/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.7
Applied rewrites88.7%
if -5.0000000000000004e301 < (-.f64 (*.f64 x y) (*.f64 z t)) < 4.9999999999999998e196Initial program 91.4%
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-*.f6491.6
Applied rewrites91.6%
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 (- (* x y) (* z t))) (t_2 (* (/ (fma x (/ y z) (- t)) a) z)))
(if (<= t_1 -5e+287)
t_2
(if (<= t_1 4e+289) (/ (fma (- z) t (* y x)) a) t_2))))assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double t_1 = (x * y) - (z * t);
double t_2 = (fma(x, (y / z), -t) / a) * z;
double tmp;
if (t_1 <= -5e+287) {
tmp = t_2;
} else if (t_1 <= 4e+289) {
tmp = fma(-z, t, (y * x)) / a;
} else {
tmp = t_2;
}
return tmp;
}
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) t_1 = Float64(Float64(x * y) - Float64(z * t)) t_2 = Float64(Float64(fma(x, Float64(y / z), Float64(-t)) / a) * z) tmp = 0.0 if (t_1 <= -5e+287) tmp = t_2; elseif (t_1 <= 4e+289) tmp = Float64(fma(Float64(-z), t, Float64(y * x)) / a); else tmp = t_2; 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 * y), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(x * N[(y / z), $MachinePrecision] + (-t)), $MachinePrecision] / a), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+287], t$95$2, If[LessEqual[t$95$1, 4e+289], N[(N[((-z) * t + N[(y * x), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
t_2 := \frac{\mathsf{fma}\left(x, \frac{y}{z}, -t\right)}{a} \cdot z\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+287}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+289}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, t, y \cdot x\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z t)) < -5e287 or 4.0000000000000002e289 < (-.f64 (*.f64 x y) (*.f64 z t)) Initial program 91.4%
Taylor expanded in z around inf
Applied rewrites78.2%
Taylor expanded in a around 0
lower-/.f64N/A
mul-1-negN/A
lift-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6482.2
Applied rewrites82.2%
if -5e287 < (-.f64 (*.f64 x y) (*.f64 z t)) < 4.0000000000000002e289Initial program 91.4%
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-*.f6491.6
Applied rewrites91.6%
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 (* (/ y a) x)))
(if (<= (* x y) -5e+301)
t_1
(if (<= (* x y) 1e+264) (/ (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 = (y / a) * x;
double tmp;
if ((x * y) <= -5e+301) {
tmp = t_1;
} else if ((x * y) <= 1e+264) {
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 = Float64(Float64(y / a) * x) tmp = 0.0 if (Float64(x * y) <= -5e+301) tmp = t_1; elseif (Float64(x * y) <= 1e+264) 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[(y / a), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -5e+301], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 1e+264], 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 := \frac{y}{a} \cdot x\\
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+301}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot y \leq 10^{+264}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, t, y \cdot x\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 x y) < -5.0000000000000004e301 or 1.00000000000000004e264 < (*.f64 x y) Initial program 91.4%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.8
Applied rewrites50.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6450.9
Applied rewrites50.9%
if -5.0000000000000004e301 < (*.f64 x y) < 1.00000000000000004e264Initial program 91.4%
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-*.f6491.6
Applied rewrites91.6%
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 (* (/ y a) x)))
(if (<= (* x y) -5e+301)
t_1
(if (<= (* x y) 1e+264) (/ (- (* 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 = (y / a) * x;
double tmp;
if ((x * y) <= -5e+301) {
tmp = t_1;
} else if ((x * y) <= 1e+264) {
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 = (y / a) * x
if ((x * y) <= (-5d+301)) then
tmp = t_1
else if ((x * y) <= 1d+264) 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 = (y / a) * x;
double tmp;
if ((x * y) <= -5e+301) {
tmp = t_1;
} else if ((x * y) <= 1e+264) {
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 = (y / a) * x tmp = 0 if (x * y) <= -5e+301: tmp = t_1 elif (x * y) <= 1e+264: 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(y / a) * x) tmp = 0.0 if (Float64(x * y) <= -5e+301) tmp = t_1; elseif (Float64(x * y) <= 1e+264) 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 = (y / a) * x;
tmp = 0.0;
if ((x * y) <= -5e+301)
tmp = t_1;
elseif ((x * y) <= 1e+264)
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[(y / a), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -5e+301], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 1e+264], 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{y}{a} \cdot x\\
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+301}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot y \leq 10^{+264}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 x y) < -5.0000000000000004e301 or 1.00000000000000004e264 < (*.f64 x y) Initial program 91.4%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.8
Applied rewrites50.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6450.9
Applied rewrites50.9%
if -5.0000000000000004e301 < (*.f64 x y) < 1.00000000000000004e264Initial program 91.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) -1e+23) (* (/ x a) y) (if (<= (* x y) 5e+47) (/ (* (- 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) <= -1e+23) {
tmp = (x / a) * y;
} else if ((x * y) <= 5e+47) {
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) <= (-1d+23)) then
tmp = (x / a) * y
else if ((x * y) <= 5d+47) 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) <= -1e+23) {
tmp = (x / a) * y;
} else if ((x * y) <= 5e+47) {
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) <= -1e+23: tmp = (x / a) * y elif (x * y) <= 5e+47: 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) <= -1e+23) tmp = Float64(Float64(x / a) * y); elseif (Float64(x * y) <= 5e+47) 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) <= -1e+23)
tmp = (x / a) * y;
elseif ((x * y) <= 5e+47)
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], -1e+23], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 5e+47], 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 -1 \cdot 10^{+23}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{+47}:\\
\;\;\;\;\frac{\left(-z\right) \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\end{array}
\end{array}
if (*.f64 x y) < -9.9999999999999992e22Initial program 91.4%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.8
Applied rewrites50.8%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.7
Applied rewrites51.7%
if -9.9999999999999992e22 < (*.f64 x y) < 5.00000000000000022e47Initial program 91.4%
Taylor expanded in x around 0
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6450.2
Applied rewrites50.2%
if 5.00000000000000022e47 < (*.f64 x y) Initial program 91.4%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.8
Applied rewrites50.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6450.9
Applied rewrites50.9%
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 (<= (* z t) -2e-32) (* (/ (- z) a) t) (if (<= (* z t) 5e-13) (* (/ x a) y) (* (- z) (/ t a)))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z * t) <= -2e-32) {
tmp = (-z / a) * t;
} else if ((z * t) <= 5e-13) {
tmp = (x / a) * y;
} else {
tmp = -z * (t / a);
}
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 ((z * t) <= (-2d-32)) then
tmp = (-z / a) * t
else if ((z * t) <= 5d-13) then
tmp = (x / a) * y
else
tmp = -z * (t / a)
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 ((z * t) <= -2e-32) {
tmp = (-z / a) * t;
} else if ((z * t) <= 5e-13) {
tmp = (x / a) * y;
} else {
tmp = -z * (t / a);
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (z * t) <= -2e-32: tmp = (-z / a) * t elif (z * t) <= 5e-13: tmp = (x / a) * y else: tmp = -z * (t / a) 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(z * t) <= -2e-32) tmp = Float64(Float64(Float64(-z) / a) * t); elseif (Float64(z * t) <= 5e-13) tmp = Float64(Float64(x / a) * y); else tmp = Float64(Float64(-z) * Float64(t / a)); 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 ((z * t) <= -2e-32)
tmp = (-z / a) * t;
elseif ((z * t) <= 5e-13)
tmp = (x / a) * y;
else
tmp = -z * (t / a);
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[(z * t), $MachinePrecision], -2e-32], N[(N[((-z) / a), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e-13], N[(N[(x / a), $MachinePrecision] * y), $MachinePrecision], N[((-z) * N[(t / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{-32}:\\
\;\;\;\;\frac{-z}{a} \cdot t\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) \cdot \frac{t}{a}\\
\end{array}
\end{array}
if (*.f64 z t) < -2.00000000000000011e-32Initial program 91.4%
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-*.f6491.6
Applied rewrites91.6%
Taylor expanded in x around 0
*-commutativeN/A
associate-*l/N/A
associate-*l*N/A
lower-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lift-neg.f6451.4
Applied rewrites51.4%
if -2.00000000000000011e-32 < (*.f64 z t) < 4.9999999999999999e-13Initial program 91.4%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.8
Applied rewrites50.8%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.7
Applied rewrites51.7%
if 4.9999999999999999e-13 < (*.f64 z t) Initial program 91.4%
Taylor expanded in x around 0
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-/.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 (let* ((t_1 (* (/ (- z) a) t))) (if (<= (* z t) -2e-32) t_1 (if (<= (* z t) 5e-58) (* (/ x a) y) 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) <= -2e-32) {
tmp = t_1;
} else if ((z * t) <= 5e-58) {
tmp = (x / a) * y;
} 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) <= (-2d-32)) then
tmp = t_1
else if ((z * t) <= 5d-58) then
tmp = (x / a) * y
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) <= -2e-32) {
tmp = t_1;
} else if ((z * t) <= 5e-58) {
tmp = (x / a) * y;
} 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) <= -2e-32: tmp = t_1 elif (z * t) <= 5e-58: tmp = (x / a) * y 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) <= -2e-32) tmp = t_1; elseif (Float64(z * t) <= 5e-58) tmp = Float64(Float64(x / a) * y); 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) <= -2e-32)
tmp = t_1;
elseif ((z * t) <= 5e-58)
tmp = (x / a) * y;
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], -2e-32], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 5e-58], N[(N[(x / a), $MachinePrecision] * y), $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 -2 \cdot 10^{-32}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{-58}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -2.00000000000000011e-32 or 4.99999999999999977e-58 < (*.f64 z t) Initial program 91.4%
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-*.f6491.6
Applied rewrites91.6%
Taylor expanded in x around 0
*-commutativeN/A
associate-*l/N/A
associate-*l*N/A
lower-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lift-neg.f6451.4
Applied rewrites51.4%
if -2.00000000000000011e-32 < (*.f64 z t) < 4.99999999999999977e-58Initial program 91.4%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.8
Applied rewrites50.8%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.7
Applied rewrites51.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 -2e+129) (* (/ 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 <= -2e+129) {
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 <= (-2d+129)) 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 <= -2e+129) {
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 <= -2e+129: 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 (x <= -2e+129) 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 <= -2e+129)
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[x, -2e+129], 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 \leq -2 \cdot 10^{+129}:\\
\;\;\;\;\frac{x}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot x\\
\end{array}
\end{array}
if x < -2e129Initial program 91.4%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.8
Applied rewrites50.8%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.7
Applied rewrites51.7%
if -2e129 < x Initial program 91.4%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.8
Applied rewrites50.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6450.9
Applied rewrites50.9%
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.4%
Taylor expanded in x around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.8
Applied rewrites50.8%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.7
Applied rewrites51.7%
herbie shell --seed 2025142
(FPCore (x y z t a)
:name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
:precision binary64
(/ (- (* x y) (* z t)) a))