
(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}
Herbie found 13 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}
c\_m = (fabs.f64 c)
c\_s = (copysign.f64 #s(literal 1 binary64) c)
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
(FPCore (c_s x y z t a b c_m)
:precision binary64
(let* ((t_1 (fma (* y x) 9.0 b)))
(*
c_s
(if (<= c_m 2.5e+100)
(/ (fma (* a t) -4.0 (/ t_1 z)) c_m)
(fma -4.0 (* a (/ t c_m)) (/ t_1 (* c_m z)))))))c\_m = fabs(c);
c\_s = copysign(1.0, c);
assert(x < y && y < z && z < t && t < a && a < b && b < c_m);
double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
double t_1 = fma((y * x), 9.0, b);
double tmp;
if (c_m <= 2.5e+100) {
tmp = fma((a * t), -4.0, (t_1 / z)) / c_m;
} else {
tmp = fma(-4.0, (a * (t / c_m)), (t_1 / (c_m * z)));
}
return c_s * tmp;
}
c\_m = abs(c) c\_s = copysign(1.0, c) x, y, z, t, a, b, c_m = sort([x, y, z, t, a, b, c_m]) function code(c_s, x, y, z, t, a, b, c_m) t_1 = fma(Float64(y * x), 9.0, b) tmp = 0.0 if (c_m <= 2.5e+100) tmp = Float64(fma(Float64(a * t), -4.0, Float64(t_1 / z)) / c_m); else tmp = fma(-4.0, Float64(a * Float64(t / c_m)), Float64(t_1 / Float64(c_m * z))); end return Float64(c_s * tmp) end
c\_m = N[Abs[c], $MachinePrecision]
c\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
code[c$95$s_, x_, y_, z_, t_, a_, b_, c$95$m_] := Block[{t$95$1 = N[(N[(y * x), $MachinePrecision] * 9.0 + b), $MachinePrecision]}, N[(c$95$s * If[LessEqual[c$95$m, 2.5e+100], N[(N[(N[(a * t), $MachinePrecision] * -4.0 + N[(t$95$1 / z), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision], N[(-4.0 * N[(a * N[(t / c$95$m), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 / N[(c$95$m * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
c\_m = \left|c\right|
\\
c\_s = \mathsf{copysign}\left(1, c\right)
\\
[x, y, z, t, a, b, c_m] = \mathsf{sort}([x, y, z, t, a, b, c_m])\\
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y \cdot x, 9, b\right)\\
c\_s \cdot \begin{array}{l}
\mathbf{if}\;c\_m \leq 2.5 \cdot 10^{+100}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a \cdot t, -4, \frac{t\_1}{z}\right)}{c\_m}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-4, a \cdot \frac{t}{c\_m}, \frac{t\_1}{c\_m \cdot z}\right)\\
\end{array}
\end{array}
\end{array}
if c < 2.4999999999999999e100Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites77.8%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6485.7
Applied rewrites85.7%
if 2.4999999999999999e100 < c Initial program 78.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
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6483.9
Applied rewrites83.9%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6483.5
Applied rewrites83.5%
c\_m = (fabs.f64 c)
c\_s = (copysign.f64 #s(literal 1 binary64) c)
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
(FPCore (c_s x y z t a b c_m)
:precision binary64
(*
c_s
(if (<= (* (* x 9.0) y) 1e+176)
(/ (fma (* a t) -4.0 (/ (fma (* y x) 9.0 b) z)) c_m)
(* (* (/ y (* c_m z)) x) 9.0))))c\_m = fabs(c);
c\_s = copysign(1.0, c);
assert(x < y && y < z && z < t && t < a && a < b && b < c_m);
double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
double tmp;
if (((x * 9.0) * y) <= 1e+176) {
tmp = fma((a * t), -4.0, (fma((y * x), 9.0, b) / z)) / c_m;
} else {
tmp = ((y / (c_m * z)) * x) * 9.0;
}
return c_s * tmp;
}
c\_m = abs(c) c\_s = copysign(1.0, c) x, y, z, t, a, b, c_m = sort([x, y, z, t, a, b, c_m]) function code(c_s, x, y, z, t, a, b, c_m) tmp = 0.0 if (Float64(Float64(x * 9.0) * y) <= 1e+176) tmp = Float64(fma(Float64(a * t), -4.0, Float64(fma(Float64(y * x), 9.0, b) / z)) / c_m); else tmp = Float64(Float64(Float64(y / Float64(c_m * z)) * x) * 9.0); end return Float64(c_s * tmp) end
c\_m = N[Abs[c], $MachinePrecision]
c\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
code[c$95$s_, x_, y_, z_, t_, a_, b_, c$95$m_] := N[(c$95$s * If[LessEqual[N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision], 1e+176], N[(N[(N[(a * t), $MachinePrecision] * -4.0 + N[(N[(N[(y * x), $MachinePrecision] * 9.0 + b), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision], N[(N[(N[(y / N[(c$95$m * z), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * 9.0), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
c\_m = \left|c\right|
\\
c\_s = \mathsf{copysign}\left(1, c\right)
\\
[x, y, z, t, a, b, c_m] = \mathsf{sort}([x, y, z, t, a, b, c_m])\\
\\
c\_s \cdot \begin{array}{l}
\mathbf{if}\;\left(x \cdot 9\right) \cdot y \leq 10^{+176}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a \cdot t, -4, \frac{\mathsf{fma}\left(y \cdot x, 9, b\right)}{z}\right)}{c\_m}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{y}{c\_m \cdot z} \cdot x\right) \cdot 9\\
\end{array}
\end{array}
if (*.f64 (*.f64 x #s(literal 9 binary64)) y) < 1e176Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites77.8%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6485.7
Applied rewrites85.7%
if 1e176 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites77.8%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6485.7
Applied rewrites85.7%
lift-*.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
div-addN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-*r/N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
associate--l+N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
Applied rewrites84.2%
Taylor expanded in x around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f6436.8
Applied rewrites36.8%
c\_m = (fabs.f64 c)
c\_s = (copysign.f64 #s(literal 1 binary64) c)
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
(FPCore (c_s x y z t a b c_m)
:precision binary64
(let* ((t_1 (/ (fma (* -4.0 a) t (* (/ (* x y) z) 9.0)) c_m))
(t_2 (* (* x 9.0) y)))
(*
c_s
(if (<= t_2 -4e-68)
t_1
(if (<= t_2 2e-111) (/ (fma (* a t) -4.0 (/ b z)) c_m) t_1)))))c\_m = fabs(c);
c\_s = copysign(1.0, c);
assert(x < y && y < z && z < t && t < a && a < b && b < c_m);
double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
double t_1 = fma((-4.0 * a), t, (((x * y) / z) * 9.0)) / c_m;
double t_2 = (x * 9.0) * y;
double tmp;
if (t_2 <= -4e-68) {
tmp = t_1;
} else if (t_2 <= 2e-111) {
tmp = fma((a * t), -4.0, (b / z)) / c_m;
} else {
tmp = t_1;
}
return c_s * tmp;
}
c\_m = abs(c) c\_s = copysign(1.0, c) x, y, z, t, a, b, c_m = sort([x, y, z, t, a, b, c_m]) function code(c_s, x, y, z, t, a, b, c_m) t_1 = Float64(fma(Float64(-4.0 * a), t, Float64(Float64(Float64(x * y) / z) * 9.0)) / c_m) t_2 = Float64(Float64(x * 9.0) * y) tmp = 0.0 if (t_2 <= -4e-68) tmp = t_1; elseif (t_2 <= 2e-111) tmp = Float64(fma(Float64(a * t), -4.0, Float64(b / z)) / c_m); else tmp = t_1; end return Float64(c_s * tmp) end
c\_m = N[Abs[c], $MachinePrecision]
c\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
code[c$95$s_, x_, y_, z_, t_, a_, b_, c$95$m_] := Block[{t$95$1 = N[(N[(N[(-4.0 * a), $MachinePrecision] * t + N[(N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision] * 9.0), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision]}, N[(c$95$s * If[LessEqual[t$95$2, -4e-68], t$95$1, If[LessEqual[t$95$2, 2e-111], N[(N[(N[(a * t), $MachinePrecision] * -4.0 + N[(b / z), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision], t$95$1]]), $MachinePrecision]]]
\begin{array}{l}
c\_m = \left|c\right|
\\
c\_s = \mathsf{copysign}\left(1, c\right)
\\
[x, y, z, t, a, b, c_m] = \mathsf{sort}([x, y, z, t, a, b, c_m])\\
\\
\begin{array}{l}
t_1 := \frac{\mathsf{fma}\left(-4 \cdot a, t, \frac{x \cdot y}{z} \cdot 9\right)}{c\_m}\\
t_2 := \left(x \cdot 9\right) \cdot y\\
c\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{-68}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-111}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a \cdot t, -4, \frac{b}{z}\right)}{c\_m}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
\end{array}
if (*.f64 (*.f64 x #s(literal 9 binary64)) y) < -4.00000000000000027e-68 or 2.00000000000000018e-111 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites77.8%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6485.7
Applied rewrites85.7%
Taylor expanded in b around 0
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6462.9
Applied rewrites62.9%
if -4.00000000000000027e-68 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < 2.00000000000000018e-111Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites77.8%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6485.7
Applied rewrites85.7%
Taylor expanded in x around 0
Applied rewrites64.2%
c\_m = (fabs.f64 c)
c\_s = (copysign.f64 #s(literal 1 binary64) c)
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
(FPCore (c_s x y z t a b c_m)
:precision binary64
(let* ((t_1 (* (* x 9.0) y)))
(*
c_s
(if (<= t_1 -5e+187)
(- (* (* (/ (/ y c_m) z) -9.0) x))
(if (<= t_1 1e+94)
(/ (fma (* a t) -4.0 (/ b z)) c_m)
(* (* (/ y (* c_m z)) x) 9.0))))))c\_m = fabs(c);
c\_s = copysign(1.0, c);
assert(x < y && y < z && z < t && t < a && a < b && b < c_m);
double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
double t_1 = (x * 9.0) * y;
double tmp;
if (t_1 <= -5e+187) {
tmp = -((((y / c_m) / z) * -9.0) * x);
} else if (t_1 <= 1e+94) {
tmp = fma((a * t), -4.0, (b / z)) / c_m;
} else {
tmp = ((y / (c_m * z)) * x) * 9.0;
}
return c_s * tmp;
}
c\_m = abs(c) c\_s = copysign(1.0, c) x, y, z, t, a, b, c_m = sort([x, y, z, t, a, b, c_m]) function code(c_s, x, y, z, t, a, b, c_m) t_1 = Float64(Float64(x * 9.0) * y) tmp = 0.0 if (t_1 <= -5e+187) tmp = Float64(-Float64(Float64(Float64(Float64(y / c_m) / z) * -9.0) * x)); elseif (t_1 <= 1e+94) tmp = Float64(fma(Float64(a * t), -4.0, Float64(b / z)) / c_m); else tmp = Float64(Float64(Float64(y / Float64(c_m * z)) * x) * 9.0); end return Float64(c_s * tmp) end
c\_m = N[Abs[c], $MachinePrecision]
c\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
code[c$95$s_, x_, y_, z_, t_, a_, b_, c$95$m_] := Block[{t$95$1 = N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision]}, N[(c$95$s * If[LessEqual[t$95$1, -5e+187], (-N[(N[(N[(N[(y / c$95$m), $MachinePrecision] / z), $MachinePrecision] * -9.0), $MachinePrecision] * x), $MachinePrecision]), If[LessEqual[t$95$1, 1e+94], N[(N[(N[(a * t), $MachinePrecision] * -4.0 + N[(b / z), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision], N[(N[(N[(y / N[(c$95$m * z), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * 9.0), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
c\_m = \left|c\right|
\\
c\_s = \mathsf{copysign}\left(1, c\right)
\\
[x, y, z, t, a, b, c_m] = \mathsf{sort}([x, y, z, t, a, b, c_m])\\
\\
\begin{array}{l}
t_1 := \left(x \cdot 9\right) \cdot y\\
c\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+187}:\\
\;\;\;\;-\left(\frac{\frac{y}{c\_m}}{z} \cdot -9\right) \cdot x\\
\mathbf{elif}\;t\_1 \leq 10^{+94}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a \cdot t, -4, \frac{b}{z}\right)}{c\_m}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{y}{c\_m \cdot z} \cdot x\right) \cdot 9\\
\end{array}
\end{array}
\end{array}
if (*.f64 (*.f64 x #s(literal 9 binary64)) y) < -5.0000000000000001e187Initial program 78.7%
Taylor expanded in x around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f6436.8
Applied rewrites36.8%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6437.0
Applied rewrites37.0%
if -5.0000000000000001e187 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < 1e94Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites77.8%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6485.7
Applied rewrites85.7%
Taylor expanded in x around 0
Applied rewrites64.2%
if 1e94 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites77.8%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6485.7
Applied rewrites85.7%
lift-*.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
div-addN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-*r/N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
associate--l+N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
Applied rewrites84.2%
Taylor expanded in x around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f6436.8
Applied rewrites36.8%
c\_m = (fabs.f64 c)
c\_s = (copysign.f64 #s(literal 1 binary64) c)
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
(FPCore (c_s x y z t a b c_m)
:precision binary64
(let* ((t_1 (* -4.0 (/ (* a t) c_m))))
(*
c_s
(if (<= t -3.7e+217)
t_1
(if (<= t 2.25e-51) (/ (/ (fma (* y x) 9.0 b) z) c_m) t_1)))))c\_m = fabs(c);
c\_s = copysign(1.0, c);
assert(x < y && y < z && z < t && t < a && a < b && b < c_m);
double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
double t_1 = -4.0 * ((a * t) / c_m);
double tmp;
if (t <= -3.7e+217) {
tmp = t_1;
} else if (t <= 2.25e-51) {
tmp = (fma((y * x), 9.0, b) / z) / c_m;
} else {
tmp = t_1;
}
return c_s * tmp;
}
c\_m = abs(c) c\_s = copysign(1.0, c) x, y, z, t, a, b, c_m = sort([x, y, z, t, a, b, c_m]) function code(c_s, x, y, z, t, a, b, c_m) t_1 = Float64(-4.0 * Float64(Float64(a * t) / c_m)) tmp = 0.0 if (t <= -3.7e+217) tmp = t_1; elseif (t <= 2.25e-51) tmp = Float64(Float64(fma(Float64(y * x), 9.0, b) / z) / c_m); else tmp = t_1; end return Float64(c_s * tmp) end
c\_m = N[Abs[c], $MachinePrecision]
c\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
code[c$95$s_, x_, y_, z_, t_, a_, b_, c$95$m_] := Block[{t$95$1 = N[(-4.0 * N[(N[(a * t), $MachinePrecision] / c$95$m), $MachinePrecision]), $MachinePrecision]}, N[(c$95$s * If[LessEqual[t, -3.7e+217], t$95$1, If[LessEqual[t, 2.25e-51], N[(N[(N[(N[(y * x), $MachinePrecision] * 9.0 + b), $MachinePrecision] / z), $MachinePrecision] / c$95$m), $MachinePrecision], t$95$1]]), $MachinePrecision]]
\begin{array}{l}
c\_m = \left|c\right|
\\
c\_s = \mathsf{copysign}\left(1, c\right)
\\
[x, y, z, t, a, b, c_m] = \mathsf{sort}([x, y, z, t, a, b, c_m])\\
\\
\begin{array}{l}
t_1 := -4 \cdot \frac{a \cdot t}{c\_m}\\
c\_s \cdot \begin{array}{l}
\mathbf{if}\;t \leq -3.7 \cdot 10^{+217}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 2.25 \cdot 10^{-51}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(y \cdot x, 9, b\right)}{z}}{c\_m}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
\end{array}
if t < -3.70000000000000011e217 or 2.24999999999999987e-51 < t Initial program 78.7%
Taylor expanded in z around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6438.4
Applied rewrites38.4%
if -3.70000000000000011e217 < t < 2.24999999999999987e-51Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites77.8%
Taylor expanded in z around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6457.6
Applied rewrites57.6%
c\_m = (fabs.f64 c)
c\_s = (copysign.f64 #s(literal 1 binary64) c)
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
(FPCore (c_s x y z t a b c_m)
:precision binary64
(let* ((t_1 (* (* x 9.0) y)))
(*
c_s
(if (<= t_1 -4e+134)
(- (* (* (/ (/ y c_m) z) -9.0) x))
(if (<= t_1 -1e-198)
(* -4.0 (/ (* a t) c_m))
(if (<= t_1 1e-252)
(/ (/ b c_m) z)
(if (<= t_1 2e+38)
(/ (* (* a t) -4.0) c_m)
(* (* (/ y (* c_m z)) x) 9.0))))))))c\_m = fabs(c);
c\_s = copysign(1.0, c);
assert(x < y && y < z && z < t && t < a && a < b && b < c_m);
double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
double t_1 = (x * 9.0) * y;
double tmp;
if (t_1 <= -4e+134) {
tmp = -((((y / c_m) / z) * -9.0) * x);
} else if (t_1 <= -1e-198) {
tmp = -4.0 * ((a * t) / c_m);
} else if (t_1 <= 1e-252) {
tmp = (b / c_m) / z;
} else if (t_1 <= 2e+38) {
tmp = ((a * t) * -4.0) / c_m;
} else {
tmp = ((y / (c_m * z)) * x) * 9.0;
}
return c_s * tmp;
}
c\_m = private
c\_s = private
NOTE: x, y, z, t, a, b, and c_m 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(c_s, x, y, z, t, a, b, c_m)
use fmin_fmax_functions
real(8), intent (in) :: c_s
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_m
real(8) :: t_1
real(8) :: tmp
t_1 = (x * 9.0d0) * y
if (t_1 <= (-4d+134)) then
tmp = -((((y / c_m) / z) * (-9.0d0)) * x)
else if (t_1 <= (-1d-198)) then
tmp = (-4.0d0) * ((a * t) / c_m)
else if (t_1 <= 1d-252) then
tmp = (b / c_m) / z
else if (t_1 <= 2d+38) then
tmp = ((a * t) * (-4.0d0)) / c_m
else
tmp = ((y / (c_m * z)) * x) * 9.0d0
end if
code = c_s * tmp
end function
c\_m = Math.abs(c);
c\_s = Math.copySign(1.0, c);
assert x < y && y < z && z < t && t < a && a < b && b < c_m;
public static double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
double t_1 = (x * 9.0) * y;
double tmp;
if (t_1 <= -4e+134) {
tmp = -((((y / c_m) / z) * -9.0) * x);
} else if (t_1 <= -1e-198) {
tmp = -4.0 * ((a * t) / c_m);
} else if (t_1 <= 1e-252) {
tmp = (b / c_m) / z;
} else if (t_1 <= 2e+38) {
tmp = ((a * t) * -4.0) / c_m;
} else {
tmp = ((y / (c_m * z)) * x) * 9.0;
}
return c_s * tmp;
}
c\_m = math.fabs(c) c\_s = math.copysign(1.0, c) [x, y, z, t, a, b, c_m] = sort([x, y, z, t, a, b, c_m]) def code(c_s, x, y, z, t, a, b, c_m): t_1 = (x * 9.0) * y tmp = 0 if t_1 <= -4e+134: tmp = -((((y / c_m) / z) * -9.0) * x) elif t_1 <= -1e-198: tmp = -4.0 * ((a * t) / c_m) elif t_1 <= 1e-252: tmp = (b / c_m) / z elif t_1 <= 2e+38: tmp = ((a * t) * -4.0) / c_m else: tmp = ((y / (c_m * z)) * x) * 9.0 return c_s * tmp
c\_m = abs(c) c\_s = copysign(1.0, c) x, y, z, t, a, b, c_m = sort([x, y, z, t, a, b, c_m]) function code(c_s, x, y, z, t, a, b, c_m) t_1 = Float64(Float64(x * 9.0) * y) tmp = 0.0 if (t_1 <= -4e+134) tmp = Float64(-Float64(Float64(Float64(Float64(y / c_m) / z) * -9.0) * x)); elseif (t_1 <= -1e-198) tmp = Float64(-4.0 * Float64(Float64(a * t) / c_m)); elseif (t_1 <= 1e-252) tmp = Float64(Float64(b / c_m) / z); elseif (t_1 <= 2e+38) tmp = Float64(Float64(Float64(a * t) * -4.0) / c_m); else tmp = Float64(Float64(Float64(y / Float64(c_m * z)) * x) * 9.0); end return Float64(c_s * tmp) end
c\_m = abs(c);
c\_s = sign(c) * abs(1.0);
x, y, z, t, a, b, c_m = num2cell(sort([x, y, z, t, a, b, c_m])){:}
function tmp_2 = code(c_s, x, y, z, t, a, b, c_m)
t_1 = (x * 9.0) * y;
tmp = 0.0;
if (t_1 <= -4e+134)
tmp = -((((y / c_m) / z) * -9.0) * x);
elseif (t_1 <= -1e-198)
tmp = -4.0 * ((a * t) / c_m);
elseif (t_1 <= 1e-252)
tmp = (b / c_m) / z;
elseif (t_1 <= 2e+38)
tmp = ((a * t) * -4.0) / c_m;
else
tmp = ((y / (c_m * z)) * x) * 9.0;
end
tmp_2 = c_s * tmp;
end
c\_m = N[Abs[c], $MachinePrecision]
c\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
code[c$95$s_, x_, y_, z_, t_, a_, b_, c$95$m_] := Block[{t$95$1 = N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision]}, N[(c$95$s * If[LessEqual[t$95$1, -4e+134], (-N[(N[(N[(N[(y / c$95$m), $MachinePrecision] / z), $MachinePrecision] * -9.0), $MachinePrecision] * x), $MachinePrecision]), If[LessEqual[t$95$1, -1e-198], N[(-4.0 * N[(N[(a * t), $MachinePrecision] / c$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-252], N[(N[(b / c$95$m), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t$95$1, 2e+38], N[(N[(N[(a * t), $MachinePrecision] * -4.0), $MachinePrecision] / c$95$m), $MachinePrecision], N[(N[(N[(y / N[(c$95$m * z), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * 9.0), $MachinePrecision]]]]]), $MachinePrecision]]
\begin{array}{l}
c\_m = \left|c\right|
\\
c\_s = \mathsf{copysign}\left(1, c\right)
\\
[x, y, z, t, a, b, c_m] = \mathsf{sort}([x, y, z, t, a, b, c_m])\\
\\
\begin{array}{l}
t_1 := \left(x \cdot 9\right) \cdot y\\
c\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+134}:\\
\;\;\;\;-\left(\frac{\frac{y}{c\_m}}{z} \cdot -9\right) \cdot x\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-198}:\\
\;\;\;\;-4 \cdot \frac{a \cdot t}{c\_m}\\
\mathbf{elif}\;t\_1 \leq 10^{-252}:\\
\;\;\;\;\frac{\frac{b}{c\_m}}{z}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+38}:\\
\;\;\;\;\frac{\left(a \cdot t\right) \cdot -4}{c\_m}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{y}{c\_m \cdot z} \cdot x\right) \cdot 9\\
\end{array}
\end{array}
\end{array}
if (*.f64 (*.f64 x #s(literal 9 binary64)) y) < -3.99999999999999969e134Initial program 78.7%
Taylor expanded in x around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f6436.8
Applied rewrites36.8%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6437.0
Applied rewrites37.0%
if -3.99999999999999969e134 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < -9.9999999999999991e-199Initial program 78.7%
Taylor expanded in z around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6438.4
Applied rewrites38.4%
if -9.9999999999999991e-199 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < 9.99999999999999943e-253Initial program 78.7%
Taylor expanded in b around inf
lower-/.f64N/A
lower-*.f6435.9
Applied rewrites35.9%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6435.0
Applied rewrites35.0%
if 9.99999999999999943e-253 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < 1.99999999999999995e38Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites77.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lift-*.f6438.4
Applied rewrites38.4%
if 1.99999999999999995e38 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites77.8%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6485.7
Applied rewrites85.7%
lift-*.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
div-addN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-*r/N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
associate--l+N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
Applied rewrites84.2%
Taylor expanded in x around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f6436.8
Applied rewrites36.8%
c\_m = (fabs.f64 c)
c\_s = (copysign.f64 #s(literal 1 binary64) c)
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
(FPCore (c_s x y z t a b c_m)
:precision binary64
(let* ((t_1 (* (* x 9.0) y)))
(*
c_s
(if (<= t_1 -5000.0)
(- (/ (* (* -9.0 x) y) (* c_m z)))
(if (<= t_1 -1e-198)
(* -4.0 (/ (* a t) c_m))
(if (<= t_1 1e-252)
(/ (/ b c_m) z)
(if (<= t_1 2e+38)
(/ (* (* a t) -4.0) c_m)
(* (* (/ y (* c_m z)) x) 9.0))))))))c\_m = fabs(c);
c\_s = copysign(1.0, c);
assert(x < y && y < z && z < t && t < a && a < b && b < c_m);
double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
double t_1 = (x * 9.0) * y;
double tmp;
if (t_1 <= -5000.0) {
tmp = -(((-9.0 * x) * y) / (c_m * z));
} else if (t_1 <= -1e-198) {
tmp = -4.0 * ((a * t) / c_m);
} else if (t_1 <= 1e-252) {
tmp = (b / c_m) / z;
} else if (t_1 <= 2e+38) {
tmp = ((a * t) * -4.0) / c_m;
} else {
tmp = ((y / (c_m * z)) * x) * 9.0;
}
return c_s * tmp;
}
c\_m = private
c\_s = private
NOTE: x, y, z, t, a, b, and c_m 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(c_s, x, y, z, t, a, b, c_m)
use fmin_fmax_functions
real(8), intent (in) :: c_s
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_m
real(8) :: t_1
real(8) :: tmp
t_1 = (x * 9.0d0) * y
if (t_1 <= (-5000.0d0)) then
tmp = -((((-9.0d0) * x) * y) / (c_m * z))
else if (t_1 <= (-1d-198)) then
tmp = (-4.0d0) * ((a * t) / c_m)
else if (t_1 <= 1d-252) then
tmp = (b / c_m) / z
else if (t_1 <= 2d+38) then
tmp = ((a * t) * (-4.0d0)) / c_m
else
tmp = ((y / (c_m * z)) * x) * 9.0d0
end if
code = c_s * tmp
end function
c\_m = Math.abs(c);
c\_s = Math.copySign(1.0, c);
assert x < y && y < z && z < t && t < a && a < b && b < c_m;
public static double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
double t_1 = (x * 9.0) * y;
double tmp;
if (t_1 <= -5000.0) {
tmp = -(((-9.0 * x) * y) / (c_m * z));
} else if (t_1 <= -1e-198) {
tmp = -4.0 * ((a * t) / c_m);
} else if (t_1 <= 1e-252) {
tmp = (b / c_m) / z;
} else if (t_1 <= 2e+38) {
tmp = ((a * t) * -4.0) / c_m;
} else {
tmp = ((y / (c_m * z)) * x) * 9.0;
}
return c_s * tmp;
}
c\_m = math.fabs(c) c\_s = math.copysign(1.0, c) [x, y, z, t, a, b, c_m] = sort([x, y, z, t, a, b, c_m]) def code(c_s, x, y, z, t, a, b, c_m): t_1 = (x * 9.0) * y tmp = 0 if t_1 <= -5000.0: tmp = -(((-9.0 * x) * y) / (c_m * z)) elif t_1 <= -1e-198: tmp = -4.0 * ((a * t) / c_m) elif t_1 <= 1e-252: tmp = (b / c_m) / z elif t_1 <= 2e+38: tmp = ((a * t) * -4.0) / c_m else: tmp = ((y / (c_m * z)) * x) * 9.0 return c_s * tmp
c\_m = abs(c) c\_s = copysign(1.0, c) x, y, z, t, a, b, c_m = sort([x, y, z, t, a, b, c_m]) function code(c_s, x, y, z, t, a, b, c_m) t_1 = Float64(Float64(x * 9.0) * y) tmp = 0.0 if (t_1 <= -5000.0) tmp = Float64(-Float64(Float64(Float64(-9.0 * x) * y) / Float64(c_m * z))); elseif (t_1 <= -1e-198) tmp = Float64(-4.0 * Float64(Float64(a * t) / c_m)); elseif (t_1 <= 1e-252) tmp = Float64(Float64(b / c_m) / z); elseif (t_1 <= 2e+38) tmp = Float64(Float64(Float64(a * t) * -4.0) / c_m); else tmp = Float64(Float64(Float64(y / Float64(c_m * z)) * x) * 9.0); end return Float64(c_s * tmp) end
c\_m = abs(c);
c\_s = sign(c) * abs(1.0);
x, y, z, t, a, b, c_m = num2cell(sort([x, y, z, t, a, b, c_m])){:}
function tmp_2 = code(c_s, x, y, z, t, a, b, c_m)
t_1 = (x * 9.0) * y;
tmp = 0.0;
if (t_1 <= -5000.0)
tmp = -(((-9.0 * x) * y) / (c_m * z));
elseif (t_1 <= -1e-198)
tmp = -4.0 * ((a * t) / c_m);
elseif (t_1 <= 1e-252)
tmp = (b / c_m) / z;
elseif (t_1 <= 2e+38)
tmp = ((a * t) * -4.0) / c_m;
else
tmp = ((y / (c_m * z)) * x) * 9.0;
end
tmp_2 = c_s * tmp;
end
c\_m = N[Abs[c], $MachinePrecision]
c\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
code[c$95$s_, x_, y_, z_, t_, a_, b_, c$95$m_] := Block[{t$95$1 = N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision]}, N[(c$95$s * If[LessEqual[t$95$1, -5000.0], (-N[(N[(N[(-9.0 * x), $MachinePrecision] * y), $MachinePrecision] / N[(c$95$m * z), $MachinePrecision]), $MachinePrecision]), If[LessEqual[t$95$1, -1e-198], N[(-4.0 * N[(N[(a * t), $MachinePrecision] / c$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-252], N[(N[(b / c$95$m), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t$95$1, 2e+38], N[(N[(N[(a * t), $MachinePrecision] * -4.0), $MachinePrecision] / c$95$m), $MachinePrecision], N[(N[(N[(y / N[(c$95$m * z), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * 9.0), $MachinePrecision]]]]]), $MachinePrecision]]
\begin{array}{l}
c\_m = \left|c\right|
\\
c\_s = \mathsf{copysign}\left(1, c\right)
\\
[x, y, z, t, a, b, c_m] = \mathsf{sort}([x, y, z, t, a, b, c_m])\\
\\
\begin{array}{l}
t_1 := \left(x \cdot 9\right) \cdot y\\
c\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq -5000:\\
\;\;\;\;-\frac{\left(-9 \cdot x\right) \cdot y}{c\_m \cdot z}\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-198}:\\
\;\;\;\;-4 \cdot \frac{a \cdot t}{c\_m}\\
\mathbf{elif}\;t\_1 \leq 10^{-252}:\\
\;\;\;\;\frac{\frac{b}{c\_m}}{z}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+38}:\\
\;\;\;\;\frac{\left(a \cdot t\right) \cdot -4}{c\_m}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{y}{c\_m \cdot z} \cdot x\right) \cdot 9\\
\end{array}
\end{array}
\end{array}
if (*.f64 (*.f64 x #s(literal 9 binary64)) y) < -5e3Initial program 78.7%
Taylor expanded in x around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f6436.8
Applied rewrites36.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f6436.8
Applied rewrites36.8%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-*r/N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f6434.7
Applied rewrites34.7%
if -5e3 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < -9.9999999999999991e-199Initial program 78.7%
Taylor expanded in z around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6438.4
Applied rewrites38.4%
if -9.9999999999999991e-199 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < 9.99999999999999943e-253Initial program 78.7%
Taylor expanded in b around inf
lower-/.f64N/A
lower-*.f6435.9
Applied rewrites35.9%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6435.0
Applied rewrites35.0%
if 9.99999999999999943e-253 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < 1.99999999999999995e38Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites77.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lift-*.f6438.4
Applied rewrites38.4%
if 1.99999999999999995e38 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites77.8%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6485.7
Applied rewrites85.7%
lift-*.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
div-addN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-*r/N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
associate--l+N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
Applied rewrites84.2%
Taylor expanded in x around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f6436.8
Applied rewrites36.8%
c\_m = (fabs.f64 c)
c\_s = (copysign.f64 #s(literal 1 binary64) c)
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
(FPCore (c_s x y z t a b c_m)
:precision binary64
(let* ((t_1 (* (* x 9.0) y)))
(*
c_s
(if (<= t_1 -5000.0)
(/ (* (* y x) 9.0) (* c_m z))
(if (<= t_1 -1e-198)
(* -4.0 (/ (* a t) c_m))
(if (<= t_1 1e-252)
(/ (/ b c_m) z)
(if (<= t_1 2e+38)
(/ (* (* a t) -4.0) c_m)
(* (* (/ y (* c_m z)) x) 9.0))))))))c\_m = fabs(c);
c\_s = copysign(1.0, c);
assert(x < y && y < z && z < t && t < a && a < b && b < c_m);
double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
double t_1 = (x * 9.0) * y;
double tmp;
if (t_1 <= -5000.0) {
tmp = ((y * x) * 9.0) / (c_m * z);
} else if (t_1 <= -1e-198) {
tmp = -4.0 * ((a * t) / c_m);
} else if (t_1 <= 1e-252) {
tmp = (b / c_m) / z;
} else if (t_1 <= 2e+38) {
tmp = ((a * t) * -4.0) / c_m;
} else {
tmp = ((y / (c_m * z)) * x) * 9.0;
}
return c_s * tmp;
}
c\_m = private
c\_s = private
NOTE: x, y, z, t, a, b, and c_m 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(c_s, x, y, z, t, a, b, c_m)
use fmin_fmax_functions
real(8), intent (in) :: c_s
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_m
real(8) :: t_1
real(8) :: tmp
t_1 = (x * 9.0d0) * y
if (t_1 <= (-5000.0d0)) then
tmp = ((y * x) * 9.0d0) / (c_m * z)
else if (t_1 <= (-1d-198)) then
tmp = (-4.0d0) * ((a * t) / c_m)
else if (t_1 <= 1d-252) then
tmp = (b / c_m) / z
else if (t_1 <= 2d+38) then
tmp = ((a * t) * (-4.0d0)) / c_m
else
tmp = ((y / (c_m * z)) * x) * 9.0d0
end if
code = c_s * tmp
end function
c\_m = Math.abs(c);
c\_s = Math.copySign(1.0, c);
assert x < y && y < z && z < t && t < a && a < b && b < c_m;
public static double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
double t_1 = (x * 9.0) * y;
double tmp;
if (t_1 <= -5000.0) {
tmp = ((y * x) * 9.0) / (c_m * z);
} else if (t_1 <= -1e-198) {
tmp = -4.0 * ((a * t) / c_m);
} else if (t_1 <= 1e-252) {
tmp = (b / c_m) / z;
} else if (t_1 <= 2e+38) {
tmp = ((a * t) * -4.0) / c_m;
} else {
tmp = ((y / (c_m * z)) * x) * 9.0;
}
return c_s * tmp;
}
c\_m = math.fabs(c) c\_s = math.copysign(1.0, c) [x, y, z, t, a, b, c_m] = sort([x, y, z, t, a, b, c_m]) def code(c_s, x, y, z, t, a, b, c_m): t_1 = (x * 9.0) * y tmp = 0 if t_1 <= -5000.0: tmp = ((y * x) * 9.0) / (c_m * z) elif t_1 <= -1e-198: tmp = -4.0 * ((a * t) / c_m) elif t_1 <= 1e-252: tmp = (b / c_m) / z elif t_1 <= 2e+38: tmp = ((a * t) * -4.0) / c_m else: tmp = ((y / (c_m * z)) * x) * 9.0 return c_s * tmp
c\_m = abs(c) c\_s = copysign(1.0, c) x, y, z, t, a, b, c_m = sort([x, y, z, t, a, b, c_m]) function code(c_s, x, y, z, t, a, b, c_m) t_1 = Float64(Float64(x * 9.0) * y) tmp = 0.0 if (t_1 <= -5000.0) tmp = Float64(Float64(Float64(y * x) * 9.0) / Float64(c_m * z)); elseif (t_1 <= -1e-198) tmp = Float64(-4.0 * Float64(Float64(a * t) / c_m)); elseif (t_1 <= 1e-252) tmp = Float64(Float64(b / c_m) / z); elseif (t_1 <= 2e+38) tmp = Float64(Float64(Float64(a * t) * -4.0) / c_m); else tmp = Float64(Float64(Float64(y / Float64(c_m * z)) * x) * 9.0); end return Float64(c_s * tmp) end
c\_m = abs(c);
c\_s = sign(c) * abs(1.0);
x, y, z, t, a, b, c_m = num2cell(sort([x, y, z, t, a, b, c_m])){:}
function tmp_2 = code(c_s, x, y, z, t, a, b, c_m)
t_1 = (x * 9.0) * y;
tmp = 0.0;
if (t_1 <= -5000.0)
tmp = ((y * x) * 9.0) / (c_m * z);
elseif (t_1 <= -1e-198)
tmp = -4.0 * ((a * t) / c_m);
elseif (t_1 <= 1e-252)
tmp = (b / c_m) / z;
elseif (t_1 <= 2e+38)
tmp = ((a * t) * -4.0) / c_m;
else
tmp = ((y / (c_m * z)) * x) * 9.0;
end
tmp_2 = c_s * tmp;
end
c\_m = N[Abs[c], $MachinePrecision]
c\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
code[c$95$s_, x_, y_, z_, t_, a_, b_, c$95$m_] := Block[{t$95$1 = N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision]}, N[(c$95$s * If[LessEqual[t$95$1, -5000.0], N[(N[(N[(y * x), $MachinePrecision] * 9.0), $MachinePrecision] / N[(c$95$m * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -1e-198], N[(-4.0 * N[(N[(a * t), $MachinePrecision] / c$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-252], N[(N[(b / c$95$m), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t$95$1, 2e+38], N[(N[(N[(a * t), $MachinePrecision] * -4.0), $MachinePrecision] / c$95$m), $MachinePrecision], N[(N[(N[(y / N[(c$95$m * z), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * 9.0), $MachinePrecision]]]]]), $MachinePrecision]]
\begin{array}{l}
c\_m = \left|c\right|
\\
c\_s = \mathsf{copysign}\left(1, c\right)
\\
[x, y, z, t, a, b, c_m] = \mathsf{sort}([x, y, z, t, a, b, c_m])\\
\\
\begin{array}{l}
t_1 := \left(x \cdot 9\right) \cdot y\\
c\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq -5000:\\
\;\;\;\;\frac{\left(y \cdot x\right) \cdot 9}{c\_m \cdot z}\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-198}:\\
\;\;\;\;-4 \cdot \frac{a \cdot t}{c\_m}\\
\mathbf{elif}\;t\_1 \leq 10^{-252}:\\
\;\;\;\;\frac{\frac{b}{c\_m}}{z}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+38}:\\
\;\;\;\;\frac{\left(a \cdot t\right) \cdot -4}{c\_m}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{y}{c\_m \cdot z} \cdot x\right) \cdot 9\\
\end{array}
\end{array}
\end{array}
if (*.f64 (*.f64 x #s(literal 9 binary64)) y) < -5e3Initial program 78.7%
Taylor expanded in x around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6434.7
Applied rewrites34.7%
if -5e3 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < -9.9999999999999991e-199Initial program 78.7%
Taylor expanded in z around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6438.4
Applied rewrites38.4%
if -9.9999999999999991e-199 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < 9.99999999999999943e-253Initial program 78.7%
Taylor expanded in b around inf
lower-/.f64N/A
lower-*.f6435.9
Applied rewrites35.9%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6435.0
Applied rewrites35.0%
if 9.99999999999999943e-253 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < 1.99999999999999995e38Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites77.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lift-*.f6438.4
Applied rewrites38.4%
if 1.99999999999999995e38 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites77.8%
Taylor expanded in x around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6485.7
Applied rewrites85.7%
lift-*.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
div-addN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-*r/N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
associate--l+N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
Applied rewrites84.2%
Taylor expanded in x around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f6436.8
Applied rewrites36.8%
c\_m = (fabs.f64 c)
c\_s = (copysign.f64 #s(literal 1 binary64) c)
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
(FPCore (c_s x y z t a b c_m)
:precision binary64
(let* ((t_1 (/ (* (* y x) 9.0) (* c_m z))) (t_2 (* (* x 9.0) y)))
(*
c_s
(if (<= t_2 -5000.0)
t_1
(if (<= t_2 -1e-198)
(* -4.0 (/ (* a t) c_m))
(if (<= t_2 1e-252)
(/ (/ b c_m) z)
(if (<= t_2 2e+38) (/ (* (* a t) -4.0) c_m) t_1)))))))c\_m = fabs(c);
c\_s = copysign(1.0, c);
assert(x < y && y < z && z < t && t < a && a < b && b < c_m);
double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
double t_1 = ((y * x) * 9.0) / (c_m * z);
double t_2 = (x * 9.0) * y;
double tmp;
if (t_2 <= -5000.0) {
tmp = t_1;
} else if (t_2 <= -1e-198) {
tmp = -4.0 * ((a * t) / c_m);
} else if (t_2 <= 1e-252) {
tmp = (b / c_m) / z;
} else if (t_2 <= 2e+38) {
tmp = ((a * t) * -4.0) / c_m;
} else {
tmp = t_1;
}
return c_s * tmp;
}
c\_m = private
c\_s = private
NOTE: x, y, z, t, a, b, and c_m 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(c_s, x, y, z, t, a, b, c_m)
use fmin_fmax_functions
real(8), intent (in) :: c_s
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_m
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = ((y * x) * 9.0d0) / (c_m * z)
t_2 = (x * 9.0d0) * y
if (t_2 <= (-5000.0d0)) then
tmp = t_1
else if (t_2 <= (-1d-198)) then
tmp = (-4.0d0) * ((a * t) / c_m)
else if (t_2 <= 1d-252) then
tmp = (b / c_m) / z
else if (t_2 <= 2d+38) then
tmp = ((a * t) * (-4.0d0)) / c_m
else
tmp = t_1
end if
code = c_s * tmp
end function
c\_m = Math.abs(c);
c\_s = Math.copySign(1.0, c);
assert x < y && y < z && z < t && t < a && a < b && b < c_m;
public static double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
double t_1 = ((y * x) * 9.0) / (c_m * z);
double t_2 = (x * 9.0) * y;
double tmp;
if (t_2 <= -5000.0) {
tmp = t_1;
} else if (t_2 <= -1e-198) {
tmp = -4.0 * ((a * t) / c_m);
} else if (t_2 <= 1e-252) {
tmp = (b / c_m) / z;
} else if (t_2 <= 2e+38) {
tmp = ((a * t) * -4.0) / c_m;
} else {
tmp = t_1;
}
return c_s * tmp;
}
c\_m = math.fabs(c) c\_s = math.copysign(1.0, c) [x, y, z, t, a, b, c_m] = sort([x, y, z, t, a, b, c_m]) def code(c_s, x, y, z, t, a, b, c_m): t_1 = ((y * x) * 9.0) / (c_m * z) t_2 = (x * 9.0) * y tmp = 0 if t_2 <= -5000.0: tmp = t_1 elif t_2 <= -1e-198: tmp = -4.0 * ((a * t) / c_m) elif t_2 <= 1e-252: tmp = (b / c_m) / z elif t_2 <= 2e+38: tmp = ((a * t) * -4.0) / c_m else: tmp = t_1 return c_s * tmp
c\_m = abs(c) c\_s = copysign(1.0, c) x, y, z, t, a, b, c_m = sort([x, y, z, t, a, b, c_m]) function code(c_s, x, y, z, t, a, b, c_m) t_1 = Float64(Float64(Float64(y * x) * 9.0) / Float64(c_m * z)) t_2 = Float64(Float64(x * 9.0) * y) tmp = 0.0 if (t_2 <= -5000.0) tmp = t_1; elseif (t_2 <= -1e-198) tmp = Float64(-4.0 * Float64(Float64(a * t) / c_m)); elseif (t_2 <= 1e-252) tmp = Float64(Float64(b / c_m) / z); elseif (t_2 <= 2e+38) tmp = Float64(Float64(Float64(a * t) * -4.0) / c_m); else tmp = t_1; end return Float64(c_s * tmp) end
c\_m = abs(c);
c\_s = sign(c) * abs(1.0);
x, y, z, t, a, b, c_m = num2cell(sort([x, y, z, t, a, b, c_m])){:}
function tmp_2 = code(c_s, x, y, z, t, a, b, c_m)
t_1 = ((y * x) * 9.0) / (c_m * z);
t_2 = (x * 9.0) * y;
tmp = 0.0;
if (t_2 <= -5000.0)
tmp = t_1;
elseif (t_2 <= -1e-198)
tmp = -4.0 * ((a * t) / c_m);
elseif (t_2 <= 1e-252)
tmp = (b / c_m) / z;
elseif (t_2 <= 2e+38)
tmp = ((a * t) * -4.0) / c_m;
else
tmp = t_1;
end
tmp_2 = c_s * tmp;
end
c\_m = N[Abs[c], $MachinePrecision]
c\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
code[c$95$s_, x_, y_, z_, t_, a_, b_, c$95$m_] := Block[{t$95$1 = N[(N[(N[(y * x), $MachinePrecision] * 9.0), $MachinePrecision] / N[(c$95$m * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision]}, N[(c$95$s * If[LessEqual[t$95$2, -5000.0], t$95$1, If[LessEqual[t$95$2, -1e-198], N[(-4.0 * N[(N[(a * t), $MachinePrecision] / c$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e-252], N[(N[(b / c$95$m), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t$95$2, 2e+38], N[(N[(N[(a * t), $MachinePrecision] * -4.0), $MachinePrecision] / c$95$m), $MachinePrecision], t$95$1]]]]), $MachinePrecision]]]
\begin{array}{l}
c\_m = \left|c\right|
\\
c\_s = \mathsf{copysign}\left(1, c\right)
\\
[x, y, z, t, a, b, c_m] = \mathsf{sort}([x, y, z, t, a, b, c_m])\\
\\
\begin{array}{l}
t_1 := \frac{\left(y \cdot x\right) \cdot 9}{c\_m \cdot z}\\
t_2 := \left(x \cdot 9\right) \cdot y\\
c\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -5000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -1 \cdot 10^{-198}:\\
\;\;\;\;-4 \cdot \frac{a \cdot t}{c\_m}\\
\mathbf{elif}\;t\_2 \leq 10^{-252}:\\
\;\;\;\;\frac{\frac{b}{c\_m}}{z}\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+38}:\\
\;\;\;\;\frac{\left(a \cdot t\right) \cdot -4}{c\_m}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
\end{array}
if (*.f64 (*.f64 x #s(literal 9 binary64)) y) < -5e3 or 1.99999999999999995e38 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) Initial program 78.7%
Taylor expanded in x around inf
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6434.7
Applied rewrites34.7%
if -5e3 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < -9.9999999999999991e-199Initial program 78.7%
Taylor expanded in z around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6438.4
Applied rewrites38.4%
if -9.9999999999999991e-199 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < 9.99999999999999943e-253Initial program 78.7%
Taylor expanded in b around inf
lower-/.f64N/A
lower-*.f6435.9
Applied rewrites35.9%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6435.0
Applied rewrites35.0%
if 9.99999999999999943e-253 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < 1.99999999999999995e38Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites77.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lift-*.f6438.4
Applied rewrites38.4%
c\_m = (fabs.f64 c)
c\_s = (copysign.f64 #s(literal 1 binary64) c)
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
(FPCore (c_s x y z t a b c_m)
:precision binary64
(*
c_s
(if (<= b -1.12e+67)
(/ (/ b c_m) z)
(if (<= b 1.06e+29) (/ (* (* a t) -4.0) c_m) (/ b (* c_m z))))))c\_m = fabs(c);
c\_s = copysign(1.0, c);
assert(x < y && y < z && z < t && t < a && a < b && b < c_m);
double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
double tmp;
if (b <= -1.12e+67) {
tmp = (b / c_m) / z;
} else if (b <= 1.06e+29) {
tmp = ((a * t) * -4.0) / c_m;
} else {
tmp = b / (c_m * z);
}
return c_s * tmp;
}
c\_m = private
c\_s = private
NOTE: x, y, z, t, a, b, and c_m 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(c_s, x, y, z, t, a, b, c_m)
use fmin_fmax_functions
real(8), intent (in) :: c_s
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_m
real(8) :: tmp
if (b <= (-1.12d+67)) then
tmp = (b / c_m) / z
else if (b <= 1.06d+29) then
tmp = ((a * t) * (-4.0d0)) / c_m
else
tmp = b / (c_m * z)
end if
code = c_s * tmp
end function
c\_m = Math.abs(c);
c\_s = Math.copySign(1.0, c);
assert x < y && y < z && z < t && t < a && a < b && b < c_m;
public static double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
double tmp;
if (b <= -1.12e+67) {
tmp = (b / c_m) / z;
} else if (b <= 1.06e+29) {
tmp = ((a * t) * -4.0) / c_m;
} else {
tmp = b / (c_m * z);
}
return c_s * tmp;
}
c\_m = math.fabs(c) c\_s = math.copysign(1.0, c) [x, y, z, t, a, b, c_m] = sort([x, y, z, t, a, b, c_m]) def code(c_s, x, y, z, t, a, b, c_m): tmp = 0 if b <= -1.12e+67: tmp = (b / c_m) / z elif b <= 1.06e+29: tmp = ((a * t) * -4.0) / c_m else: tmp = b / (c_m * z) return c_s * tmp
c\_m = abs(c) c\_s = copysign(1.0, c) x, y, z, t, a, b, c_m = sort([x, y, z, t, a, b, c_m]) function code(c_s, x, y, z, t, a, b, c_m) tmp = 0.0 if (b <= -1.12e+67) tmp = Float64(Float64(b / c_m) / z); elseif (b <= 1.06e+29) tmp = Float64(Float64(Float64(a * t) * -4.0) / c_m); else tmp = Float64(b / Float64(c_m * z)); end return Float64(c_s * tmp) end
c\_m = abs(c);
c\_s = sign(c) * abs(1.0);
x, y, z, t, a, b, c_m = num2cell(sort([x, y, z, t, a, b, c_m])){:}
function tmp_2 = code(c_s, x, y, z, t, a, b, c_m)
tmp = 0.0;
if (b <= -1.12e+67)
tmp = (b / c_m) / z;
elseif (b <= 1.06e+29)
tmp = ((a * t) * -4.0) / c_m;
else
tmp = b / (c_m * z);
end
tmp_2 = c_s * tmp;
end
c\_m = N[Abs[c], $MachinePrecision]
c\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
code[c$95$s_, x_, y_, z_, t_, a_, b_, c$95$m_] := N[(c$95$s * If[LessEqual[b, -1.12e+67], N[(N[(b / c$95$m), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[b, 1.06e+29], N[(N[(N[(a * t), $MachinePrecision] * -4.0), $MachinePrecision] / c$95$m), $MachinePrecision], N[(b / N[(c$95$m * z), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
c\_m = \left|c\right|
\\
c\_s = \mathsf{copysign}\left(1, c\right)
\\
[x, y, z, t, a, b, c_m] = \mathsf{sort}([x, y, z, t, a, b, c_m])\\
\\
c\_s \cdot \begin{array}{l}
\mathbf{if}\;b \leq -1.12 \cdot 10^{+67}:\\
\;\;\;\;\frac{\frac{b}{c\_m}}{z}\\
\mathbf{elif}\;b \leq 1.06 \cdot 10^{+29}:\\
\;\;\;\;\frac{\left(a \cdot t\right) \cdot -4}{c\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c\_m \cdot z}\\
\end{array}
\end{array}
if b < -1.12e67Initial program 78.7%
Taylor expanded in b around inf
lower-/.f64N/A
lower-*.f6435.9
Applied rewrites35.9%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6435.0
Applied rewrites35.0%
if -1.12e67 < b < 1.0600000000000001e29Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites77.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lift-*.f6438.4
Applied rewrites38.4%
if 1.0600000000000001e29 < b Initial program 78.7%
Taylor expanded in b around inf
lower-/.f64N/A
lower-*.f6435.9
Applied rewrites35.9%
c\_m = (fabs.f64 c)
c\_s = (copysign.f64 #s(literal 1 binary64) c)
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
(FPCore (c_s x y z t a b c_m)
:precision binary64
(*
c_s
(if (<= b -1.12e+67)
(/ (/ b c_m) z)
(if (<= b 1.06e+29) (* -4.0 (/ (* a t) c_m)) (/ b (* c_m z))))))c\_m = fabs(c);
c\_s = copysign(1.0, c);
assert(x < y && y < z && z < t && t < a && a < b && b < c_m);
double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
double tmp;
if (b <= -1.12e+67) {
tmp = (b / c_m) / z;
} else if (b <= 1.06e+29) {
tmp = -4.0 * ((a * t) / c_m);
} else {
tmp = b / (c_m * z);
}
return c_s * tmp;
}
c\_m = private
c\_s = private
NOTE: x, y, z, t, a, b, and c_m 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(c_s, x, y, z, t, a, b, c_m)
use fmin_fmax_functions
real(8), intent (in) :: c_s
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_m
real(8) :: tmp
if (b <= (-1.12d+67)) then
tmp = (b / c_m) / z
else if (b <= 1.06d+29) then
tmp = (-4.0d0) * ((a * t) / c_m)
else
tmp = b / (c_m * z)
end if
code = c_s * tmp
end function
c\_m = Math.abs(c);
c\_s = Math.copySign(1.0, c);
assert x < y && y < z && z < t && t < a && a < b && b < c_m;
public static double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
double tmp;
if (b <= -1.12e+67) {
tmp = (b / c_m) / z;
} else if (b <= 1.06e+29) {
tmp = -4.0 * ((a * t) / c_m);
} else {
tmp = b / (c_m * z);
}
return c_s * tmp;
}
c\_m = math.fabs(c) c\_s = math.copysign(1.0, c) [x, y, z, t, a, b, c_m] = sort([x, y, z, t, a, b, c_m]) def code(c_s, x, y, z, t, a, b, c_m): tmp = 0 if b <= -1.12e+67: tmp = (b / c_m) / z elif b <= 1.06e+29: tmp = -4.0 * ((a * t) / c_m) else: tmp = b / (c_m * z) return c_s * tmp
c\_m = abs(c) c\_s = copysign(1.0, c) x, y, z, t, a, b, c_m = sort([x, y, z, t, a, b, c_m]) function code(c_s, x, y, z, t, a, b, c_m) tmp = 0.0 if (b <= -1.12e+67) tmp = Float64(Float64(b / c_m) / z); elseif (b <= 1.06e+29) tmp = Float64(-4.0 * Float64(Float64(a * t) / c_m)); else tmp = Float64(b / Float64(c_m * z)); end return Float64(c_s * tmp) end
c\_m = abs(c);
c\_s = sign(c) * abs(1.0);
x, y, z, t, a, b, c_m = num2cell(sort([x, y, z, t, a, b, c_m])){:}
function tmp_2 = code(c_s, x, y, z, t, a, b, c_m)
tmp = 0.0;
if (b <= -1.12e+67)
tmp = (b / c_m) / z;
elseif (b <= 1.06e+29)
tmp = -4.0 * ((a * t) / c_m);
else
tmp = b / (c_m * z);
end
tmp_2 = c_s * tmp;
end
c\_m = N[Abs[c], $MachinePrecision]
c\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
code[c$95$s_, x_, y_, z_, t_, a_, b_, c$95$m_] := N[(c$95$s * If[LessEqual[b, -1.12e+67], N[(N[(b / c$95$m), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[b, 1.06e+29], N[(-4.0 * N[(N[(a * t), $MachinePrecision] / c$95$m), $MachinePrecision]), $MachinePrecision], N[(b / N[(c$95$m * z), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
c\_m = \left|c\right|
\\
c\_s = \mathsf{copysign}\left(1, c\right)
\\
[x, y, z, t, a, b, c_m] = \mathsf{sort}([x, y, z, t, a, b, c_m])\\
\\
c\_s \cdot \begin{array}{l}
\mathbf{if}\;b \leq -1.12 \cdot 10^{+67}:\\
\;\;\;\;\frac{\frac{b}{c\_m}}{z}\\
\mathbf{elif}\;b \leq 1.06 \cdot 10^{+29}:\\
\;\;\;\;-4 \cdot \frac{a \cdot t}{c\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c\_m \cdot z}\\
\end{array}
\end{array}
if b < -1.12e67Initial program 78.7%
Taylor expanded in b around inf
lower-/.f64N/A
lower-*.f6435.9
Applied rewrites35.9%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6435.0
Applied rewrites35.0%
if -1.12e67 < b < 1.0600000000000001e29Initial program 78.7%
Taylor expanded in z around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6438.4
Applied rewrites38.4%
if 1.0600000000000001e29 < b Initial program 78.7%
Taylor expanded in b around inf
lower-/.f64N/A
lower-*.f6435.9
Applied rewrites35.9%
c\_m = (fabs.f64 c) c\_s = (copysign.f64 #s(literal 1 binary64) c) NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function. (FPCore (c_s x y z t a b c_m) :precision binary64 (* c_s (/ (/ b c_m) z)))
c\_m = fabs(c);
c\_s = copysign(1.0, c);
assert(x < y && y < z && z < t && t < a && a < b && b < c_m);
double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
return c_s * ((b / c_m) / z);
}
c\_m = private
c\_s = private
NOTE: x, y, z, t, a, b, and c_m 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(c_s, x, y, z, t, a, b, c_m)
use fmin_fmax_functions
real(8), intent (in) :: c_s
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_m
code = c_s * ((b / c_m) / z)
end function
c\_m = Math.abs(c);
c\_s = Math.copySign(1.0, c);
assert x < y && y < z && z < t && t < a && a < b && b < c_m;
public static double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
return c_s * ((b / c_m) / z);
}
c\_m = math.fabs(c) c\_s = math.copysign(1.0, c) [x, y, z, t, a, b, c_m] = sort([x, y, z, t, a, b, c_m]) def code(c_s, x, y, z, t, a, b, c_m): return c_s * ((b / c_m) / z)
c\_m = abs(c) c\_s = copysign(1.0, c) x, y, z, t, a, b, c_m = sort([x, y, z, t, a, b, c_m]) function code(c_s, x, y, z, t, a, b, c_m) return Float64(c_s * Float64(Float64(b / c_m) / z)) end
c\_m = abs(c);
c\_s = sign(c) * abs(1.0);
x, y, z, t, a, b, c_m = num2cell(sort([x, y, z, t, a, b, c_m])){:}
function tmp = code(c_s, x, y, z, t, a, b, c_m)
tmp = c_s * ((b / c_m) / z);
end
c\_m = N[Abs[c], $MachinePrecision]
c\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
code[c$95$s_, x_, y_, z_, t_, a_, b_, c$95$m_] := N[(c$95$s * N[(N[(b / c$95$m), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c\_m = \left|c\right|
\\
c\_s = \mathsf{copysign}\left(1, c\right)
\\
[x, y, z, t, a, b, c_m] = \mathsf{sort}([x, y, z, t, a, b, c_m])\\
\\
c\_s \cdot \frac{\frac{b}{c\_m}}{z}
\end{array}
Initial program 78.7%
Taylor expanded in b around inf
lower-/.f64N/A
lower-*.f6435.9
Applied rewrites35.9%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6435.0
Applied rewrites35.0%
c\_m = (fabs.f64 c) c\_s = (copysign.f64 #s(literal 1 binary64) c) NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function. (FPCore (c_s x y z t a b c_m) :precision binary64 (* c_s (/ b (* c_m z))))
c\_m = fabs(c);
c\_s = copysign(1.0, c);
assert(x < y && y < z && z < t && t < a && a < b && b < c_m);
double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
return c_s * (b / (c_m * z));
}
c\_m = private
c\_s = private
NOTE: x, y, z, t, a, b, and c_m 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(c_s, x, y, z, t, a, b, c_m)
use fmin_fmax_functions
real(8), intent (in) :: c_s
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_m
code = c_s * (b / (c_m * z))
end function
c\_m = Math.abs(c);
c\_s = Math.copySign(1.0, c);
assert x < y && y < z && z < t && t < a && a < b && b < c_m;
public static double code(double c_s, double x, double y, double z, double t, double a, double b, double c_m) {
return c_s * (b / (c_m * z));
}
c\_m = math.fabs(c) c\_s = math.copysign(1.0, c) [x, y, z, t, a, b, c_m] = sort([x, y, z, t, a, b, c_m]) def code(c_s, x, y, z, t, a, b, c_m): return c_s * (b / (c_m * z))
c\_m = abs(c) c\_s = copysign(1.0, c) x, y, z, t, a, b, c_m = sort([x, y, z, t, a, b, c_m]) function code(c_s, x, y, z, t, a, b, c_m) return Float64(c_s * Float64(b / Float64(c_m * z))) end
c\_m = abs(c);
c\_s = sign(c) * abs(1.0);
x, y, z, t, a, b, c_m = num2cell(sort([x, y, z, t, a, b, c_m])){:}
function tmp = code(c_s, x, y, z, t, a, b, c_m)
tmp = c_s * (b / (c_m * z));
end
c\_m = N[Abs[c], $MachinePrecision]
c\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x, y, z, t, a, b, and c_m should be sorted in increasing order before calling this function.
code[c$95$s_, x_, y_, z_, t_, a_, b_, c$95$m_] := N[(c$95$s * N[(b / N[(c$95$m * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c\_m = \left|c\right|
\\
c\_s = \mathsf{copysign}\left(1, c\right)
\\
[x, y, z, t, a, b, c_m] = \mathsf{sort}([x, y, z, t, a, b, c_m])\\
\\
c\_s \cdot \frac{b}{c\_m \cdot z}
\end{array}
Initial program 78.7%
Taylor expanded in b around inf
lower-/.f64N/A
lower-*.f6435.9
Applied rewrites35.9%
herbie shell --seed 2025139
(FPCore (x y z t a b c)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, J"
:precision binary64
(/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))