Average Error: 0.0 → 0.0
Time: 13.2s
Precision: binary64
Cost: 19776
\[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
\[\mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, \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 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 (((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(c, i, fma(a, b, 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(c, i, fma(a, b, 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[(c * i + N[(a * b + 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(c, i, \mathsf{fma}\left(a, b, \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(c, i, \mathsf{fma}\left(a, b, \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}{c \cdot i + \left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right)} \]

    fma-def [=>]0.0

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

    +-commutative [=>]0.0

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

    fma-def [=>]0.0

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

    fma-def [=>]0.0

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

    \[\leadsto \mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, \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
Error0.0
Cost7232
\[\mathsf{fma}\left(z, t, x \cdot y\right) + \left(a \cdot b + c \cdot i\right) \]
Alternative 3
Error38.8
Cost3572
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -2.5 \cdot 10^{+139}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1 \cdot 10^{+35}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq -5.2 \cdot 10^{-64}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq -1.45 \cdot 10^{-67}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -3.2 \cdot 10^{-172}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq -6.6 \cdot 10^{-205}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq -5 \cdot 10^{-314}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 7.5 \cdot 10^{-99}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 1.4 \cdot 10^{-67}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 1.5 \cdot 10^{-64}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 3.4 \cdot 10^{-39}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 7.4 \cdot 10^{-32}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 3.9 \cdot 10^{+40}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 4
Error32.8
Cost2268
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ \mathbf{if}\;c \cdot i \leq -3.2 \cdot 10^{-81}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -1.8 \cdot 10^{-159}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq -9.8 \cdot 10^{-207}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -5 \cdot 10^{-314}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 1.76 \cdot 10^{-100}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 1.4 \cdot 10^{-66}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 1.6 \cdot 10^{-64}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error22.4
Cost2268
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + c \cdot i\\ t_3 := x \cdot y + a \cdot b\\ \mathbf{if}\;c \cdot i \leq -9.5 \cdot 10^{+55}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -5.2 \cdot 10^{-64}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -1.12 \cdot 10^{-80}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -5 \cdot 10^{-314}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq 2.3 \cdot 10^{-119}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 5.2 \cdot 10^{-31}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq 2.6 \cdot 10^{+31}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error38.9
Cost2012
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -2.4 \cdot 10^{+138}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1.62 \cdot 10^{+34}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq -1.1 \cdot 10^{-41}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq -2.1 \cdot 10^{-202}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 1.5 \cdot 10^{-64}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 3.5 \cdot 10^{-41}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 5.2 \cdot 10^{+33}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 7
Error24.0
Cost2008
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + c \cdot i\\ \mathbf{if}\;c \cdot i \leq -4.8 \cdot 10^{+56}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -1.46 \cdot 10^{-67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -7.5 \cdot 10^{-153}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq -5 \cdot 10^{-219}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -5 \cdot 10^{-314}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 2.05 \cdot 10^{+32}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error26.5
Cost1505
\[\begin{array}{l} t_1 := x \cdot y + c \cdot i\\ t_2 := a \cdot b + z \cdot t\\ \mathbf{if}\;b \leq -8.8 \cdot 10^{-159}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq -1.9 \cdot 10^{-234}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -4.8 \cdot 10^{-293}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;b \leq 8800:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 10^{+42}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 4.5 \cdot 10^{+67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 1.6 \cdot 10^{+141} \lor \neg \left(b \leq 8 \cdot 10^{+245}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;x \cdot y + a \cdot b\\ \end{array} \]
Alternative 9
Error8.7
Cost1225
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -2.3 \cdot 10^{+78} \lor \neg \left(c \cdot i \leq 6.8 \cdot 10^{+56}\right):\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \end{array} \]
Alternative 10
Error6.4
Cost1225
\[\begin{array}{l} t_1 := x \cdot y + z \cdot t\\ \mathbf{if}\;a \cdot b \leq -2.7 \cdot 10^{+64} \lor \neg \left(a \cdot b \leq 4.2 \cdot 10^{+26}\right):\\ \;\;\;\;a \cdot b + t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + t_1\\ \end{array} \]
Alternative 11
Error0.0
Cost960
\[c \cdot i + \left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right) \]
Alternative 12
Error38.2
Cost712
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -6.2 \cdot 10^{+64}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 0.0135:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 13
Error46.8
Cost192
\[a \cdot b \]

Error

Reproduce

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