?

Average Error: 0.0 → 0.0
Time: 4.5s
Precision: binary64
Cost: 6848

?

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

Error?

Derivation?

  1. Initial program 0.0

    \[x + y \cdot \left(z + x\right) \]
  2. Taylor expanded in z around 0 0.0

    \[\leadsto x + \color{blue}{\left(y \cdot z + y \cdot x\right)} \]
  3. Applied egg-rr0.0

    \[\leadsto x + \color{blue}{\mathsf{fma}\left(y, x, y \cdot z\right)} \]
  4. Final simplification0.0

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

Alternatives

Alternative 1
Error24.2
Cost1248
\[\begin{array}{l} \mathbf{if}\;y \leq -4.4 \cdot 10^{+102}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -4.5 \cdot 10^{+61}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq -3.1 \cdot 10^{-58}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 9.2 \cdot 10^{-102}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-92}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{+167}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{+233}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 2
Error16.5
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{-71} \lor \neg \left(x \leq 2.2 \cdot 10^{-60}\right):\\ \;\;\;\;x + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 3
Error7.4
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -2.05 \cdot 10^{-44} \lor \neg \left(z \leq 5.2 \cdot 10^{-135}\right):\\ \;\;\;\;x + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + x \cdot y\\ \end{array} \]
Alternative 4
Error24.5
Cost457
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error0.0
Cost448
\[x + y \cdot \left(x + z\right) \]
Alternative 6
Error35.1
Cost64
\[x \]

Error

Reproduce?

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