?

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

?

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

Alternatives

Alternative 1
Error22.9
Cost2008
\[\begin{array}{l} t_1 := t \cdot z + a \cdot b\\ \mathbf{if}\;a \cdot b \leq -2 \cdot 10^{-18}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-75}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;a \cdot b \leq -5 \cdot 10^{-144}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq -4 \cdot 10^{-192}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{-207}:\\ \;\;\;\;t \cdot z\\ \mathbf{elif}\;a \cdot b \leq 8 \cdot 10^{-72}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error36.8
Cost1512
\[\begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{+75}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-174}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{-286}:\\ \;\;\;\;t \cdot z\\ \mathbf{elif}\;x \leq 4.3 \cdot 10^{-250}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-141}:\\ \;\;\;\;t \cdot z\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-81}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-26}:\\ \;\;\;\;t \cdot z\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{+21}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{+91}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 3.25 \cdot 10^{+184}:\\ \;\;\;\;t \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 3
Error9.4
Cost1228
\[\begin{array}{l} t_1 := t \cdot z + a \cdot b\\ \mathbf{if}\;a \cdot b \leq -2.5 \cdot 10^{-18}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-63}:\\ \;\;\;\;y \cdot x + t \cdot z\\ \mathbf{elif}\;a \cdot b \leq 50:\\ \;\;\;\;y \cdot x + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error36.5
Cost984
\[\begin{array}{l} \mathbf{if}\;t \leq -5.6 \cdot 10^{-25}:\\ \;\;\;\;t \cdot z\\ \mathbf{elif}\;t \leq 1.02 \cdot 10^{-196}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;t \leq 6.2 \cdot 10^{-143}:\\ \;\;\;\;t \cdot z\\ \mathbf{elif}\;t \leq 9 \cdot 10^{+29}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;t \leq 9.8 \cdot 10^{+113}:\\ \;\;\;\;t \cdot z\\ \mathbf{elif}\;t \leq 1.7 \cdot 10^{+175}:\\ \;\;\;\;b \cdot a\\ \mathbf{else}:\\ \;\;\;\;t \cdot z\\ \end{array} \]
Alternative 5
Error9.2
Cost968
\[\begin{array}{l} t_1 := t \cdot z + a \cdot b\\ \mathbf{if}\;z \cdot t \leq -2 \cdot 10^{-35}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \cdot t \leq 2:\\ \;\;\;\;y \cdot x + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error0.0
Cost704
\[\left(x \cdot y + z \cdot t\right) + a \cdot b \]
Alternative 7
Error42.1
Cost192
\[b \cdot a \]

Error

Reproduce?

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