Average Error: 0.0 → 0.0
Time: 4.1s
Precision: 64
\[\left(x \cdot 2 + x \cdot x\right) + y \cdot y\]
\[\mathsf{fma}\left(y, y, x \cdot 2 + x \cdot x\right)\]
\left(x \cdot 2 + x \cdot x\right) + y \cdot y
\mathsf{fma}\left(y, y, x \cdot 2 + x \cdot x\right)
double f(double x, double y) {
        double r24960787 = x;
        double r24960788 = 2.0;
        double r24960789 = r24960787 * r24960788;
        double r24960790 = r24960787 * r24960787;
        double r24960791 = r24960789 + r24960790;
        double r24960792 = y;
        double r24960793 = r24960792 * r24960792;
        double r24960794 = r24960791 + r24960793;
        return r24960794;
}

double f(double x, double y) {
        double r24960795 = y;
        double r24960796 = x;
        double r24960797 = 2.0;
        double r24960798 = r24960796 * r24960797;
        double r24960799 = r24960796 * r24960796;
        double r24960800 = r24960798 + r24960799;
        double r24960801 = fma(r24960795, r24960795, r24960800);
        return r24960801;
}

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(y, y, x \cdot \left(2 + x\right)\right)}\]
  3. Using strategy rm
  4. Applied distribute-lft-in0.0

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

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

Reproduce

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