
(FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
real(8) function code(x, y, z, t, a, b, c, i)
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 = (((x * y) + (z * t)) + (a * b)) + (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 (((x * y) + (z * t)) + (a * b)) + (c * i);
}
def code(x, y, z, t, a, b, c, i): return (((x * y) + (z * t)) + (a * b)) + (c * i)
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (((x * y) + (z * t)) + (a * b)) + (c * i); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
real(8) function code(x, y, z, t, a, b, c, i)
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 = (((x * y) + (z * t)) + (a * b)) + (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 (((x * y) + (z * t)) + (a * b)) + (c * i);
}
def code(x, y, z, t, a, b, c, i): return (((x * y) + (z * t)) + (a * b)) + (c * i)
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (((x * y) + (z * t)) + (a * b)) + (c * i); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\end{array}
(FPCore (x y z t a b c i) :precision binary64 (fma z t (fma y x (fma i c (* b a)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(z, t, fma(y, x, fma(i, c, (b * a))));
}
function code(x, y, z, t, a, b, c, i) return fma(z, t, fma(y, x, fma(i, c, Float64(b * a)))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(z * t + N[(y * x + N[(i * c + N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, t, \mathsf{fma}\left(y, x, \mathsf{fma}\left(i, c, b \cdot a\right)\right)\right)
\end{array}
Initial program 95.3%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma t z (* x y))) (t_2 (+ (* x y) (* z t))))
(if (<= t_2 -1e+87)
t_1
(if (<= t_2 2e+35)
(fma b a (* c i))
(if (<= t_2 5e+191) (fma y x (* a b)) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(t, z, (x * y));
double t_2 = (x * y) + (z * t);
double tmp;
if (t_2 <= -1e+87) {
tmp = t_1;
} else if (t_2 <= 2e+35) {
tmp = fma(b, a, (c * i));
} else if (t_2 <= 5e+191) {
tmp = fma(y, x, (a * b));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(t, z, Float64(x * y)) t_2 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if (t_2 <= -1e+87) tmp = t_1; elseif (t_2 <= 2e+35) tmp = fma(b, a, Float64(c * i)); elseif (t_2 <= 5e+191) tmp = fma(y, x, Float64(a * b)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(t * z + N[(x * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+87], t$95$1, If[LessEqual[t$95$2, 2e+35], N[(b * a + N[(c * i), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+191], N[(y * x + N[(a * b), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, z, x \cdot y\right)\\
t_2 := x \cdot y + z \cdot t\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+87}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+35}:\\
\;\;\;\;\mathsf{fma}\left(b, a, c \cdot i\right)\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+191}:\\
\;\;\;\;\mathsf{fma}\left(y, x, a \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (*.f64 x y) (*.f64 z t)) < -9.9999999999999996e86 or 5.0000000000000002e191 < (+.f64 (*.f64 x y) (*.f64 z t)) Initial program 91.1%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6485.8
Applied rewrites85.8%
Applied rewrites87.5%
Taylor expanded in x around 0
Applied rewrites58.5%
Taylor expanded in c around 0
Applied rewrites77.6%
if -9.9999999999999996e86 < (+.f64 (*.f64 x y) (*.f64 z t)) < 1.9999999999999999e35Initial program 98.9%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6489.0
Applied rewrites89.0%
Taylor expanded in x around 0
Applied rewrites83.1%
if 1.9999999999999999e35 < (+.f64 (*.f64 x y) (*.f64 z t)) < 5.0000000000000002e191Initial program 99.9%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6482.9
Applied rewrites82.9%
Taylor expanded in x around 0
Applied rewrites48.9%
Taylor expanded in c around 0
Applied rewrites71.1%
Applied rewrites71.2%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma t z (* x y))) (t_2 (+ (* x y) (* z t))))
(if (<= t_2 -4e+87)
t_1
(if (<= t_2 2e+35)
(fma i c (* b a))
(if (<= t_2 5e+191) (fma y x (* a b)) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(t, z, (x * y));
double t_2 = (x * y) + (z * t);
double tmp;
if (t_2 <= -4e+87) {
tmp = t_1;
} else if (t_2 <= 2e+35) {
tmp = fma(i, c, (b * a));
} else if (t_2 <= 5e+191) {
tmp = fma(y, x, (a * b));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(t, z, Float64(x * y)) t_2 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if (t_2 <= -4e+87) tmp = t_1; elseif (t_2 <= 2e+35) tmp = fma(i, c, Float64(b * a)); elseif (t_2 <= 5e+191) tmp = fma(y, x, Float64(a * b)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(t * z + N[(x * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -4e+87], t$95$1, If[LessEqual[t$95$2, 2e+35], N[(i * c + N[(b * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+191], N[(y * x + N[(a * b), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, z, x \cdot y\right)\\
t_2 := x \cdot y + z \cdot t\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{+87}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+35}:\\
\;\;\;\;\mathsf{fma}\left(i, c, b \cdot a\right)\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+191}:\\
\;\;\;\;\mathsf{fma}\left(y, x, a \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (*.f64 x y) (*.f64 z t)) < -3.9999999999999998e87 or 5.0000000000000002e191 < (+.f64 (*.f64 x y) (*.f64 z t)) Initial program 91.9%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6486.5
Applied rewrites86.5%
Applied rewrites88.2%
Taylor expanded in x around 0
Applied rewrites59.0%
Taylor expanded in c around 0
Applied rewrites78.2%
if -3.9999999999999998e87 < (+.f64 (*.f64 x y) (*.f64 z t)) < 1.9999999999999999e35Initial program 98.0%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6488.1
Applied rewrites88.1%
Taylor expanded in x around 0
Applied rewrites82.3%
Taylor expanded in x around 0
Applied rewrites82.3%
if 1.9999999999999999e35 < (+.f64 (*.f64 x y) (*.f64 z t)) < 5.0000000000000002e191Initial program 99.9%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6482.9
Applied rewrites82.9%
Taylor expanded in x around 0
Applied rewrites48.9%
Taylor expanded in c around 0
Applied rewrites71.1%
Applied rewrites71.2%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* z t) -5e+127)
(* t z)
(if (<= (* z t) -2e-91)
(* i c)
(if (<= (* z t) -5e-321)
(* b a)
(if (<= (* z t) 1e+24)
(* i c)
(if (<= (* z t) 2e+193) (* b a) (* t z)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((z * t) <= -5e+127) {
tmp = t * z;
} else if ((z * t) <= -2e-91) {
tmp = i * c;
} else if ((z * t) <= -5e-321) {
tmp = b * a;
} else if ((z * t) <= 1e+24) {
tmp = i * c;
} else if ((z * t) <= 2e+193) {
tmp = b * a;
} else {
tmp = t * z;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
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) <= (-5d+127)) then
tmp = t * z
else if ((z * t) <= (-2d-91)) then
tmp = i * c
else if ((z * t) <= (-5d-321)) then
tmp = b * a
else if ((z * t) <= 1d+24) then
tmp = i * c
else if ((z * t) <= 2d+193) then
tmp = b * a
else
tmp = t * z
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 i) {
double tmp;
if ((z * t) <= -5e+127) {
tmp = t * z;
} else if ((z * t) <= -2e-91) {
tmp = i * c;
} else if ((z * t) <= -5e-321) {
tmp = b * a;
} else if ((z * t) <= 1e+24) {
tmp = i * c;
} else if ((z * t) <= 2e+193) {
tmp = b * a;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (z * t) <= -5e+127: tmp = t * z elif (z * t) <= -2e-91: tmp = i * c elif (z * t) <= -5e-321: tmp = b * a elif (z * t) <= 1e+24: tmp = i * c elif (z * t) <= 2e+193: tmp = b * a else: tmp = t * z return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -5e+127) tmp = Float64(t * z); elseif (Float64(z * t) <= -2e-91) tmp = Float64(i * c); elseif (Float64(z * t) <= -5e-321) tmp = Float64(b * a); elseif (Float64(z * t) <= 1e+24) tmp = Float64(i * c); elseif (Float64(z * t) <= 2e+193) tmp = Float64(b * a); else tmp = Float64(t * z); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((z * t) <= -5e+127) tmp = t * z; elseif ((z * t) <= -2e-91) tmp = i * c; elseif ((z * t) <= -5e-321) tmp = b * a; elseif ((z * t) <= 1e+24) tmp = i * c; elseif ((z * t) <= 2e+193) tmp = b * a; else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -5e+127], N[(t * z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], -2e-91], N[(i * c), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], -5e-321], N[(b * a), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1e+24], N[(i * c), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+193], N[(b * a), $MachinePrecision], N[(t * z), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+127}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;z \cdot t \leq -2 \cdot 10^{-91}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;z \cdot t \leq -5 \cdot 10^{-321}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;z \cdot t \leq 10^{+24}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+193}:\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (*.f64 z t) < -5.0000000000000004e127 or 2.00000000000000013e193 < (*.f64 z t) Initial program 93.8%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6435.1
Applied rewrites35.1%
Taylor expanded in x around 0
Applied rewrites24.2%
Taylor expanded in i around inf
Applied rewrites36.6%
Taylor expanded in z around inf
lower-*.f6469.0
Applied rewrites69.0%
if -5.0000000000000004e127 < (*.f64 z t) < -2.00000000000000004e-91 or -4.99994e-321 < (*.f64 z t) < 9.9999999999999998e23Initial program 96.6%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6443.2
Applied rewrites43.2%
if -2.00000000000000004e-91 < (*.f64 z t) < -4.99994e-321 or 9.9999999999999998e23 < (*.f64 z t) < 2.00000000000000013e193Initial program 94.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6468.9
Applied rewrites68.9%
Taylor expanded in c around 0
Applied rewrites60.9%
Taylor expanded in z around 0
Applied rewrites50.3%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma a b (* t z))) (t_2 (fma i c (* b a))))
(if (<= (* c i) -2e+162)
t_2
(if (<= (* c i) -1e-308)
t_1
(if (<= (* c i) 2e-172)
(fma b a (* y x))
(if (<= (* c i) 2e-7) t_1 t_2))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(a, b, (t * z));
double t_2 = fma(i, c, (b * a));
double tmp;
if ((c * i) <= -2e+162) {
tmp = t_2;
} else if ((c * i) <= -1e-308) {
tmp = t_1;
} else if ((c * i) <= 2e-172) {
tmp = fma(b, a, (y * x));
} else if ((c * i) <= 2e-7) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(a, b, Float64(t * z)) t_2 = fma(i, c, Float64(b * a)) tmp = 0.0 if (Float64(c * i) <= -2e+162) tmp = t_2; elseif (Float64(c * i) <= -1e-308) tmp = t_1; elseif (Float64(c * i) <= 2e-172) tmp = fma(b, a, Float64(y * x)); elseif (Float64(c * i) <= 2e-7) tmp = t_1; else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(i * c + N[(b * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(c * i), $MachinePrecision], -2e+162], t$95$2, If[LessEqual[N[(c * i), $MachinePrecision], -1e-308], t$95$1, If[LessEqual[N[(c * i), $MachinePrecision], 2e-172], N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 2e-7], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, b, t \cdot z\right)\\
t_2 := \mathsf{fma}\left(i, c, b \cdot a\right)\\
\mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+162}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;c \cdot i \leq -1 \cdot 10^{-308}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{-172}:\\
\;\;\;\;\mathsf{fma}\left(b, a, y \cdot x\right)\\
\mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 c i) < -1.9999999999999999e162 or 1.9999999999999999e-7 < (*.f64 c i) Initial program 88.3%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6484.5
Applied rewrites84.5%
Taylor expanded in x around 0
Applied rewrites78.0%
Taylor expanded in x around 0
Applied rewrites82.3%
if -1.9999999999999999e162 < (*.f64 c i) < -9.9999999999999991e-309 or 2.0000000000000001e-172 < (*.f64 c i) < 1.9999999999999999e-7Initial program 99.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6478.0
Applied rewrites78.0%
Taylor expanded in c around 0
Applied rewrites71.3%
if -9.9999999999999991e-309 < (*.f64 c i) < 2.0000000000000001e-172Initial program 100.0%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6472.0
Applied rewrites72.0%
Taylor expanded in x around 0
Applied rewrites24.3%
Taylor expanded in c around 0
Applied rewrites72.0%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma a b (* t z))))
(if (<= (* z t) -5e+21)
t_1
(if (<= (* z t) -1e-86)
(* i c)
(if (<= (* z t) 1e+118) (fma b a (* y x)) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(a, b, (t * z));
double tmp;
if ((z * t) <= -5e+21) {
tmp = t_1;
} else if ((z * t) <= -1e-86) {
tmp = i * c;
} else if ((z * t) <= 1e+118) {
tmp = fma(b, a, (y * x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(a, b, Float64(t * z)) tmp = 0.0 if (Float64(z * t) <= -5e+21) tmp = t_1; elseif (Float64(z * t) <= -1e-86) tmp = Float64(i * c); elseif (Float64(z * t) <= 1e+118) tmp = fma(b, a, Float64(y * x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -5e+21], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], -1e-86], N[(i * c), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1e+118], N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, b, t \cdot z\right)\\
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+21}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq -1 \cdot 10^{-86}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;z \cdot t \leq 10^{+118}:\\
\;\;\;\;\mathsf{fma}\left(b, a, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -5e21 or 9.99999999999999967e117 < (*.f64 z t) Initial program 93.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6482.6
Applied rewrites82.6%
Taylor expanded in c around 0
Applied rewrites77.2%
if -5e21 < (*.f64 z t) < -1.00000000000000008e-86Initial program 86.7%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6474.5
Applied rewrites74.5%
if -1.00000000000000008e-86 < (*.f64 z t) < 9.99999999999999967e117Initial program 97.6%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6491.8
Applied rewrites91.8%
Taylor expanded in x around 0
Applied rewrites63.3%
Taylor expanded in c around 0
Applied rewrites62.7%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* a b) -2e+23) (not (<= (* a b) 4e-13))) (fma x y (fma c i (* a b))) (fma z t (fma c i (* x y)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((a * b) <= -2e+23) || !((a * b) <= 4e-13)) {
tmp = fma(x, y, fma(c, i, (a * b)));
} else {
tmp = fma(z, t, fma(c, i, (x * y)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(a * b) <= -2e+23) || !(Float64(a * b) <= 4e-13)) tmp = fma(x, y, fma(c, i, Float64(a * b))); else tmp = fma(z, t, fma(c, i, Float64(x * y))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -2e+23], N[Not[LessEqual[N[(a * b), $MachinePrecision], 4e-13]], $MachinePrecision]], N[(x * y + N[(c * i + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * t + N[(c * i + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+23} \lor \neg \left(a \cdot b \leq 4 \cdot 10^{-13}\right):\\
\;\;\;\;\mathsf{fma}\left(x, y, \mathsf{fma}\left(c, i, a \cdot b\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t, \mathsf{fma}\left(c, i, x \cdot y\right)\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -1.9999999999999998e23 or 4.0000000000000001e-13 < (*.f64 a b) Initial program 91.6%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6482.7
Applied rewrites82.7%
Applied rewrites85.8%
if -1.9999999999999998e23 < (*.f64 a b) < 4.0000000000000001e-13Initial program 99.2%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
Applied rewrites98.2%
Final simplification91.8%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* a b) -2e+23) (not (<= (* a b) 4e-13))) (fma x y (fma c i (* a b))) (fma i c (fma t z (* y x)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((a * b) <= -2e+23) || !((a * b) <= 4e-13)) {
tmp = fma(x, y, fma(c, i, (a * b)));
} else {
tmp = fma(i, c, fma(t, z, (y * x)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(a * b) <= -2e+23) || !(Float64(a * b) <= 4e-13)) tmp = fma(x, y, fma(c, i, Float64(a * b))); else tmp = fma(i, c, fma(t, z, Float64(y * x))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -2e+23], N[Not[LessEqual[N[(a * b), $MachinePrecision], 4e-13]], $MachinePrecision]], N[(x * y + N[(c * i + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(i * c + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+23} \lor \neg \left(a \cdot b \leq 4 \cdot 10^{-13}\right):\\
\;\;\;\;\mathsf{fma}\left(x, y, \mathsf{fma}\left(c, i, a \cdot b\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -1.9999999999999998e23 or 4.0000000000000001e-13 < (*.f64 a b) Initial program 91.6%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6482.7
Applied rewrites82.7%
Applied rewrites85.8%
if -1.9999999999999998e23 < (*.f64 a b) < 4.0000000000000001e-13Initial program 99.2%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
Final simplification91.8%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* x y) -1e+186) (not (<= (* x y) 1e+45))) (fma b a (fma i c (* y x))) (fma b a (fma i c (* t z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((x * y) <= -1e+186) || !((x * y) <= 1e+45)) {
tmp = fma(b, a, fma(i, c, (y * x)));
} else {
tmp = fma(b, a, fma(i, c, (t * z)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(x * y) <= -1e+186) || !(Float64(x * y) <= 1e+45)) tmp = fma(b, a, fma(i, c, Float64(y * x))); else tmp = fma(b, a, fma(i, c, Float64(t * z))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -1e+186], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1e+45]], $MachinePrecision]], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+186} \lor \neg \left(x \cdot y \leq 10^{+45}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -9.9999999999999998e185 or 9.9999999999999993e44 < (*.f64 x y) Initial program 93.2%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6486.7
Applied rewrites86.7%
if -9.9999999999999998e185 < (*.f64 x y) < 9.9999999999999993e44Initial program 96.1%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6489.2
Applied rewrites89.2%
Final simplification88.5%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* x y) -1e+87) (not (<= (* x y) 2e+64))) (fma t z (* x y)) (fma b a (fma i c (* t z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((x * y) <= -1e+87) || !((x * y) <= 2e+64)) {
tmp = fma(t, z, (x * y));
} else {
tmp = fma(b, a, fma(i, c, (t * z)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(x * y) <= -1e+87) || !(Float64(x * y) <= 2e+64)) tmp = fma(t, z, Float64(x * y)); else tmp = fma(b, a, fma(i, c, Float64(t * z))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -1e+87], N[Not[LessEqual[N[(x * y), $MachinePrecision], 2e+64]], $MachinePrecision]], N[(t * z + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+87} \lor \neg \left(x \cdot y \leq 2 \cdot 10^{+64}\right):\\
\;\;\;\;\mathsf{fma}\left(t, z, x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -9.9999999999999996e86 or 2.00000000000000004e64 < (*.f64 x y) Initial program 93.0%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6486.8
Applied rewrites86.8%
Applied rewrites86.8%
Taylor expanded in x around 0
Applied rewrites35.7%
Taylor expanded in c around 0
Applied rewrites76.1%
if -9.9999999999999996e86 < (*.f64 x y) < 2.00000000000000004e64Initial program 96.4%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6491.3
Applied rewrites91.3%
Final simplification86.2%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* a b) -5e+191)
(fma i c (* b a))
(if (<= (* a b) 4e-13)
(fma i c (fma t z (* y x)))
(fma b a (fma i c (* y x))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((a * b) <= -5e+191) {
tmp = fma(i, c, (b * a));
} else if ((a * b) <= 4e-13) {
tmp = fma(i, c, fma(t, z, (y * x)));
} else {
tmp = fma(b, a, fma(i, c, (y * x)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(a * b) <= -5e+191) tmp = fma(i, c, Float64(b * a)); elseif (Float64(a * b) <= 4e-13) tmp = fma(i, c, fma(t, z, Float64(y * x))); else tmp = fma(b, a, fma(i, c, Float64(y * x))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(a * b), $MachinePrecision], -5e+191], N[(i * c + N[(b * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 4e-13], N[(i * c + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+191}:\\
\;\;\;\;\mathsf{fma}\left(i, c, b \cdot a\right)\\
\mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(i, c, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -5.0000000000000002e191Initial program 89.1%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6484.0
Applied rewrites84.0%
Taylor expanded in x around 0
Applied rewrites84.6%
Taylor expanded in x around 0
Applied rewrites90.0%
if -5.0000000000000002e191 < (*.f64 a b) < 4.0000000000000001e-13Initial program 98.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6494.6
Applied rewrites94.6%
if 4.0000000000000001e-13 < (*.f64 a b) Initial program 91.3%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6485.2
Applied rewrites85.2%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* c i) -1e+286) (not (<= (* c i) 1e+130))) (* i c) (fma a b (* t z))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((c * i) <= -1e+286) || !((c * i) <= 1e+130)) {
tmp = i * c;
} else {
tmp = fma(a, b, (t * z));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(c * i) <= -1e+286) || !(Float64(c * i) <= 1e+130)) tmp = Float64(i * c); else tmp = fma(a, b, Float64(t * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(c * i), $MachinePrecision], -1e+286], N[Not[LessEqual[N[(c * i), $MachinePrecision], 1e+130]], $MachinePrecision]], N[(i * c), $MachinePrecision], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+286} \lor \neg \left(c \cdot i \leq 10^{+130}\right):\\
\;\;\;\;i \cdot c\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 c i) < -1.00000000000000003e286 or 1.0000000000000001e130 < (*.f64 c i) Initial program 82.0%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6478.7
Applied rewrites78.7%
if -1.00000000000000003e286 < (*.f64 c i) < 1.0000000000000001e130Initial program 99.4%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6472.9
Applied rewrites72.9%
Taylor expanded in c around 0
Applied rewrites63.4%
Final simplification67.0%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* a b) -5e+211) (not (<= (* a b) 1e+65))) (* b a) (* i c)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((a * b) <= -5e+211) || !((a * b) <= 1e+65)) {
tmp = b * a;
} else {
tmp = i * c;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
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 (((a * b) <= (-5d+211)) .or. (.not. ((a * b) <= 1d+65))) then
tmp = b * a
else
tmp = i * c
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 i) {
double tmp;
if (((a * b) <= -5e+211) || !((a * b) <= 1e+65)) {
tmp = b * a;
} else {
tmp = i * c;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if ((a * b) <= -5e+211) or not ((a * b) <= 1e+65): tmp = b * a else: tmp = i * c return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(a * b) <= -5e+211) || !(Float64(a * b) <= 1e+65)) tmp = Float64(b * a); else tmp = Float64(i * c); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if (((a * b) <= -5e+211) || ~(((a * b) <= 1e+65))) tmp = b * a; else tmp = i * c; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -5e+211], N[Not[LessEqual[N[(a * b), $MachinePrecision], 1e+65]], $MachinePrecision]], N[(b * a), $MachinePrecision], N[(i * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+211} \lor \neg \left(a \cdot b \leq 10^{+65}\right):\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;i \cdot c\\
\end{array}
\end{array}
if (*.f64 a b) < -4.9999999999999995e211 or 9.9999999999999999e64 < (*.f64 a b) Initial program 89.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6485.4
Applied rewrites85.4%
Taylor expanded in c around 0
Applied rewrites80.7%
Taylor expanded in z around 0
Applied rewrites70.5%
if -4.9999999999999995e211 < (*.f64 a b) < 9.9999999999999999e64Initial program 98.2%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6432.6
Applied rewrites32.6%
Final simplification45.8%
(FPCore (x y z t a b c i) :precision binary64 (* b a))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return b * a;
}
real(8) function code(x, y, z, t, a, b, c, i)
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 = b * a
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return b * a;
}
def code(x, y, z, t, a, b, c, i): return b * a
function code(x, y, z, t, a, b, c, i) return Float64(b * a) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = b * a; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(b * a), $MachinePrecision]
\begin{array}{l}
\\
b \cdot a
\end{array}
Initial program 95.3%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6475.4
Applied rewrites75.4%
Taylor expanded in c around 0
Applied rewrites54.1%
Taylor expanded in z around 0
Applied rewrites29.3%
herbie shell --seed 2024320
(FPCore (x y z t a b c i)
:name "Linear.V4:$cdot from linear-1.19.1.3, C"
:precision binary64
(+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))