?

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

?

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

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, \mathsf{fma}\left(z, t, a \cdot b\right)\right)} \]
    Proof

    [Start]100.0

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

    associate-+l+ [=>]100.0

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

    fma-def [=>]100.0

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

    fma-def [=>]100.0

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

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

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

    [Start]100.0

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

    +-commutative [=>]100.0

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

    *-commutative [=>]100.0

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

    *-commutative [<=]100.0

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

    associate-+r+ [=>]100.0

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

    +-commutative [<=]100.0

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

    associate-+r+ [<=]100.0

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

    fma-def [=>]100.0

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

    +-commutative [=>]100.0

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

    fma-def [=>]100.0

    \[ \mathsf{fma}\left(z, t, \color{blue}{\mathsf{fma}\left(x, y, a \cdot b\right)}\right) \]
  5. Applied egg-rr100.0%

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

    [Start]100.0

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

    fma-udef [=>]100.0

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

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

Alternatives

Alternative 1
Accuracy51.2%
Cost2272
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+85}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -1.4 \cdot 10^{-73}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq -2.25 \cdot 10^{-241}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 3 \cdot 10^{-306}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 1.25 \cdot 10^{-238}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 9 \cdot 10^{-66}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+37}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 3.1 \cdot 10^{+57}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 2
Accuracy83.8%
Cost969
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -6 \cdot 10^{-73} \lor \neg \left(a \cdot b \leq 4.8 \cdot 10^{+49}\right):\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;z \cdot t + x \cdot y\\ \end{array} \]
Alternative 3
Accuracy68.4%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -4.4 \cdot 10^{+176} \lor \neg \left(x \leq 3.8 \cdot 10^{-12}\right):\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]
Alternative 4
Accuracy77.3%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -2.8 \cdot 10^{+54} \lor \neg \left(x \leq 5 \cdot 10^{-14}\right):\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]
Alternative 5
Accuracy51.1%
Cost712
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.8 \cdot 10^{+85}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 5.6 \cdot 10^{+57}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 6
Accuracy100.0%
Cost704
\[a \cdot b + \left(z \cdot t + x \cdot y\right) \]
Alternative 7
Accuracy35.2%
Cost192
\[a \cdot b \]

Error

Reproduce?

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