Average Error: 0.0 → 0.0
Time: 1.9s
Precision: binary64
Cost: 6720
\[\left(x \cdot y + x\right) + y \]
\[\mathsf{fma}\left(y, x, y + x\right) \]
(FPCore (x y) :precision binary64 (+ (+ (* x y) x) y))
(FPCore (x y) :precision binary64 (fma y x (+ y x)))
double code(double x, double y) {
	return ((x * y) + x) + y;
}
double code(double x, double y) {
	return fma(y, x, (y + x));
}
function code(x, y)
	return Float64(Float64(Float64(x * y) + x) + y)
end
function code(x, y)
	return fma(y, x, Float64(y + x))
end
code[x_, y_] := N[(N[(N[(x * y), $MachinePrecision] + x), $MachinePrecision] + y), $MachinePrecision]
code[x_, y_] := N[(y * x + N[(y + x), $MachinePrecision]), $MachinePrecision]
\left(x \cdot y + x\right) + y
\mathsf{fma}\left(y, x, y + x\right)

Error

Derivation

  1. Initial program 0.0

    \[\left(x \cdot y + x\right) + y \]
  2. Applied egg-rr0.0

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

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

Alternatives

Alternative 1
Error0.0
Cost6720
\[y + \mathsf{fma}\left(x, y, x\right) \]
Alternative 2
Error23.3
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-39}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.06 \cdot 10^{+55}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 9 \cdot 10^{+64}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 3
Error19.4
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.22 \cdot 10^{-60}:\\ \;\;\;\;x \cdot \left(y + 1\right)\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 4
Error18.6
Cost452
\[\begin{array}{l} \mathbf{if}\;y \leq 2.3 \cdot 10^{-47}:\\ \;\;\;\;x \cdot \left(y + 1\right)\\ \mathbf{else}:\\ \;\;\;\;y + y \cdot x\\ \end{array} \]
Alternative 5
Error0.0
Cost448
\[y + \left(x + y \cdot x\right) \]
Alternative 6
Error27.7
Cost196
\[\begin{array}{l} \mathbf{if}\;x \leq -2.36 \cdot 10^{-60}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 7
Error36.1
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022329 
(FPCore (x y)
  :name "Numeric.Log:$cexpm1 from log-domain-0.10.2.1, B"
  :precision binary64
  (+ (+ (* x y) x) y))