?

Average Accuracy: 58.5% → 58.5%
Time: 17.9s
Precision: binary64
Cost: 19776

?

\[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
\[\mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)\right) \]
(FPCore (x y z t a b c i)
 :precision binary64
 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))
(FPCore (x y z t a b c i)
 :precision binary64
 (fma c i (fma x y (fma z t (* a b)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return fma(c, i, fma(x, y, fma(z, t, (a * b))));
}
function code(x, y, z, t, a, b, c, i)
	return Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i))
end
function code(x, y, z, t, a, b, c, i)
	return fma(c, i, fma(x, y, fma(z, t, Float64(a * b))))
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(c * i + N[(x * y + N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)\right)

Error?

Derivation?

  1. Initial program 59.7%

    \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
  2. Simplified59.7%

    \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)\right)} \]
    Step-by-step derivation

    [Start]59.7

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

    +-commutative [=>]59.7

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

    fma-def [=>]59.7

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

    associate-+l+ [=>]59.7

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

    fma-def [=>]59.7

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

    fma-def [=>]59.7

    \[ \mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, \color{blue}{\mathsf{fma}\left(z, t, a \cdot b\right)}\right)\right) \]
  3. Final simplification59.7%

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

Alternatives

Alternative 1
Accuracy58.5%
Cost7232
\[\mathsf{fma}\left(x, y, z \cdot t\right) + \left(a \cdot b + c \cdot i\right) \]
Alternative 2
Accuracy24.4%
Cost1492
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.15 \cdot 10^{+57}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -2.7 \cdot 10^{-34}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 10^{-318}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 1.4 \cdot 10^{-113}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 11500000:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 3
Accuracy36.9%
Cost1488
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -7 \cdot 10^{+69}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -8 \cdot 10^{-306}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.5 \cdot 10^{-260}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 6.8 \cdot 10^{+71}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 4
Accuracy38.4%
Cost1488
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + c \cdot i\\ \mathbf{if}\;c \cdot i \leq -1.15 \cdot 10^{+66}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -2.3 \cdot 10^{-300}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 8 \cdot 10^{-262}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 8.8 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Accuracy38.9%
Cost1488
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -1.6 \cdot 10^{+66}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -4.4 \cdot 10^{-307}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 2.45 \cdot 10^{-259}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 5.3 \cdot 10^{+39}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \end{array} \]
Alternative 6
Accuracy51.1%
Cost1224
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -1.62 \cdot 10^{+66}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 7.8 \cdot 10^{+71}:\\ \;\;\;\;a \cdot b + \left(z \cdot t + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \end{array} \]
Alternative 7
Accuracy52.2%
Cost1224
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -2.5 \cdot 10^{+59}:\\ \;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\ \mathbf{elif}\;c \cdot i \leq 3.4 \cdot 10^{+71}:\\ \;\;\;\;a \cdot b + \left(z \cdot t + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \end{array} \]
Alternative 8
Accuracy53.3%
Cost1224
\[\begin{array}{l} t_1 := z \cdot t + x \cdot y\\ \mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+57}:\\ \;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\ \mathbf{elif}\;c \cdot i \leq 5.8 \cdot 10^{+15}:\\ \;\;\;\;a \cdot b + t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + t_1\\ \end{array} \]
Alternative 9
Accuracy20.3%
Cost984
\[\begin{array}{l} \mathbf{if}\;t \leq -1.3 \cdot 10^{-79}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;t \leq -1.3 \cdot 10^{-288}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;t \leq 1.02 \cdot 10^{-262}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;t \leq 1.55 \cdot 10^{-186}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;t \leq 1.08 \cdot 10^{-41}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;t \leq 2.1 \cdot 10^{+108}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
Alternative 10
Accuracy37.1%
Cost968
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -6.8 \cdot 10^{+69}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 2.95 \cdot 10^{+72}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 11
Accuracy58.5%
Cost960
\[c \cdot i + \left(a \cdot b + \left(z \cdot t + x \cdot y\right)\right) \]
Alternative 12
Accuracy24.8%
Cost712
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -6.8 \cdot 10^{+69}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 1.9 \cdot 10^{+16}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 13
Accuracy15.8%
Cost192
\[a \cdot b \]

Error

Reproduce?

herbie shell --seed 2023157 
(FPCore (x y z t a b c i)
  :name "Linear.V4:$cdot from linear-1.19.1.3, C"
  :precision binary64
  (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))