Average Error: 0.0 → 0.0
Time: 17.6s
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))))): 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))))): 2 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
Error24.5
Cost3048
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ \mathbf{if}\;c \cdot i \leq -1.5861817794182834 \cdot 10^{+111}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1.9783636499985824 \cdot 10^{+72}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -6.725002976982434 \cdot 10^{+28}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -2.60329005008175:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -3.6536423374613737 \cdot 10^{-153}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -1.7928102115681634 \cdot 10^{-189}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 3.407894878446139 \cdot 10^{-233}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 7.354243352626241 \cdot 10^{-120}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 3.6444506979209956 \cdot 10^{-10}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 2.4752696748309327 \cdot 10^{+125}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 3
Error24.3
Cost3048
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ t_3 := x \cdot y + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -1.5861817794182834 \cdot 10^{+111}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1.9783636499985824 \cdot 10^{+72}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -6.725002976982434 \cdot 10^{+28}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -4.746280094471139:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -3.6536423374613737 \cdot 10^{-153}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -1.7928102115681634 \cdot 10^{-189}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 3.407894878446139 \cdot 10^{-233}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 7.354243352626241 \cdot 10^{-120}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 8.563812012560354 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 2.245671752058582 \cdot 10^{+120}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 4
Error22.2
Cost2268
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ t_3 := a \cdot b + c \cdot i\\ \mathbf{if}\;c \cdot i \leq -6.725002976982434 \cdot 10^{+28}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -3.6536423374613737 \cdot 10^{-153}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -1.7928102115681634 \cdot 10^{-189}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 3.407894878446139 \cdot 10^{-233}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 7.354243352626241 \cdot 10^{-120}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 8.563812012560354 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 2.245671752058582 \cdot 10^{+120}:\\ \;\;\;\;x \cdot y + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 5
Error21.9
Cost2268
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ \mathbf{if}\;c \cdot i \leq -6.725002976982434 \cdot 10^{+28}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -3.6536423374613737 \cdot 10^{-153}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -1.7928102115681634 \cdot 10^{-189}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 3.407894878446139 \cdot 10^{-233}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 7.354243352626241 \cdot 10^{-120}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 8.563812012560354 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 2.2657300911518845 \cdot 10^{+103}:\\ \;\;\;\;x \cdot y + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \end{array} \]
Alternative 6
Error26.7
Cost1900
\[\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\\ t_4 := a \cdot b + x \cdot y\\ \mathbf{if}\;t \leq -3.602923674511332 \cdot 10^{-119}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 1.810090742487807 \cdot 10^{-278}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.583183976748807 \cdot 10^{-222}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq 2.463730693800578 \cdot 10^{-104}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4.954048685970513 \cdot 10^{-69}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;t \leq 14.225072778404131:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.0422334852816393 \cdot 10^{+41}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 10^{+85}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 10^{+104}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 9.5 \cdot 10^{+164}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 1.1 \cdot 10^{+207}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]
Alternative 7
Error37.7
Cost1752
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -6.725002976982434 \cdot 10^{+28}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1.9288925597302295 \cdot 10^{-276}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 0:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 6.156641087175686 \cdot 10^{-168}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 8.563812012560354 \cdot 10^{-11}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 5.1968078350081935 \cdot 10^{+113}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 8
Error43.1
Cost1512
\[\begin{array}{l} \mathbf{if}\;x \leq -2.85 \cdot 10^{+138}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq -4.4 \cdot 10^{+90}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \leq -6.4891678964657214 \cdot 10^{+38}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;x \leq -7.823293815619849 \cdot 10^{+21}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \leq -1.722751382591565 \cdot 10^{-65}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;x \leq -1.6903547289927321 \cdot 10^{-236}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \leq 8.275097694765717 \cdot 10^{-264}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;x \leq 7.675720693101379 \cdot 10^{-227}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \leq 7.798060715415573 \cdot 10^{-67}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;x \leq 3.1766728897651825 \cdot 10^{-14}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 9
Error25.6
Cost1488
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ \mathbf{if}\;c \cdot i \leq -6.725002976982434 \cdot 10^{+28}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1.7928102115681634 \cdot 10^{-189}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -1.9288925597302295 \cdot 10^{-276}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 2.4752696748309327 \cdot 10^{+125}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 10
Error9.3
Cost1224
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -6.725002976982434 \cdot 10^{+28}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 2.4752696748309327 \cdot 10^{+125}:\\ \;\;\;\;x \cdot y + \left(a \cdot b + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \end{array} \]
Alternative 11
Error6.0
Cost1224
\[\begin{array}{l} t_1 := c \cdot i + \left(x \cdot y + z \cdot t\right)\\ \mathbf{if}\;c \cdot i \leq -6.725002976982434 \cdot 10^{+28}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 8.563812012560354 \cdot 10^{-11}:\\ \;\;\;\;x \cdot y + \left(a \cdot b + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error0.0
Cost960
\[\left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right) + c \cdot i \]
Alternative 13
Error42.7
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -3.936370583441513 \cdot 10^{-158}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;t \leq 4.954048685970513 \cdot 10^{-69}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
Alternative 14
Error47.5
Cost192
\[z \cdot t \]

Error

Reproduce

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