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

Error

Derivation

  1. Initial program 0.0

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

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

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

Alternatives

Alternative 1
Error29.0
Cost984
\[\begin{array}{l} \mathbf{if}\;z \leq -1.1579974111594026 \cdot 10^{-88}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 7.194918048588965 \cdot 10^{-194}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;z \leq 5.712248937390512 \cdot 10^{-149}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \leq 4.664629525171111 \cdot 10^{-134}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;z \leq 5.134227242420965 \cdot 10^{-119}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 1.100189012993165 \cdot 10^{+81}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 2
Error11.5
Cost848
\[\begin{array}{l} \mathbf{if}\;y \leq -3.6 \cdot 10^{+114}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq -3.2097596329413378 \cdot 10^{+63}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq -190000000000:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+88}:\\ \;\;\;\;z + x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 3
Error11.8
Cost584
\[\begin{array}{l} t_0 := z + x \cdot 0.5\\ \mathbf{if}\;z \leq -1.1579974111594026 \cdot 10^{-88}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.100189012993165 \cdot 10^{+81}:\\ \;\;\;\;x \cdot \left(y + 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error1.0
Cost584
\[\begin{array}{l} t_0 := z + x \cdot y\\ \mathbf{if}\;y \leq -190000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.0003449627705008839:\\ \;\;\;\;z + x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error0.0
Cost576
\[z + \left(\frac{x}{2} + x \cdot y\right) \]
Alternative 6
Error27.8
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -1.1579974111594026 \cdot 10^{-88}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 4.664629525171111 \cdot 10^{-134}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 7
Error34.6
Cost64
\[z \]

Error

Reproduce

herbie shell --seed 2022295 
(FPCore (x y z)
  :name "Data.Histogram.Bin.BinF:$cfromIndex from histogram-fill-0.8.4.1"
  :precision binary64
  (+ (+ (/ x 2.0) (* y x)) z))