Average Error: 0.0 → 0.0
Time: 16.5s
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))))): 0 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))))): 3 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
Error38.2
Cost2792
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.2262941703047695 \cdot 10^{+137}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -1.752068487092581 \cdot 10^{+41}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq -1.7133184715305773 \cdot 10^{-7}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -3.3717413330577254 \cdot 10^{-52}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq -1.1377419624280116 \cdot 10^{-120}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq -2.2000216942998936 \cdot 10^{-160}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq -2.295004615232815 \cdot 10^{-307}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 3.4524827158117685 \cdot 10^{-272}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 5.597765517608566 \cdot 10^{-22}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 2.091612017628143 \cdot 10^{+77}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 2
Error27.3
Cost2164
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ t_2 := a \cdot b + z \cdot t\\ t_3 := c \cdot i + z \cdot t\\ \mathbf{if}\;z \leq -1.1 \cdot 10^{+108}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -5.2 \cdot 10^{+73}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -9.575870123414639 \cdot 10^{+33}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -5.82025291643974 \cdot 10^{+23}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.524989730031518 \cdot 10^{-91}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -3.254748266135068 \cdot 10^{-111}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.201343148291517 \cdot 10^{-128}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -2.4753945096812134 \cdot 10^{-228}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.3718968462187837 \cdot 10^{-294}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;z \leq 3.746613471948433 \cdot 10^{-194}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.920588260265729 \cdot 10^{-152}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 1.2382982087947776 \cdot 10^{-114}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.1305807991024928 \cdot 10^{-26}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error27.4
Cost2032
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ t_2 := c \cdot i + x \cdot y\\ t_3 := a \cdot b + x \cdot y\\ t_4 := a \cdot b + z \cdot t\\ \mathbf{if}\;z \leq -1.1 \cdot 10^{+108}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;z \leq -1.6 \cdot 10^{+62}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -3.633819394952762 \cdot 10^{-26}:\\ \;\;\;\;x \cdot y + z \cdot t\\ \mathbf{elif}\;z \leq -4.524989730031518 \cdot 10^{-91}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.254748266135068 \cdot 10^{-111}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -2.201343148291517 \cdot 10^{-128}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.4753945096812134 \cdot 10^{-228}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -2.3718968462187837 \cdot 10^{-294}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 3.746613471948433 \cdot 10^{-194}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 2.920588260265729 \cdot 10^{-152}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.2382982087947776 \cdot 10^{-114}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 1.1305807991024928 \cdot 10^{-26}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_4\\ \end{array} \]
Alternative 4
Error27.0
Cost2032
\[\begin{array}{l} t_1 := x \cdot y + z \cdot t\\ t_2 := a \cdot b + c \cdot i\\ t_3 := a \cdot b + z \cdot t\\ t_4 := c \cdot i + x \cdot y\\ \mathbf{if}\;c \leq -1 \cdot 10^{+253}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;c \leq -1 \cdot 10^{+120}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -7.5 \cdot 10^{+79}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq -4.416404699707867 \cdot 10^{+43}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;c \leq -1.3810584533796385 \cdot 10^{-11}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -1.213348884728547 \cdot 10^{-43}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq -2.5853453954942436 \cdot 10^{-98}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -8.866393046620784 \cdot 10^{-116}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -9.935589498688963 \cdot 10^{-298}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 1.3351196157635446 \cdot 10^{-170}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.9911277113322299 \cdot 10^{-125}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 6.683106745506148 \cdot 10^{-27}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error24.5
Cost1748
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ t_2 := c \cdot i + x \cdot y\\ \mathbf{if}\;a \cdot b \leq -1.2262941703047695 \cdot 10^{+137}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -2.295004615232815 \cdot 10^{-307}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 3.4524827158117685 \cdot 10^{-272}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 5.597765517608566 \cdot 10^{-22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 3.1637184468039277 \cdot 10^{+98}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 6
Error21.6
Cost1748
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ t_2 := c \cdot i + x \cdot y\\ t_3 := a \cdot b + z \cdot t\\ \mathbf{if}\;a \cdot b \leq -1.7133184715305773 \cdot 10^{-7}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq -2.295004615232815 \cdot 10^{-307}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 3.4524827158117685 \cdot 10^{-272}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 5.597765517608566 \cdot 10^{-22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 647862829457.7161:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 7
Error24.8
Cost1488
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ \mathbf{if}\;a \cdot b \leq -1.2262941703047695 \cdot 10^{+137}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 5.597765517608566 \cdot 10^{-22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 3.05383689775349 \cdot 10^{-5}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 3.1637184468039277 \cdot 10^{+98}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 8
Error42.4
Cost1380
\[\begin{array}{l} \mathbf{if}\;a \leq -7.5 \cdot 10^{+176}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \leq -9 \cdot 10^{+121}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \leq -1.2 \cdot 10^{+97}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \leq -2.15 \cdot 10^{+74}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \leq -3.003169964668077 \cdot 10^{+34}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \leq -196247603231.12012:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \leq -2.732159090092539 \cdot 10^{-210}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \leq 2.0538911176509357 \cdot 10^{-285}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \leq 2.4726653561487757 \cdot 10^{-88}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 9
Error8.6
Cost1224
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.4033230368514006 \cdot 10^{+107}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 3.1637184468039277 \cdot 10^{+98}:\\ \;\;\;\;c \cdot i + \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \end{array} \]
Alternative 10
Error6.0
Cost1224
\[\begin{array}{l} t_1 := x \cdot y + z \cdot t\\ t_2 := a \cdot b + t_1\\ \mathbf{if}\;a \cdot b \leq -1.7133184715305773 \cdot 10^{-7}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 647862829457.7161:\\ \;\;\;\;c \cdot i + t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \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
Error42.0
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -1.2689455329832716 \cdot 10^{-85}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 13320579269985864:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 13
Error47.4
Cost192
\[x \cdot y \]

Error

Reproduce

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