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

Error

Derivation

  1. Initial program 0.1

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

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

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

Alternatives

Alternative 1
Error15.0
Cost584
\[\begin{array}{l} t_0 := z \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -3.7423143190924004 \cdot 10^{-44}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{+61}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.1
Cost448
\[x + z \cdot \left(y \cdot z\right) \]
Alternative 3
Error20.9
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022308 
(FPCore (x y z)
  :name "Statistics.Sample:robustSumVarWeighted from math-functions-0.1.5.2"
  :precision binary64
  (+ x (* (* y z) z)))