Average Error: 0.0 → 0.0
Time: 4.2s
Precision: 64
\[\left(x \cdot 2 + x \cdot x\right) + y \cdot y\]
\[x \cdot 2 + \mathsf{fma}\left(y, y, x \cdot x\right)\]
\left(x \cdot 2 + x \cdot x\right) + y \cdot y
x \cdot 2 + \mathsf{fma}\left(y, y, x \cdot x\right)
double f(double x, double y) {
        double r329746 = x;
        double r329747 = 2.0;
        double r329748 = r329746 * r329747;
        double r329749 = r329746 * r329746;
        double r329750 = r329748 + r329749;
        double r329751 = y;
        double r329752 = r329751 * r329751;
        double r329753 = r329750 + r329752;
        return r329753;
}

double f(double x, double y) {
        double r329754 = x;
        double r329755 = 2.0;
        double r329756 = r329754 * r329755;
        double r329757 = y;
        double r329758 = r329754 * r329754;
        double r329759 = fma(r329757, r329757, r329758);
        double r329760 = r329756 + r329759;
        return r329760;
}

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. Using strategy rm
  3. Applied associate-+l+0.0

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

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

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

Reproduce

herbie shell --seed 2019305 +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)))