?

Average Accuracy: 100.0% → 100.0%
Time: 3.1s
Precision: binary64
Cost: 6720

?

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

Error?

Derivation?

  1. Initial program 100.0%

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

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

    [Start]100.0

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

    +-commutative [=>]100.0

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

    fma-def [=>]100.0

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

    +-commutative [=>]100.0

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

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

Alternatives

Alternative 1
Accuracy59.2%
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{+61}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -5.2 \cdot 10^{-121}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;x \leq -5.9 \cdot 10^{-145}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.12 \cdot 10^{+27}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Accuracy80.5%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -2.25 \cdot 10^{-54} \lor \neg \left(y \leq 1.55 \cdot 10^{-11}\right):\\ \;\;\;\;y \cdot \left(x + z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Accuracy97.9%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -2.55 \cdot 10^{+23} \lor \neg \left(y \leq 1\right):\\ \;\;\;\;y \cdot \left(x + z\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot z\\ \end{array} \]
Alternative 4
Accuracy60.7%
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -2.55 \cdot 10^{+23}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 5
Accuracy100.0%
Cost448
\[x + y \cdot \left(x + z\right) \]
Alternative 6
Accuracy44.8%
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023122 
(FPCore (x y z)
  :name "Main:bigenough2 from A"
  :precision binary64
  (+ x (* y (+ z x))))