Average Error: 0.0 → 0.0
Time: 4.9s
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
Error32.0
Cost1512
\[\begin{array}{l} \mathbf{if}\;y \leq -6 \cdot 10^{+120}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq -1091240029.3184428:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq -1.0012360023512695 \cdot 10^{-90}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq -2.7017302611477015 \cdot 10^{-170}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq -1.6634726031464027 \cdot 10^{-276}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 2.127821614455566 \cdot 10^{-126}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 2.8545573739559197 \cdot 10^{-71}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 3.54451591727026 \cdot 10^{+19}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{+175}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{+224}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 2
Error14.4
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -5.6 \cdot 10^{+238}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{+149}:\\ \;\;\;\;z + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5\\ \end{array} \]
Alternative 3
Error10.0
Cost584
\[\begin{array}{l} t_0 := x \cdot \left(y + 0.5\right)\\ \mathbf{if}\;x \leq -3.6715641379790693 \cdot 10^{+21}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.3151347911029887 \cdot 10^{+38}:\\ \;\;\;\;z + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error1.1
Cost584
\[\begin{array}{l} t_0 := z + x \cdot y\\ \mathbf{if}\;y \leq -1091240029.3184428:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.01492553826258822:\\ \;\;\;\;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.0
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{+85}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 2.3151347911029887 \cdot 10^{+38}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5\\ \end{array} \]
Alternative 7
Error0.0
Cost448
\[z + x \cdot \left(y + 0.5\right) \]
Alternative 8
Error34.6
Cost64
\[z \]

Error

Reproduce

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