Average Error: 0.0 → 0.0
Time: 23.5s
Precision: 64
\[\left(x \cdot y + x\right) + y\]
\[\mathsf{fma}\left(y, x, x + y\right)\]
\left(x \cdot y + x\right) + y
\mathsf{fma}\left(y, x, x + y\right)
double f(double x, double y) {
        double r6275398 = x;
        double r6275399 = y;
        double r6275400 = r6275398 * r6275399;
        double r6275401 = r6275400 + r6275398;
        double r6275402 = r6275401 + r6275399;
        return r6275402;
}

double f(double x, double y) {
        double r6275403 = y;
        double r6275404 = x;
        double r6275405 = r6275404 + r6275403;
        double r6275406 = fma(r6275403, r6275404, r6275405);
        return r6275406;
}

Error

Bits error versus x

Bits error versus y

Derivation

  1. Initial program 0.0

    \[\left(x \cdot y + x\right) + y\]
  2. Simplified0.0

    \[\leadsto \color{blue}{y + \mathsf{fma}\left(y, x, x\right)}\]
  3. Taylor expanded around 0 0.0

    \[\leadsto \color{blue}{x + \left(y + x \cdot y\right)}\]
  4. Simplified0.0

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

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

Reproduce

herbie shell --seed 2019162 +o rules:numerics
(FPCore (x y)
  :name "Numeric.Log:$cexpm1 from log-domain-0.10.2.1, B"
  (+ (+ (* x y) x) y))