Average Error: 0.0 → 0.0
Time: 7.9s
Precision: binary64
Cost: 13504
\[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
\[\mathsf{fma}\left(x, y, z \cdot t\right) + \mathsf{fma}\left(b, a, c \cdot i\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 (* z t)) (fma b a (* c i))))
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, (z * t)) + fma(b, a, (c * i));
}
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 Float64(fma(x, y, Float64(z * t)) + fma(b, a, Float64(c * i)))
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[(N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(b * a + N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\mathsf{fma}\left(x, y, z \cdot t\right) + \mathsf{fma}\left(b, a, c \cdot i\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, z \cdot t\right) + \left(a \cdot b + c \cdot i\right)} \]
    Proof
    (+.f64 (fma.f64 x y (*.f64 z t)) (+.f64 (*.f64 a b) (*.f64 c i))): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 x y) (*.f64 z t))) (+.f64 (*.f64 a b) (*.f64 c i))): 2 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. Applied egg-rr0.0

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

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

Alternatives

Alternative 1
Error0.0
Cost7232
\[\mathsf{fma}\left(x, y, z \cdot t\right) + \left(c \cdot i + b \cdot a\right) \]
Alternative 2
Error37.2
Cost2532
\[\begin{array}{l} \mathbf{if}\;b \cdot a \leq -3.1 \cdot 10^{+41}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;b \cdot a \leq -1.4 \cdot 10^{-165}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;b \cdot a \leq -1.3 \cdot 10^{-179}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;b \cdot a \leq -4.1 \cdot 10^{-227}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;b \cdot a \leq -1.15 \cdot 10^{-302}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;b \cdot a \leq 1.52 \cdot 10^{-305}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;b \cdot a \leq 3.6 \cdot 10^{-238}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;b \cdot a \leq 1.75 \cdot 10^{-57}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;b \cdot a \leq 420:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;b \cdot a\\ \end{array} \]
Alternative 3
Error22.1
Cost2528
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ t_2 := z \cdot t + x \cdot y\\ t_3 := c \cdot i + b \cdot a\\ \mathbf{if}\;b \cdot a \leq -2.1 \cdot 10^{+74}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq -3.6 \cdot 10^{-70}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -4.6 \cdot 10^{-78}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq -1.3 \cdot 10^{-148}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -2.5 \cdot 10^{-238}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -6.7 \cdot 10^{-298}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 1.05 \cdot 10^{-267}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq 2200000:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Error37.5
Cost2012
\[\begin{array}{l} \mathbf{if}\;b \cdot a \leq -5.4 \cdot 10^{-31}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;b \cdot a \leq -2.5 \cdot 10^{-155}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;b \cdot a \leq 6.3 \cdot 10^{-306}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;b \cdot a \leq 6.2 \cdot 10^{-239}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;b \cdot a \leq 6.8 \cdot 10^{-59}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;b \cdot a \leq 0.00095:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;b \cdot a \leq 2800000:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;b \cdot a\\ \end{array} \]
Alternative 5
Error23.1
Cost1488
\[\begin{array}{l} t_1 := c \cdot i + b \cdot a\\ \mathbf{if}\;b \cdot a \leq -8200000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -2.25 \cdot 10^{-64}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;b \cdot a \leq -4.6 \cdot 10^{-78}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 2900000:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error32.5
Cost1240
\[\begin{array}{l} t_1 := c \cdot i + b \cdot a\\ \mathbf{if}\;x \leq -1.08 \cdot 10^{+189}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq -6.5 \cdot 10^{-66}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -9.5 \cdot 10^{-102}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \leq -4.5 \cdot 10^{-262}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-294}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \leq 0.00034:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 7
Error9.3
Cost1224
\[\begin{array}{l} t_1 := c \cdot i + b \cdot a\\ \mathbf{if}\;b \cdot a \leq -1.6 \cdot 10^{+144}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 8.6 \cdot 10^{+48}:\\ \;\;\;\;c \cdot i + \left(z \cdot t + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error5.8
Cost1224
\[\begin{array}{l} t_1 := c \cdot i + \left(b \cdot a + z \cdot t\right)\\ \mathbf{if}\;b \cdot a \leq -5 \cdot 10^{+39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 3.6 \cdot 10^{+17}:\\ \;\;\;\;c \cdot i + \left(z \cdot t + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error0.0
Cost960
\[c \cdot i + \left(b \cdot a + \left(z \cdot t + x \cdot y\right)\right) \]
Alternative 10
Error37.3
Cost712
\[\begin{array}{l} \mathbf{if}\;b \cdot a \leq -4 \cdot 10^{-29}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;b \cdot a \leq 2600:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;b \cdot a\\ \end{array} \]
Alternative 11
Error46.7
Cost192
\[b \cdot a \]

Error

Reproduce

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