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

Error

Derivation

  1. Initial program 0.0

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

    \[\leadsto \color{blue}{x \cdot z + y \cdot z} \]
  3. Applied egg-rr0.0

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

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

Alternatives

Alternative 1
Error0.0
Cost6720
\[\mathsf{fma}\left(z, x, z \cdot y\right) \]
Alternative 2
Error22.8
Cost588
\[\begin{array}{l} \mathbf{if}\;x \leq -7.448530240903691 \cdot 10^{-6}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq -4.941277679574535 \cdot 10^{-23}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;x \leq -7.5623579938513935 \cdot 10^{-87}:\\ \;\;\;\;z \cdot x\\ \mathbf{else}:\\ \;\;\;\;z \cdot y\\ \end{array} \]
Alternative 3
Error0.0
Cost448
\[z \cdot x + z \cdot y \]
Alternative 4
Error0.0
Cost320
\[z \cdot \left(y + x\right) \]
Alternative 5
Error29.9
Cost192
\[z \cdot x \]

Error

Reproduce

herbie shell --seed 2022228 
(FPCore (x y z)
  :name "Text.Parsec.Token:makeTokenParser from parsec-3.1.9, B"
  :precision binary64
  (* (+ x y) z))