Average Error: 0.0 → 0.0
Time: 1.6s
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 r25728 = x;
        double r25729 = r25728 * r25728;
        double r25730 = y;
        double r25731 = r25730 * r25730;
        double r25732 = r25729 + r25731;
        return r25732;
}

double f(double x, double y) {
        double r25733 = x;
        double r25734 = y;
        double r25735 = r25734 * r25734;
        double r25736 = fma(r25733, r25733, r25735);
        return r25736;
}

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