?

Average Accuracy: 99.9% → 99.9%
Time: 8.3s
Precision: binary64
Cost: 6720

?

\[x + \left(y \cdot z\right) \cdot z \]
\[\mathsf{fma}\left(y \cdot z, z, x\right) \]
(FPCore (x y z) :precision binary64 (+ x (* (* y z) z)))
(FPCore (x y z) :precision binary64 (fma (* y z) z x))
double code(double x, double y, double z) {
	return x + ((y * z) * z);
}
double code(double x, double y, double z) {
	return fma((y * z), z, x);
}
function code(x, y, z)
	return Float64(x + Float64(Float64(y * z) * z))
end
function code(x, y, z)
	return fma(Float64(y * z), z, x)
end
code[x_, y_, z_] := N[(x + N[(N[(y * z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(N[(y * z), $MachinePrecision] * z + x), $MachinePrecision]
x + \left(y \cdot z\right) \cdot z
\mathsf{fma}\left(y \cdot z, z, x\right)

Error?

Derivation?

  1. Initial program 99.9%

    \[x + \left(y \cdot z\right) \cdot z \]
  2. Simplified90.2%

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

    [Start]99.9

    \[ x + \left(y \cdot z\right) \cdot z \]

    associate-*l* [=>]90.2

    \[ x + \color{blue}{y \cdot \left(z \cdot z\right)} \]
  3. Applied egg-rr99.9%

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

    [Start]90.2

    \[ x + y \cdot \left(z \cdot z\right) \]

    +-commutative [=>]90.2

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

    associate-*r* [=>]99.9

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

    fma-def [=>]99.9

    \[ \color{blue}{\mathsf{fma}\left(y \cdot z, z, x\right)} \]
  4. Final simplification99.9%

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

Alternatives

Alternative 1
Accuracy68.0%
Cost850
\[\begin{array}{l} \mathbf{if}\;z \leq -2 \cdot 10^{+18} \lor \neg \left(z \leq -4 \cdot 10^{-39}\right) \land \left(z \leq -4.9 \cdot 10^{-106} \lor \neg \left(z \leq 1.1 \cdot 10^{-17}\right)\right):\\ \;\;\;\;y \cdot \left(z \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Accuracy74.9%
Cost848
\[\begin{array}{l} t_0 := z \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -3.6 \cdot 10^{+16}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -9.6 \cdot 10^{-39}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{-106}:\\ \;\;\;\;y \cdot \left(z \cdot z\right)\\ \mathbf{elif}\;z \leq 2.25 \cdot 10^{-17}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Accuracy96.5%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{+147} \lor \neg \left(z \leq 3.7 \cdot 10^{+123}\right):\\ \;\;\;\;z \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(z \cdot z\right)\\ \end{array} \]
Alternative 4
Accuracy99.9%
Cost448
\[x + z \cdot \left(y \cdot z\right) \]
Alternative 5
Accuracy66.8%
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023137 
(FPCore (x y z)
  :name "Statistics.Sample:robustSumVarWeighted from math-functions-0.1.5.2"
  :precision binary64
  (+ x (* (* y z) z)))