Average Error: 0.1 → 0.1
Time: 9.6s
Precision: binary64
Cost: 13120
\[\left(x \cdot y + z\right) \cdot y + t \]
\[\mathsf{fma}\left(y, \mathsf{fma}\left(x, y, z\right), t\right) \]
(FPCore (x y z t) :precision binary64 (+ (* (+ (* x y) z) y) t))
(FPCore (x y z t) :precision binary64 (fma y (fma x y z) t))
double code(double x, double y, double z, double t) {
	return (((x * y) + z) * y) + t;
}
double code(double x, double y, double z, double t) {
	return fma(y, fma(x, y, z), t);
}
function code(x, y, z, t)
	return Float64(Float64(Float64(Float64(x * y) + z) * y) + t)
end
function code(x, y, z, t)
	return fma(y, fma(x, y, z), t)
end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * y), $MachinePrecision] + z), $MachinePrecision] * y), $MachinePrecision] + t), $MachinePrecision]
code[x_, y_, z_, t_] := N[(y * N[(x * y + z), $MachinePrecision] + t), $MachinePrecision]
\left(x \cdot y + z\right) \cdot y + t
\mathsf{fma}\left(y, \mathsf{fma}\left(x, y, z\right), t\right)

Error

Derivation

  1. Initial program 0.1

    \[\left(x \cdot y + z\right) \cdot y + t \]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, \mathsf{fma}\left(x, y, z\right), t\right)} \]
    Proof
    (fma.f64 y (fma.f64 x y z) t): 0 points increase in error, 0 points decrease in error
    (fma.f64 y (Rewrite<= fma-def_binary64 (+.f64 (*.f64 x y) z)) t): 2 points increase in error, 1 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 y (+.f64 (*.f64 x y) z)) t)): 1 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (+.f64 (*.f64 x y) z) y)) t): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(y, \mathsf{fma}\left(x, y, z\right), t\right) \]

Alternatives

Alternative 1
Error13.7
Cost848
\[\begin{array}{l} t_1 := y \cdot \left(y \cdot x\right)\\ t_2 := t + y \cdot z\\ \mathbf{if}\;y \leq -4.3 \cdot 10^{+37}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 101385099450620510:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.02 \cdot 10^{+86}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 7.8 \cdot 10^{+196}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error9.6
Cost844
\[\begin{array}{l} t_1 := y \cdot \left(z + y \cdot x\right)\\ \mathbf{if}\;y \leq -1215981697100302000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 151052704120543.6:\\ \;\;\;\;t + y \cdot z\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{+152}:\\ \;\;\;\;t + x \cdot \left(y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error25.9
Cost720
\[\begin{array}{l} \mathbf{if}\;t \leq -0.0002179152449677972:\\ \;\;\;\;t\\ \mathbf{elif}\;t \leq -1.3413497320467244 \cdot 10^{-79}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;t \leq -4.148290432917078 \cdot 10^{-171}:\\ \;\;\;\;t\\ \mathbf{elif}\;t \leq 3.4947624458340494 \cdot 10^{-64}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 4
Error8.1
Cost712
\[\begin{array}{l} t_1 := t + y \cdot z\\ \mathbf{if}\;z \leq -9.96863780295364 \cdot 10^{-32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.125940662459599 \cdot 10^{+32}:\\ \;\;\;\;t + x \cdot \left(y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error0.1
Cost704
\[t + \left(y \cdot \left(y \cdot x\right) + y \cdot z\right) \]
Alternative 6
Error0.1
Cost576
\[t + y \cdot \left(z + y \cdot x\right) \]
Alternative 7
Error13.6
Cost320
\[t + y \cdot z \]
Alternative 8
Error29.9
Cost64
\[t \]

Error

Reproduce

herbie shell --seed 2022308 
(FPCore (x y z t)
  :name "Language.Haskell.HsColour.ColourHighlight:unbase from hscolour-1.23"
  :precision binary64
  (+ (* (+ (* x y) z) y) t))