Average Error: 0.0 → 0.0
Time: 3.4s
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 r352991 = x;
        double r352992 = 2.0;
        double r352993 = r352991 * r352992;
        double r352994 = r352991 * r352991;
        double r352995 = r352993 + r352994;
        double r352996 = y;
        double r352997 = r352996 * r352996;
        double r352998 = r352995 + r352997;
        return r352998;
}

double f(double x, double y) {
        double r352999 = x;
        double r353000 = 2.0;
        double r353001 = r353000 + r352999;
        double r353002 = y;
        double r353003 = r353002 * r353002;
        double r353004 = fma(r352999, r353001, r353003);
        return r353004;
}

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 2019199 +o rules:numerics
(FPCore (x y)
  :name "Numeric.Log:$clog1p from log-domain-0.10.2.1, A"

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

  (+ (+ (* x 2.0) (* x x)) (* y y)))