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

Error

Derivation

  1. Initial program 0.0

    \[\left(x \cdot y + z \cdot t\right) + a \cdot b \]
  2. Applied egg-rr0.0

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

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

Alternatives

Alternative 1
Error0.0
Cost6976
\[a \cdot b + \mathsf{fma}\left(z, t, x \cdot y\right) \]
Alternative 2
Error30.3
Cost1492
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.0343818289721886 \cdot 10^{+40}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -5.863064413199493 \cdot 10^{-74}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 0:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 3.0857381932457447 \cdot 10^{-211}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 0.027713940983546258:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 3
Error20.7
Cost976
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ \mathbf{if}\;t \leq -5.718962599885292 \cdot 10^{-46}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;t \leq 2.1 \cdot 10^{+86}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.1 \cdot 10^{+174}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;t \leq 1.25 \cdot 10^{+231}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
Alternative 4
Error14.3
Cost976
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ t_2 := a \cdot b + z \cdot t\\ \mathbf{if}\;t \leq -1.3457258737983367 \cdot 10^{-109}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 8.385577096170122 \cdot 10^{-56}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.45 \cdot 10^{+189}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.25 \cdot 10^{+231}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error8.8
Cost968
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -3655369533477786.5:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 1.760804751392109 \cdot 10^{-42}:\\ \;\;\;\;z \cdot t + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \end{array} \]
Alternative 6
Error29.8
Cost712
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.0343818289721886 \cdot 10^{+40}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 2.3505536286885863 \cdot 10^{-35}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 7
Error0.0
Cost704
\[a \cdot b + \left(z \cdot t + x \cdot y\right) \]
Alternative 8
Error41.9
Cost192
\[z \cdot t \]

Error

Reproduce

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