Average Error: 0.0 → 0.0
Time: 5.6s
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.2
Cost2272
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -7.056002558491595 \cdot 10^{+90}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -2.172983854954962 \cdot 10^{+69}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq -1.3182851531349158 \cdot 10^{+27}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -1.5517600932540332 \cdot 10^{-31}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq -1.0485789527920044 \cdot 10^{-79}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq -9.74414526077647 \cdot 10^{-181}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq -3.9864205270420105 \cdot 10^{-269}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 2.3145488614605767 \cdot 10^{-9}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 3
Error13.4
Cost1488
\[\begin{array}{l} t_1 := z \cdot t + x \cdot y\\ \mathbf{if}\;a \cdot b \leq -7.056002558491595 \cdot 10^{+90}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -2.172983854954962 \cdot 10^{+69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq -1.3182851531349158 \cdot 10^{+27}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 65449262970.78595:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 4
Error10.2
Cost1488
\[\begin{array}{l} t_1 := z \cdot t + x \cdot y\\ t_2 := a \cdot b + x \cdot y\\ \mathbf{if}\;a \cdot b \leq -7.056002558491595 \cdot 10^{+90}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -2.172983854954962 \cdot 10^{+69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq -1.3182851531349158 \cdot 10^{+27}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 3.8408839563133917 \cdot 10^{-20}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error9.3
Cost968
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -3.147366156679038 \cdot 10^{-25}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 3.8408839563133917 \cdot 10^{-20}:\\ \;\;\;\;z \cdot t + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \end{array} \]
Alternative 6
Error35.6
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -1.5336725179590313 \cdot 10^{-61}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 104785299182392240:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;y \leq 9 \cdot 10^{+67}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{+107}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 7
Error0.0
Cost704
\[a \cdot b + \left(z \cdot t + x \cdot y\right) \]
Alternative 8
Error42.0
Cost192
\[x \cdot y \]

Error

Reproduce

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