Average Error: 0.1 → 0.1
Time: 3.9s
Precision: binary64
\[\left(x \cdot y + z\right) \cdot y + t \]
\[\mathsf{fma}\left(z, y, \mathsf{fma}\left(y, y \cdot x, t\right)\right) \]
(FPCore (x y z t) :precision binary64 (+ (* (+ (* x y) z) y) t))
(FPCore (x y z t) :precision binary64 (fma z y (fma y (* y x) 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(z, y, fma(y, (y * x), 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(z, y, fma(y, Float64(y * x), 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[(z * y + N[(y * N[(y * x), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]
\left(x \cdot y + z\right) \cdot y + t
\mathsf{fma}\left(z, y, \mathsf{fma}\left(y, y \cdot x, t\right)\right)

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Derivation

  1. Initial program 0.1

    \[\left(x \cdot y + z\right) \cdot y + t \]
  2. Applied egg-rr0.6

    \[\leadsto \color{blue}{{\left(\sqrt[3]{\mathsf{fma}\left(x, y, z\right)}\right)}^{3}} \cdot y + t \]
  3. Taylor expanded in x around 0 4.2

    \[\leadsto \color{blue}{t + \left(y \cdot z + {y}^{2} \cdot x\right)} \]
  4. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, \mathsf{fma}\left(y, y \cdot x, t\right)\right)} \]
  5. Final simplification0.1

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

Reproduce

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