Average Error: 0.0 → 0.0
Time: 4.1s
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.4
Cost984
\[\begin{array}{l} \mathbf{if}\;y \leq -4.827528565300812 \cdot 10^{+47}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq -6.2228111057112274 \cdot 10^{-145}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq -2.5096327862574454 \cdot 10^{-157}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 2.738548022968859 \cdot 10^{-238}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 5.7 \cdot 10^{-51}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1.3359313812916617 \cdot 10^{+21}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 2
Error14.2
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -3.6 \cdot 10^{+132}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{+155}:\\ \;\;\;\;z + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5\\ \end{array} \]
Alternative 3
Error11.3
Cost584
\[\begin{array}{l} t_0 := z + x \cdot y\\ \mathbf{if}\;z \leq -5.0484148568097176 \cdot 10^{+63}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.4908293007251165 \cdot 10^{-18}:\\ \;\;\;\;x \cdot \left(y + 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error1.6
Cost584
\[\begin{array}{l} t_0 := z + x \cdot y\\ \mathbf{if}\;y \leq -1.4393553516169048 \cdot 10^{+32}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.0241694495757966 \cdot 10^{-5}:\\ \;\;\;\;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.6
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -6.745237407405351 \cdot 10^{+36}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 61501.94132655628:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 7
Error34.6
Cost64
\[z \]

Error

Reproduce

herbie shell --seed 2022294 
(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))