Average Error: 0.0 → 0.0
Time: 637.0ms
Precision: 64
\[x \cdot x + y \cdot y\]
\[\mathsf{fma}\left(x, x, y \cdot y\right)\]
x \cdot x + y \cdot y
\mathsf{fma}\left(x, x, y \cdot y\right)
double f(double x, double y) {
        double r147281 = x;
        double r147282 = r147281 * r147281;
        double r147283 = y;
        double r147284 = r147283 * r147283;
        double r147285 = r147282 + r147284;
        return r147285;
}

double f(double x, double y) {
        double r147286 = x;
        double r147287 = y;
        double r147288 = r147287 * r147287;
        double r147289 = fma(r147286, r147286, r147288);
        return r147289;
}

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(x, x, y \cdot y\right)}\]
  3. Final simplification0.0

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

Reproduce

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