Average Error: 0.0 → 0.0
Time: 10.1s
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 r107608 = x;
        double r107609 = r107608 * r107608;
        double r107610 = y;
        double r107611 = r107610 * r107610;
        double r107612 = r107609 + r107611;
        return r107612;
}

double f(double x, double y) {
        double r107613 = x;
        double r107614 = y;
        double r107615 = r107614 * r107614;
        double r107616 = fma(r107613, r107613, r107615);
        return r107616;
}

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