Average Error: 0.1 → 0.1
Time: 6.9s
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
Error3.5
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{+150}:\\ \;\;\;\;z \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+153}:\\ \;\;\;\;x + y \cdot \left(z \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error14.8
Cost584
\[\begin{array}{l} t_0 := z \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -6.52251261662656 \cdot 10^{-30}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.75 \cdot 10^{+72}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error0.1
Cost448
\[x + z \cdot \left(y \cdot z\right) \]
Alternative 4
Error21.1
Cost64
\[x \]

Error

Reproduce

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