
(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 13 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 c i (fma x y (fma z t (* a b)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(c, i, fma(x, y, fma(z, t, (a * b))));
}
function code(x, y, z, t, a, b, c, i) return fma(c, i, fma(x, y, fma(z, t, Float64(a * b)))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(c * i + N[(x * y + N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)\right)
\end{array}
Initial program 94.9%
+-commutative94.9%
fma-def96.9%
associate-+l+96.9%
fma-def98.0%
fma-def98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x y z t a b c i) :precision binary64 (fma c i (fma a b (fma x y (* z t)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(c, i, fma(a, b, fma(x, y, (z * t))));
}
function code(x, y, z, t, a, b, c, i) return fma(c, i, fma(a, b, fma(x, y, Float64(z * t)))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(c * i + N[(a * b + N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, \mathsf{fma}\left(x, y, z \cdot t\right)\right)\right)
\end{array}
Initial program 94.9%
+-commutative94.9%
fma-def96.9%
+-commutative96.9%
fma-def97.3%
fma-def97.7%
Simplified97.7%
Final simplification97.7%
(FPCore (x y z t a b c i) :precision binary64 (fma c i (+ (+ (* a b) (* x y)) (* z t))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(c, i, (((a * b) + (x * y)) + (z * t)));
}
function code(x, y, z, t, a, b, c, i) return fma(c, i, Float64(Float64(Float64(a * b) + Float64(x * y)) + Float64(z * t))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(c * i + N[(N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(c, i, \left(a \cdot b + x \cdot y\right) + z \cdot t\right)
\end{array}
Initial program 94.9%
+-commutative94.9%
fma-def96.9%
+-commutative96.9%
fma-def97.3%
fma-def97.7%
Simplified97.7%
fma-udef97.2%
fma-def96.9%
associate-+r+96.9%
Applied egg-rr96.9%
Final simplification96.9%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (+ (* c i) (* z t))) (t_2 (+ (* x y) (* c i))))
(if (<= (* a b) -5.2e+153)
(* a b)
(if (<= (* a b) -1.4e-89)
t_1
(if (<= (* a b) 2.8e-134)
t_2
(if (<= (* a b) 7e-61)
t_1
(if (<= (* a b) 7.2e+133) t_2 (* a b))))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (c * i) + (z * t);
double t_2 = (x * y) + (c * i);
double tmp;
if ((a * b) <= -5.2e+153) {
tmp = a * b;
} else if ((a * b) <= -1.4e-89) {
tmp = t_1;
} else if ((a * b) <= 2.8e-134) {
tmp = t_2;
} else if ((a * b) <= 7e-61) {
tmp = t_1;
} else if ((a * b) <= 7.2e+133) {
tmp = t_2;
} else {
tmp = a * b;
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (c * i) + (z * t)
t_2 = (x * y) + (c * i)
if ((a * b) <= (-5.2d+153)) then
tmp = a * b
else if ((a * b) <= (-1.4d-89)) then
tmp = t_1
else if ((a * b) <= 2.8d-134) then
tmp = t_2
else if ((a * b) <= 7d-61) then
tmp = t_1
else if ((a * b) <= 7.2d+133) then
tmp = t_2
else
tmp = a * b
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 t_1 = (c * i) + (z * t);
double t_2 = (x * y) + (c * i);
double tmp;
if ((a * b) <= -5.2e+153) {
tmp = a * b;
} else if ((a * b) <= -1.4e-89) {
tmp = t_1;
} else if ((a * b) <= 2.8e-134) {
tmp = t_2;
} else if ((a * b) <= 7e-61) {
tmp = t_1;
} else if ((a * b) <= 7.2e+133) {
tmp = t_2;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): t_1 = (c * i) + (z * t) t_2 = (x * y) + (c * i) tmp = 0 if (a * b) <= -5.2e+153: tmp = a * b elif (a * b) <= -1.4e-89: tmp = t_1 elif (a * b) <= 2.8e-134: tmp = t_2 elif (a * b) <= 7e-61: tmp = t_1 elif (a * b) <= 7.2e+133: tmp = t_2 else: tmp = a * b return tmp
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(c * i) + Float64(z * t)) t_2 = Float64(Float64(x * y) + Float64(c * i)) tmp = 0.0 if (Float64(a * b) <= -5.2e+153) tmp = Float64(a * b); elseif (Float64(a * b) <= -1.4e-89) tmp = t_1; elseif (Float64(a * b) <= 2.8e-134) tmp = t_2; elseif (Float64(a * b) <= 7e-61) tmp = t_1; elseif (Float64(a * b) <= 7.2e+133) tmp = t_2; else tmp = Float64(a * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) t_1 = (c * i) + (z * t); t_2 = (x * y) + (c * i); tmp = 0.0; if ((a * b) <= -5.2e+153) tmp = a * b; elseif ((a * b) <= -1.4e-89) tmp = t_1; elseif ((a * b) <= 2.8e-134) tmp = t_2; elseif ((a * b) <= 7e-61) tmp = t_1; elseif ((a * b) <= 7.2e+133) tmp = t_2; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(c * i), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -5.2e+153], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -1.4e-89], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], 2.8e-134], t$95$2, If[LessEqual[N[(a * b), $MachinePrecision], 7e-61], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], 7.2e+133], t$95$2, N[(a * b), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := c \cdot i + z \cdot t\\
t_2 := x \cdot y + c \cdot i\\
\mathbf{if}\;a \cdot b \leq -5.2 \cdot 10^{+153}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq -1.4 \cdot 10^{-89}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq 2.8 \cdot 10^{-134}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;a \cdot b \leq 7 \cdot 10^{-61}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq 7.2 \cdot 10^{+133}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -5.1999999999999998e153 or 7.19999999999999956e133 < (*.f64 a b) Initial program 91.9%
Taylor expanded in a around inf 81.2%
if -5.1999999999999998e153 < (*.f64 a b) < -1.3999999999999999e-89 or 2.7999999999999999e-134 < (*.f64 a b) < 7.0000000000000006e-61Initial program 94.2%
Taylor expanded in a around 0 83.0%
Taylor expanded in x around 0 64.8%
if -1.3999999999999999e-89 < (*.f64 a b) < 2.7999999999999999e-134 or 7.0000000000000006e-61 < (*.f64 a b) < 7.19999999999999956e133Initial program 97.3%
Taylor expanded in z around 0 76.6%
fma-def76.6%
Simplified76.6%
Taylor expanded in a around 0 71.3%
Final simplification72.4%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* c i) -1.75e+108)
(* c i)
(if (<= (* c i) -7e-80)
(* z t)
(if (<= (* c i) -2.9e-274)
(* a b)
(if (<= (* c i) 4.8e-225)
(* z t)
(if (<= (* c i) 5.4e+103) (* a b) (* c i)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c * i) <= -1.75e+108) {
tmp = c * i;
} else if ((c * i) <= -7e-80) {
tmp = z * t;
} else if ((c * i) <= -2.9e-274) {
tmp = a * b;
} else if ((c * i) <= 4.8e-225) {
tmp = z * t;
} else if ((c * i) <= 5.4e+103) {
tmp = a * b;
} else {
tmp = c * i;
}
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 ((c * i) <= (-1.75d+108)) then
tmp = c * i
else if ((c * i) <= (-7d-80)) then
tmp = z * t
else if ((c * i) <= (-2.9d-274)) then
tmp = a * b
else if ((c * i) <= 4.8d-225) then
tmp = z * t
else if ((c * i) <= 5.4d+103) then
tmp = a * b
else
tmp = c * i
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 ((c * i) <= -1.75e+108) {
tmp = c * i;
} else if ((c * i) <= -7e-80) {
tmp = z * t;
} else if ((c * i) <= -2.9e-274) {
tmp = a * b;
} else if ((c * i) <= 4.8e-225) {
tmp = z * t;
} else if ((c * i) <= 5.4e+103) {
tmp = a * b;
} else {
tmp = c * i;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (c * i) <= -1.75e+108: tmp = c * i elif (c * i) <= -7e-80: tmp = z * t elif (c * i) <= -2.9e-274: tmp = a * b elif (c * i) <= 4.8e-225: tmp = z * t elif (c * i) <= 5.4e+103: tmp = a * b else: tmp = c * i return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(c * i) <= -1.75e+108) tmp = Float64(c * i); elseif (Float64(c * i) <= -7e-80) tmp = Float64(z * t); elseif (Float64(c * i) <= -2.9e-274) tmp = Float64(a * b); elseif (Float64(c * i) <= 4.8e-225) tmp = Float64(z * t); elseif (Float64(c * i) <= 5.4e+103) tmp = Float64(a * b); else tmp = Float64(c * i); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((c * i) <= -1.75e+108) tmp = c * i; elseif ((c * i) <= -7e-80) tmp = z * t; elseif ((c * i) <= -2.9e-274) tmp = a * b; elseif ((c * i) <= 4.8e-225) tmp = z * t; elseif ((c * i) <= 5.4e+103) tmp = a * b; else tmp = c * i; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -1.75e+108], N[(c * i), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -7e-80], N[(z * t), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -2.9e-274], N[(a * b), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 4.8e-225], N[(z * t), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 5.4e+103], N[(a * b), $MachinePrecision], N[(c * i), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -1.75 \cdot 10^{+108}:\\
\;\;\;\;c \cdot i\\
\mathbf{elif}\;c \cdot i \leq -7 \cdot 10^{-80}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;c \cdot i \leq -2.9 \cdot 10^{-274}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;c \cdot i \leq 4.8 \cdot 10^{-225}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;c \cdot i \leq 5.4 \cdot 10^{+103}:\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;c \cdot i\\
\end{array}
\end{array}
if (*.f64 c i) < -1.7500000000000001e108 or 5.39999999999999985e103 < (*.f64 c i) Initial program 89.0%
Taylor expanded in c around inf 66.6%
if -1.7500000000000001e108 < (*.f64 c i) < -7.00000000000000029e-80 or -2.89999999999999976e-274 < (*.f64 c i) < 4.79999999999999992e-225Initial program 98.9%
Taylor expanded in z around inf 46.9%
if -7.00000000000000029e-80 < (*.f64 c i) < -2.89999999999999976e-274 or 4.79999999999999992e-225 < (*.f64 c i) < 5.39999999999999985e103Initial program 96.3%
Taylor expanded in a around inf 48.6%
Final simplification53.8%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (+ (* x y) (* z t))))
(if (<= (* a b) -5e+153)
(* a b)
(if (<= (* a b) -1.95e-87)
t_1
(if (<= (* a b) 6.5e-116)
(+ (* x y) (* c i))
(if (<= (* a b) 1.35e+133) t_1 (* a b)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (x * y) + (z * t);
double tmp;
if ((a * b) <= -5e+153) {
tmp = a * b;
} else if ((a * b) <= -1.95e-87) {
tmp = t_1;
} else if ((a * b) <= 6.5e-116) {
tmp = (x * y) + (c * i);
} else if ((a * b) <= 1.35e+133) {
tmp = t_1;
} else {
tmp = a * b;
}
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) :: t_1
real(8) :: tmp
t_1 = (x * y) + (z * t)
if ((a * b) <= (-5d+153)) then
tmp = a * b
else if ((a * b) <= (-1.95d-87)) then
tmp = t_1
else if ((a * b) <= 6.5d-116) then
tmp = (x * y) + (c * i)
else if ((a * b) <= 1.35d+133) then
tmp = t_1
else
tmp = a * b
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 t_1 = (x * y) + (z * t);
double tmp;
if ((a * b) <= -5e+153) {
tmp = a * b;
} else if ((a * b) <= -1.95e-87) {
tmp = t_1;
} else if ((a * b) <= 6.5e-116) {
tmp = (x * y) + (c * i);
} else if ((a * b) <= 1.35e+133) {
tmp = t_1;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): t_1 = (x * y) + (z * t) tmp = 0 if (a * b) <= -5e+153: tmp = a * b elif (a * b) <= -1.95e-87: tmp = t_1 elif (a * b) <= 6.5e-116: tmp = (x * y) + (c * i) elif (a * b) <= 1.35e+133: tmp = t_1 else: tmp = a * b return tmp
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if (Float64(a * b) <= -5e+153) tmp = Float64(a * b); elseif (Float64(a * b) <= -1.95e-87) tmp = t_1; elseif (Float64(a * b) <= 6.5e-116) tmp = Float64(Float64(x * y) + Float64(c * i)); elseif (Float64(a * b) <= 1.35e+133) tmp = t_1; else tmp = Float64(a * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) t_1 = (x * y) + (z * t); tmp = 0.0; if ((a * b) <= -5e+153) tmp = a * b; elseif ((a * b) <= -1.95e-87) tmp = t_1; elseif ((a * b) <= 6.5e-116) tmp = (x * y) + (c * i); elseif ((a * b) <= 1.35e+133) tmp = t_1; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -5e+153], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -1.95e-87], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], 6.5e-116], N[(N[(x * y), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1.35e+133], t$95$1, N[(a * b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+153}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq -1.95 \cdot 10^{-87}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq 6.5 \cdot 10^{-116}:\\
\;\;\;\;x \cdot y + c \cdot i\\
\mathbf{elif}\;a \cdot b \leq 1.35 \cdot 10^{+133}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -5.00000000000000018e153 or 1.3500000000000001e133 < (*.f64 a b) Initial program 91.9%
Taylor expanded in a around inf 81.2%
if -5.00000000000000018e153 < (*.f64 a b) < -1.9499999999999999e-87 or 6.5000000000000001e-116 < (*.f64 a b) < 1.3500000000000001e133Initial program 94.3%
Taylor expanded in a around 0 81.3%
Taylor expanded in c around 0 64.6%
if -1.9499999999999999e-87 < (*.f64 a b) < 6.5000000000000001e-116Initial program 98.7%
Taylor expanded in z around 0 78.6%
fma-def78.6%
Simplified78.6%
Taylor expanded in a around 0 78.6%
Final simplification73.6%
(FPCore (x y z t a b c i) :precision binary64 (let* ((t_1 (+ (* x y) (* z t))) (t_2 (+ (* c i) (+ (* a b) t_1)))) (if (<= t_2 INFINITY) t_2 t_1)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (x * y) + (z * t);
double t_2 = (c * i) + ((a * b) + t_1);
double tmp;
if (t_2 <= ((double) INFINITY)) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (x * y) + (z * t);
double t_2 = (c * i) + ((a * b) + t_1);
double tmp;
if (t_2 <= Double.POSITIVE_INFINITY) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): t_1 = (x * y) + (z * t) t_2 = (c * i) + ((a * b) + t_1) tmp = 0 if t_2 <= math.inf: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(x * y) + Float64(z * t)) t_2 = Float64(Float64(c * i) + Float64(Float64(a * b) + t_1)) tmp = 0.0 if (t_2 <= Inf) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) t_1 = (x * y) + (z * t); t_2 = (c * i) + ((a * b) + t_1); tmp = 0.0; if (t_2 <= Inf) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * i), $MachinePrecision] + N[(N[(a * b), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, Infinity], t$95$2, t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
t_2 := c \cdot i + \left(a \cdot b + t\_1\right)\\
\mathbf{if}\;t\_2 \leq \infty:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i)) < +inf.0Initial program 100.0%
if +inf.0 < (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i)) Initial program 0.0%
Taylor expanded in a around 0 23.1%
Taylor expanded in c around 0 46.6%
Final simplification97.3%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (+ (* x y) (* z t))))
(if (or (<= (* c i) -2e+17) (not (<= (* c i) 1.12e+104)))
(+ (* c i) t_1)
(+ (* 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 = (x * y) + (z * t);
double tmp;
if (((c * i) <= -2e+17) || !((c * i) <= 1.12e+104)) {
tmp = (c * i) + t_1;
} else {
tmp = (a * b) + t_1;
}
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) :: t_1
real(8) :: tmp
t_1 = (x * y) + (z * t)
if (((c * i) <= (-2d+17)) .or. (.not. ((c * i) <= 1.12d+104))) then
tmp = (c * i) + t_1
else
tmp = (a * b) + t_1
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 t_1 = (x * y) + (z * t);
double tmp;
if (((c * i) <= -2e+17) || !((c * i) <= 1.12e+104)) {
tmp = (c * i) + t_1;
} else {
tmp = (a * b) + t_1;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): t_1 = (x * y) + (z * t) tmp = 0 if ((c * i) <= -2e+17) or not ((c * i) <= 1.12e+104): tmp = (c * i) + t_1 else: tmp = (a * b) + t_1 return tmp
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(x * y) + Float64(z * t)) tmp = 0.0 if ((Float64(c * i) <= -2e+17) || !(Float64(c * i) <= 1.12e+104)) tmp = Float64(Float64(c * i) + t_1); else tmp = Float64(Float64(a * b) + t_1); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) t_1 = (x * y) + (z * t); tmp = 0.0; if (((c * i) <= -2e+17) || ~(((c * i) <= 1.12e+104))) tmp = (c * i) + t_1; else tmp = (a * b) + t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[N[(c * i), $MachinePrecision], -2e+17], N[Not[LessEqual[N[(c * i), $MachinePrecision], 1.12e+104]], $MachinePrecision]], N[(N[(c * i), $MachinePrecision] + t$95$1), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + t$95$1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
\mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+17} \lor \neg \left(c \cdot i \leq 1.12 \cdot 10^{+104}\right):\\
\;\;\;\;c \cdot i + t\_1\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + t\_1\\
\end{array}
\end{array}
if (*.f64 c i) < -2e17 or 1.12000000000000003e104 < (*.f64 c i) Initial program 89.7%
Taylor expanded in a around 0 82.8%
if -2e17 < (*.f64 c i) < 1.12000000000000003e104Initial program 98.1%
Taylor expanded in c around 0 93.9%
Final simplification89.7%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* c i) -6.5e+203)
(+ (* c i) (* z t))
(if (<= (* c i) 1.45e+110)
(+ (* a b) (+ (* x y) (* z t)))
(+ (* x y) (* c i)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c * i) <= -6.5e+203) {
tmp = (c * i) + (z * t);
} else if ((c * i) <= 1.45e+110) {
tmp = (a * b) + ((x * y) + (z * t));
} else {
tmp = (x * y) + (c * i);
}
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 ((c * i) <= (-6.5d+203)) then
tmp = (c * i) + (z * t)
else if ((c * i) <= 1.45d+110) then
tmp = (a * b) + ((x * y) + (z * t))
else
tmp = (x * y) + (c * i)
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 ((c * i) <= -6.5e+203) {
tmp = (c * i) + (z * t);
} else if ((c * i) <= 1.45e+110) {
tmp = (a * b) + ((x * y) + (z * t));
} else {
tmp = (x * y) + (c * i);
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (c * i) <= -6.5e+203: tmp = (c * i) + (z * t) elif (c * i) <= 1.45e+110: tmp = (a * b) + ((x * y) + (z * t)) else: tmp = (x * y) + (c * i) return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(c * i) <= -6.5e+203) tmp = Float64(Float64(c * i) + Float64(z * t)); elseif (Float64(c * i) <= 1.45e+110) tmp = Float64(Float64(a * b) + Float64(Float64(x * y) + Float64(z * t))); else tmp = Float64(Float64(x * y) + Float64(c * i)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((c * i) <= -6.5e+203) tmp = (c * i) + (z * t); elseif ((c * i) <= 1.45e+110) tmp = (a * b) + ((x * y) + (z * t)); else tmp = (x * y) + (c * i); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -6.5e+203], N[(N[(c * i), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 1.45e+110], N[(N[(a * b), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -6.5 \cdot 10^{+203}:\\
\;\;\;\;c \cdot i + z \cdot t\\
\mathbf{elif}\;c \cdot i \leq 1.45 \cdot 10^{+110}:\\
\;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot y + c \cdot i\\
\end{array}
\end{array}
if (*.f64 c i) < -6.5000000000000003e203Initial program 86.7%
Taylor expanded in a around 0 83.5%
Taylor expanded in x around 0 76.9%
if -6.5000000000000003e203 < (*.f64 c i) < 1.45e110Initial program 97.9%
Taylor expanded in c around 0 89.7%
if 1.45e110 < (*.f64 c i) Initial program 86.4%
Taylor expanded in z around 0 86.7%
fma-def86.7%
Simplified86.7%
Taylor expanded in a around 0 84.2%
Final simplification87.4%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* a b) -5.6e+153)
(* a b)
(if (<= (* a b) -1.52e-89)
(* z t)
(if (<= (* a b) 6.8e+105) (* x y) (* a b)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((a * b) <= -5.6e+153) {
tmp = a * b;
} else if ((a * b) <= -1.52e-89) {
tmp = z * t;
} else if ((a * b) <= 6.8e+105) {
tmp = x * y;
} else {
tmp = a * b;
}
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) <= (-5.6d+153)) then
tmp = a * b
else if ((a * b) <= (-1.52d-89)) then
tmp = z * t
else if ((a * b) <= 6.8d+105) then
tmp = x * y
else
tmp = a * b
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) <= -5.6e+153) {
tmp = a * b;
} else if ((a * b) <= -1.52e-89) {
tmp = z * t;
} else if ((a * b) <= 6.8e+105) {
tmp = x * y;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (a * b) <= -5.6e+153: tmp = a * b elif (a * b) <= -1.52e-89: tmp = z * t elif (a * b) <= 6.8e+105: tmp = x * y else: tmp = a * b return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(a * b) <= -5.6e+153) tmp = Float64(a * b); elseif (Float64(a * b) <= -1.52e-89) tmp = Float64(z * t); elseif (Float64(a * b) <= 6.8e+105) tmp = Float64(x * y); else tmp = Float64(a * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((a * b) <= -5.6e+153) tmp = a * b; elseif ((a * b) <= -1.52e-89) tmp = z * t; elseif ((a * b) <= 6.8e+105) tmp = x * y; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(a * b), $MachinePrecision], -5.6e+153], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -1.52e-89], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 6.8e+105], N[(x * y), $MachinePrecision], N[(a * b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5.6 \cdot 10^{+153}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq -1.52 \cdot 10^{-89}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 6.8 \cdot 10^{+105}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -5.5999999999999997e153 or 6.7999999999999999e105 < (*.f64 a b) Initial program 92.8%
Taylor expanded in a around inf 76.2%
if -5.5999999999999997e153 < (*.f64 a b) < -1.52e-89Initial program 92.7%
Taylor expanded in z around inf 43.2%
if -1.52e-89 < (*.f64 a b) < 6.7999999999999999e105Initial program 97.4%
Taylor expanded in x around inf 43.6%
Final simplification54.1%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* x y) -2e+124) (not (<= (* x y) 3.4e+138))) (* x y) (+ (* c i) (* z t))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((x * y) <= -2e+124) || !((x * y) <= 3.4e+138)) {
tmp = x * y;
} else {
tmp = (c * i) + (z * t);
}
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 (((x * y) <= (-2d+124)) .or. (.not. ((x * y) <= 3.4d+138))) then
tmp = x * y
else
tmp = (c * i) + (z * t)
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 (((x * y) <= -2e+124) || !((x * y) <= 3.4e+138)) {
tmp = x * y;
} else {
tmp = (c * i) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if ((x * y) <= -2e+124) or not ((x * y) <= 3.4e+138): tmp = x * y else: tmp = (c * i) + (z * t) return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(x * y) <= -2e+124) || !(Float64(x * y) <= 3.4e+138)) tmp = Float64(x * y); else tmp = Float64(Float64(c * i) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if (((x * y) <= -2e+124) || ~(((x * y) <= 3.4e+138))) tmp = x * y; else tmp = (c * i) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -2e+124], N[Not[LessEqual[N[(x * y), $MachinePrecision], 3.4e+138]], $MachinePrecision]], N[(x * y), $MachinePrecision], N[(N[(c * i), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+124} \lor \neg \left(x \cdot y \leq 3.4 \cdot 10^{+138}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;c \cdot i + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -1.9999999999999999e124 or 3.40000000000000011e138 < (*.f64 x y) Initial program 88.6%
Taylor expanded in x around inf 71.6%
if -1.9999999999999999e124 < (*.f64 x y) < 3.40000000000000011e138Initial program 97.7%
Taylor expanded in a around 0 66.4%
Taylor expanded in x around 0 59.1%
Final simplification62.9%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* c i) -2e+17) (not (<= (* c i) 2.4e+103))) (* c i) (* a b)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((c * i) <= -2e+17) || !((c * i) <= 2.4e+103)) {
tmp = c * i;
} else {
tmp = a * b;
}
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 (((c * i) <= (-2d+17)) .or. (.not. ((c * i) <= 2.4d+103))) then
tmp = c * i
else
tmp = a * b
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 (((c * i) <= -2e+17) || !((c * i) <= 2.4e+103)) {
tmp = c * i;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if ((c * i) <= -2e+17) or not ((c * i) <= 2.4e+103): tmp = c * i else: tmp = a * b return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(c * i) <= -2e+17) || !(Float64(c * i) <= 2.4e+103)) tmp = Float64(c * i); else tmp = Float64(a * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if (((c * i) <= -2e+17) || ~(((c * i) <= 2.4e+103))) tmp = c * i; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(c * i), $MachinePrecision], -2e+17], N[Not[LessEqual[N[(c * i), $MachinePrecision], 2.4e+103]], $MachinePrecision]], N[(c * i), $MachinePrecision], N[(a * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+17} \lor \neg \left(c \cdot i \leq 2.4 \cdot 10^{+103}\right):\\
\;\;\;\;c \cdot i\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 c i) < -2e17 or 2.3999999999999998e103 < (*.f64 c i) Initial program 89.7%
Taylor expanded in c around inf 60.4%
if -2e17 < (*.f64 c i) < 2.3999999999999998e103Initial program 98.1%
Taylor expanded in a around inf 38.4%
Final simplification46.8%
(FPCore (x y z t a b c i) :precision binary64 (* a b))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return a * b;
}
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 = a * b
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return a * b;
}
def code(x, y, z, t, a, b, c, i): return a * b
function code(x, y, z, t, a, b, c, i) return Float64(a * b) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = a * b; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(a * b), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b
\end{array}
Initial program 94.9%
Taylor expanded in a around inf 30.4%
Final simplification30.4%
herbie shell --seed 2024029
(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)))