?

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

?

\[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
\[\mathsf{fma}\left(x, y, \mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, 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 x y (fma c i (fma a b (* 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(x, y, fma(c, i, fma(a, b, (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(x, y, fma(c, i, fma(a, b, 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[(x * y + N[(c * i + N[(a * b + 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(x, y, \mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, 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(x, y, \mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, 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 \]

    associate-+l+ [=>]0.0

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

    associate-+l+ [=>]0.0

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

    fma-def [=>]0.0

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

    associate-+r+ [=>]0.0

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

    +-commutative [=>]0.0

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

    fma-def [=>]0.0

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

    +-commutative [=>]0.0

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

    fma-def [=>]0.0

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

    \[\leadsto \mathsf{fma}\left(x, y, \mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, 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
Error21.3
Cost2788
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ t_3 := c \cdot i + z \cdot t\\ t_4 := x \cdot y + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -3 \cdot 10^{+39}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -1.24 \cdot 10^{-119}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 1.95 \cdot 10^{-171}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \cdot i \leq 1.9 \cdot 10^{-137}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 3.6 \cdot 10^{-39}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \cdot i \leq 4500:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 4.3 \cdot 10^{+39}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq 1.22 \cdot 10^{+67}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 1.65 \cdot 10^{+179}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \end{array} \]
Alternative 3
Error17.9
Cost2026
\[\begin{array}{l} t_1 := x \cdot y + z \cdot t\\ t_2 := c \cdot i + z \cdot t\\ t_3 := c \cdot i + x \cdot y\\ t_4 := a \cdot b + t_3\\ \mathbf{if}\;b \leq -3.25 \cdot 10^{-223}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \leq -1.9 \cdot 10^{-277}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq -8.2 \cdot 10^{-308}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 8.3 \cdot 10^{-255}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 9.5 \cdot 10^{-182}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \leq 8.2 \cdot 10^{-135}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 5 \cdot 10^{-41} \lor \neg \left(b \leq 2.6 \cdot 10^{-8} \lor \neg \left(b \leq 6 \cdot 10^{+94}\right) \land b \leq 3.2 \cdot 10^{+124}\right):\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error27.0
Cost1900
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ t_2 := c \cdot i + z \cdot t\\ t_3 := a \cdot b + z \cdot t\\ t_4 := c \cdot i + x \cdot y\\ \mathbf{if}\;x \leq -4.8 \cdot 10^{+106}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;x \leq -2.2 \cdot 10^{+101}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -5 \cdot 10^{+92}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;x \leq -3.5 \cdot 10^{+76}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5.8 \cdot 10^{+41}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -3050000000:\\ \;\;\;\;t_4\\ \mathbf{elif}\;x \leq -5.4 \cdot 10^{-9}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -6 \cdot 10^{-36}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;x \leq -5.8 \cdot 10^{-71}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.86 \cdot 10^{-106}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 1.46 \cdot 10^{-180}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error22.0
Cost1490
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -3 \cdot 10^{+39} \lor \neg \left(c \cdot i \leq 190 \lor \neg \left(c \cdot i \leq 8.5 \cdot 10^{+38}\right) \land c \cdot i \leq 7 \cdot 10^{+67}\right):\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \end{array} \]
Alternative 6
Error38.7
Cost1232
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -6.2 \cdot 10^{+45}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 3.05 \cdot 10^{-207}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 2.25 \cdot 10^{-129}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 1.8 \cdot 10^{-65}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 7
Error36.7
Cost1232
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -5.5 \cdot 10^{+42}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 7.2 \cdot 10^{-172}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 1.95 \cdot 10^{-137}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 1.4 \cdot 10^{+25}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 8
Error7.3
Cost1224
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+70}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 3.5 \cdot 10^{+28}:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + \left(c \cdot i + x \cdot y\right)\\ \end{array} \]
Alternative 9
Error6.0
Cost1224
\[\begin{array}{l} t_1 := x \cdot y + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -2.55 \cdot 10^{+33}:\\ \;\;\;\;c \cdot i + t_1\\ \mathbf{elif}\;c \cdot i \leq 1.6 \cdot 10^{+28}:\\ \;\;\;\;a \cdot b + t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + \left(c \cdot i + x \cdot y\right)\\ \end{array} \]
Alternative 10
Error6.2
Cost1224
\[\begin{array}{l} t_1 := x \cdot y + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -1.12 \cdot 10^{+36}:\\ \;\;\;\;c \cdot i + t_1\\ \mathbf{elif}\;c \cdot i \leq 1.8 \cdot 10^{+23}:\\ \;\;\;\;a \cdot b + t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot t + \left(a \cdot b + c \cdot i\right)\\ \end{array} \]
Alternative 11
Error24.4
Cost969
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -4.6 \cdot 10^{+61} \lor \neg \left(c \cdot i \leq 1.2 \cdot 10^{+67}\right):\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \end{array} \]
Alternative 12
Error21.7
Cost969
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -7.6 \cdot 10^{+41} \lor \neg \left(c \cdot i \leq 2.75 \cdot 10^{+26}\right):\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \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.7
Cost712
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -2.1 \cdot 10^{+64}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 170:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 15
Error47.8
Cost192
\[a \cdot b \]

Error

Reproduce?

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