Average Error: 0.0 → 0.0
Time: 10.8s
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 r335299 = 2.0;
        double r335300 = x;
        double r335301 = r335300 * r335300;
        double r335302 = y;
        double r335303 = r335300 * r335302;
        double r335304 = r335301 + r335303;
        double r335305 = r335299 * r335304;
        return r335305;
}

double f(double x, double y) {
        double r335306 = 2.0;
        double r335307 = x;
        double r335308 = y;
        double r335309 = r335307 * r335308;
        double r335310 = fma(r335307, r335307, r335309);
        double r335311 = r335306 * r335310;
        return r335311;
}

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 2019305 +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))))