?

Average Error: 0.1 → 0.1
Time: 6.7s
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. Simplified6.1

    \[\leadsto \color{blue}{x + y \cdot \left(z \cdot z\right)} \]
    Proof

    [Start]0.1

    \[ x + \left(y \cdot z\right) \cdot z \]

    associate-*l* [=>]6.1

    \[ x + \color{blue}{y \cdot \left(z \cdot z\right)} \]
  3. Applied egg-rr0.1

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

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

Alternatives

Alternative 1
Error19.5
Cost850
\[\begin{array}{l} \mathbf{if}\;z \leq -2.4 \cdot 10^{+63} \lor \neg \left(z \leq -420000000000 \lor \neg \left(z \leq -8.8 \cdot 10^{-38}\right) \land z \leq 2.65 \cdot 10^{+73}\right):\\ \;\;\;\;y \cdot \left(z \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error15.2
Cost850
\[\begin{array}{l} \mathbf{if}\;z \leq -7.2 \cdot 10^{+62} \lor \neg \left(z \leq -1300000000000 \lor \neg \left(z \leq -8.8 \cdot 10^{-38}\right) \land z \leq 1.9 \cdot 10^{+74}\right):\\ \;\;\;\;z \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error1.8
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -1.35 \cdot 10^{+154} \lor \neg \left(z \leq 1.35 \cdot 10^{+154}\right):\\ \;\;\;\;z \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(z \cdot z\right)\\ \end{array} \]
Alternative 4
Error0.1
Cost448
\[x + z \cdot \left(y \cdot z\right) \]
Alternative 5
Error21.0
Cost64
\[x \]

Error

Reproduce?

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