?

Average Accuracy: 87.2% → 87.2%
Time: 5.1s
Precision: binary64
Cost: 6848

?

\[\left(\frac{x}{2} + y \cdot x\right) + z \]
\[\frac{x}{2} + \mathsf{fma}\left(x, y, z\right) \]
(FPCore (x y z) :precision binary64 (+ (+ (/ x 2.0) (* y x)) z))
(FPCore (x y z) :precision binary64 (+ (/ x 2.0) (fma x y 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 (x / 2.0) + fma(x, y, z);
}
function code(x, y, z)
	return Float64(Float64(Float64(x / 2.0) + Float64(y * x)) + z)
end
function code(x, y, z)
	return Float64(Float64(x / 2.0) + fma(x, y, 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[(N[(x / 2.0), $MachinePrecision] + N[(x * y + z), $MachinePrecision]), $MachinePrecision]
\left(\frac{x}{2} + y \cdot x\right) + z
\frac{x}{2} + \mathsf{fma}\left(x, y, z\right)

Error?

Derivation?

  1. Initial program 89.4%

    \[\left(\frac{x}{2} + y \cdot x\right) + z \]
  2. Simplified89.4%

    \[\leadsto \color{blue}{\frac{x}{2} + \mathsf{fma}\left(x, y, z\right)} \]
    Step-by-step derivation

    [Start]89.4

    \[ \left(\frac{x}{2} + y \cdot x\right) + z \]

    associate-+l+ [=>]89.4

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

    *-commutative [=>]89.4

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

    fma-def [=>]89.4

    \[ \frac{x}{2} + \color{blue}{\mathsf{fma}\left(x, y, z\right)} \]
  3. Final simplification89.4%

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

Alternatives

Alternative 1
Accuracy46.3%
Cost1248
\[\begin{array}{l} \mathbf{if}\;y \leq -3.1 \cdot 10^{+57}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq -1.05 \cdot 10^{-37}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq -3.05 \cdot 10^{-176}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{-74}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-34}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{+92}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 1.02 \cdot 10^{+192}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{+249}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 2
Accuracy72.6%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -7.8 \cdot 10^{+34} \lor \neg \left(z \leq 4.8 \cdot 10^{-70}\right):\\ \;\;\;\;z + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y + 0.5\right)\\ \end{array} \]
Alternative 3
Accuracy86.3%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -72000000 \lor \neg \left(y \leq 0.5\right):\\ \;\;\;\;z + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{2} + z\\ \end{array} \]
Alternative 4
Accuracy66.1%
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -1.65 \cdot 10^{+101}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 1.82 \cdot 10^{-22}:\\ \;\;\;\;x \cdot \left(y + 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 5
Accuracy50.9%
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -1.6 \cdot 10^{+38}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-68}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 6
Accuracy87.2%
Cost448
\[z + x \cdot \left(y - -0.5\right) \]
Alternative 7
Accuracy40.8%
Cost64
\[z \]

Error

Reproduce?

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