?

Average Accuracy: 100.0% → 100.0%
Time: 5.2s
Precision: binary64
Cost: 6976

?

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

Error?

Derivation?

  1. Initial program 100.0%

    \[\left(x \cdot y + z \cdot t\right) + a \cdot b \]
  2. Simplified100.0%

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

    [Start]100.0

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

    fma-def [=>]100.0

    \[ \color{blue}{\mathsf{fma}\left(x, y, z \cdot t\right)} + a \cdot b \]
  3. Taylor expanded in x around 0 100.0%

    \[\leadsto \color{blue}{\left(y \cdot x + t \cdot z\right)} + a \cdot b \]
  4. Simplified100.0%

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

    [Start]100.0

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

    +-commutative [=>]100.0

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

    *-commutative [<=]100.0

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

    *-commutative [=>]100.0

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

    fma-def [=>]100.0

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

    *-commutative [<=]100.0

    \[ \mathsf{fma}\left(z, t, \color{blue}{y \cdot x}\right) + a \cdot b \]
  5. Final simplification100.0%

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

Alternatives

Alternative 1
Accuracy100.0%
Cost6976
\[a \cdot b + \mathsf{fma}\left(x, y, z \cdot t\right) \]
Alternative 2
Accuracy52.2%
Cost1232
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -4.5 \cdot 10^{-127}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -5 \cdot 10^{-309}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;a \cdot b \leq 2.1 \cdot 10^{-94}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 0.0033:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 3
Accuracy74.9%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -3.9 \cdot 10^{+74} \lor \neg \left(x \leq 1.3 \cdot 10^{-225}\right):\\ \;\;\;\;y \cdot x + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]
Alternative 4
Accuracy51.6%
Cost712
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -4.5 \cdot 10^{-142}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 8.4 \cdot 10^{-14}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 5
Accuracy66.8%
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -2.8 \cdot 10^{+104}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-71}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 6
Accuracy100.0%
Cost704
\[a \cdot b + \left(y \cdot x + z \cdot t\right) \]
Alternative 7
Accuracy35.0%
Cost192
\[a \cdot b \]

Error

Reproduce?

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