Average Error: 0.0 → 0.0
Time: 12.3s
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
Error0.0
Cost6976
\[\mathsf{fma}\left(z, t, x \cdot y\right) + a \cdot b \]
Alternative 2
Error24.4
Cost1504
\[\begin{array}{l} t_1 := a \cdot b + t \cdot z\\ \mathbf{if}\;t \leq -1.85 \cdot 10^{+169}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -5.2 \cdot 10^{+119}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;t \leq -2.25 \cdot 10^{-83}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.55 \cdot 10^{-110}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;t \leq 5.7 \cdot 10^{-120}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4 \cdot 10^{-84}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;t \leq 10^{+16}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.5 \cdot 10^{+86}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error30.0
Cost972
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.6 \cdot 10^{+23}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -8.6 \cdot 10^{-280}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 1.25 \cdot 10^{+17}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 4
Error10.1
Cost968
\[\begin{array}{l} t_1 := a \cdot b + t \cdot z\\ \mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+77}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \cdot t \leq 4 \cdot 10^{+41}:\\ \;\;\;\;a \cdot b + y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error9.5
Cost968
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -5 \cdot 10^{-45}:\\ \;\;\;\;a \cdot b + t \cdot z\\ \mathbf{elif}\;a \cdot b \leq 3.5 \cdot 10^{-31}:\\ \;\;\;\;y \cdot x + t \cdot z\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + y \cdot x\\ \end{array} \]
Alternative 6
Error30.6
Cost712
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -4.1 \cdot 10^{-62}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 1.22 \cdot 10^{+17}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 7
Error0.0
Cost704
\[\left(x \cdot y + z \cdot t\right) + a \cdot b \]
Alternative 8
Error41.7
Cost192
\[a \cdot b \]

Error

Reproduce

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