
(FPCore (x y z t a b c) :precision binary64 (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))
double code(double x, double y, double z, double t, double a, double b, double c) {
return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = ((((x * 9.0d0) * y) - (((z * 4.0d0) * t) * a)) + b) / (z * c)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
}
def code(x, y, z, t, a, b, c): return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c)
function code(x, y, z, t, a, b, c) return Float64(Float64(Float64(Float64(Float64(x * 9.0) * y) - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c)) end
function tmp = code(x, y, z, t, a, b, c) tmp = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c); end
code[x_, y_, z_, t_, a_, b_, c_] := N[(N[(N[(N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision] - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c) :precision binary64 (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))
double code(double x, double y, double z, double t, double a, double b, double c) {
return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = ((((x * 9.0d0) * y) - (((z * 4.0d0) * t) * a)) + b) / (z * c)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
}
def code(x, y, z, t, a, b, c): return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c)
function code(x, y, z, t, a, b, c) return Float64(Float64(Float64(Float64(Float64(x * 9.0) * y) - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c)) end
function tmp = code(x, y, z, t, a, b, c) tmp = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c); end
code[x_, y_, z_, t_, a_, b_, c_] := N[(N[(N[(N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision] - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\end{array}
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c)
:precision binary64
(if (<= z -4.5e-34)
(/ (fma (* a t) -4.0 (/ (fma (* y x) 9.0 b) z)) c)
(if (<= z 68000000000.0)
(/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))
(/ (fma (* a t) -4.0 (* (fma (/ y z) 9.0 (/ b (* z x))) x)) c))))assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (z <= -4.5e-34) {
tmp = fma((a * t), -4.0, (fma((y * x), 9.0, b) / z)) / c;
} else if (z <= 68000000000.0) {
tmp = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
} else {
tmp = fma((a * t), -4.0, (fma((y / z), 9.0, (b / (z * x))) * x)) / c;
}
return tmp;
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) tmp = 0.0 if (z <= -4.5e-34) tmp = Float64(fma(Float64(a * t), -4.0, Float64(fma(Float64(y * x), 9.0, b) / z)) / c); elseif (z <= 68000000000.0) tmp = Float64(Float64(Float64(Float64(Float64(x * 9.0) * y) - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c)); else tmp = Float64(fma(Float64(a * t), -4.0, Float64(fma(Float64(y / z), 9.0, Float64(b / Float64(z * x))) * x)) / c); end return tmp end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[z, -4.5e-34], N[(N[(N[(a * t), $MachinePrecision] * -4.0 + N[(N[(N[(y * x), $MachinePrecision] * 9.0 + b), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[z, 68000000000.0], N[(N[(N[(N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision] - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * t), $MachinePrecision] * -4.0 + N[(N[(N[(y / z), $MachinePrecision] * 9.0 + N[(b / N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{-34}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a \cdot t, -4, \frac{\mathsf{fma}\left(y \cdot x, 9, b\right)}{z}\right)}{c}\\
\mathbf{elif}\;z \leq 68000000000:\\
\;\;\;\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a \cdot t, -4, \mathsf{fma}\left(\frac{y}{z}, 9, \frac{b}{z \cdot x}\right) \cdot x\right)}{c}\\
\end{array}
\end{array}
if z < -4.50000000000000042e-34Initial program 71.7%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites84.3%
Taylor expanded in c around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6493.8
Applied rewrites93.8%
if -4.50000000000000042e-34 < z < 6.8e10Initial program 96.0%
if 6.8e10 < z Initial program 53.6%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites76.3%
Taylor expanded in c around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6487.3
Applied rewrites87.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6490.0
Applied rewrites90.0%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (* (* x 9.0) y)))
(if (<= t_1 -1e+120)
(/ (* (* 9.0 x) y) (* z c))
(if (<= t_1 -2e-53)
(/ (* (* a t) -4.0) c)
(if (<= t_1 5e+15) (/ (/ b c) z) (/ (* (* y x) 9.0) (* z c)))))))assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = (x * 9.0) * y;
double tmp;
if (t_1 <= -1e+120) {
tmp = ((9.0 * x) * y) / (z * c);
} else if (t_1 <= -2e-53) {
tmp = ((a * t) * -4.0) / c;
} else if (t_1 <= 5e+15) {
tmp = (b / c) / z;
} else {
tmp = ((y * x) * 9.0) / (z * c);
}
return tmp;
}
NOTE: x, y, z, t, a, b, and c 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, b, c)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_1
real(8) :: tmp
t_1 = (x * 9.0d0) * y
if (t_1 <= (-1d+120)) then
tmp = ((9.0d0 * x) * y) / (z * c)
else if (t_1 <= (-2d-53)) then
tmp = ((a * t) * (-4.0d0)) / c
else if (t_1 <= 5d+15) then
tmp = (b / c) / z
else
tmp = ((y * x) * 9.0d0) / (z * c)
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c;
public static double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = (x * 9.0) * y;
double tmp;
if (t_1 <= -1e+120) {
tmp = ((9.0 * x) * y) / (z * c);
} else if (t_1 <= -2e-53) {
tmp = ((a * t) * -4.0) / c;
} else if (t_1 <= 5e+15) {
tmp = (b / c) / z;
} else {
tmp = ((y * x) * 9.0) / (z * c);
}
return tmp;
}
[x, y, z, t, a, b, c] = sort([x, y, z, t, a, b, c]) def code(x, y, z, t, a, b, c): t_1 = (x * 9.0) * y tmp = 0 if t_1 <= -1e+120: tmp = ((9.0 * x) * y) / (z * c) elif t_1 <= -2e-53: tmp = ((a * t) * -4.0) / c elif t_1 <= 5e+15: tmp = (b / c) / z else: tmp = ((y * x) * 9.0) / (z * c) return tmp
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) t_1 = Float64(Float64(x * 9.0) * y) tmp = 0.0 if (t_1 <= -1e+120) tmp = Float64(Float64(Float64(9.0 * x) * y) / Float64(z * c)); elseif (t_1 <= -2e-53) tmp = Float64(Float64(Float64(a * t) * -4.0) / c); elseif (t_1 <= 5e+15) tmp = Float64(Float64(b / c) / z); else tmp = Float64(Float64(Float64(y * x) * 9.0) / Float64(z * c)); end return tmp end
x, y, z, t, a, b, c = num2cell(sort([x, y, z, t, a, b, c])){:}
function tmp_2 = code(x, y, z, t, a, b, c)
t_1 = (x * 9.0) * y;
tmp = 0.0;
if (t_1 <= -1e+120)
tmp = ((9.0 * x) * y) / (z * c);
elseif (t_1 <= -2e-53)
tmp = ((a * t) * -4.0) / c;
elseif (t_1 <= 5e+15)
tmp = (b / c) / z;
else
tmp = ((y * x) * 9.0) / (z * c);
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+120], N[(N[(N[(9.0 * x), $MachinePrecision] * y), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -2e-53], N[(N[(N[(a * t), $MachinePrecision] * -4.0), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[t$95$1, 5e+15], N[(N[(b / c), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(y * x), $MachinePrecision] * 9.0), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
t_1 := \left(x \cdot 9\right) \cdot y\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+120}:\\
\;\;\;\;\frac{\left(9 \cdot x\right) \cdot y}{z \cdot c}\\
\mathbf{elif}\;t\_1 \leq -2 \cdot 10^{-53}:\\
\;\;\;\;\frac{\left(a \cdot t\right) \cdot -4}{c}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+15}:\\
\;\;\;\;\frac{\frac{b}{c}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(y \cdot x\right) \cdot 9}{z \cdot c}\\
\end{array}
\end{array}
if (*.f64 (*.f64 x #s(literal 9 binary64)) y) < -9.9999999999999998e119Initial program 85.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6471.4
Applied rewrites71.4%
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6471.4
Applied rewrites71.4%
if -9.9999999999999998e119 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < -2.00000000000000006e-53Initial program 59.6%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites91.5%
Taylor expanded in c around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6491.5
Applied rewrites91.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6451.5
Applied rewrites51.5%
if -2.00000000000000006e-53 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < 5e15Initial program 85.3%
Taylor expanded in x around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6479.6
Applied rewrites79.6%
Taylor expanded in z around 0
Applied rewrites54.6%
if 5e15 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) Initial program 77.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6464.4
Applied rewrites64.4%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (* (* x 9.0) y)) (t_2 (/ (* (* 9.0 x) y) (* z c))))
(if (<= t_1 -1e+120)
t_2
(if (<= t_1 -2e-53)
(/ (* (* a t) -4.0) c)
(if (<= t_1 5e+15) (/ (/ b c) z) t_2)))))assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = (x * 9.0) * y;
double t_2 = ((9.0 * x) * y) / (z * c);
double tmp;
if (t_1 <= -1e+120) {
tmp = t_2;
} else if (t_1 <= -2e-53) {
tmp = ((a * t) * -4.0) / c;
} else if (t_1 <= 5e+15) {
tmp = (b / c) / z;
} else {
tmp = t_2;
}
return tmp;
}
NOTE: x, y, z, t, a, b, and c 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, b, c)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (x * 9.0d0) * y
t_2 = ((9.0d0 * x) * y) / (z * c)
if (t_1 <= (-1d+120)) then
tmp = t_2
else if (t_1 <= (-2d-53)) then
tmp = ((a * t) * (-4.0d0)) / c
else if (t_1 <= 5d+15) then
tmp = (b / c) / z
else
tmp = t_2
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c;
public static double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = (x * 9.0) * y;
double t_2 = ((9.0 * x) * y) / (z * c);
double tmp;
if (t_1 <= -1e+120) {
tmp = t_2;
} else if (t_1 <= -2e-53) {
tmp = ((a * t) * -4.0) / c;
} else if (t_1 <= 5e+15) {
tmp = (b / c) / z;
} else {
tmp = t_2;
}
return tmp;
}
[x, y, z, t, a, b, c] = sort([x, y, z, t, a, b, c]) def code(x, y, z, t, a, b, c): t_1 = (x * 9.0) * y t_2 = ((9.0 * x) * y) / (z * c) tmp = 0 if t_1 <= -1e+120: tmp = t_2 elif t_1 <= -2e-53: tmp = ((a * t) * -4.0) / c elif t_1 <= 5e+15: tmp = (b / c) / z else: tmp = t_2 return tmp
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) t_1 = Float64(Float64(x * 9.0) * y) t_2 = Float64(Float64(Float64(9.0 * x) * y) / Float64(z * c)) tmp = 0.0 if (t_1 <= -1e+120) tmp = t_2; elseif (t_1 <= -2e-53) tmp = Float64(Float64(Float64(a * t) * -4.0) / c); elseif (t_1 <= 5e+15) tmp = Float64(Float64(b / c) / z); else tmp = t_2; end return tmp end
x, y, z, t, a, b, c = num2cell(sort([x, y, z, t, a, b, c])){:}
function tmp_2 = code(x, y, z, t, a, b, c)
t_1 = (x * 9.0) * y;
t_2 = ((9.0 * x) * y) / (z * c);
tmp = 0.0;
if (t_1 <= -1e+120)
tmp = t_2;
elseif (t_1 <= -2e-53)
tmp = ((a * t) * -4.0) / c;
elseif (t_1 <= 5e+15)
tmp = (b / c) / z;
else
tmp = t_2;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(9.0 * x), $MachinePrecision] * y), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+120], t$95$2, If[LessEqual[t$95$1, -2e-53], N[(N[(N[(a * t), $MachinePrecision] * -4.0), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[t$95$1, 5e+15], N[(N[(b / c), $MachinePrecision] / z), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
t_1 := \left(x \cdot 9\right) \cdot y\\
t_2 := \frac{\left(9 \cdot x\right) \cdot y}{z \cdot c}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+120}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq -2 \cdot 10^{-53}:\\
\;\;\;\;\frac{\left(a \cdot t\right) \cdot -4}{c}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+15}:\\
\;\;\;\;\frac{\frac{b}{c}}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (*.f64 x #s(literal 9 binary64)) y) < -9.9999999999999998e119 or 5e15 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) Initial program 80.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6467.1
Applied rewrites67.1%
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6467.1
Applied rewrites67.1%
if -9.9999999999999998e119 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < -2.00000000000000006e-53Initial program 59.6%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites91.5%
Taylor expanded in c around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6491.5
Applied rewrites91.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6451.5
Applied rewrites51.5%
if -2.00000000000000006e-53 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < 5e15Initial program 85.3%
Taylor expanded in x around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6479.6
Applied rewrites79.6%
Taylor expanded in z around 0
Applied rewrites54.6%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. (FPCore (x y z t a b c) :precision binary64 (if (or (<= z -4.5e-34) (not (<= z 0.1))) (/ (fma (* a t) -4.0 (/ (fma (* y x) 9.0 b) z)) c) (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))))
assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((z <= -4.5e-34) || !(z <= 0.1)) {
tmp = fma((a * t), -4.0, (fma((y * x), 9.0, b) / z)) / c;
} else {
tmp = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
}
return tmp;
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) tmp = 0.0 if ((z <= -4.5e-34) || !(z <= 0.1)) tmp = Float64(fma(Float64(a * t), -4.0, Float64(fma(Float64(y * x), 9.0, b) / z)) / c); else tmp = Float64(Float64(Float64(Float64(Float64(x * 9.0) * y) - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c)); end return tmp end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[z, -4.5e-34], N[Not[LessEqual[z, 0.1]], $MachinePrecision]], N[(N[(N[(a * t), $MachinePrecision] * -4.0 + N[(N[(N[(y * x), $MachinePrecision] * 9.0 + b), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision] - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{-34} \lor \neg \left(z \leq 0.1\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(a \cdot t, -4, \frac{\mathsf{fma}\left(y \cdot x, 9, b\right)}{z}\right)}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\\
\end{array}
\end{array}
if z < -4.50000000000000042e-34 or 0.10000000000000001 < z Initial program 62.1%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites80.1%
Taylor expanded in c around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.3
Applied rewrites90.3%
if -4.50000000000000042e-34 < z < 0.10000000000000001Initial program 95.9%
Final simplification93.2%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. (FPCore (x y z t a b c) :precision binary64 (if (or (<= z -4.5e-34) (not (<= z 0.1))) (/ (fma (* a t) -4.0 (/ (fma (* y x) 9.0 b) z)) c) (/ (+ (- (* (* x 9.0) y) (* (* 4.0 z) (* a t))) b) (* z c))))
assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((z <= -4.5e-34) || !(z <= 0.1)) {
tmp = fma((a * t), -4.0, (fma((y * x), 9.0, b) / z)) / c;
} else {
tmp = ((((x * 9.0) * y) - ((4.0 * z) * (a * t))) + b) / (z * c);
}
return tmp;
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) tmp = 0.0 if ((z <= -4.5e-34) || !(z <= 0.1)) tmp = Float64(fma(Float64(a * t), -4.0, Float64(fma(Float64(y * x), 9.0, b) / z)) / c); else tmp = Float64(Float64(Float64(Float64(Float64(x * 9.0) * y) - Float64(Float64(4.0 * z) * Float64(a * t))) + b) / Float64(z * c)); end return tmp end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[z, -4.5e-34], N[Not[LessEqual[z, 0.1]], $MachinePrecision]], N[(N[(N[(a * t), $MachinePrecision] * -4.0 + N[(N[(N[(y * x), $MachinePrecision] * 9.0 + b), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision] - N[(N[(4.0 * z), $MachinePrecision] * N[(a * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{-34} \lor \neg \left(z \leq 0.1\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(a \cdot t, -4, \frac{\mathsf{fma}\left(y \cdot x, 9, b\right)}{z}\right)}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(4 \cdot z\right) \cdot \left(a \cdot t\right)\right) + b}{z \cdot c}\\
\end{array}
\end{array}
if z < -4.50000000000000042e-34 or 0.10000000000000001 < z Initial program 62.1%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites80.1%
Taylor expanded in c around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.3
Applied rewrites90.3%
if -4.50000000000000042e-34 < z < 0.10000000000000001Initial program 95.9%
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6492.4
Applied rewrites92.4%
Final simplification91.4%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c)
:precision binary64
(if (<= z -2.75e+147)
(/ (fma (* a t) -4.0 (/ b z)) c)
(if (<= z 1.45e+19)
(/ (fma (* y x) 9.0 b) (* z c))
(/ (fma (* a t) -4.0 (/ (* (* y x) 9.0) z)) c))))assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (z <= -2.75e+147) {
tmp = fma((a * t), -4.0, (b / z)) / c;
} else if (z <= 1.45e+19) {
tmp = fma((y * x), 9.0, b) / (z * c);
} else {
tmp = fma((a * t), -4.0, (((y * x) * 9.0) / z)) / c;
}
return tmp;
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) tmp = 0.0 if (z <= -2.75e+147) tmp = Float64(fma(Float64(a * t), -4.0, Float64(b / z)) / c); elseif (z <= 1.45e+19) tmp = Float64(fma(Float64(y * x), 9.0, b) / Float64(z * c)); else tmp = Float64(fma(Float64(a * t), -4.0, Float64(Float64(Float64(y * x) * 9.0) / z)) / c); end return tmp end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[z, -2.75e+147], N[(N[(N[(a * t), $MachinePrecision] * -4.0 + N[(b / z), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[z, 1.45e+19], N[(N[(N[(y * x), $MachinePrecision] * 9.0 + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * t), $MachinePrecision] * -4.0 + N[(N[(N[(y * x), $MachinePrecision] * 9.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.75 \cdot 10^{+147}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a \cdot t, -4, \frac{b}{z}\right)}{c}\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{+19}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y \cdot x, 9, b\right)}{z \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a \cdot t, -4, \frac{\left(y \cdot x\right) \cdot 9}{z}\right)}{c}\\
\end{array}
\end{array}
if z < -2.7499999999999999e147Initial program 45.9%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites76.1%
Taylor expanded in c around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.1
Applied rewrites90.1%
Taylor expanded in x around 0
Applied rewrites89.9%
if -2.7499999999999999e147 < z < 1.45e19Initial program 94.9%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6481.8
Applied rewrites81.8%
if 1.45e19 < z Initial program 52.9%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites76.0%
Taylor expanded in c around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6487.1
Applied rewrites87.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6477.5
Applied rewrites77.5%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. (FPCore (x y z t a b c) :precision binary64 (if (<= a -1.72e-56) (* (fma (/ a c) -4.0 (/ b (* (* t z) c))) t) (/ (fma (* a t) -4.0 (/ (fma (* y x) 9.0 b) z)) c)))
assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (a <= -1.72e-56) {
tmp = fma((a / c), -4.0, (b / ((t * z) * c))) * t;
} else {
tmp = fma((a * t), -4.0, (fma((y * x), 9.0, b) / z)) / c;
}
return tmp;
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) tmp = 0.0 if (a <= -1.72e-56) tmp = Float64(fma(Float64(a / c), -4.0, Float64(b / Float64(Float64(t * z) * c))) * t); else tmp = Float64(fma(Float64(a * t), -4.0, Float64(fma(Float64(y * x), 9.0, b) / z)) / c); end return tmp end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[a, -1.72e-56], N[(N[(N[(a / c), $MachinePrecision] * -4.0 + N[(b / N[(N[(t * z), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision], N[(N[(N[(a * t), $MachinePrecision] * -4.0 + N[(N[(N[(y * x), $MachinePrecision] * 9.0 + b), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.72 \cdot 10^{-56}:\\
\;\;\;\;\mathsf{fma}\left(\frac{a}{c}, -4, \frac{b}{\left(t \cdot z\right) \cdot c}\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a \cdot t, -4, \frac{\mathsf{fma}\left(y \cdot x, 9, b\right)}{z}\right)}{c}\\
\end{array}
\end{array}
if a < -1.72000000000000009e-56Initial program 77.7%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites78.4%
Taylor expanded in x around 0
Applied rewrites67.8%
if -1.72000000000000009e-56 < a Initial program 80.8%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites87.9%
Taylor expanded in c around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.4
Applied rewrites90.4%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. (FPCore (x y z t a b c) :precision binary64 (if (<= a -1.72e-56) (* (fma (/ a c) -4.0 (/ b (* (* t z) c))) t) (/ (fma (* a t) -4.0 (/ (fma x (* y 9.0) b) z)) c)))
assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (a <= -1.72e-56) {
tmp = fma((a / c), -4.0, (b / ((t * z) * c))) * t;
} else {
tmp = fma((a * t), -4.0, (fma(x, (y * 9.0), b) / z)) / c;
}
return tmp;
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) tmp = 0.0 if (a <= -1.72e-56) tmp = Float64(fma(Float64(a / c), -4.0, Float64(b / Float64(Float64(t * z) * c))) * t); else tmp = Float64(fma(Float64(a * t), -4.0, Float64(fma(x, Float64(y * 9.0), b) / z)) / c); end return tmp end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[a, -1.72e-56], N[(N[(N[(a / c), $MachinePrecision] * -4.0 + N[(b / N[(N[(t * z), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision], N[(N[(N[(a * t), $MachinePrecision] * -4.0 + N[(N[(x * N[(y * 9.0), $MachinePrecision] + b), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.72 \cdot 10^{-56}:\\
\;\;\;\;\mathsf{fma}\left(\frac{a}{c}, -4, \frac{b}{\left(t \cdot z\right) \cdot c}\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a \cdot t, -4, \frac{\mathsf{fma}\left(x, y \cdot 9, b\right)}{z}\right)}{c}\\
\end{array}
\end{array}
if a < -1.72000000000000009e-56Initial program 77.7%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites78.4%
Taylor expanded in x around 0
Applied rewrites67.8%
if -1.72000000000000009e-56 < a Initial program 80.8%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites87.9%
Taylor expanded in c around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.4
Applied rewrites90.4%
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.3
Applied rewrites90.3%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. (FPCore (x y z t a b c) :precision binary64 (if (or (<= z -2.75e+147) (not (<= z 6.1e+28))) (/ (fma (* a t) -4.0 (/ b z)) c) (/ (fma (* y x) 9.0 b) (* z c))))
assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((z <= -2.75e+147) || !(z <= 6.1e+28)) {
tmp = fma((a * t), -4.0, (b / z)) / c;
} else {
tmp = fma((y * x), 9.0, b) / (z * c);
}
return tmp;
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) tmp = 0.0 if ((z <= -2.75e+147) || !(z <= 6.1e+28)) tmp = Float64(fma(Float64(a * t), -4.0, Float64(b / z)) / c); else tmp = Float64(fma(Float64(y * x), 9.0, b) / Float64(z * c)); end return tmp end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[z, -2.75e+147], N[Not[LessEqual[z, 6.1e+28]], $MachinePrecision]], N[(N[(N[(a * t), $MachinePrecision] * -4.0 + N[(b / z), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(y * x), $MachinePrecision] * 9.0 + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.75 \cdot 10^{+147} \lor \neg \left(z \leq 6.1 \cdot 10^{+28}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(a \cdot t, -4, \frac{b}{z}\right)}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y \cdot x, 9, b\right)}{z \cdot c}\\
\end{array}
\end{array}
if z < -2.7499999999999999e147 or 6.1000000000000002e28 < z Initial program 49.6%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites75.2%
Taylor expanded in c around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6487.4
Applied rewrites87.4%
Taylor expanded in x around 0
Applied rewrites75.7%
if -2.7499999999999999e147 < z < 6.1000000000000002e28Initial program 95.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6482.1
Applied rewrites82.1%
Final simplification80.0%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. (FPCore (x y z t a b c) :precision binary64 (if (<= z -5.7e+221) (* (* (/ a c) -4.0) t) (if (<= z 9.5e+32) (/ (fma (* y x) 9.0 b) (* z c)) (/ (* (* a t) -4.0) c))))
assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (z <= -5.7e+221) {
tmp = ((a / c) * -4.0) * t;
} else if (z <= 9.5e+32) {
tmp = fma((y * x), 9.0, b) / (z * c);
} else {
tmp = ((a * t) * -4.0) / c;
}
return tmp;
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) tmp = 0.0 if (z <= -5.7e+221) tmp = Float64(Float64(Float64(a / c) * -4.0) * t); elseif (z <= 9.5e+32) tmp = Float64(fma(Float64(y * x), 9.0, b) / Float64(z * c)); else tmp = Float64(Float64(Float64(a * t) * -4.0) / c); end return tmp end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[z, -5.7e+221], N[(N[(N[(a / c), $MachinePrecision] * -4.0), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[z, 9.5e+32], N[(N[(N[(y * x), $MachinePrecision] * 9.0 + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * t), $MachinePrecision] * -4.0), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.7 \cdot 10^{+221}:\\
\;\;\;\;\left(\frac{a}{c} \cdot -4\right) \cdot t\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{+32}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y \cdot x, 9, b\right)}{z \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(a \cdot t\right) \cdot -4}{c}\\
\end{array}
\end{array}
if z < -5.70000000000000011e221Initial program 21.2%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites80.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6480.5
Applied rewrites80.5%
if -5.70000000000000011e221 < z < 9.50000000000000006e32Initial program 93.7%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6479.9
Applied rewrites79.9%
if 9.50000000000000006e32 < z Initial program 50.8%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites74.9%
Taylor expanded in c around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6486.5
Applied rewrites86.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6461.4
Applied rewrites61.4%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. (FPCore (x y z t a b c) :precision binary64 (if (<= z -5.7e+221) (* (* (/ a c) -4.0) t) (if (<= z 9.5e+32) (/ (fma (* 9.0 x) y b) (* z c)) (/ (* (* a t) -4.0) c))))
assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (z <= -5.7e+221) {
tmp = ((a / c) * -4.0) * t;
} else if (z <= 9.5e+32) {
tmp = fma((9.0 * x), y, b) / (z * c);
} else {
tmp = ((a * t) * -4.0) / c;
}
return tmp;
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) tmp = 0.0 if (z <= -5.7e+221) tmp = Float64(Float64(Float64(a / c) * -4.0) * t); elseif (z <= 9.5e+32) tmp = Float64(fma(Float64(9.0 * x), y, b) / Float64(z * c)); else tmp = Float64(Float64(Float64(a * t) * -4.0) / c); end return tmp end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[z, -5.7e+221], N[(N[(N[(a / c), $MachinePrecision] * -4.0), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[z, 9.5e+32], N[(N[(N[(9.0 * x), $MachinePrecision] * y + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * t), $MachinePrecision] * -4.0), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.7 \cdot 10^{+221}:\\
\;\;\;\;\left(\frac{a}{c} \cdot -4\right) \cdot t\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{+32}:\\
\;\;\;\;\frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{z \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(a \cdot t\right) \cdot -4}{c}\\
\end{array}
\end{array}
if z < -5.70000000000000011e221Initial program 21.2%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites80.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6480.5
Applied rewrites80.5%
if -5.70000000000000011e221 < z < 9.50000000000000006e32Initial program 93.7%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6479.9
Applied rewrites79.9%
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6479.9
Applied rewrites79.9%
if 9.50000000000000006e32 < z Initial program 50.8%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites74.9%
Taylor expanded in c around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6486.5
Applied rewrites86.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6461.4
Applied rewrites61.4%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. (FPCore (x y z t a b c) :precision binary64 (if (<= z -5.7e+221) (* (* (/ a c) -4.0) t) (if (<= z 9.5e+32) (/ (fma x (* y 9.0) b) (* z c)) (/ (* (* a t) -4.0) c))))
assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (z <= -5.7e+221) {
tmp = ((a / c) * -4.0) * t;
} else if (z <= 9.5e+32) {
tmp = fma(x, (y * 9.0), b) / (z * c);
} else {
tmp = ((a * t) * -4.0) / c;
}
return tmp;
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) tmp = 0.0 if (z <= -5.7e+221) tmp = Float64(Float64(Float64(a / c) * -4.0) * t); elseif (z <= 9.5e+32) tmp = Float64(fma(x, Float64(y * 9.0), b) / Float64(z * c)); else tmp = Float64(Float64(Float64(a * t) * -4.0) / c); end return tmp end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[z, -5.7e+221], N[(N[(N[(a / c), $MachinePrecision] * -4.0), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[z, 9.5e+32], N[(N[(x * N[(y * 9.0), $MachinePrecision] + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * t), $MachinePrecision] * -4.0), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.7 \cdot 10^{+221}:\\
\;\;\;\;\left(\frac{a}{c} \cdot -4\right) \cdot t\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{+32}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y \cdot 9, b\right)}{z \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(a \cdot t\right) \cdot -4}{c}\\
\end{array}
\end{array}
if z < -5.70000000000000011e221Initial program 21.2%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites80.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6480.5
Applied rewrites80.5%
if -5.70000000000000011e221 < z < 9.50000000000000006e32Initial program 93.7%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6479.9
Applied rewrites79.9%
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6479.9
Applied rewrites79.9%
if 9.50000000000000006e32 < z Initial program 50.8%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites74.9%
Taylor expanded in c around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6486.5
Applied rewrites86.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6461.4
Applied rewrites61.4%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. (FPCore (x y z t a b c) :precision binary64 (if (<= t -2.8e+24) (* (* (/ t c) -4.0) a) (if (<= t 1.5e-68) (/ (/ b z) c) (* (* (/ a c) -4.0) t))))
assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (t <= -2.8e+24) {
tmp = ((t / c) * -4.0) * a;
} else if (t <= 1.5e-68) {
tmp = (b / z) / c;
} else {
tmp = ((a / c) * -4.0) * t;
}
return tmp;
}
NOTE: x, y, z, t, a, b, and c 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, b, c)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (t <= (-2.8d+24)) then
tmp = ((t / c) * (-4.0d0)) * a
else if (t <= 1.5d-68) then
tmp = (b / z) / c
else
tmp = ((a / c) * (-4.0d0)) * t
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c;
public static double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (t <= -2.8e+24) {
tmp = ((t / c) * -4.0) * a;
} else if (t <= 1.5e-68) {
tmp = (b / z) / c;
} else {
tmp = ((a / c) * -4.0) * t;
}
return tmp;
}
[x, y, z, t, a, b, c] = sort([x, y, z, t, a, b, c]) def code(x, y, z, t, a, b, c): tmp = 0 if t <= -2.8e+24: tmp = ((t / c) * -4.0) * a elif t <= 1.5e-68: tmp = (b / z) / c else: tmp = ((a / c) * -4.0) * t return tmp
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) tmp = 0.0 if (t <= -2.8e+24) tmp = Float64(Float64(Float64(t / c) * -4.0) * a); elseif (t <= 1.5e-68) tmp = Float64(Float64(b / z) / c); else tmp = Float64(Float64(Float64(a / c) * -4.0) * t); end return tmp end
x, y, z, t, a, b, c = num2cell(sort([x, y, z, t, a, b, c])){:}
function tmp_2 = code(x, y, z, t, a, b, c)
tmp = 0.0;
if (t <= -2.8e+24)
tmp = ((t / c) * -4.0) * a;
elseif (t <= 1.5e-68)
tmp = (b / z) / c;
else
tmp = ((a / c) * -4.0) * t;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[t, -2.8e+24], N[(N[(N[(t / c), $MachinePrecision] * -4.0), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[t, 1.5e-68], N[(N[(b / z), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(a / c), $MachinePrecision] * -4.0), $MachinePrecision] * t), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.8 \cdot 10^{+24}:\\
\;\;\;\;\left(\frac{t}{c} \cdot -4\right) \cdot a\\
\mathbf{elif}\;t \leq 1.5 \cdot 10^{-68}:\\
\;\;\;\;\frac{\frac{b}{z}}{c}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{a}{c} \cdot -4\right) \cdot t\\
\end{array}
\end{array}
if t < -2.8000000000000002e24Initial program 71.2%
Taylor expanded in x around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6463.7
Applied rewrites63.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6477.4
Applied rewrites77.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6462.0
Applied rewrites62.0%
if -2.8000000000000002e24 < t < 1.5e-68Initial program 88.9%
Taylor expanded in b around inf
Applied rewrites49.5%
associate-/r*N/A
lower-/.f64N/A
lower-/.f6448.8
Applied rewrites48.8%
if 1.5e-68 < t Initial program 75.2%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites82.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6439.3
Applied rewrites39.3%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. (FPCore (x y z t a b c) :precision binary64 (if (or (<= z -2.4e+101) (not (<= z 4.3e+20))) (/ (* (* a t) -4.0) c) (/ b (* z c))))
assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((z <= -2.4e+101) || !(z <= 4.3e+20)) {
tmp = ((a * t) * -4.0) / c;
} else {
tmp = b / (z * c);
}
return tmp;
}
NOTE: x, y, z, t, a, b, and c 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, b, c)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if ((z <= (-2.4d+101)) .or. (.not. (z <= 4.3d+20))) then
tmp = ((a * t) * (-4.0d0)) / c
else
tmp = b / (z * c)
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c;
public static double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((z <= -2.4e+101) || !(z <= 4.3e+20)) {
tmp = ((a * t) * -4.0) / c;
} else {
tmp = b / (z * c);
}
return tmp;
}
[x, y, z, t, a, b, c] = sort([x, y, z, t, a, b, c]) def code(x, y, z, t, a, b, c): tmp = 0 if (z <= -2.4e+101) or not (z <= 4.3e+20): tmp = ((a * t) * -4.0) / c else: tmp = b / (z * c) return tmp
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) tmp = 0.0 if ((z <= -2.4e+101) || !(z <= 4.3e+20)) tmp = Float64(Float64(Float64(a * t) * -4.0) / c); else tmp = Float64(b / Float64(z * c)); end return tmp end
x, y, z, t, a, b, c = num2cell(sort([x, y, z, t, a, b, c])){:}
function tmp_2 = code(x, y, z, t, a, b, c)
tmp = 0.0;
if ((z <= -2.4e+101) || ~((z <= 4.3e+20)))
tmp = ((a * t) * -4.0) / c;
else
tmp = b / (z * c);
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[z, -2.4e+101], N[Not[LessEqual[z, 4.3e+20]], $MachinePrecision]], N[(N[(N[(a * t), $MachinePrecision] * -4.0), $MachinePrecision] / c), $MachinePrecision], N[(b / N[(z * c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{+101} \lor \neg \left(z \leq 4.3 \cdot 10^{+20}\right):\\
\;\;\;\;\frac{\left(a \cdot t\right) \cdot -4}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{z \cdot c}\\
\end{array}
\end{array}
if z < -2.39999999999999988e101 or 4.3e20 < z Initial program 53.8%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites75.3%
Taylor expanded in c around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6487.9
Applied rewrites87.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6456.1
Applied rewrites56.1%
if -2.39999999999999988e101 < z < 4.3e20Initial program 95.9%
Taylor expanded in b around inf
Applied rewrites49.6%
Final simplification52.1%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. (FPCore (x y z t a b c) :precision binary64 (if (<= z -1150000.0) (* (* (/ a c) -4.0) t) (if (<= z 4.3e+20) (/ b (* z c)) (/ (* (* a t) -4.0) c))))
assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (z <= -1150000.0) {
tmp = ((a / c) * -4.0) * t;
} else if (z <= 4.3e+20) {
tmp = b / (z * c);
} else {
tmp = ((a * t) * -4.0) / c;
}
return tmp;
}
NOTE: x, y, z, t, a, b, and c 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, b, c)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (z <= (-1150000.0d0)) then
tmp = ((a / c) * (-4.0d0)) * t
else if (z <= 4.3d+20) then
tmp = b / (z * c)
else
tmp = ((a * t) * (-4.0d0)) / c
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c;
public static double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (z <= -1150000.0) {
tmp = ((a / c) * -4.0) * t;
} else if (z <= 4.3e+20) {
tmp = b / (z * c);
} else {
tmp = ((a * t) * -4.0) / c;
}
return tmp;
}
[x, y, z, t, a, b, c] = sort([x, y, z, t, a, b, c]) def code(x, y, z, t, a, b, c): tmp = 0 if z <= -1150000.0: tmp = ((a / c) * -4.0) * t elif z <= 4.3e+20: tmp = b / (z * c) else: tmp = ((a * t) * -4.0) / c return tmp
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) tmp = 0.0 if (z <= -1150000.0) tmp = Float64(Float64(Float64(a / c) * -4.0) * t); elseif (z <= 4.3e+20) tmp = Float64(b / Float64(z * c)); else tmp = Float64(Float64(Float64(a * t) * -4.0) / c); end return tmp end
x, y, z, t, a, b, c = num2cell(sort([x, y, z, t, a, b, c])){:}
function tmp_2 = code(x, y, z, t, a, b, c)
tmp = 0.0;
if (z <= -1150000.0)
tmp = ((a / c) * -4.0) * t;
elseif (z <= 4.3e+20)
tmp = b / (z * c);
else
tmp = ((a * t) * -4.0) / c;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[z, -1150000.0], N[(N[(N[(a / c), $MachinePrecision] * -4.0), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[z, 4.3e+20], N[(b / N[(z * c), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * t), $MachinePrecision] * -4.0), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1150000:\\
\;\;\;\;\left(\frac{a}{c} \cdot -4\right) \cdot t\\
\mathbf{elif}\;z \leq 4.3 \cdot 10^{+20}:\\
\;\;\;\;\frac{b}{z \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(a \cdot t\right) \cdot -4}{c}\\
\end{array}
\end{array}
if z < -1.15e6Initial program 67.1%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites74.2%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6444.4
Applied rewrites44.4%
if -1.15e6 < z < 4.3e20Initial program 96.2%
Taylor expanded in b around inf
Applied rewrites50.1%
if 4.3e20 < z Initial program 52.2%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites75.6%
Taylor expanded in c around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6486.9
Applied rewrites86.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6459.7
Applied rewrites59.7%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. (FPCore (x y z t a b c) :precision binary64 (if (<= z -2.4e+101) (* (* (/ t c) -4.0) a) (if (<= z 4.3e+20) (/ b (* z c)) (/ (* (* a t) -4.0) c))))
assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (z <= -2.4e+101) {
tmp = ((t / c) * -4.0) * a;
} else if (z <= 4.3e+20) {
tmp = b / (z * c);
} else {
tmp = ((a * t) * -4.0) / c;
}
return tmp;
}
NOTE: x, y, z, t, a, b, and c 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, b, c)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (z <= (-2.4d+101)) then
tmp = ((t / c) * (-4.0d0)) * a
else if (z <= 4.3d+20) then
tmp = b / (z * c)
else
tmp = ((a * t) * (-4.0d0)) / c
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c;
public static double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (z <= -2.4e+101) {
tmp = ((t / c) * -4.0) * a;
} else if (z <= 4.3e+20) {
tmp = b / (z * c);
} else {
tmp = ((a * t) * -4.0) / c;
}
return tmp;
}
[x, y, z, t, a, b, c] = sort([x, y, z, t, a, b, c]) def code(x, y, z, t, a, b, c): tmp = 0 if z <= -2.4e+101: tmp = ((t / c) * -4.0) * a elif z <= 4.3e+20: tmp = b / (z * c) else: tmp = ((a * t) * -4.0) / c return tmp
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) tmp = 0.0 if (z <= -2.4e+101) tmp = Float64(Float64(Float64(t / c) * -4.0) * a); elseif (z <= 4.3e+20) tmp = Float64(b / Float64(z * c)); else tmp = Float64(Float64(Float64(a * t) * -4.0) / c); end return tmp end
x, y, z, t, a, b, c = num2cell(sort([x, y, z, t, a, b, c])){:}
function tmp_2 = code(x, y, z, t, a, b, c)
tmp = 0.0;
if (z <= -2.4e+101)
tmp = ((t / c) * -4.0) * a;
elseif (z <= 4.3e+20)
tmp = b / (z * c);
else
tmp = ((a * t) * -4.0) / c;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[z, -2.4e+101], N[(N[(N[(t / c), $MachinePrecision] * -4.0), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[z, 4.3e+20], N[(b / N[(z * c), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * t), $MachinePrecision] * -4.0), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{+101}:\\
\;\;\;\;\left(\frac{t}{c} \cdot -4\right) \cdot a\\
\mathbf{elif}\;z \leq 4.3 \cdot 10^{+20}:\\
\;\;\;\;\frac{b}{z \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(a \cdot t\right) \cdot -4}{c}\\
\end{array}
\end{array}
if z < -2.39999999999999988e101Initial program 57.2%
Taylor expanded in x around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6441.8
Applied rewrites41.8%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6467.4
Applied rewrites67.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6451.3
Applied rewrites51.3%
if -2.39999999999999988e101 < z < 4.3e20Initial program 95.9%
Taylor expanded in b around inf
Applied rewrites49.6%
if 4.3e20 < z Initial program 52.2%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites75.6%
Taylor expanded in c around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6486.9
Applied rewrites86.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6459.7
Applied rewrites59.7%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. (FPCore (x y z t a b c) :precision binary64 (/ b (* z c)))
assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
return b / (z * c);
}
NOTE: x, y, z, t, a, b, and c 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, b, c)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = b / (z * c)
end function
assert x < y && y < z && z < t && t < a && a < b && b < c;
public static double code(double x, double y, double z, double t, double a, double b, double c) {
return b / (z * c);
}
[x, y, z, t, a, b, c] = sort([x, y, z, t, a, b, c]) def code(x, y, z, t, a, b, c): return b / (z * c)
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) return Float64(b / Float64(z * c)) end
x, y, z, t, a, b, c = num2cell(sort([x, y, z, t, a, b, c])){:}
function tmp = code(x, y, z, t, a, b, c)
tmp = b / (z * c);
end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := N[(b / N[(z * c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\frac{b}{z \cdot c}
\end{array}
Initial program 79.9%
Taylor expanded in b around inf
Applied rewrites37.4%
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (/ b (* c z)))
(t_2 (* 4.0 (/ (* a t) c)))
(t_3 (* (* x 9.0) y))
(t_4 (+ (- t_3 (* (* (* z 4.0) t) a)) b))
(t_5 (/ t_4 (* z c)))
(t_6 (/ (+ (- t_3 (* (* z 4.0) (* t a))) b) (* z c))))
(if (< t_5 -1.100156740804105e-171)
t_6
(if (< t_5 0.0)
(/ (/ t_4 z) c)
(if (< t_5 1.1708877911747488e-53)
t_6
(if (< t_5 2.876823679546137e+130)
(- (+ (* (* 9.0 (/ y c)) (/ x z)) t_1) t_2)
(if (< t_5 1.3838515042456319e+158)
t_6
(- (+ (* 9.0 (* (/ y (* c z)) x)) t_1) t_2))))))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = b / (c * z);
double t_2 = 4.0 * ((a * t) / c);
double t_3 = (x * 9.0) * y;
double t_4 = (t_3 - (((z * 4.0) * t) * a)) + b;
double t_5 = t_4 / (z * c);
double t_6 = ((t_3 - ((z * 4.0) * (t * a))) + b) / (z * c);
double tmp;
if (t_5 < -1.100156740804105e-171) {
tmp = t_6;
} else if (t_5 < 0.0) {
tmp = (t_4 / z) / c;
} else if (t_5 < 1.1708877911747488e-53) {
tmp = t_6;
} else if (t_5 < 2.876823679546137e+130) {
tmp = (((9.0 * (y / c)) * (x / z)) + t_1) - t_2;
} else if (t_5 < 1.3838515042456319e+158) {
tmp = t_6;
} else {
tmp = ((9.0 * ((y / (c * z)) * x)) + t_1) - t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: tmp
t_1 = b / (c * z)
t_2 = 4.0d0 * ((a * t) / c)
t_3 = (x * 9.0d0) * y
t_4 = (t_3 - (((z * 4.0d0) * t) * a)) + b
t_5 = t_4 / (z * c)
t_6 = ((t_3 - ((z * 4.0d0) * (t * a))) + b) / (z * c)
if (t_5 < (-1.100156740804105d-171)) then
tmp = t_6
else if (t_5 < 0.0d0) then
tmp = (t_4 / z) / c
else if (t_5 < 1.1708877911747488d-53) then
tmp = t_6
else if (t_5 < 2.876823679546137d+130) then
tmp = (((9.0d0 * (y / c)) * (x / z)) + t_1) - t_2
else if (t_5 < 1.3838515042456319d+158) then
tmp = t_6
else
tmp = ((9.0d0 * ((y / (c * z)) * x)) + t_1) - t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = b / (c * z);
double t_2 = 4.0 * ((a * t) / c);
double t_3 = (x * 9.0) * y;
double t_4 = (t_3 - (((z * 4.0) * t) * a)) + b;
double t_5 = t_4 / (z * c);
double t_6 = ((t_3 - ((z * 4.0) * (t * a))) + b) / (z * c);
double tmp;
if (t_5 < -1.100156740804105e-171) {
tmp = t_6;
} else if (t_5 < 0.0) {
tmp = (t_4 / z) / c;
} else if (t_5 < 1.1708877911747488e-53) {
tmp = t_6;
} else if (t_5 < 2.876823679546137e+130) {
tmp = (((9.0 * (y / c)) * (x / z)) + t_1) - t_2;
} else if (t_5 < 1.3838515042456319e+158) {
tmp = t_6;
} else {
tmp = ((9.0 * ((y / (c * z)) * x)) + t_1) - t_2;
}
return tmp;
}
def code(x, y, z, t, a, b, c): t_1 = b / (c * z) t_2 = 4.0 * ((a * t) / c) t_3 = (x * 9.0) * y t_4 = (t_3 - (((z * 4.0) * t) * a)) + b t_5 = t_4 / (z * c) t_6 = ((t_3 - ((z * 4.0) * (t * a))) + b) / (z * c) tmp = 0 if t_5 < -1.100156740804105e-171: tmp = t_6 elif t_5 < 0.0: tmp = (t_4 / z) / c elif t_5 < 1.1708877911747488e-53: tmp = t_6 elif t_5 < 2.876823679546137e+130: tmp = (((9.0 * (y / c)) * (x / z)) + t_1) - t_2 elif t_5 < 1.3838515042456319e+158: tmp = t_6 else: tmp = ((9.0 * ((y / (c * z)) * x)) + t_1) - t_2 return tmp
function code(x, y, z, t, a, b, c) t_1 = Float64(b / Float64(c * z)) t_2 = Float64(4.0 * Float64(Float64(a * t) / c)) t_3 = Float64(Float64(x * 9.0) * y) t_4 = Float64(Float64(t_3 - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) t_5 = Float64(t_4 / Float64(z * c)) t_6 = Float64(Float64(Float64(t_3 - Float64(Float64(z * 4.0) * Float64(t * a))) + b) / Float64(z * c)) tmp = 0.0 if (t_5 < -1.100156740804105e-171) tmp = t_6; elseif (t_5 < 0.0) tmp = Float64(Float64(t_4 / z) / c); elseif (t_5 < 1.1708877911747488e-53) tmp = t_6; elseif (t_5 < 2.876823679546137e+130) tmp = Float64(Float64(Float64(Float64(9.0 * Float64(y / c)) * Float64(x / z)) + t_1) - t_2); elseif (t_5 < 1.3838515042456319e+158) tmp = t_6; else tmp = Float64(Float64(Float64(9.0 * Float64(Float64(y / Float64(c * z)) * x)) + t_1) - t_2); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c) t_1 = b / (c * z); t_2 = 4.0 * ((a * t) / c); t_3 = (x * 9.0) * y; t_4 = (t_3 - (((z * 4.0) * t) * a)) + b; t_5 = t_4 / (z * c); t_6 = ((t_3 - ((z * 4.0) * (t * a))) + b) / (z * c); tmp = 0.0; if (t_5 < -1.100156740804105e-171) tmp = t_6; elseif (t_5 < 0.0) tmp = (t_4 / z) / c; elseif (t_5 < 1.1708877911747488e-53) tmp = t_6; elseif (t_5 < 2.876823679546137e+130) tmp = (((9.0 * (y / c)) * (x / z)) + t_1) - t_2; elseif (t_5 < 1.3838515042456319e+158) tmp = t_6; else tmp = ((9.0 * ((y / (c * z)) * x)) + t_1) - t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(b / N[(c * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(4.0 * N[(N[(a * t), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$4 = N[(N[(t$95$3 - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 / N[(z * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(N[(N[(t$95$3 - N[(N[(z * 4.0), $MachinePrecision] * N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$5, -1.100156740804105e-171], t$95$6, If[Less[t$95$5, 0.0], N[(N[(t$95$4 / z), $MachinePrecision] / c), $MachinePrecision], If[Less[t$95$5, 1.1708877911747488e-53], t$95$6, If[Less[t$95$5, 2.876823679546137e+130], N[(N[(N[(N[(9.0 * N[(y / c), $MachinePrecision]), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision] - t$95$2), $MachinePrecision], If[Less[t$95$5, 1.3838515042456319e+158], t$95$6, N[(N[(N[(9.0 * N[(N[(y / N[(c * z), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision] - t$95$2), $MachinePrecision]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{b}{c \cdot z}\\
t_2 := 4 \cdot \frac{a \cdot t}{c}\\
t_3 := \left(x \cdot 9\right) \cdot y\\
t_4 := \left(t\_3 - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b\\
t_5 := \frac{t\_4}{z \cdot c}\\
t_6 := \frac{\left(t\_3 - \left(z \cdot 4\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\
\mathbf{if}\;t\_5 < -1.100156740804105 \cdot 10^{-171}:\\
\;\;\;\;t\_6\\
\mathbf{elif}\;t\_5 < 0:\\
\;\;\;\;\frac{\frac{t\_4}{z}}{c}\\
\mathbf{elif}\;t\_5 < 1.1708877911747488 \cdot 10^{-53}:\\
\;\;\;\;t\_6\\
\mathbf{elif}\;t\_5 < 2.876823679546137 \cdot 10^{+130}:\\
\;\;\;\;\left(\left(9 \cdot \frac{y}{c}\right) \cdot \frac{x}{z} + t\_1\right) - t\_2\\
\mathbf{elif}\;t\_5 < 1.3838515042456319 \cdot 10^{+158}:\\
\;\;\;\;t\_6\\
\mathbf{else}:\\
\;\;\;\;\left(9 \cdot \left(\frac{y}{c \cdot z} \cdot x\right) + t\_1\right) - t\_2\\
\end{array}
\end{array}
herbie shell --seed 2025044
(FPCore (x y z t a b c)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, J"
:precision binary64
:alt
(! :herbie-platform default (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) -220031348160821/200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (+ (- (* (* x 9) y) (* (* z 4) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 0) (/ (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) z) c) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 365902434742109/31250000000000000000000000000000000000000000000000000000000000000000) (/ (+ (- (* (* x 9) y) (* (* z 4) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 28768236795461370000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (+ (* (* 9 (/ y c)) (/ x z)) (/ b (* c z))) (* 4 (/ (* a t) c))) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 138385150424563190000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (+ (- (* (* x 9) y) (* (* z 4) (* t a))) b) (* z c)) (- (+ (* 9 (* (/ y (* c z)) x)) (/ b (* c z))) (* 4 (/ (* a t) c)))))))))
(/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))