Average Error: 0.1 → 0.1
Time: 8.1s
Precision: binary64
Cost: 6720
\[x + \left(y \cdot z\right) \cdot z \]
\[\mathsf{fma}\left(z, z \cdot y, x\right) \]
(FPCore (x y z) :precision binary64 (+ x (* (* y z) z)))
(FPCore (x y z) :precision binary64 (fma z (* z y) x))
double code(double x, double y, double z) {
	return x + ((y * z) * z);
}
double code(double x, double y, double z) {
	return fma(z, (z * y), x);
}
function code(x, y, z)
	return Float64(x + Float64(Float64(y * z) * z))
end
function code(x, y, z)
	return fma(z, Float64(z * y), x)
end
code[x_, y_, z_] := N[(x + N[(N[(y * z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(z * N[(z * y), $MachinePrecision] + x), $MachinePrecision]
x + \left(y \cdot z\right) \cdot z
\mathsf{fma}\left(z, z \cdot y, 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(z, y \cdot z, x\right)} \]
  3. Final simplification0.1

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

Alternatives

Alternative 1
Error11.0
Cost1096
\[\begin{array}{l} t_0 := z \cdot \left(z \cdot y\right)\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{-27}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+61}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.1
Cost448
\[x + z \cdot \left(z \cdot y\right) \]
Alternative 3
Error21.3
Cost64
\[x \]

Error

Reproduce

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