?

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
Error26.3
Cost2033
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ t_2 := a \cdot b + z \cdot t\\ t_3 := a \cdot b + x \cdot y\\ t_4 := x \cdot y + z \cdot t\\ \mathbf{if}\;i \leq -7.8 \cdot 10^{-65}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;i \leq -2.4 \cdot 10^{-208}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;i \leq -9.6 \cdot 10^{-228}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;i \leq -1.3 \cdot 10^{-245}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;i \leq 6.4 \cdot 10^{-289}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;i \leq 2.1 \cdot 10^{-230}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;i \leq 1.14 \cdot 10^{-200}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;i \leq 4 \cdot 10^{-179}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;i \leq 3.1 \cdot 10^{-81}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;i \leq 3350000000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;i \leq 4.6 \cdot 10^{+50} \lor \neg \left(i \leq 3.6 \cdot 10^{+177}\right):\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error28.5
Cost2008
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -3.5 \cdot 10^{+116}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -2.3 \cdot 10^{+18}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -6.2 \cdot 10^{-35}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 3.5 \cdot 10^{-173}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 0.0006:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 1.55 \cdot 10^{+126}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 4
Error42.8
Cost1776
\[\begin{array}{l} \mathbf{if}\;a \leq -1 \cdot 10^{+138}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \leq -3.45 \cdot 10^{+131}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \leq -6.1 \cdot 10^{+109}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \leq -1.3 \cdot 10^{+92}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \leq -4.8 \cdot 10^{+52}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \leq -9.6 \cdot 10^{-27}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \leq -4.8 \cdot 10^{-116}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \leq -2.9 \cdot 10^{-155}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \leq -6.6 \cdot 10^{-239}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \leq -5.5 \cdot 10^{-279}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \leq 3.5 \cdot 10^{-277}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \leq 1.35 \cdot 10^{-116}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 5
Error26.7
Cost1768
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ t_2 := c \cdot i + x \cdot y\\ t_3 := a \cdot b + x \cdot y\\ t_4 := a \cdot b + z \cdot t\\ \mathbf{if}\;i \leq -1.9 \cdot 10^{-67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;i \leq -2.4 \cdot 10^{-208}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;i \leq -1 \cdot 10^{-227}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;i \leq -2.35 \cdot 10^{-237}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;i \leq 4.4 \cdot 10^{-179}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;i \leq 5.4 \cdot 10^{-81}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;i \leq 85000000:\\ \;\;\;\;t_4\\ \mathbf{elif}\;i \leq 4.5 \cdot 10^{+50}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;i \leq 3.25 \cdot 10^{+177}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;i \leq 3.8 \cdot 10^{+202}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \end{array} \]
Alternative 6
Error26.4
Cost1504
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ t_3 := a \cdot b + z \cdot t\\ \mathbf{if}\;i \leq -2.9 \cdot 10^{-65}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;i \leq -2.4 \cdot 10^{-208}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;i \leq -1 \cdot 10^{-227}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;i \leq -8 \cdot 10^{-236}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;i \leq 4 \cdot 10^{-179}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;i \leq 5 \cdot 10^{-81}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;i \leq 5.2 \cdot 10^{-55}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;i \leq 3.5 \cdot 10^{-16}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error24.8
Cost1488
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ \mathbf{if}\;c \cdot i \leq -1.7 \cdot 10^{+100}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1.3 \cdot 10^{-59}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 3.3 \cdot 10^{-307}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 1.35 \cdot 10^{+73}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 8
Error6.1
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -5.3 \cdot 10^{+19} \lor \neg \left(a \cdot b \leq 0.062\right):\\ \;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + \left(x \cdot y + z \cdot t\right)\\ \end{array} \]
Alternative 9
Error9.6
Cost1224
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.5 \cdot 10^{+22}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 9000000000000:\\ \;\;\;\;c \cdot i + \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \end{array} \]
Alternative 10
Error6.1
Cost1224
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -3800000:\\ \;\;\;\;c \cdot i + \left(a \cdot b + x \cdot y\right)\\ \mathbf{elif}\;a \cdot b \leq 0.00375:\\ \;\;\;\;c \cdot i + \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\ \end{array} \]
Alternative 11
Error42.8
Cost1116
\[\begin{array}{l} \mathbf{if}\;b \leq -3.3 \cdot 10^{-48}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;b \leq 5.2 \cdot 10^{-183}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;b \leq 8.5 \cdot 10^{-103}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;b \leq 1.7 \cdot 10^{-19}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;b \leq 5.2 \cdot 10^{+34}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;b \leq 4.8 \cdot 10^{+84}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;b \leq 2.2 \cdot 10^{+137}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 12
Error27.1
Cost1108
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ t_2 := a \cdot b + z \cdot t\\ t_3 := a \cdot b + x \cdot y\\ \mathbf{if}\;t \leq -2.4 \cdot 10^{-90}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -1.28 \cdot 10^{-272}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.26 \cdot 10^{-232}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 8.5 \cdot 10^{-106}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 6 \cdot 10^{+45}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 13
Error0.0
Cost960
\[c \cdot i + \left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right) \]
Alternative 14
Error37.5
Cost712
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -5.5 \cdot 10^{+14}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 3.45 \cdot 10^{+25}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 15
Error47.9
Cost192
\[a \cdot b \]

Error

Reproduce?

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