Average Error: 0.0 → 0.0
Time: 1.5s
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 r25178289 = x;
        double r25178290 = r25178289 * r25178289;
        double r25178291 = y;
        double r25178292 = r25178291 * r25178291;
        double r25178293 = r25178290 + r25178292;
        return r25178293;
}

double f(double x, double y) {
        double r25178294 = x;
        double r25178295 = y;
        double r25178296 = r25178295 * r25178295;
        double r25178297 = fma(r25178294, r25178294, r25178296);
        return r25178297;
}

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 2019173 +o rules:numerics
(FPCore (x y)
  :name "Graphics.Rasterific.Linear:$cquadrance from Rasterific-0.6.1"
  (+ (* x x) (* y y)))