Average Error: 0.0 → 0.0
Time: 14.8s
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
Error0.0
Cost7232
\[\mathsf{fma}\left(x, y, z \cdot t\right) + \left(a \cdot b + c \cdot i\right) \]
Alternative 2
Error38.2
Cost3052
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.56 \cdot 10^{+44}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -8 \cdot 10^{+29}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq -5.4 \cdot 10^{+18}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -2.2 \cdot 10^{-53}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq -8.2 \cdot 10^{-58}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq -7.2 \cdot 10^{-100}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 1.6 \cdot 10^{-191}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 8.4 \cdot 10^{-42}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 2.7 \cdot 10^{+19}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 3.9 \cdot 10^{+68}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 1.2 \cdot 10^{+128}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 3
Error21.9
Cost2528
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ t_3 := a \cdot b + c \cdot i\\ \mathbf{if}\;c \cdot i \leq -9.5 \cdot 10^{+85}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -1.7 \cdot 10^{-75}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -4 \cdot 10^{-320}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 8.6 \cdot 10^{-247}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 9 \cdot 10^{-120}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 2.1 \cdot 10^{+40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 3 \cdot 10^{+87}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 3.35 \cdot 10^{+87}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Error22.4
Cost2528
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ t_2 := a \cdot b + z \cdot t\\ t_3 := z \cdot t + x \cdot y\\ t_4 := c \cdot i + x \cdot y\\ \mathbf{if}\;c \cdot i \leq -3.85 \cdot 10^{+173}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \cdot i \leq -1.25 \cdot 10^{+89}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1.6 \cdot 10^{-169}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -4 \cdot 10^{-320}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 4.9 \cdot 10^{-247}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 1.05 \cdot 10^{-120}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 140:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq 2.7 \cdot 10^{+41}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_4\\ \end{array} \]
Alternative 5
Error27.1
Cost2164
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ \mathbf{if}\;x \leq -1.7 \cdot 10^{+124}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -5 \cdot 10^{+110}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.1 \cdot 10^{+89}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq -2.1 \cdot 10^{+37}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.5 \cdot 10^{-8}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -7 \cdot 10^{-24}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.5 \cdot 10^{-37}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.6 \cdot 10^{-74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.7 \cdot 10^{-103}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -8.5 \cdot 10^{-248}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{-187}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-148}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-100}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error27.0
Cost2032
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ t_3 := c \cdot i + x \cdot y\\ \mathbf{if}\;x \leq -7 \cdot 10^{+124}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.56 \cdot 10^{+109}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.22 \cdot 10^{+83}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -1.32 \cdot 10^{+37}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.48 \cdot 10^{-8}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-24}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-36}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.5 \cdot 10^{-73}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{-102}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -5 \cdot 10^{-250}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-186}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{-108}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 7
Error37.9
Cost1752
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -4.8 \cdot 10^{+88}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -2.4 \cdot 10^{-172}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq -5 \cdot 10^{-324}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 3000000000000:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 3.6 \cdot 10^{+39}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 6 \cdot 10^{+46}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 8
Error15.2
Cost1629
\[\begin{array}{l} t_1 := z \cdot t + x \cdot y\\ t_2 := a \cdot b + \left(c \cdot i + z \cdot t\right)\\ \mathbf{if}\;y \leq -1.46 \cdot 10^{-6}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+60}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{+77}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{+121}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.18 \cdot 10^{+144}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+175} \lor \neg \left(y \leq 8.5 \cdot 10^{+229}\right):\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Error31.3
Cost1505
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ \mathbf{if}\;t \leq -2.4 \cdot 10^{-25}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;t \leq 3.6 \cdot 10^{-135}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 7.2 \cdot 10^{-91}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;t \leq 82000000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.7 \cdot 10^{+38}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;t \leq 5.8 \cdot 10^{+125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.65 \cdot 10^{+186} \lor \neg \left(t \leq 1.45 \cdot 10^{+217}\right):\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 10
Error32.3
Cost1504
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ \mathbf{if}\;t \leq -1.85 \cdot 10^{-25}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;t \leq 1.7 \cdot 10^{-135}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.65 \cdot 10^{-93}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;t \leq 85000000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.1 \cdot 10^{+38}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;t \leq 6 \cdot 10^{+125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.92 \cdot 10^{+180}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;t \leq 3.8 \cdot 10^{+185}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.35 \cdot 10^{+217}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
Alternative 11
Error7.6
Cost1224
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -5.9 \cdot 10^{+85}:\\ \;\;\;\;a \cdot b + \left(c \cdot i + z \cdot t\right)\\ \mathbf{elif}\;c \cdot i \leq 6.8 \cdot 10^{+92}:\\ \;\;\;\;a \cdot b + \left(z \cdot t + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \end{array} \]
Alternative 12
Error0.0
Cost960
\[c \cdot i + \left(a \cdot b + \left(z \cdot t + x \cdot y\right)\right) \]
Alternative 13
Error37.2
Cost712
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -1.2 \cdot 10^{+39}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 4.3 \cdot 10^{+46}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 14
Error46.8
Cost192
\[a \cdot b \]

Error

Reproduce

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