Average Error: 0.0 → 0.0
Time: 12.4s
Precision: binary64
Cost: 19776
\[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
\[\mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, \mathsf{fma}\left(c, i, 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 x y (fma z t (fma c i (* 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(x, y, fma(z, t, fma(c, i, (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(x, y, fma(z, t, fma(c, i, 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[(x * y + N[(z * t + N[(c * i + 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(x, y, \mathsf{fma}\left(z, t, \mathsf{fma}\left(c, i, a \cdot b\right)\right)\right)

Error

Derivation

  1. Initial program 0.0

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, \mathsf{fma}\left(c, i, a \cdot b\right)\right)\right)} \]
    Proof
    (fma.f64 x y (fma.f64 z t (fma.f64 c i (*.f64 a b)))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 z t (Rewrite<= fma-def_binary64 (+.f64 (*.f64 c i) (*.f64 a b))))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 z t (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 a b) (*.f64 c i))))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (Rewrite<= fma-def_binary64 (+.f64 (*.f64 z t) (+.f64 (*.f64 a b) (*.f64 c i))))): 4 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 x y) (+.f64 (*.f64 z t) (+.f64 (*.f64 a b) (*.f64 c i))))): 1 points increase in error, 0 points decrease in error
    (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (+.f64 (*.f64 a b) (*.f64 c i)))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i))): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.0

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

Alternatives

Alternative 1
Error0.0
Cost13504
\[\mathsf{fma}\left(z, t, \mathsf{fma}\left(c, i, a \cdot b\right)\right) + x \cdot y \]
Alternative 2
Error0.0
Cost7232
\[x \cdot y + \left(a \cdot b + \mathsf{fma}\left(z, t, c \cdot i\right)\right) \]
Alternative 3
Error22.9
Cost2528
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ t_2 := x \cdot y + z \cdot t\\ t_3 := c \cdot i + z \cdot t\\ \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+93}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{+42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot y \leq -5 \cdot 10^{-176}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{-204}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{-166}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \cdot y \leq 2.3 \cdot 10^{-25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot y \leq 0.01:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \cdot y \leq 10^{+109}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error27.3
Cost2268
\[\begin{array}{l} t_1 := x \cdot y + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ \mathbf{if}\;a \cdot b \leq -6.602995088872467 \cdot 10^{+95}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -4.284678858099299 \cdot 10^{-12}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq -5.357299628203318 \cdot 10^{-24}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq -7.781851573985181 \cdot 10^{-202}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 2.946772324054719 \cdot 10^{-149}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 3.76775614528453 \cdot 10^{-83}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 3.7143353556154977 \cdot 10^{-17}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error24.0
Cost2008
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ t_2 := x \cdot y + z \cdot t\\ \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+93}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{+42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot y \leq -6 \cdot 10^{-62}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{-204}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot y \leq 10^{-175}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \cdot y \leq 10^{+109}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error42.1
Cost1512
\[\begin{array}{l} \mathbf{if}\;z \leq -1.75 \cdot 10^{+128}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;z \leq -2.1442213362759935 \cdot 10^{+64}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;z \leq -3.653461646652633 \cdot 10^{-50}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;z \leq -5.0510511457650253 \cdot 10^{-144}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;z \leq -6.265415425150223 \cdot 10^{-156}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;z \leq -4.0798840007093424 \cdot 10^{-227}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \leq 1.587811603621264 \cdot 10^{-308}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;z \leq 1.0695877401982802 \cdot 10^{-263}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;z \leq 4.8175726525463826 \cdot 10^{-210}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \leq 1.8456618392961016 \cdot 10^{-131}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
Alternative 7
Error25.8
Cost1488
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ \mathbf{if}\;c \cdot i \leq -3.6 \cdot 10^{+55}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1.2837655069738792 \cdot 10^{-84}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -7.230569029682756 \cdot 10^{-156}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 7.703326665501798 \cdot 10^{+62}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 8
Error8.9
Cost1224
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -3.6 \cdot 10^{+55}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 7.703326665501798 \cdot 10^{+62}:\\ \;\;\;\;x \cdot y + \left(a \cdot b + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error42.7
Cost984
\[\begin{array}{l} \mathbf{if}\;z \leq -1.75 \cdot 10^{+128}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;z \leq -2658816.1203759187:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;z \leq -1.9283599011860352 \cdot 10^{-12}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;z \leq -5.0510511457650253 \cdot 10^{-144}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;z \leq -4.0798840007093424 \cdot 10^{-227}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \leq 4.6984800791498024 \cdot 10^{-126}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
Alternative 10
Error0.0
Cost960
\[c \cdot i + \left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right) \]
Alternative 11
Error42.6
Cost720
\[\begin{array}{l} \mathbf{if}\;z \leq -1.75 \cdot 10^{+128}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;z \leq -2658816.1203759187:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;z \leq -1.9283599011860352 \cdot 10^{-12}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;z \leq 4.6984800791498024 \cdot 10^{-126}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
Alternative 12
Error46.9
Cost192
\[z \cdot t \]

Error

Reproduce

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