Average Error: 0.0 → 0.0
Time: 12.3s
Precision: 64
\[2 \cdot \left(x \cdot x + x \cdot y\right)\]
\[2 \cdot \mathsf{fma}\left(x, x, x \cdot y\right)\]
2 \cdot \left(x \cdot x + x \cdot y\right)
2 \cdot \mathsf{fma}\left(x, x, x \cdot y\right)
double f(double x, double y) {
        double r412198 = 2.0;
        double r412199 = x;
        double r412200 = r412199 * r412199;
        double r412201 = y;
        double r412202 = r412199 * r412201;
        double r412203 = r412200 + r412202;
        double r412204 = r412198 * r412203;
        return r412204;
}

double f(double x, double y) {
        double r412205 = 2.0;
        double r412206 = x;
        double r412207 = y;
        double r412208 = r412206 * r412207;
        double r412209 = fma(r412206, r412206, r412208);
        double r412210 = r412205 * r412209;
        return r412210;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 0.0

    \[2 \cdot \left(x \cdot x + x \cdot y\right)\]
  2. Using strategy rm
  3. Applied fma-def0.0

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

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

Reproduce

herbie shell --seed 2019212 +o rules:numerics
(FPCore (x y)
  :name "Linear.Matrix:fromQuaternion from linear-1.19.1.3, B"
  :precision binary64

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

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