Average Error: 0.0 → 0.0
Time: 2.4s
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 r9967623 = x;
        double r9967624 = r9967623 * r9967623;
        double r9967625 = y;
        double r9967626 = r9967625 * r9967625;
        double r9967627 = r9967624 + r9967626;
        return r9967627;
}

double f(double x, double y) {
        double r9967628 = y;
        double r9967629 = x;
        double r9967630 = r9967629 * r9967629;
        double r9967631 = fma(r9967628, r9967628, r9967630);
        return r9967631;
}

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