
(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 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 (* (* x 9.0) y))
(t_2 (/ (+ (- t_1 (* (* (* z 4.0) t) a)) b) (* z c_m))))
(*
c_s
(if (<= t_2 -1e-266)
(/ (+ (- t_1 (* (* 4.0 z) (* a t))) b) (* z c_m))
(if (<= t_2 0.0)
(/
(* (fma (/ x z) -9.0 (/ (fma (* a t) -4.0 (/ b z)) (- y))) (- y))
c_m)
(if (<= t_2 5e+275)
(/ (+ (fma x (* y 9.0) (* (* (* 4.0 z) (- t)) a)) b) (* z c_m))
(*
(fma (/ a c_m) -4.0 (/ (fma (* 9.0 x) y b) (* (* t z) c_m)))
t)))))))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 t_2 = ((t_1 - (((z * 4.0) * t) * a)) + b) / (z * c_m);
double tmp;
if (t_2 <= -1e-266) {
tmp = ((t_1 - ((4.0 * z) * (a * t))) + b) / (z * c_m);
} else if (t_2 <= 0.0) {
tmp = (fma((x / z), -9.0, (fma((a * t), -4.0, (b / z)) / -y)) * -y) / c_m;
} else if (t_2 <= 5e+275) {
tmp = (fma(x, (y * 9.0), (((4.0 * z) * -t) * a)) + b) / (z * c_m);
} else {
tmp = fma((a / c_m), -4.0, (fma((9.0 * x), y, b) / ((t * z) * c_m))) * t;
}
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) t_2 = Float64(Float64(Float64(t_1 - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c_m)) tmp = 0.0 if (t_2 <= -1e-266) tmp = Float64(Float64(Float64(t_1 - Float64(Float64(4.0 * z) * Float64(a * t))) + b) / Float64(z * c_m)); elseif (t_2 <= 0.0) tmp = Float64(Float64(fma(Float64(x / z), -9.0, Float64(fma(Float64(a * t), -4.0, Float64(b / z)) / Float64(-y))) * Float64(-y)) / c_m); elseif (t_2 <= 5e+275) tmp = Float64(Float64(fma(x, Float64(y * 9.0), Float64(Float64(Float64(4.0 * z) * Float64(-t)) * a)) + b) / Float64(z * c_m)); else tmp = Float64(fma(Float64(a / c_m), -4.0, Float64(fma(Float64(9.0 * x), y, b) / Float64(Float64(t * z) * c_m))) * t); 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]}, Block[{t$95$2 = N[(N[(N[(t$95$1 - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c$95$m), $MachinePrecision]), $MachinePrecision]}, N[(c$95$s * If[LessEqual[t$95$2, -1e-266], N[(N[(N[(t$95$1 - N[(N[(4.0 * z), $MachinePrecision] * N[(a * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(N[(N[(N[(x / z), $MachinePrecision] * -9.0 + N[(N[(N[(a * t), $MachinePrecision] * -4.0 + N[(b / z), $MachinePrecision]), $MachinePrecision] / (-y)), $MachinePrecision]), $MachinePrecision] * (-y)), $MachinePrecision] / c$95$m), $MachinePrecision], If[LessEqual[t$95$2, 5e+275], N[(N[(N[(x * N[(y * 9.0), $MachinePrecision] + N[(N[(N[(4.0 * z), $MachinePrecision] * (-t)), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a / c$95$m), $MachinePrecision] * -4.0 + N[(N[(N[(9.0 * x), $MachinePrecision] * y + b), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $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\\
t_2 := \frac{\left(t\_1 - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c\_m}\\
c\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{-266}:\\
\;\;\;\;\frac{\left(t\_1 - \left(4 \cdot z\right) \cdot \left(a \cdot t\right)\right) + b}{z \cdot c\_m}\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{x}{z}, -9, \frac{\mathsf{fma}\left(a \cdot t, -4, \frac{b}{z}\right)}{-y}\right) \cdot \left(-y\right)}{c\_m}\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+275}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y \cdot 9, \left(\left(4 \cdot z\right) \cdot \left(-t\right)\right) \cdot a\right) + b}{z \cdot c\_m}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{a}{c\_m}, -4, \frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{\left(t \cdot z\right) \cdot c\_m}\right) \cdot t\\
\end{array}
\end{array}
\end{array}
if (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) < -9.9999999999999998e-267Initial program 90.0%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6493.7
Applied rewrites93.7%
if -9.9999999999999998e-267 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) < 0.0Initial program 44.3%
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 rewrites94.4%
Taylor expanded in y around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.8%
if 0.0 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) < 5.0000000000000003e275Initial program 99.4%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
associate-*l*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.4
Applied rewrites99.4%
if 5.0000000000000003e275 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) Initial program 61.1%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites83.3%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6483.3
Applied rewrites83.3%
Final simplification90.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))
(t_2 (/ (+ (- t_1 (* (* (* z 4.0) t) a)) b) (* z c_m))))
(*
c_s
(if (<= t_2 -1e-266)
(/ (+ (- t_1 (* (* 4.0 z) (* a t))) b) (* z c_m))
(if (<= t_2 0.0)
(/ (/ (- (* (* y x) 9.0) (- (* (* (* 4.0 z) t) a) b)) z) c_m)
(if (<= t_2 5e+275)
(/ (+ (fma x (* y 9.0) (* (* (* 4.0 z) (- t)) a)) b) (* z c_m))
(*
(fma (/ a c_m) -4.0 (/ (fma (* 9.0 x) y b) (* (* t z) c_m)))
t)))))))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 t_2 = ((t_1 - (((z * 4.0) * t) * a)) + b) / (z * c_m);
double tmp;
if (t_2 <= -1e-266) {
tmp = ((t_1 - ((4.0 * z) * (a * t))) + b) / (z * c_m);
} else if (t_2 <= 0.0) {
tmp = ((((y * x) * 9.0) - ((((4.0 * z) * t) * a) - b)) / z) / c_m;
} else if (t_2 <= 5e+275) {
tmp = (fma(x, (y * 9.0), (((4.0 * z) * -t) * a)) + b) / (z * c_m);
} else {
tmp = fma((a / c_m), -4.0, (fma((9.0 * x), y, b) / ((t * z) * c_m))) * t;
}
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) t_2 = Float64(Float64(Float64(t_1 - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c_m)) tmp = 0.0 if (t_2 <= -1e-266) tmp = Float64(Float64(Float64(t_1 - Float64(Float64(4.0 * z) * Float64(a * t))) + b) / Float64(z * c_m)); elseif (t_2 <= 0.0) tmp = Float64(Float64(Float64(Float64(Float64(y * x) * 9.0) - Float64(Float64(Float64(Float64(4.0 * z) * t) * a) - b)) / z) / c_m); elseif (t_2 <= 5e+275) tmp = Float64(Float64(fma(x, Float64(y * 9.0), Float64(Float64(Float64(4.0 * z) * Float64(-t)) * a)) + b) / Float64(z * c_m)); else tmp = Float64(fma(Float64(a / c_m), -4.0, Float64(fma(Float64(9.0 * x), y, b) / Float64(Float64(t * z) * c_m))) * t); 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]}, Block[{t$95$2 = N[(N[(N[(t$95$1 - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c$95$m), $MachinePrecision]), $MachinePrecision]}, N[(c$95$s * If[LessEqual[t$95$2, -1e-266], N[(N[(N[(t$95$1 - N[(N[(4.0 * z), $MachinePrecision] * N[(a * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(N[(N[(N[(N[(y * x), $MachinePrecision] * 9.0), $MachinePrecision] - N[(N[(N[(N[(4.0 * z), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] / c$95$m), $MachinePrecision], If[LessEqual[t$95$2, 5e+275], N[(N[(N[(x * N[(y * 9.0), $MachinePrecision] + N[(N[(N[(4.0 * z), $MachinePrecision] * (-t)), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a / c$95$m), $MachinePrecision] * -4.0 + N[(N[(N[(9.0 * x), $MachinePrecision] * y + b), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $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\\
t_2 := \frac{\left(t\_1 - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c\_m}\\
c\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{-266}:\\
\;\;\;\;\frac{\left(t\_1 - \left(4 \cdot z\right) \cdot \left(a \cdot t\right)\right) + b}{z \cdot c\_m}\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;\frac{\frac{\left(y \cdot x\right) \cdot 9 - \left(\left(\left(4 \cdot z\right) \cdot t\right) \cdot a - b\right)}{z}}{c\_m}\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+275}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y \cdot 9, \left(\left(4 \cdot z\right) \cdot \left(-t\right)\right) \cdot a\right) + b}{z \cdot c\_m}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{a}{c\_m}, -4, \frac{\mathsf{fma}\left(9 \cdot x, y, b\right)}{\left(t \cdot z\right) \cdot c\_m}\right) \cdot t\\
\end{array}
\end{array}
\end{array}
if (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) < -9.9999999999999998e-267Initial program 90.0%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6493.7
Applied rewrites93.7%
if -9.9999999999999998e-267 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) < 0.0Initial program 44.3%
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 rewrites94.4%
if 0.0 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) < 5.0000000000000003e275Initial program 99.4%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
associate-*l*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.4
Applied rewrites99.4%
if 5.0000000000000003e275 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) Initial program 61.1%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites83.3%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6483.3
Applied rewrites83.3%
Final simplification90.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))
(t_2 (/ (+ (- t_1 (* (* (* z 4.0) t) a)) b) (* z c_m)))
(t_3 (/ (+ (- t_1 (* (* 4.0 z) (* a t))) b) (* z c_m))))
(*
c_s
(if (<= t_2 -1e-266)
t_3
(if (<= t_2 0.0)
(/ (/ (- (* (* y x) 9.0) (- (* (* (* 4.0 z) t) a) b)) z) c_m)
(if (<= t_2 INFINITY)
t_3
(* (/ (fma -4.0 t (/ b (* a z))) c_m) a)))))))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 t_2 = ((t_1 - (((z * 4.0) * t) * a)) + b) / (z * c_m);
double t_3 = ((t_1 - ((4.0 * z) * (a * t))) + b) / (z * c_m);
double tmp;
if (t_2 <= -1e-266) {
tmp = t_3;
} else if (t_2 <= 0.0) {
tmp = ((((y * x) * 9.0) - ((((4.0 * z) * t) * a) - b)) / z) / c_m;
} else if (t_2 <= ((double) INFINITY)) {
tmp = t_3;
} else {
tmp = (fma(-4.0, t, (b / (a * z))) / c_m) * a;
}
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) t_2 = Float64(Float64(Float64(t_1 - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c_m)) t_3 = Float64(Float64(Float64(t_1 - Float64(Float64(4.0 * z) * Float64(a * t))) + b) / Float64(z * c_m)) tmp = 0.0 if (t_2 <= -1e-266) tmp = t_3; elseif (t_2 <= 0.0) tmp = Float64(Float64(Float64(Float64(Float64(y * x) * 9.0) - Float64(Float64(Float64(Float64(4.0 * z) * t) * a) - b)) / z) / c_m); elseif (t_2 <= Inf) tmp = t_3; else tmp = Float64(Float64(fma(-4.0, t, Float64(b / Float64(a * z))) / c_m) * a); 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]}, Block[{t$95$2 = N[(N[(N[(t$95$1 - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(t$95$1 - N[(N[(4.0 * z), $MachinePrecision] * N[(a * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c$95$m), $MachinePrecision]), $MachinePrecision]}, N[(c$95$s * If[LessEqual[t$95$2, -1e-266], t$95$3, If[LessEqual[t$95$2, 0.0], N[(N[(N[(N[(N[(y * x), $MachinePrecision] * 9.0), $MachinePrecision] - N[(N[(N[(N[(4.0 * z), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] / c$95$m), $MachinePrecision], If[LessEqual[t$95$2, Infinity], t$95$3, N[(N[(N[(-4.0 * t + N[(b / N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision] * a), $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\\
t_2 := \frac{\left(t\_1 - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c\_m}\\
t_3 := \frac{\left(t\_1 - \left(4 \cdot z\right) \cdot \left(a \cdot t\right)\right) + b}{z \cdot c\_m}\\
c\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{-266}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;\frac{\frac{\left(y \cdot x\right) \cdot 9 - \left(\left(\left(4 \cdot z\right) \cdot t\right) \cdot a - b\right)}{z}}{c\_m}\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-4, t, \frac{b}{a \cdot z}\right)}{c\_m} \cdot a\\
\end{array}
\end{array}
\end{array}
if (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) < -9.9999999999999998e-267 or 0.0 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) < +inf.0Initial program 89.2%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6491.9
Applied rewrites91.9%
if -9.9999999999999998e-267 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) < 0.0Initial program 44.3%
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 rewrites94.4%
if +inf.0 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) Initial program 0.0%
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-*.f643.7
Applied rewrites3.7%
Taylor expanded in a around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6431.7
Applied rewrites31.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6483.7
Applied rewrites83.7%
Taylor expanded in c around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6483.7
Applied rewrites83.7%
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 (* (* (* z 4.0) t) a)) b) (* z c_m)) INFINITY)
(/ (+ (- t_1 (* (* 4.0 z) (* a t))) b) (* z c_m))
(* (/ (fma -4.0 t (/ b (* a z))) c_m) a)))))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 - (((z * 4.0) * t) * a)) + b) / (z * c_m)) <= ((double) INFINITY)) {
tmp = ((t_1 - ((4.0 * z) * (a * t))) + b) / (z * c_m);
} else {
tmp = (fma(-4.0, t, (b / (a * z))) / c_m) * a;
}
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 (Float64(Float64(Float64(t_1 - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c_m)) <= Inf) tmp = Float64(Float64(Float64(t_1 - Float64(Float64(4.0 * z) * Float64(a * t))) + b) / Float64(z * c_m)); else tmp = Float64(Float64(fma(-4.0, t, Float64(b / Float64(a * z))) / c_m) * a); 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[N[(N[(N[(t$95$1 - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c$95$m), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(t$95$1 - N[(N[(4.0 * z), $MachinePrecision] * N[(a * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * t + N[(b / N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision] * a), $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}\;\frac{\left(t\_1 - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c\_m} \leq \infty:\\
\;\;\;\;\frac{\left(t\_1 - \left(4 \cdot z\right) \cdot \left(a \cdot t\right)\right) + b}{z \cdot c\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-4, t, \frac{b}{a \cdot z}\right)}{c\_m} \cdot a\\
\end{array}
\end{array}
\end{array}
if (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) < +inf.0Initial program 85.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6488.4
Applied rewrites88.4%
if +inf.0 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) Initial program 0.0%
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-*.f643.7
Applied rewrites3.7%
Taylor expanded in a around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6431.7
Applied rewrites31.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6483.7
Applied rewrites83.7%
Taylor expanded in c around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6483.7
Applied rewrites83.7%
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 (/ (* (* 9.0 x) y) (* z c_m))) (t_2 (* (* x 9.0) y)))
(*
c_s
(if (<= t_2 -2e+183)
t_1
(if (<= t_2 -5e-225)
(* (* (/ a c_m) -4.0) t)
(if (<= t_2 2e-243)
(/ b (* z c_m))
(if (<= t_2 1e+15) (* (* (/ t c_m) -4.0) a) 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 = ((9.0 * x) * y) / (z * c_m);
double t_2 = (x * 9.0) * y;
double tmp;
if (t_2 <= -2e+183) {
tmp = t_1;
} else if (t_2 <= -5e-225) {
tmp = ((a / c_m) * -4.0) * t;
} else if (t_2 <= 2e-243) {
tmp = b / (z * c_m);
} else if (t_2 <= 1e+15) {
tmp = ((t / c_m) * -4.0) * a;
} 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 = ((9.0d0 * x) * y) / (z * c_m)
t_2 = (x * 9.0d0) * y
if (t_2 <= (-2d+183)) then
tmp = t_1
else if (t_2 <= (-5d-225)) then
tmp = ((a / c_m) * (-4.0d0)) * t
else if (t_2 <= 2d-243) then
tmp = b / (z * c_m)
else if (t_2 <= 1d+15) then
tmp = ((t / c_m) * (-4.0d0)) * a
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 = ((9.0 * x) * y) / (z * c_m);
double t_2 = (x * 9.0) * y;
double tmp;
if (t_2 <= -2e+183) {
tmp = t_1;
} else if (t_2 <= -5e-225) {
tmp = ((a / c_m) * -4.0) * t;
} else if (t_2 <= 2e-243) {
tmp = b / (z * c_m);
} else if (t_2 <= 1e+15) {
tmp = ((t / c_m) * -4.0) * a;
} 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 = ((9.0 * x) * y) / (z * c_m) t_2 = (x * 9.0) * y tmp = 0 if t_2 <= -2e+183: tmp = t_1 elif t_2 <= -5e-225: tmp = ((a / c_m) * -4.0) * t elif t_2 <= 2e-243: tmp = b / (z * c_m) elif t_2 <= 1e+15: tmp = ((t / c_m) * -4.0) * a 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(9.0 * x) * y) / Float64(z * c_m)) t_2 = Float64(Float64(x * 9.0) * y) tmp = 0.0 if (t_2 <= -2e+183) tmp = t_1; elseif (t_2 <= -5e-225) tmp = Float64(Float64(Float64(a / c_m) * -4.0) * t); elseif (t_2 <= 2e-243) tmp = Float64(b / Float64(z * c_m)); elseif (t_2 <= 1e+15) tmp = Float64(Float64(Float64(t / c_m) * -4.0) * a); 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 = ((9.0 * x) * y) / (z * c_m);
t_2 = (x * 9.0) * y;
tmp = 0.0;
if (t_2 <= -2e+183)
tmp = t_1;
elseif (t_2 <= -5e-225)
tmp = ((a / c_m) * -4.0) * t;
elseif (t_2 <= 2e-243)
tmp = b / (z * c_m);
elseif (t_2 <= 1e+15)
tmp = ((t / c_m) * -4.0) * a;
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[(9.0 * x), $MachinePrecision] * y), $MachinePrecision] / N[(z * c$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision]}, N[(c$95$s * If[LessEqual[t$95$2, -2e+183], t$95$1, If[LessEqual[t$95$2, -5e-225], N[(N[(N[(a / c$95$m), $MachinePrecision] * -4.0), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[t$95$2, 2e-243], N[(b / N[(z * c$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e+15], N[(N[(N[(t / c$95$m), $MachinePrecision] * -4.0), $MachinePrecision] * a), $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(9 \cdot x\right) \cdot y}{z \cdot c\_m}\\
t_2 := \left(x \cdot 9\right) \cdot y\\
c\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+183}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -5 \cdot 10^{-225}:\\
\;\;\;\;\left(\frac{a}{c\_m} \cdot -4\right) \cdot t\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-243}:\\
\;\;\;\;\frac{b}{z \cdot c\_m}\\
\mathbf{elif}\;t\_2 \leq 10^{+15}:\\
\;\;\;\;\left(\frac{t}{c\_m} \cdot -4\right) \cdot a\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
\end{array}
if (*.f64 (*.f64 x #s(literal 9 binary64)) y) < -1.99999999999999989e183 or 1e15 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) Initial program 77.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6471.8
Applied rewrites71.8%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
lift-*.f6465.5
Applied rewrites65.5%
if -1.99999999999999989e183 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < -5.0000000000000001e-225Initial program 64.4%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites80.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lift-/.f6460.2
Applied rewrites60.2%
if -5.0000000000000001e-225 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < 1.99999999999999999e-243Initial program 88.0%
Taylor expanded in b around inf
Applied rewrites66.9%
if 1.99999999999999999e-243 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < 1e15Initial program 88.1%
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-*.f6477.4
Applied rewrites77.4%
Taylor expanded in a around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6468.5
Applied rewrites68.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6468.4
Applied rewrites68.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lift-/.f6454.5
Applied rewrites54.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 (or (<= z -4.5e-140) (not (<= z 1.75e+17)))
(* (/ (fma -4.0 t (/ b (* a z))) c_m) a)
(/ (/ (fma (* y x) 9.0 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 ((z <= -4.5e-140) || !(z <= 1.75e+17)) {
tmp = (fma(-4.0, t, (b / (a * z))) / c_m) * a;
} else {
tmp = (fma((y * x), 9.0, 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 ((z <= -4.5e-140) || !(z <= 1.75e+17)) tmp = Float64(Float64(fma(-4.0, t, Float64(b / Float64(a * z))) / c_m) * a); else tmp = Float64(Float64(fma(Float64(y * x), 9.0, b) / 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_] := N[(c$95$s * If[Or[LessEqual[z, -4.5e-140], N[Not[LessEqual[z, 1.75e+17]], $MachinePrecision]], N[(N[(N[(-4.0 * t + N[(b / N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision] * a), $MachinePrecision], N[(N[(N[(N[(y * x), $MachinePrecision] * 9.0 + b), $MachinePrecision] / 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 \begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{-140} \lor \neg \left(z \leq 1.75 \cdot 10^{+17}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(-4, t, \frac{b}{a \cdot z}\right)}{c\_m} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(y \cdot x, 9, b\right)}{c\_m}}{z}\\
\end{array}
\end{array}
if z < -4.50000000000000004e-140 or 1.75e17 < z Initial program 63.9%
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-*.f6452.2
Applied rewrites52.2%
Taylor expanded in a around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6449.9
Applied rewrites49.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6469.0
Applied rewrites69.0%
Taylor expanded in c around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6471.5
Applied rewrites71.5%
if -4.50000000000000004e-140 < z < 1.75e17Initial program 98.0%
Taylor expanded in z around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6491.5
Applied rewrites91.5%
Final simplification79.7%
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 (<= z -8.5e-20)
(* (fma (/ t c_m) -4.0 (/ b (* (* c_m z) a))) a)
(if (<= z 1.75e+17)
(/ (/ (fma (* y x) 9.0 b) c_m) z)
(* (/ (fma -4.0 t (/ b (* a z))) c_m) a)))))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 (z <= -8.5e-20) {
tmp = fma((t / c_m), -4.0, (b / ((c_m * z) * a))) * a;
} else if (z <= 1.75e+17) {
tmp = (fma((y * x), 9.0, b) / c_m) / z;
} else {
tmp = (fma(-4.0, t, (b / (a * z))) / c_m) * a;
}
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 (z <= -8.5e-20) tmp = Float64(fma(Float64(t / c_m), -4.0, Float64(b / Float64(Float64(c_m * z) * a))) * a); elseif (z <= 1.75e+17) tmp = Float64(Float64(fma(Float64(y * x), 9.0, b) / c_m) / z); else tmp = Float64(Float64(fma(-4.0, t, Float64(b / Float64(a * z))) / c_m) * a); 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[z, -8.5e-20], N[(N[(N[(t / c$95$m), $MachinePrecision] * -4.0 + N[(b / N[(N[(c$95$m * z), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[z, 1.75e+17], N[(N[(N[(N[(y * x), $MachinePrecision] * 9.0 + b), $MachinePrecision] / c$95$m), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(-4.0 * t + N[(b / N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision] * a), $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}\;z \leq -8.5 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{c\_m}, -4, \frac{b}{\left(c\_m \cdot z\right) \cdot a}\right) \cdot a\\
\mathbf{elif}\;z \leq 1.75 \cdot 10^{+17}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(y \cdot x, 9, b\right)}{c\_m}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-4, t, \frac{b}{a \cdot z}\right)}{c\_m} \cdot a\\
\end{array}
\end{array}
if z < -8.5000000000000005e-20Initial program 66.7%
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-*.f6454.8
Applied rewrites54.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-*.f6472.5
Applied rewrites72.5%
if -8.5000000000000005e-20 < z < 1.75e17Initial program 97.4%
Taylor expanded in z around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6487.8
Applied rewrites87.8%
if 1.75e17 < z Initial program 50.5%
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-*.f6446.2
Applied rewrites46.2%
Taylor expanded in a around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6458.0
Applied rewrites58.0%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6473.5
Applied rewrites73.5%
Taylor expanded in c around 0
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6477.3
Applied rewrites77.3%
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 (or (<= z -7.2e+81) (not (<= z 1.55e+31)))
(* (* (/ a c_m) -4.0) t)
(/ (/ (fma (* y x) 9.0 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 ((z <= -7.2e+81) || !(z <= 1.55e+31)) {
tmp = ((a / c_m) * -4.0) * t;
} else {
tmp = (fma((y * x), 9.0, 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 ((z <= -7.2e+81) || !(z <= 1.55e+31)) tmp = Float64(Float64(Float64(a / c_m) * -4.0) * t); else tmp = Float64(Float64(fma(Float64(y * x), 9.0, b) / 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_] := N[(c$95$s * If[Or[LessEqual[z, -7.2e+81], N[Not[LessEqual[z, 1.55e+31]], $MachinePrecision]], N[(N[(N[(a / c$95$m), $MachinePrecision] * -4.0), $MachinePrecision] * t), $MachinePrecision], N[(N[(N[(N[(y * x), $MachinePrecision] * 9.0 + b), $MachinePrecision] / 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 \begin{array}{l}
\mathbf{if}\;z \leq -7.2 \cdot 10^{+81} \lor \neg \left(z \leq 1.55 \cdot 10^{+31}\right):\\
\;\;\;\;\left(\frac{a}{c\_m} \cdot -4\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(y \cdot x, 9, b\right)}{c\_m}}{z}\\
\end{array}
\end{array}
if z < -7.20000000000000011e81 or 1.5500000000000001e31 < z Initial program 53.6%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lift-/.f6464.0
Applied rewrites64.0%
if -7.20000000000000011e81 < z < 1.5500000000000001e31Initial program 95.3%
Taylor expanded in z around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6482.4
Applied rewrites82.4%
Final simplification74.7%
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 (or (<= z -3.7e+73) (not (<= z 1.55e+31)))
(* (* (/ a c_m) -4.0) t)
(/ (fma (* y x) 9.0 b) (* z c_m)))))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 ((z <= -3.7e+73) || !(z <= 1.55e+31)) {
tmp = ((a / c_m) * -4.0) * t;
} else {
tmp = fma((y * x), 9.0, b) / (z * c_m);
}
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 ((z <= -3.7e+73) || !(z <= 1.55e+31)) tmp = Float64(Float64(Float64(a / c_m) * -4.0) * t); else tmp = Float64(fma(Float64(y * x), 9.0, b) / Float64(z * c_m)); 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[Or[LessEqual[z, -3.7e+73], N[Not[LessEqual[z, 1.55e+31]], $MachinePrecision]], N[(N[(N[(a / c$95$m), $MachinePrecision] * -4.0), $MachinePrecision] * t), $MachinePrecision], N[(N[(N[(y * x), $MachinePrecision] * 9.0 + b), $MachinePrecision] / N[(z * c$95$m), $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}\;z \leq -3.7 \cdot 10^{+73} \lor \neg \left(z \leq 1.55 \cdot 10^{+31}\right):\\
\;\;\;\;\left(\frac{a}{c\_m} \cdot -4\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y \cdot x, 9, b\right)}{z \cdot c\_m}\\
\end{array}
\end{array}
if z < -3.69999999999999973e73 or 1.5500000000000001e31 < z Initial program 53.6%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lift-/.f6464.0
Applied rewrites64.0%
if -3.69999999999999973e73 < z < 1.5500000000000001e31Initial program 95.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6481.4
Applied rewrites81.4%
Final simplification74.1%
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 (or (<= z -4.5e-190) (not (<= z 2.6e+28)))
(* (* (/ t c_m) -4.0) a)
(/ b (* z c_m)))))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 ((z <= -4.5e-190) || !(z <= 2.6e+28)) {
tmp = ((t / c_m) * -4.0) * a;
} else {
tmp = b / (z * c_m);
}
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 ((z <= (-4.5d-190)) .or. (.not. (z <= 2.6d+28))) then
tmp = ((t / c_m) * (-4.0d0)) * a
else
tmp = b / (z * c_m)
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 ((z <= -4.5e-190) || !(z <= 2.6e+28)) {
tmp = ((t / c_m) * -4.0) * a;
} else {
tmp = b / (z * c_m);
}
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 (z <= -4.5e-190) or not (z <= 2.6e+28): tmp = ((t / c_m) * -4.0) * a else: tmp = b / (z * c_m) 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 ((z <= -4.5e-190) || !(z <= 2.6e+28)) tmp = Float64(Float64(Float64(t / c_m) * -4.0) * a); else tmp = Float64(b / Float64(z * c_m)); 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 ((z <= -4.5e-190) || ~((z <= 2.6e+28)))
tmp = ((t / c_m) * -4.0) * a;
else
tmp = b / (z * c_m);
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[Or[LessEqual[z, -4.5e-190], N[Not[LessEqual[z, 2.6e+28]], $MachinePrecision]], N[(N[(N[(t / c$95$m), $MachinePrecision] * -4.0), $MachinePrecision] * a), $MachinePrecision], N[(b / N[(z * c$95$m), $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}\;z \leq -4.5 \cdot 10^{-190} \lor \neg \left(z \leq 2.6 \cdot 10^{+28}\right):\\
\;\;\;\;\left(\frac{t}{c\_m} \cdot -4\right) \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{z \cdot c\_m}\\
\end{array}
\end{array}
if z < -4.50000000000000021e-190 or 2.6000000000000002e28 < z Initial program 64.4%
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-*.f6452.8
Applied rewrites52.8%
Taylor expanded in a around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6450.6
Applied rewrites50.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6468.7
Applied rewrites68.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lift-/.f6459.2
Applied rewrites59.2%
if -4.50000000000000021e-190 < z < 2.6000000000000002e28Initial program 98.0%
Taylor expanded in b around inf
Applied rewrites59.8%
Final simplification59.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 (<= z -4.5e-190)
(* (* (/ t c_m) -4.0) a)
(if (<= z 2.6e+28) (/ b (* z c_m)) (* (* (/ a c_m) -4.0) t)))))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 (z <= -4.5e-190) {
tmp = ((t / c_m) * -4.0) * a;
} else if (z <= 2.6e+28) {
tmp = b / (z * c_m);
} else {
tmp = ((a / c_m) * -4.0) * t;
}
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 (z <= (-4.5d-190)) then
tmp = ((t / c_m) * (-4.0d0)) * a
else if (z <= 2.6d+28) then
tmp = b / (z * c_m)
else
tmp = ((a / c_m) * (-4.0d0)) * t
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 (z <= -4.5e-190) {
tmp = ((t / c_m) * -4.0) * a;
} else if (z <= 2.6e+28) {
tmp = b / (z * c_m);
} else {
tmp = ((a / c_m) * -4.0) * t;
}
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 z <= -4.5e-190: tmp = ((t / c_m) * -4.0) * a elif z <= 2.6e+28: tmp = b / (z * c_m) else: tmp = ((a / c_m) * -4.0) * t 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 (z <= -4.5e-190) tmp = Float64(Float64(Float64(t / c_m) * -4.0) * a); elseif (z <= 2.6e+28) tmp = Float64(b / Float64(z * c_m)); else tmp = Float64(Float64(Float64(a / c_m) * -4.0) * t); 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 (z <= -4.5e-190)
tmp = ((t / c_m) * -4.0) * a;
elseif (z <= 2.6e+28)
tmp = b / (z * c_m);
else
tmp = ((a / c_m) * -4.0) * t;
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[z, -4.5e-190], N[(N[(N[(t / c$95$m), $MachinePrecision] * -4.0), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[z, 2.6e+28], N[(b / N[(z * c$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a / c$95$m), $MachinePrecision] * -4.0), $MachinePrecision] * t), $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}\;z \leq -4.5 \cdot 10^{-190}:\\
\;\;\;\;\left(\frac{t}{c\_m} \cdot -4\right) \cdot a\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{+28}:\\
\;\;\;\;\frac{b}{z \cdot c\_m}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{a}{c\_m} \cdot -4\right) \cdot t\\
\end{array}
\end{array}
if z < -4.50000000000000021e-190Initial program 72.7%
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-*.f6457.4
Applied rewrites57.4%
Taylor expanded in a around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6447.5
Applied rewrites47.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6466.7
Applied rewrites66.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lift-/.f6455.0
Applied rewrites55.0%
if -4.50000000000000021e-190 < z < 2.6000000000000002e28Initial program 98.0%
Taylor expanded in b around inf
Applied rewrites59.8%
if 2.6000000000000002e28 < z Initial program 48.7%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites81.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lift-/.f6470.7
Applied rewrites70.7%
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 (<= z -4.5e-190)
(* (* (/ t c_m) -4.0) a)
(if (<= z 5.8e+29) (/ b (* z c_m)) (* -4.0 (/ (* a t) c_m))))))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 (z <= -4.5e-190) {
tmp = ((t / c_m) * -4.0) * a;
} else if (z <= 5.8e+29) {
tmp = b / (z * c_m);
} else {
tmp = -4.0 * ((a * t) / c_m);
}
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 (z <= (-4.5d-190)) then
tmp = ((t / c_m) * (-4.0d0)) * a
else if (z <= 5.8d+29) then
tmp = b / (z * c_m)
else
tmp = (-4.0d0) * ((a * t) / c_m)
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 (z <= -4.5e-190) {
tmp = ((t / c_m) * -4.0) * a;
} else if (z <= 5.8e+29) {
tmp = b / (z * c_m);
} else {
tmp = -4.0 * ((a * t) / c_m);
}
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 z <= -4.5e-190: tmp = ((t / c_m) * -4.0) * a elif z <= 5.8e+29: tmp = b / (z * c_m) else: tmp = -4.0 * ((a * t) / c_m) 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 (z <= -4.5e-190) tmp = Float64(Float64(Float64(t / c_m) * -4.0) * a); elseif (z <= 5.8e+29) tmp = Float64(b / Float64(z * c_m)); else tmp = Float64(-4.0 * Float64(Float64(a * t) / c_m)); 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 (z <= -4.5e-190)
tmp = ((t / c_m) * -4.0) * a;
elseif (z <= 5.8e+29)
tmp = b / (z * c_m);
else
tmp = -4.0 * ((a * t) / c_m);
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[z, -4.5e-190], N[(N[(N[(t / c$95$m), $MachinePrecision] * -4.0), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[z, 5.8e+29], N[(b / N[(z * c$95$m), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(N[(a * t), $MachinePrecision] / c$95$m), $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}\;z \leq -4.5 \cdot 10^{-190}:\\
\;\;\;\;\left(\frac{t}{c\_m} \cdot -4\right) \cdot a\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{+29}:\\
\;\;\;\;\frac{b}{z \cdot c\_m}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{a \cdot t}{c\_m}\\
\end{array}
\end{array}
if z < -4.50000000000000021e-190Initial program 72.7%
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-*.f6457.4
Applied rewrites57.4%
Taylor expanded in a around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6447.5
Applied rewrites47.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6466.7
Applied rewrites66.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lift-/.f6455.0
Applied rewrites55.0%
if -4.50000000000000021e-190 < z < 5.7999999999999999e29Initial program 98.0%
Taylor expanded in b around inf
Applied rewrites59.8%
if 5.7999999999999999e29 < z Initial program 48.7%
Taylor expanded in z around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6467.4
Applied rewrites67.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 (/ b (* z c_m))))
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 / (z * c_m));
}
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 / (z * c_m))
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 / (z * c_m));
}
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 / (z * c_m))
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(z * c_m))) 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 / (z * c_m));
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[(z * c$95$m), $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}{z \cdot c\_m}
\end{array}
Initial program 77.9%
Taylor expanded in b around inf
Applied rewrites37.8%
(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 2025057
(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)))