Average Error: 0.0 → 0.0
Time: 1.8s
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 r6701274 = x;
        double r6701275 = r6701274 * r6701274;
        double r6701276 = y;
        double r6701277 = r6701276 * r6701276;
        double r6701278 = r6701275 + r6701277;
        return r6701278;
}

double f(double x, double y) {
        double r6701279 = y;
        double r6701280 = x;
        double r6701281 = r6701280 * r6701280;
        double r6701282 = fma(r6701279, r6701279, r6701281);
        return r6701282;
}

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