?

Average Error: 0.0 → 0.0
Time: 11.6s
Precision: binary64
Cost: 19776

?

\[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
\[\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, z \cdot t\right)\right)\right) \]
(FPCore (x y z t a b c i)
 :precision binary64
 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))
(FPCore (x y z t a b c i)
 :precision binary64
 (fma a b (fma c i (fma x y (* z t)))))
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);
}
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return fma(a, b, fma(c, i, fma(x, y, (z * t))));
}
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 code(x, y, z, t, a, b, c, i)
	return fma(a, b, fma(c, i, fma(x, y, Float64(z * t))))
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]
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(a * b + N[(c * i + N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, z \cdot t\right)\right)\right)

Error?

Derivation?

  1. Initial program 0.0

    \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
  2. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, z \cdot t\right)\right)\right)} \]
    Proof

    [Start]0.0

    \[ \left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]

    +-commutative [=>]0.0

    \[ \color{blue}{\left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right)} + c \cdot i \]

    associate-+l+ [=>]0.0

    \[ \color{blue}{a \cdot b + \left(\left(x \cdot y + z \cdot t\right) + c \cdot i\right)} \]

    fma-def [=>]0.0

    \[ \color{blue}{\mathsf{fma}\left(a, b, \left(x \cdot y + z \cdot t\right) + c \cdot i\right)} \]

    +-commutative [=>]0.0

    \[ \mathsf{fma}\left(a, b, \color{blue}{c \cdot i + \left(x \cdot y + z \cdot t\right)}\right) \]

    fma-def [=>]0.0

    \[ \mathsf{fma}\left(a, b, \color{blue}{\mathsf{fma}\left(c, i, x \cdot y + z \cdot t\right)}\right) \]

    fma-def [=>]0.0

    \[ \mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, \color{blue}{\mathsf{fma}\left(x, y, z \cdot t\right)}\right)\right) \]
  3. Final simplification0.0

    \[\leadsto \mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, z \cdot t\right)\right)\right) \]

Alternatives

Alternative 1
Error22.8
Cost2268
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ t_2 := x \cdot y + z \cdot t\\ t_3 := a \cdot b + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -2.8 \cdot 10^{+94}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -1.02 \cdot 10^{+76}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -3.7 \cdot 10^{+15}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -1.4 \cdot 10^{-76}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -1.5 \cdot 10^{-178}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq 1.35 \cdot 10^{-252}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 1.35 \cdot 10^{-77}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error26.2
Cost1768
\[\begin{array}{l} t_1 := c \cdot i + x \cdot y\\ t_2 := a \cdot b + z \cdot t\\ \mathbf{if}\;y \leq -0.00135:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.45 \cdot 10^{-212}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;y \leq 2.15 \cdot 10^{-60}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 3.75 \cdot 10^{-22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 7 \cdot 10^{+31}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.66 \cdot 10^{+121}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.1 \cdot 10^{+132}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 2.25 \cdot 10^{+176}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{+250}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+262}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error37.4
Cost1752
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -6 \cdot 10^{+23}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 1.1 \cdot 10^{-244}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 3.3 \cdot 10^{-193}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 9.5 \cdot 10^{-14}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 4.1 \cdot 10^{+14}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 6 \cdot 10^{+53}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 4
Error38.5
Cost1752
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -750000:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1.95 \cdot 10^{-79}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq -1.9 \cdot 10^{-142}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq -1.46 \cdot 10^{-170}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 1.8 \cdot 10^{-251}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 2.65 \cdot 10^{-73}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 5
Error23.7
Cost1488
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -2.3 \cdot 10^{-65}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq -2.9 \cdot 10^{-173}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 6.6 \cdot 10^{-259}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 1.5 \cdot 10^{-77}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \end{array} \]
Alternative 6
Error31.4
Cost1240
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ \mathbf{if}\;x \leq -1 \cdot 10^{+201}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq -1.6 \cdot 10^{+165}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.2 \cdot 10^{+127}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq -1.5 \cdot 10^{-190}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -4.2 \cdot 10^{-232}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-34}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 7
Error9.2
Cost1224
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -3.3 \cdot 10^{+96}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 2.55 \cdot 10^{+112}:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \end{array} \]
Alternative 8
Error23.0
Cost969
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -620000 \lor \neg \left(c \cdot i \leq 9.5 \cdot 10^{-80}\right):\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]
Alternative 9
Error22.5
Cost968
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -100:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 1.5 \cdot 10^{-13}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]
Alternative 10
Error0.0
Cost960
\[\left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right) + c \cdot i \]
Alternative 11
Error37.4
Cost712
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.35 \cdot 10^{+24}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 10^{-13}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 12
Error46.7
Cost192
\[a \cdot b \]

Error

Reproduce?

herbie shell --seed 2023054 
(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)))