Average Error: 0.0 → 0.0
Time: 8.2s
Precision: 64
\[2 \cdot \left(x \cdot x + x \cdot y\right)\]
\[\mathsf{fma}\left(x, x, y \cdot x\right) \cdot 2\]
2 \cdot \left(x \cdot x + x \cdot y\right)
\mathsf{fma}\left(x, x, y \cdot x\right) \cdot 2
double f(double x, double y) {
        double r20447194 = 2.0;
        double r20447195 = x;
        double r20447196 = r20447195 * r20447195;
        double r20447197 = y;
        double r20447198 = r20447195 * r20447197;
        double r20447199 = r20447196 + r20447198;
        double r20447200 = r20447194 * r20447199;
        return r20447200;
}

double f(double x, double y) {
        double r20447201 = x;
        double r20447202 = y;
        double r20447203 = r20447202 * r20447201;
        double r20447204 = fma(r20447201, r20447201, r20447203);
        double r20447205 = 2.0;
        double r20447206 = r20447204 * r20447205;
        return r20447206;
}

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 \mathsf{fma}\left(x, x, y \cdot x\right) \cdot 2\]

Reproduce

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

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

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