
(FPCore (x y z t a b c i) :precision binary64 (* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
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, i)
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), intent (in) :: i
code = 2.0d0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
def code(x, y, z, t, a, b, c, i): return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
function code(x, y, z, t, a, b, c, i) return Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(Float64(Float64(a + Float64(b * c)) * c) * i))) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i)); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c i) :precision binary64 (* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
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, i)
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), intent (in) :: i
code = 2.0d0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
def code(x, y, z, t, a, b, c, i): return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
function code(x, y, z, t, a, b, c, i) return Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(Float64(Float64(a + Float64(b * c)) * c) * i))) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i)); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
\end{array}
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i) :precision binary64 (if (<= c 200000000000.0) (* 2.0 (fma y x (- (* t z) (* (* (fma c b a) c) i)))) (* 2.0 (fma y x (* (- z) (fma c (/ (* (fma b c a) i) z) (- t)))))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (c <= 200000000000.0) {
tmp = 2.0 * fma(y, x, ((t * z) - ((fma(c, b, a) * c) * i)));
} else {
tmp = 2.0 * fma(y, x, (-z * fma(c, ((fma(b, c, a) * i) / z), -t)));
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (c <= 200000000000.0) tmp = Float64(2.0 * fma(y, x, Float64(Float64(t * z) - Float64(Float64(fma(c, b, a) * c) * i)))); else tmp = Float64(2.0 * fma(y, x, Float64(Float64(-z) * fma(c, Float64(Float64(fma(b, c, a) * i) / z), Float64(-t))))); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[c, 200000000000.0], N[(2.0 * N[(y * x + N[(N[(t * z), $MachinePrecision] - N[(N[(N[(c * b + a), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(y * x + N[((-z) * N[(c * N[(N[(N[(b * c + a), $MachinePrecision] * i), $MachinePrecision] / z), $MachinePrecision] + (-t)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;c \leq 200000000000:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, t \cdot z - \left(\mathsf{fma}\left(c, b, a\right) \cdot c\right) \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \left(-z\right) \cdot \mathsf{fma}\left(c, \frac{\mathsf{fma}\left(b, c, a\right) \cdot i}{z}, -t\right)\right)\\
\end{array}
\end{array}
if c < 2e11Initial program 96.5%
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower--.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f6498.0
Applied rewrites98.0%
if 2e11 < c Initial program 77.1%
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower--.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f6480.7
Applied rewrites80.7%
Taylor expanded in z around -inf
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites96.3%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* (fma c b a) i) c)) (t_2 (* (* (+ a (* b c)) c) i)))
(if (<= t_2 -4e+249)
(* 2.0 (- (* t z) t_1))
(if (<= t_2 -2e+118)
(* 2.0 (fma y x (* (* i c) (- a))))
(if (<= t_2 4e+260) (* 2.0 (fma t z (* y x))) (* -2.0 t_1))))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (fma(c, b, a) * i) * c;
double t_2 = ((a + (b * c)) * c) * i;
double tmp;
if (t_2 <= -4e+249) {
tmp = 2.0 * ((t * z) - t_1);
} else if (t_2 <= -2e+118) {
tmp = 2.0 * fma(y, x, ((i * c) * -a));
} else if (t_2 <= 4e+260) {
tmp = 2.0 * fma(t, z, (y * x));
} else {
tmp = -2.0 * t_1;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(fma(c, b, a) * i) * c) t_2 = Float64(Float64(Float64(a + Float64(b * c)) * c) * i) tmp = 0.0 if (t_2 <= -4e+249) tmp = Float64(2.0 * Float64(Float64(t * z) - t_1)); elseif (t_2 <= -2e+118) tmp = Float64(2.0 * fma(y, x, Float64(Float64(i * c) * Float64(-a)))); elseif (t_2 <= 4e+260) tmp = Float64(2.0 * fma(t, z, Float64(y * x))); else tmp = Float64(-2.0 * t_1); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(c * b + a), $MachinePrecision] * i), $MachinePrecision] * c), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[t$95$2, -4e+249], N[(2.0 * N[(N[(t * z), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -2e+118], N[(2.0 * N[(y * x + N[(N[(i * c), $MachinePrecision] * (-a)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 4e+260], N[(2.0 * N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * t$95$1), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \left(\mathsf{fma}\left(c, b, a\right) \cdot i\right) \cdot c\\
t_2 := \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{+249}:\\
\;\;\;\;2 \cdot \left(t \cdot z - t\_1\right)\\
\mathbf{elif}\;t\_2 \leq -2 \cdot 10^{+118}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \left(i \cdot c\right) \cdot \left(-a\right)\right)\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+260}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(t, z, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -3.9999999999999997e249Initial program 86.3%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6491.1
Applied rewrites91.1%
if -3.9999999999999997e249 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -1.99999999999999993e118Initial program 99.8%
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower--.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f6499.8
Applied rewrites99.8%
Taylor expanded in a around inf
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6480.2
Applied rewrites80.2%
if -1.99999999999999993e118 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 4.00000000000000026e260Initial program 99.2%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6488.1
Applied rewrites88.1%
if 4.00000000000000026e260 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 72.1%
Taylor expanded in i around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6487.2
Applied rewrites87.2%
Final simplification88.0%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* -2.0 (* (* (fma c b a) i) c))) (t_2 (* (* (+ a (* b c)) c) i)))
(if (<= t_2 -4e+249)
t_1
(if (<= t_2 -2e+118)
(* 2.0 (fma y x (* (* i c) (- a))))
(if (<= t_2 4e+260) (* 2.0 (fma t z (* y x))) t_1)))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = -2.0 * ((fma(c, b, a) * i) * c);
double t_2 = ((a + (b * c)) * c) * i;
double tmp;
if (t_2 <= -4e+249) {
tmp = t_1;
} else if (t_2 <= -2e+118) {
tmp = 2.0 * fma(y, x, ((i * c) * -a));
} else if (t_2 <= 4e+260) {
tmp = 2.0 * fma(t, z, (y * x));
} else {
tmp = t_1;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = Float64(-2.0 * Float64(Float64(fma(c, b, a) * i) * c)) t_2 = Float64(Float64(Float64(a + Float64(b * c)) * c) * i) tmp = 0.0 if (t_2 <= -4e+249) tmp = t_1; elseif (t_2 <= -2e+118) tmp = Float64(2.0 * fma(y, x, Float64(Float64(i * c) * Float64(-a)))); elseif (t_2 <= 4e+260) tmp = Float64(2.0 * fma(t, z, Float64(y * x))); else tmp = t_1; end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(-2.0 * N[(N[(N[(c * b + a), $MachinePrecision] * i), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[t$95$2, -4e+249], t$95$1, If[LessEqual[t$95$2, -2e+118], N[(2.0 * N[(y * x + N[(N[(i * c), $MachinePrecision] * (-a)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 4e+260], N[(2.0 * N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := -2 \cdot \left(\left(\mathsf{fma}\left(c, b, a\right) \cdot i\right) \cdot c\right)\\
t_2 := \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{+249}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -2 \cdot 10^{+118}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \left(i \cdot c\right) \cdot \left(-a\right)\right)\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+260}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(t, z, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -3.9999999999999997e249 or 4.00000000000000026e260 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 79.0%
Taylor expanded in i around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6487.9
Applied rewrites87.9%
if -3.9999999999999997e249 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -1.99999999999999993e118Initial program 99.8%
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower--.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f6499.8
Applied rewrites99.8%
Taylor expanded in a around inf
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6480.2
Applied rewrites80.2%
if -1.99999999999999993e118 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 4.00000000000000026e260Initial program 99.2%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6488.1
Applied rewrites88.1%
Final simplification87.6%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i) :precision binary64 (if (<= (* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))) INFINITY) (* 2.0 (fma y x (- (* t z) (* (* (fma c b a) c) i)))) (* 2.0 (fma y x (* (- z) (fma c (/ (* i a) z) (- t)))))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))) <= ((double) INFINITY)) {
tmp = 2.0 * fma(y, x, ((t * z) - ((fma(c, b, a) * c) * i)));
} else {
tmp = 2.0 * fma(y, x, (-z * fma(c, ((i * a) / z), -t)));
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(Float64(Float64(a + Float64(b * c)) * c) * i))) <= Inf) tmp = Float64(2.0 * fma(y, x, Float64(Float64(t * z) - Float64(Float64(fma(c, b, a) * c) * i)))); else tmp = Float64(2.0 * fma(y, x, Float64(Float64(-z) * fma(c, Float64(Float64(i * a) / z), Float64(-t))))); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(2.0 * N[(y * x + N[(N[(t * z), $MachinePrecision] - N[(N[(N[(c * b + a), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(y * x + N[((-z) * N[(c * N[(N[(i * a), $MachinePrecision] / z), $MachinePrecision] + (-t)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \leq \infty:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, t \cdot z - \left(\mathsf{fma}\left(c, b, a\right) \cdot c\right) \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \left(-z\right) \cdot \mathsf{fma}\left(c, \frac{i \cdot a}{z}, -t\right)\right)\\
\end{array}
\end{array}
if (*.f64 #s(literal 2 binary64) (-.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i))) < +inf.0Initial program 97.6%
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower--.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f6497.6
Applied rewrites97.6%
if +inf.0 < (*.f64 #s(literal 2 binary64) (-.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i))) Initial program 0.0%
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower--.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f6435.7
Applied rewrites35.7%
Taylor expanded in z around -inf
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites92.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6471.4
Applied rewrites71.4%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* (+ a (* b c)) c) i)))
(if (or (<= t_1 -1e+189) (not (<= t_1 4e+260)))
(* -2.0 (* (* (fma c b a) i) c))
(* 2.0 (fma t z (* y x))))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = ((a + (b * c)) * c) * i;
double tmp;
if ((t_1 <= -1e+189) || !(t_1 <= 4e+260)) {
tmp = -2.0 * ((fma(c, b, a) * i) * c);
} else {
tmp = 2.0 * fma(t, z, (y * x));
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(a + Float64(b * c)) * c) * i) tmp = 0.0 if ((t_1 <= -1e+189) || !(t_1 <= 4e+260)) tmp = Float64(-2.0 * Float64(Float64(fma(c, b, a) * i) * c)); else tmp = Float64(2.0 * fma(t, z, Float64(y * x))); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e+189], N[Not[LessEqual[t$95$1, 4e+260]], $MachinePrecision]], N[(-2.0 * N[(N[(N[(c * b + a), $MachinePrecision] * i), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+189} \lor \neg \left(t\_1 \leq 4 \cdot 10^{+260}\right):\\
\;\;\;\;-2 \cdot \left(\left(\mathsf{fma}\left(c, b, a\right) \cdot i\right) \cdot c\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(t, z, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -1e189 or 4.00000000000000026e260 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 80.7%
Taylor expanded in i around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6484.0
Applied rewrites84.0%
if -1e189 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 4.00000000000000026e260Initial program 99.3%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6486.2
Applied rewrites86.2%
Final simplification85.4%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* (+ a (* b c)) c) i)))
(if (<= t_1 -2e+118)
(* 2.0 (- (* x y) (* (* (fma b c a) c) i)))
(if (<= t_1 4e+260)
(* 2.0 (fma t z (* y x)))
(* -2.0 (* (* (fma c b a) i) c))))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = ((a + (b * c)) * c) * i;
double tmp;
if (t_1 <= -2e+118) {
tmp = 2.0 * ((x * y) - ((fma(b, c, a) * c) * i));
} else if (t_1 <= 4e+260) {
tmp = 2.0 * fma(t, z, (y * x));
} else {
tmp = -2.0 * ((fma(c, b, a) * i) * c);
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(a + Float64(b * c)) * c) * i) tmp = 0.0 if (t_1 <= -2e+118) tmp = Float64(2.0 * Float64(Float64(x * y) - Float64(Float64(fma(b, c, a) * c) * i))); elseif (t_1 <= 4e+260) tmp = Float64(2.0 * fma(t, z, Float64(y * x))); else tmp = Float64(-2.0 * Float64(Float64(fma(c, b, a) * i) * c)); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+118], N[(2.0 * N[(N[(x * y), $MachinePrecision] - N[(N[(N[(b * c + a), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+260], N[(2.0 * N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[(N[(c * b + a), $MachinePrecision] * i), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+118}:\\
\;\;\;\;2 \cdot \left(x \cdot y - \left(\mathsf{fma}\left(b, c, a\right) \cdot c\right) \cdot i\right)\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+260}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(t, z, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\left(\mathsf{fma}\left(c, b, a\right) \cdot i\right) \cdot c\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -1.99999999999999993e118Initial program 89.8%
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower--.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f6493.3
Applied rewrites93.3%
Taylor expanded in z around 0
associate-+r-N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
Applied rewrites88.1%
if -1.99999999999999993e118 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 4.00000000000000026e260Initial program 99.2%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6488.1
Applied rewrites88.1%
if 4.00000000000000026e260 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 72.1%
Taylor expanded in i around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6487.2
Applied rewrites87.2%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* (+ a (* b c)) c) i)))
(if (or (<= t_1 -4e+213) (not (<= t_1 4e+260)))
(* (* c (* c (* i b))) -2.0)
(* 2.0 (fma t z (* y x))))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = ((a + (b * c)) * c) * i;
double tmp;
if ((t_1 <= -4e+213) || !(t_1 <= 4e+260)) {
tmp = (c * (c * (i * b))) * -2.0;
} else {
tmp = 2.0 * fma(t, z, (y * x));
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(a + Float64(b * c)) * c) * i) tmp = 0.0 if ((t_1 <= -4e+213) || !(t_1 <= 4e+260)) tmp = Float64(Float64(c * Float64(c * Float64(i * b))) * -2.0); else tmp = Float64(2.0 * fma(t, z, Float64(y * x))); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -4e+213], N[Not[LessEqual[t$95$1, 4e+260]], $MachinePrecision]], N[(N[(c * N[(c * N[(i * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision], N[(2.0 * N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+213} \lor \neg \left(t\_1 \leq 4 \cdot 10^{+260}\right):\\
\;\;\;\;\left(c \cdot \left(c \cdot \left(i \cdot b\right)\right)\right) \cdot -2\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(t, z, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -3.99999999999999994e213 or 4.00000000000000026e260 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 79.7%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6460.9
Applied rewrites60.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6463.5
Applied rewrites63.5%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6465.4
Applied rewrites65.4%
if -3.99999999999999994e213 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 4.00000000000000026e260Initial program 99.3%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6484.3
Applied rewrites84.3%
Final simplification77.5%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (* (+ a (* b c)) c) i)))
(if (or (<= t_1 -2e+118) (not (<= t_1 4e+284)))
(* (* (* i c) a) -2.0)
(* 2.0 (fma t z (* y x))))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = ((a + (b * c)) * c) * i;
double tmp;
if ((t_1 <= -2e+118) || !(t_1 <= 4e+284)) {
tmp = ((i * c) * a) * -2.0;
} else {
tmp = 2.0 * fma(t, z, (y * x));
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(a + Float64(b * c)) * c) * i) tmp = 0.0 if ((t_1 <= -2e+118) || !(t_1 <= 4e+284)) tmp = Float64(Float64(Float64(i * c) * a) * -2.0); else tmp = Float64(2.0 * fma(t, z, Float64(y * x))); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+118], N[Not[LessEqual[t$95$1, 4e+284]], $MachinePrecision]], N[(N[(N[(i * c), $MachinePrecision] * a), $MachinePrecision] * -2.0), $MachinePrecision], N[(2.0 * N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+118} \lor \neg \left(t\_1 \leq 4 \cdot 10^{+284}\right):\\
\;\;\;\;\left(\left(i \cdot c\right) \cdot a\right) \cdot -2\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(t, z, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -1.99999999999999993e118 or 4.00000000000000032e284 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 81.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6443.2
Applied rewrites43.2%
if -1.99999999999999993e118 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 4.00000000000000032e284Initial program 99.2%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6487.0
Applied rewrites87.0%
Final simplification69.5%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i) :precision binary64 (if (<= (* z t) 5e+272) (* 2.0 (fma y x (- (* t z) (* (* (fma c b a) c) i)))) (* 2.0 (fma t z (* y x)))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((z * t) <= 5e+272) {
tmp = 2.0 * fma(y, x, ((t * z) - ((fma(c, b, a) * c) * i)));
} else {
tmp = 2.0 * fma(t, z, (y * x));
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= 5e+272) tmp = Float64(2.0 * fma(y, x, Float64(Float64(t * z) - Float64(Float64(fma(c, b, a) * c) * i)))); else tmp = Float64(2.0 * fma(t, z, Float64(y * x))); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], 5e+272], N[(2.0 * N[(y * x + N[(N[(t * z), $MachinePrecision] - N[(N[(N[(c * b + a), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq 5 \cdot 10^{+272}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, t \cdot z - \left(\mathsf{fma}\left(c, b, a\right) \cdot c\right) \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(t, z, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 z t) < 4.99999999999999973e272Initial program 94.5%
lift--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower--.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f6496.6
Applied rewrites96.6%
if 4.99999999999999973e272 < (*.f64 z t) Initial program 68.2%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.9
Applied rewrites90.9%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* z t) -2e+89) (not (<= (* z t) 4e-49))) (* 2.0 (* t z)) (* 2.0 (* y x))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((z * t) <= -2e+89) || !((z * t) <= 4e-49)) {
tmp = 2.0 * (t * z);
} else {
tmp = 2.0 * (y * x);
}
return tmp;
}
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: i
real(8) :: tmp
if (((z * t) <= (-2d+89)) .or. (.not. ((z * t) <= 4d-49))) then
tmp = 2.0d0 * (t * z)
else
tmp = 2.0d0 * (y * x)
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((z * t) <= -2e+89) || !((z * t) <= 4e-49)) {
tmp = 2.0 * (t * z);
} else {
tmp = 2.0 * (y * x);
}
return tmp;
}
[x, y, z, t, a, b, c, i] = sort([x, y, z, t, a, b, c, i]) def code(x, y, z, t, a, b, c, i): tmp = 0 if ((z * t) <= -2e+89) or not ((z * t) <= 4e-49): tmp = 2.0 * (t * z) else: tmp = 2.0 * (y * x) return tmp
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(z * t) <= -2e+89) || !(Float64(z * t) <= 4e-49)) tmp = Float64(2.0 * Float64(t * z)); else tmp = Float64(2.0 * Float64(y * x)); end return tmp end
x, y, z, t, a, b, c, i = num2cell(sort([x, y, z, t, a, b, c, i])){:}
function tmp_2 = code(x, y, z, t, a, b, c, i)
tmp = 0.0;
if (((z * t) <= -2e+89) || ~(((z * t) <= 4e-49)))
tmp = 2.0 * (t * z);
else
tmp = 2.0 * (y * x);
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], -2e+89], N[Not[LessEqual[N[(z * t), $MachinePrecision], 4e-49]], $MachinePrecision]], N[(2.0 * N[(t * z), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+89} \lor \neg \left(z \cdot t \leq 4 \cdot 10^{-49}\right):\\
\;\;\;\;2 \cdot \left(t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -1.99999999999999999e89 or 3.99999999999999975e-49 < (*.f64 z t) Initial program 89.2%
Taylor expanded in z around inf
lower-*.f6458.7
Applied rewrites58.7%
if -1.99999999999999999e89 < (*.f64 z t) < 3.99999999999999975e-49Initial program 94.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6450.2
Applied rewrites50.2%
Final simplification54.2%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(if (<= c -5.3e+39)
(* (* c (* c (* i b))) -2.0)
(if (<= c 7.2e+132)
(* 2.0 (fma t z (* y x)))
(* (* c (* (* i c) b)) -2.0))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (c <= -5.3e+39) {
tmp = (c * (c * (i * b))) * -2.0;
} else if (c <= 7.2e+132) {
tmp = 2.0 * fma(t, z, (y * x));
} else {
tmp = (c * ((i * c) * b)) * -2.0;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (c <= -5.3e+39) tmp = Float64(Float64(c * Float64(c * Float64(i * b))) * -2.0); elseif (c <= 7.2e+132) tmp = Float64(2.0 * fma(t, z, Float64(y * x))); else tmp = Float64(Float64(c * Float64(Float64(i * c) * b)) * -2.0); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[c, -5.3e+39], N[(N[(c * N[(c * N[(i * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision], If[LessEqual[c, 7.2e+132], N[(2.0 * N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * N[(N[(i * c), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.3 \cdot 10^{+39}:\\
\;\;\;\;\left(c \cdot \left(c \cdot \left(i \cdot b\right)\right)\right) \cdot -2\\
\mathbf{elif}\;c \leq 7.2 \cdot 10^{+132}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(t, z, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(c \cdot \left(\left(i \cdot c\right) \cdot b\right)\right) \cdot -2\\
\end{array}
\end{array}
if c < -5.29999999999999979e39Initial program 84.3%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6471.7
Applied rewrites71.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.7
Applied rewrites70.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6475.9
Applied rewrites75.9%
if -5.29999999999999979e39 < c < 7.20000000000000031e132Initial program 97.2%
Taylor expanded in c around 0
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6479.5
Applied rewrites79.5%
if 7.20000000000000031e132 < c Initial program 75.9%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6464.6
Applied rewrites64.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6470.4
Applied rewrites70.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6473.2
Applied rewrites73.2%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i) :precision binary64 (* 2.0 (* t z)))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (t * z);
}
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: i
code = 2.0d0 * (t * z)
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (t * z);
}
[x, y, z, t, a, b, c, i] = sort([x, y, z, t, a, b, c, i]) def code(x, y, z, t, a, b, c, i): return 2.0 * (t * z)
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) return Float64(2.0 * Float64(t * z)) end
x, y, z, t, a, b, c, i = num2cell(sort([x, y, z, t, a, b, c, i])){:}
function tmp = code(x, y, z, t, a, b, c, i)
tmp = 2.0 * (t * z);
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(t * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
2 \cdot \left(t \cdot z\right)
\end{array}
Initial program 92.2%
Taylor expanded in z around inf
lower-*.f6430.6
Applied rewrites30.6%
(FPCore (x y z t a b c i) :precision binary64 (* 2.0 (- (+ (* x y) (* z t)) (* (+ a (* b c)) (* c i)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - ((a + (b * c)) * (c * i)));
}
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, i)
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), intent (in) :: i
code = 2.0d0 * (((x * y) + (z * t)) - ((a + (b * c)) * (c * i)))
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - ((a + (b * c)) * (c * i)));
}
def code(x, y, z, t, a, b, c, i): return 2.0 * (((x * y) + (z * t)) - ((a + (b * c)) * (c * i)))
function code(x, y, z, t, a, b, c, i) return Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(Float64(a + Float64(b * c)) * Float64(c * i)))) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = 2.0 * (((x * y) + (z * t)) - ((a + (b * c)) * (c * i))); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(a + b \cdot c\right) \cdot \left(c \cdot i\right)\right)
\end{array}
herbie shell --seed 2025051
(FPCore (x y z t a b c i)
:name "Diagrams.ThreeD.Shapes:frustum from diagrams-lib-1.3.0.3, A"
:precision binary64
:alt
(! :herbie-platform default (* 2 (- (+ (* x y) (* z t)) (* (+ a (* b c)) (* c i)))))
(* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))