Average Error: 0.0 → 0.0
Time: 6.9s
Precision: 64
\[x \cdot x + y \cdot y\]
\[\mathsf{fma}\left(y, y, x \cdot x\right)\]
x \cdot x + y \cdot y
\mathsf{fma}\left(y, y, x \cdot x\right)
double f(double x, double y) {
        double r7945743 = x;
        double r7945744 = r7945743 * r7945743;
        double r7945745 = y;
        double r7945746 = r7945745 * r7945745;
        double r7945747 = r7945744 + r7945746;
        return r7945747;
}

double f(double x, double y) {
        double r7945748 = y;
        double r7945749 = x;
        double r7945750 = r7945749 * r7945749;
        double r7945751 = fma(r7945748, r7945748, r7945750);
        return r7945751;
}

Error

Bits error versus x

Bits error versus y

Derivation

  1. Initial program 0.0

    \[x \cdot x + y \cdot y\]
  2. Simplified0.0

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

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

Reproduce

herbie shell --seed 2019164 +o rules:numerics
(FPCore (x y)
  :name "Graphics.Rasterific.Linear:$cquadrance from Rasterific-0.6.1"
  (+ (* x x) (* y y)))