?

Average Error: 0.03% → 0.02%
Time: 7.0s
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.03

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

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

    [Start]0.03

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

    associate-+l+ [=>]0.03

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

    fma-def [=>]0.02

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

    fma-def [=>]0.02

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

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

Alternatives

Alternative 1
Error0.03%
Cost6976
\[a \cdot b + \mathsf{fma}\left(x, y, z \cdot t\right) \]
Alternative 2
Error48.25%
Cost2533
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -42000:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -2.7 \cdot 10^{-190}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq -6.4 \cdot 10^{-303}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 3.3 \cdot 10^{-268}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 1.46 \cdot 10^{-226}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 2.7 \cdot 10^{-188}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 1.8 \cdot 10^{-12} \lor \neg \left(a \cdot b \leq 8.2 \cdot 10^{+69}\right) \land a \cdot b \leq 3.6 \cdot 10^{+100}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 3
Error14.97%
Cost1489
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ \mathbf{if}\;a \cdot b \leq -21:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 1.18 \cdot 10^{-14}:\\ \;\;\;\;z \cdot t + x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 1.1 \cdot 10^{+70} \lor \neg \left(a \cdot b \leq 7.5 \cdot 10^{+101}\right):\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error48.34%
Cost1233
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -7.2 \cdot 10^{-10}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 4.7 \cdot 10^{-17} \lor \neg \left(a \cdot b \leq 3.15 \cdot 10^{+72}\right) \land a \cdot b \leq 3.6 \cdot 10^{+100}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 5
Error23.4%
Cost978
\[\begin{array}{l} \mathbf{if}\;t \leq -1.3 \cdot 10^{-104} \lor \neg \left(t \leq 1.15 \cdot 10^{-16} \lor \neg \left(t \leq 2.1 \cdot 10^{+72}\right) \land t \leq 7.6 \cdot 10^{+147}\right):\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \end{array} \]
Alternative 6
Error34.62%
Cost977
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{-70}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{+116} \lor \neg \left(y \leq 2.35 \cdot 10^{+229}\right) \land y \leq 7 \cdot 10^{+294}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 7
Error0.03%
Cost704
\[a \cdot b + \left(z \cdot t + x \cdot y\right) \]
Alternative 8
Error65.23%
Cost192
\[a \cdot b \]

Error

Reproduce?

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