Average Error: 0.0 → 0.0
Time: 12.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(a, b, \mathsf{fma}\left(x, y, z \cdot t\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 a b (fma x y (* z t)))))
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(a, b, fma(x, y, (z * t))));
}
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(a, b, fma(x, y, Float64(z * t))))
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[(a * b + N[(x * y + N[(z * t), $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(a, b, \mathsf{fma}\left(x, y, z \cdot t\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(c, i, \mathsf{fma}\left(a, b, \mathsf{fma}\left(x, y, z \cdot t\right)\right)\right)} \]
    Proof
    (fma.f64 c i (fma.f64 a b (fma.f64 x y (*.f64 z t)))): 0 points increase in error, 0 points decrease in error
    (fma.f64 c i (fma.f64 a b (Rewrite<= fma-def_binary64 (+.f64 (*.f64 x y) (*.f64 z t))))): 0 points increase in error, 0 points decrease in error
    (fma.f64 c i (Rewrite<= fma-def_binary64 (+.f64 (*.f64 a b) (+.f64 (*.f64 x y) (*.f64 z t))))): 0 points increase in error, 0 points decrease in error
    (fma.f64 c i (Rewrite<= +-commutative_binary64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 c i) (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= +-commutative_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(c, i, \mathsf{fma}\left(a, b, \mathsf{fma}\left(x, y, z \cdot t\right)\right)\right) \]

Alternatives

Alternative 1
Error27.0
Cost2428
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ t_2 := x \cdot y + z \cdot t\\ t_3 := a \cdot b + z \cdot t\\ t_4 := a \cdot b + x \cdot y\\ t_5 := c \cdot i + z \cdot t\\ \mathbf{if}\;x \leq -1.35 \cdot 10^{+120}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{+92}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -7.5 \cdot 10^{+57}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;x \leq -1.05 \cdot 10^{+30}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.3 \cdot 10^{+24}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -3.3 \cdot 10^{+14}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -7.5 \cdot 10^{-24}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;x \leq -6.8 \cdot 10^{-41}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;x \leq -1.7 \cdot 10^{-76}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -5.5 \cdot 10^{-155}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;x \leq -1.75 \cdot 10^{-211}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.86 \cdot 10^{-258}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;x \leq -9.5 \cdot 10^{-298}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-290}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;x \leq 4.9 \cdot 10^{-167}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \end{array} \]
Alternative 2
Error32.3
Cost2164
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := c \cdot i + z \cdot t\\ t_3 := a \cdot b + c \cdot i\\ \mathbf{if}\;x \leq -6 \cdot 10^{+281}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -1.2 \cdot 10^{+110}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq -2.1 \cdot 10^{+57}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1 \cdot 10^{+30}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -9700000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -390000000:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq -9.5 \cdot 10^{-77}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5.8 \cdot 10^{-155}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.9 \cdot 10^{-213}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -4.8 \cdot 10^{-259}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -9.5 \cdot 10^{-298}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 10^{-298}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-108}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 3
Error26.9
Cost1900
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := c \cdot i + z \cdot t\\ t_3 := a \cdot b + x \cdot y\\ t_4 := a \cdot b + c \cdot i\\ \mathbf{if}\;x \leq -2.8 \cdot 10^{+104}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -1.45 \cdot 10^{+57}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.1 \cdot 10^{+30}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;x \leq -3.55 \cdot 10^{+16}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.3 \cdot 10^{-68}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -3.7 \cdot 10^{-155}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -3.5 \cdot 10^{-213}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;x \leq -2.5 \cdot 10^{-258}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -8.5 \cdot 10^{-298}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-296}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{-177}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Error38.1
Cost1752
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -9.2 \cdot 10^{+84}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1.6 \cdot 10^{+24}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq -3.1 \cdot 10^{-56}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq -2.6 \cdot 10^{-286}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 2.15 \cdot 10^{-35}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 2.4 \cdot 10^{+99}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 5
Error33.4
Cost1506
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ \mathbf{if}\;y \leq -8.5 \cdot 10^{-46}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-271}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{-196}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;y \leq 0.00105 \lor \neg \left(y \leq 3.9 \cdot 10^{+18}\right) \land \left(y \leq 10^{+114} \lor \neg \left(y \leq 4.4 \cdot 10^{+166}\right) \land y \leq 1.35 \cdot 10^{+239}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 6
Error27.5
Cost1505
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ t_2 := c \cdot i + z \cdot t\\ \mathbf{if}\;y \leq -3.5 \cdot 10^{-143}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;y \leq 1.75 \cdot 10^{-195}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-10}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{+19}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{+40}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{+67}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;y \leq 5.3 \cdot 10^{+166} \lor \neg \left(y \leq 6.1 \cdot 10^{+218}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error37.8
Cost1492
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -3.75 \cdot 10^{+84}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1.2 \cdot 10^{+24}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq -1.2 \cdot 10^{-56}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq -1.7 \cdot 10^{-286}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 4.9 \cdot 10^{+17}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 8
Error24.4
Cost1228
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ \mathbf{if}\;c \cdot i \leq -1.7 \cdot 10^{+84}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 6.5 \cdot 10^{-35}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 3 \cdot 10^{+101}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error8.8
Cost1225
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -1.46 \cdot 10^{+85} \lor \neg \left(c \cdot i \leq 4.2 \cdot 10^{+41}\right):\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \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
Error37.4
Cost712
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -7.8 \cdot 10^{+56}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 3.6 \cdot 10^{+14}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 12
Error47.2
Cost192
\[a \cdot b \]

Error

Reproduce

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