?

Average Error: 0.0 → 0.0
Time: 5.7s
Precision: binary64
Cost: 13248

?

\[\left(x \cdot y + z \cdot t\right) + a \cdot b \]
\[\mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right) \]
(FPCore (x y z t a b) :precision binary64 (+ (+ (* x y) (* z t)) (* a b)))
(FPCore (x y z t a b) :precision binary64 (fma x y (fma z t (* a b))))
double code(double x, double y, double z, double t, double a, double b) {
	return ((x * y) + (z * t)) + (a * b);
}
double code(double x, double y, double z, double t, double a, double b) {
	return fma(x, y, fma(z, t, (a * b)));
}
function code(x, y, z, t, a, b)
	return Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b))
end
function code(x, y, z, t, a, b)
	return fma(x, y, fma(z, t, Float64(a * b)))
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := N[(x * y + N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(x \cdot y + z \cdot t\right) + a \cdot b
\mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)

Error?

Derivation?

  1. Initial program 0.0

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

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

    [Start]0.0

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

    associate-+l+ [=>]0.0

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

    fma-def [=>]0.0

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

    fma-def [=>]0.0

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

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

Alternatives

Alternative 1
Error36.8
Cost1248
\[\begin{array}{l} \mathbf{if}\;x \leq -1.16 \cdot 10^{+201}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq -3.5 \cdot 10^{+113}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{+81}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq -140000:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-11}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;x \leq -1.85 \cdot 10^{-144}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \leq 4.35 \cdot 10^{-277}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{-125}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 2
Error9.9
Cost1228
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ \mathbf{if}\;a \cdot b \leq -1900:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 2.2 \cdot 10^{-87}:\\ \;\;\;\;z \cdot t + x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 7 \cdot 10^{+42}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \end{array} \]
Alternative 3
Error23.2
Cost978
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+221} \lor \neg \left(x \leq -3.3 \cdot 10^{+113}\right) \land \left(x \leq -2.05 \cdot 10^{+82} \lor \neg \left(x \leq 3.8 \cdot 10^{-125}\right)\right):\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]
Alternative 4
Error15.3
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -6 \cdot 10^{-158} \lor \neg \left(t \leq 4.9 \cdot 10^{+45}\right):\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \end{array} \]
Alternative 5
Error30.4
Cost712
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.2 \cdot 10^{-35}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 9.2 \cdot 10^{-10}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 6
Error0.0
Cost704
\[a \cdot b + \left(z \cdot t + x \cdot y\right) \]
Alternative 7
Error42.4
Cost192
\[a \cdot b \]

Error

Reproduce?

herbie shell --seed 2023034 
(FPCore (x y z t a b)
  :name "Linear.V3:$cdot from linear-1.19.1.3, B"
  :precision binary64
  (+ (+ (* x y) (* z t)) (* a b)))