Average Error: 0.0 → 0.0
Time: 11.7s
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))))): 1 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))))): 1 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
Cost7232
\[\left(a \cdot b + \mathsf{fma}\left(z, t, x \cdot y\right)\right) + c \cdot i \]
Alternative 2
Error23.0
Cost2528
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := x \cdot y + z \cdot t\\ t_3 := c \cdot i + x \cdot y\\ \mathbf{if}\;c \cdot i \leq -4.697473897752212 \cdot 10^{-19}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq -3.2401571766324545 \cdot 10^{-141}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -3.573402175545362 \cdot 10^{-207}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 2.8320565703961553 \cdot 10^{-245}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 2.3671736483091406 \cdot 10^{-22}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 2.5195180782021278 \cdot 10^{+35}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.5632087357188235 \cdot 10^{+89}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq 2.4055591713342117 \cdot 10^{+161}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 3
Error22.2
Cost2268
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := x \cdot y + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -4.697473897752212 \cdot 10^{-19}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq -3.2401571766324545 \cdot 10^{-141}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -3.573402175545362 \cdot 10^{-207}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 2.8320565703961553 \cdot 10^{-245}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 2.3671736483091406 \cdot 10^{-22}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 2.5195180782021278 \cdot 10^{+35}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.5632087357188235 \cdot 10^{+89}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \end{array} \]
Alternative 4
Error38.2
Cost2012
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.1553018113381797 \cdot 10^{+112}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -6.632817441089542 \cdot 10^{-51}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq -4.5103890722006376 \cdot 10^{-108}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq -2.146227844735673 \cdot 10^{-238}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 2.3613567618600614 \cdot 10^{-34}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 5.081296903240095 \cdot 10^{+40}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 1.1582583005635591 \cdot 10^{+55}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 5
Error22.8
Cost2008
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := x \cdot y + z \cdot t\\ t_3 := c \cdot i + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -4.697473897752212 \cdot 10^{-19}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -3.2401571766324545 \cdot 10^{-141}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -3.573402175545362 \cdot 10^{-207}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 2.8320565703961553 \cdot 10^{-245}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 2.3671736483091406 \cdot 10^{-22}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 1.544313631646826 \cdot 10^{+127}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 6
Error37.5
Cost1232
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -5.3576405773166224 \cdot 10^{+88}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 2.10456845868089 \cdot 10^{-194}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 3.1747270639606527 \cdot 10^{-119}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 2.5195180782021278 \cdot 10^{+35}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 7
Error9.4
Cost1224
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -3.730310327670248 \cdot 10^{+69}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 2.4055591713342117 \cdot 10^{+161}:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \end{array} \]
Alternative 8
Error8.0
Cost1224
\[\begin{array}{l} t_1 := x \cdot y + z \cdot t\\ \mathbf{if}\;a \cdot b \leq -1.1553018113381797 \cdot 10^{+112}:\\ \;\;\;\;a \cdot b + t_1\\ \mathbf{elif}\;a \cdot b \leq 1.1582583005635591 \cdot 10^{+55}:\\ \;\;\;\;c \cdot i + t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \end{array} \]
Alternative 9
Error25.0
Cost968
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -5.3576405773166224 \cdot 10^{+88}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 2.4055591713342117 \cdot 10^{+161}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 10
Error23.0
Cost968
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -4.697473897752212 \cdot 10^{-19}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.544313631646826 \cdot 10^{+127}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error0.0
Cost960
\[c \cdot i + \left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right) \]
Alternative 12
Error37.8
Cost712
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -326085129881.50037:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 2.0806116872131426 \cdot 10^{+51}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 13
Error47.2
Cost192
\[x \cdot y \]

Error

Reproduce

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