Average Error: 0.0 → 0.0
Time: 3.5s
Precision: 64
\[\left(x \cdot 2 + x \cdot x\right) + y \cdot y\]
\[\mathsf{fma}\left(x, 2 + x, y \cdot y\right)\]
\left(x \cdot 2 + x \cdot x\right) + y \cdot y
\mathsf{fma}\left(x, 2 + x, y \cdot y\right)
double f(double x, double y) {
        double r615049 = x;
        double r615050 = 2.0;
        double r615051 = r615049 * r615050;
        double r615052 = r615049 * r615049;
        double r615053 = r615051 + r615052;
        double r615054 = y;
        double r615055 = r615054 * r615054;
        double r615056 = r615053 + r615055;
        return r615056;
}

double f(double x, double y) {
        double r615057 = x;
        double r615058 = 2.0;
        double r615059 = r615058 + r615057;
        double r615060 = y;
        double r615061 = r615060 * r615060;
        double r615062 = fma(r615057, r615059, r615061);
        return r615062;
}

Error

Bits error versus x

Bits error versus y

Target

Original0.0
Target0.0
Herbie0.0
\[y \cdot y + \left(2 \cdot x + x \cdot x\right)\]

Derivation

  1. Initial program 0.0

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

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

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

Reproduce

herbie shell --seed 2020042 +o rules:numerics
(FPCore (x y)
  :name "Numeric.Log:$clog1p from log-domain-0.10.2.1, A"
  :precision binary64

  :herbie-target
  (+ (* y y) (+ (* 2 x) (* x x)))

  (+ (+ (* x 2) (* x x)) (* y y)))