Average Error: 0.0 → 0.0
Time: 1.9s
Precision: 64
\[2 \cdot \left(x \cdot x + x \cdot y\right)\]
\[\mathsf{fma}\left(x, x, x \cdot y\right) \cdot 2\]
2 \cdot \left(x \cdot x + x \cdot y\right)
\mathsf{fma}\left(x, x, x \cdot y\right) \cdot 2
double f(double x, double y) {
        double r520292 = 2.0;
        double r520293 = x;
        double r520294 = r520293 * r520293;
        double r520295 = y;
        double r520296 = r520293 * r520295;
        double r520297 = r520294 + r520296;
        double r520298 = r520292 * r520297;
        return r520298;
}

double f(double x, double y) {
        double r520299 = x;
        double r520300 = y;
        double r520301 = r520299 * r520300;
        double r520302 = fma(r520299, r520299, r520301);
        double r520303 = 2.0;
        double r520304 = r520302 * r520303;
        return r520304;
}

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. Simplified0.0

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

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

Reproduce

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